diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / utils / build - script <nl> ppp b / utils / build - script <nl> the number of parallel build jobs to use " " " , <nl> action = " append " , dest = " extra_swift_args " , default = [ ] ) <nl> <nl> parser . add_argument ( <nl> - " - - extra - cmake - vars " , help = textwrap . dedent ( " " " <nl> - Pass through extra variables to CMake in the form of comma separated vars <nl> - ' CMAKE_VAR1 = YES , CMAKE_VAR2 = / tmp ' . Can be called multiple times to add <nl> - multiple such vars . " " " ) , <nl> - action = " append " , dest = " extra_cmake_vars " , default = [ ] ) <nl> + " - - extra - cmake - options " , help = textwrap . dedent ( " " " <nl> + Pass through extra options to CMake in the form of comma separated options <nl> + ' - DCMAKE_VAR1 = YES , - DCMAKE_VAR2 = / tmp ' . Can be called multiple times to add <nl> + multiple such options . " " " ) , <nl> + action = " append " , dest = " extra_cmake_options " , default = [ ] ) <nl> <nl> parser . add_argument ( <nl> " build_script_impl_args " , <nl> the number of parallel build jobs to use " " " , <nl> <nl> # If we have extra_cmake_args , combine all of them together and then add <nl> # them as one command . <nl> - if args . extra_cmake_vars : <nl> + if args . extra_cmake_options : <nl> build_script_impl_args + = [ <nl> - " - - extra - cmake - vars " , <nl> - " , " . join ( args . extra_cmake_vars ) ] <nl> + " - - extra - cmake - options " , <nl> + " , " . join ( args . extra_cmake_options ) ] <nl> <nl> build_script_impl_args + = args . build_script_impl_args <nl> <nl> mmm a / utils / build - script - impl <nl> ppp b / utils / build - script - impl <nl> KNOWN_SETTINGS = ( <nl> darwin - deployment - version - tvos " 9 . 0 " " minimum deployment target version for tvOS " <nl> darwin - deployment - version - watchos " 2 . 0 " " minimum deployment target version for watchOS " <nl> <nl> - extra - cmake - vars " " " Extra variables to pass to CMake for all targets " <nl> + extra - cmake - options " " " Extra options to pass to CMake for all targets " <nl> extra - swift - args " " " Extra arguments to pass to swift modules which match regex . Assumed to be a flattened cmake list consisting of [ module_regexp , args , module_regexp , args , . . . ] " <nl> sil - verify - all " 0 " " If enabled , run the SIL verifier after each transform when building Swift files during this build process " <nl> swift - enable - ast - verifier " 1 " " If enabled , and the assertions are enabled , the built Swift compiler will run the AST verifier every time it is invoked " <nl> if [ [ " $ { EXPORT_COMPILE_COMMANDS } " ] ] ; then <nl> ) <nl> fi <nl> <nl> - if [ [ " $ { EXTRA_CMAKE_VARS } " ] ] ; then <nl> - for cmake_var in $ ( echo " $ { EXTRA_CMAKE_VARS } " | tr " , " " \ n " ) <nl> + if [ [ " $ { EXTRA_CMAKE_OPTIONS } " ] ] ; then <nl> + for cmake_opt in $ ( echo " $ { EXTRA_CMAKE_OPTIONS } " | tr " , " " \ n " ) <nl> do <nl> COMMON_CMAKE_OPTIONS = ( <nl> " $ { COMMON_CMAKE_OPTIONS [ @ ] } " <nl> - " - D $ { cmake_var } " <nl> + " $ { cmake_opt } " <nl> ) <nl> done <nl> fi <nl>
|
[ utils / build - script ] Change ' - - extra - cmake - vars ' to ' - - extra - cmake - options ' .
|
apple/swift
|
abecb2f6a92c27777d9b96322bb17ce4fd1348b7
|
2016-04-12T16:53:45Z
|
mmm a / include / swift / SILPasses / Passes . h <nl> ppp b / include / swift / SILPasses / Passes . h <nl> namespace swift { <nl> / / / \ brief Cleanup instructions / builtin calls not suitable for IRGen . <nl> void performSILCleanup ( SILModule * M ) ; <nl> <nl> - / / / \ brief Eliminate unused SILFunctions , SILVTables and SILWitnessTables . <nl> - bool performSILElimination ( SILModule * M ) ; <nl> - <nl> / / Diagnostics transformations . <nl> SILTransform * createCapturePromotion ( ) ; <nl> SILTransform * createInOutDeshadowing ( ) ; <nl> mmm a / lib / SILPasses / DeadFunctionElimination . cpp <nl> ppp b / lib / SILPasses / DeadFunctionElimination . cpp <nl> using namespace swift ; <nl> <nl> STATISTIC ( NumDeadFunc , " Number of dead functions eliminated " ) ; <nl> <nl> - namespace { <nl> - struct FinalEliminator { <nl> - llvm : : SmallSetVector < SILFunction * , 16 > Worklist ; <nl> - <nl> - / / Update module information before actually removing a SILFunction . <nl> - void updateBeforeRemoveFunction ( SILFunction * F ) { <nl> - / / Collect all FRIs and insert the callees to the work list . <nl> - for ( auto & BB : * F ) <nl> - for ( auto & I : BB ) <nl> - if ( auto FRI = dyn_cast < FunctionRefInst > ( & I ) ) <nl> - Worklist . insert ( FRI - > getReferencedFunction ( ) ) ; <nl> - } <nl> - } ; <nl> - <nl> - } / / end anonymous namespace <nl> - <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / Utility Functions <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - bool tryToRemoveFunction ( SILFunction * F , FinalEliminator * FE = nullptr ) { <nl> + bool tryToRemoveFunction ( SILFunction * F ) { <nl> <nl> SILModule & M = F - > getModule ( ) ; <nl> <nl> bool tryToRemoveFunction ( SILFunction * F , FinalEliminator * FE = nullptr ) { <nl> <nl> DEBUG ( llvm : : dbgs ( ) < < " DEAD FUNCTION ELIMINATION : Erasing : " < < F - > getName ( ) <nl> < < " \ n " ) ; <nl> - if ( FE ) { <nl> - FE - > updateBeforeRemoveFunction ( F ) ; <nl> - } <nl> - <nl> M . eraseFunction ( F ) ; <nl> NumDeadFunc + + ; <nl> return true ; <nl> class SILDeadFuncElimination : public SILModuleTransform { <nl> SILTransform * swift : : createDeadFunctionElimination ( ) { <nl> return new SILDeadFuncElimination ( ) ; <nl> } <nl> - <nl> - bool swift : : performSILElimination ( SILModule * M ) { <nl> - bool Changed = false ; <nl> - llvm : : SmallSet < SILFunction * , 16 > removedFuncs ; <nl> - <nl> - FinalEliminator FE ; <nl> - <nl> - for ( auto FI = M - > begin ( ) , EI = M - > end ( ) ; FI ! = EI ; ) { <nl> - SILFunction * F = FI + + ; <nl> - if ( tryToRemoveFunction ( F , & FE ) ) { <nl> - Changed = true ; <nl> - removedFuncs . insert ( F ) ; <nl> - } <nl> - } <nl> - <nl> - while ( ! FE . Worklist . empty ( ) ) { <nl> - llvm : : SmallSetVector < SILFunction * , 16 > CurrWorklist = FE . Worklist ; <nl> - FE . Worklist . clear ( ) ; <nl> - for ( auto entry : CurrWorklist ) <nl> - if ( ! removedFuncs . count ( entry ) ) <nl> - if ( tryToRemoveFunction ( entry , & FE ) ) { <nl> - Changed = true ; <nl> - removedFuncs . insert ( entry ) ; <nl> - } <nl> - } <nl> - return Changed ; <nl> - } <nl> mmm a / lib / SILPasses / Link . cpp <nl> ppp b / lib / SILPasses / Link . cpp <nl> class SILLinker : public SILModuleTransform { <nl> for ( auto & Fn : M ) <nl> Changed | = M . linkFunction ( & Fn , SILModule : : LinkingMode : : LinkAll ) ; <nl> <nl> + M . invalidateSILLoader ( ) ; <nl> + <nl> if ( Changed ) <nl> invalidateAnalysis ( SILAnalysis : : InvalidationKind : : All ) ; <nl> } <nl> mmm a / lib / SILPasses / Passes . cpp <nl> ppp b / lib / SILPasses / Passes . cpp <nl> void swift : : runSILOptimizationPasses ( SILModule & Module , <nl> <nl> PM . resetAndRemoveTransformations ( ) ; <nl> AddLowLevelLoopOptPasses ( PM ) ; <nl> + PM . add ( createDeadFunctionElimination ( ) ) ; <nl> PM . runOneIteration ( ) ; <nl> <nl> - / / Invalidate the SILLoader and allow it to drop references to SIL functions . <nl> - Module . invalidateSILLoader ( ) ; <nl> - performSILElimination ( & Module ) ; <nl> - <nl> / / Gather instruction counts if we are asked to do so . <nl> if ( Options . PrintInstCounts ) { <nl> SILPassManager PrinterPM ( & Module , Options ) ; <nl>
|
Invalidate the deserializer caches after each SIL linking pass .
|
apple/swift
|
6b6581aa2545d6393a0a56e793d7aafd3831bf37
|
2014-10-20T11:57:27Z
|
mmm a / src / builtins / builtins - descriptors . h <nl> ppp b / src / builtins / builtins - descriptors . h <nl> namespace internal { <nl> typedef InterfaceDescriptor # # Descriptor Builtin_ # # Name # # _InterfaceDescriptor ; <nl> <nl> BUILTIN_LIST ( IGNORE_BUILTIN , IGNORE_BUILTIN , DEFINE_TFJ_INTERFACE_DESCRIPTOR , <nl> - DEFINE_TFS_INTERFACE_DESCRIPTOR , IGNORE_BUILTIN , IGNORE_BUILTIN , <nl> - IGNORE_BUILTIN ) <nl> + DEFINE_TFS_INTERFACE_DESCRIPTOR , IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> <nl> # undef DEFINE_TFJ_INTERFACE_DESCRIPTOR <nl> <nl> mmm a / src / builtins / builtins . cc <nl> ppp b / src / builtins / builtins . cc <nl> void Builtins : : SetUp ( Isolate * isolate , bool create_heap_objects ) { <nl> code = \ <nl> BuildWithMacroAssembler ( isolate , Generate_ # # Name , kBuiltinFlags , # Name ) ; \ <nl> builtins_ [ index + + ] = code ; <nl> - # define BUILD_ASH ( Name , Kind , Extra ) \ <nl> - code = BuildWithMacroAssembler ( \ <nl> - isolate , Generate_ # # Name , Code : : ComputeFlags ( Code : : Kind , Extra ) , # Name ) ; \ <nl> - builtins_ [ index + + ] = code ; <nl> <nl> BUILTIN_LIST ( BUILD_CPP , BUILD_API , BUILD_TFJ , BUILD_TFS , BUILD_ASM , <nl> - BUILD_ASH , BUILD_ASM ) ; <nl> + BUILD_ASM ) ; <nl> <nl> # undef BUILD_CPP <nl> # undef BUILD_API <nl> # undef BUILD_TFJ <nl> # undef BUILD_TFS <nl> # undef BUILD_ASM <nl> - # undef BUILD_ASH <nl> CHECK_EQ ( builtin_count , index ) ; <nl> for ( int i = 0 ; i < builtin_count ; i + + ) { <nl> Code : : cast ( builtins_ [ i ] ) - > set_builtin_index ( i ) ; <nl> bool Builtins : : IsCpp ( int index ) { <nl> return true ; <nl> # define BUILTIN_LIST_CPP ( V ) \ <nl> BUILTIN_LIST ( V , IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , \ <nl> - IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> + IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> BUILTIN_LIST_CPP ( CASE ) <nl> # undef BUILTIN_LIST_CPP <nl> # undef CASE <nl> bool Builtins : : IsApi ( int index ) { <nl> return true ; <nl> # define BUILTIN_LIST_API ( V ) \ <nl> BUILTIN_LIST ( IGNORE_BUILTIN , V , IGNORE_BUILTIN , IGNORE_BUILTIN , \ <nl> - IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> + IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> BUILTIN_LIST_API ( CASE ) ; <nl> # undef BUILTIN_LIST_API <nl> # undef CASE <nl> mmm a / src / builtins / builtins . h <nl> ppp b / src / builtins / builtins . h <nl> class Isolate ; <nl> / / Args : name , code kind , extra IC state , interface descriptor , return_size <nl> / / ASM : Builtin in platform - dependent assembly . <nl> / / Args : name <nl> - / / ASH : Handlers implemented in platform - dependent assembly . <nl> - / / Args : name , code kind , extra IC state <nl> / / DBG : Builtin in platform - dependent assembly , used by the debugger . <nl> / / Args : name <nl> <nl> - # define BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , ASH , DBG ) \ <nl> + # define BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , DBG ) \ <nl> ASM ( Abort ) \ <nl> / * Code aging * / \ <nl> CODE_AGE_LIST_WITH_ARG ( DECLARE_CODE_AGE_BUILTIN , ASM ) \ <nl> class Isolate ; <nl> 1 ) \ <nl> TFS ( LoadField , BUILTIN , kNoExtraICState , LoadField , 1 ) \ <nl> TFS ( LoadIC_FunctionPrototype , HANDLER , Code : : LOAD_IC , LoadWithVector , 1 ) \ <nl> - ASH ( LoadIC_Getter_ForDeopt , BUILTIN , kNoExtraICState ) \ <nl> + ASM ( LoadIC_Getter_ForDeopt ) \ <nl> TFS ( LoadIC_Miss , BUILTIN , kNoExtraICState , LoadWithVector , 1 ) \ <nl> TFS ( LoadIC_Slow , HANDLER , Code : : LOAD_IC , LoadWithVector , 1 ) \ <nl> TFS ( LoadIC_Uninitialized , BUILTIN , kNoExtraICState , LoadWithVector , 1 ) \ <nl> TFS ( StoreIC_Miss , BUILTIN , kNoExtraICState , StoreWithVector , 1 ) \ <nl> - ASH ( StoreIC_Setter_ForDeopt , BUILTIN , kNoExtraICState ) \ <nl> + ASM ( StoreIC_Setter_ForDeopt ) \ <nl> TFS ( StoreIC_Uninitialized , BUILTIN , kNoExtraICState , StoreWithVector , 1 ) \ <nl> TFS ( StoreICStrict_Uninitialized , BUILTIN , kNoExtraICState , StoreWithVector , \ <nl> 1 ) \ <nl> class Isolate ; <nl> TFJ ( AsyncIteratorValueUnwrap , 1 , kValue ) <nl> <nl> # ifdef V8_I18N_SUPPORT <nl> - # define BUILTIN_LIST ( CPP , API , TFJ , TFS , ASM , ASH , DBG ) \ <nl> - BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , ASH , DBG ) \ <nl> - \ <nl> - / * ES # sec - string . prototype . tolowercase * / \ <nl> - CPP ( StringPrototypeToLowerCaseI18N ) \ <nl> - / * ES # sec - string . prototype . touppercase * / \ <nl> + # define BUILTIN_LIST ( CPP , API , TFJ , TFS , ASM , DBG ) \ <nl> + BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , DBG ) \ <nl> + \ <nl> + / * ES # sec - string . prototype . tolowercase * / \ <nl> + CPP ( StringPrototypeToLowerCaseI18N ) \ <nl> + / * ES # sec - string . prototype . touppercase * / \ <nl> CPP ( StringPrototypeToUpperCaseI18N ) <nl> # else <nl> - # define BUILTIN_LIST ( CPP , API , TFJ , TFS , ASM , ASH , DBG ) \ <nl> - BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , ASH , DBG ) <nl> + # define BUILTIN_LIST ( CPP , API , TFJ , TFS , ASM , DBG ) \ <nl> + BUILTIN_LIST_BASE ( CPP , API , TFJ , TFS , ASM , DBG ) <nl> # endif / / V8_I18N_SUPPORT <nl> <nl> # define BUILTIN_PROMISE_REJECTION_PREDICTION_LIST ( V ) \ <nl> class Isolate ; <nl> <nl> # define IGNORE_BUILTIN ( . . . ) <nl> <nl> - # define BUILTIN_LIST_ALL ( V ) BUILTIN_LIST ( V , V , V , V , V , V , V ) <nl> + # define BUILTIN_LIST_ALL ( V ) BUILTIN_LIST ( V , V , V , V , V , V ) <nl> <nl> # define BUILTIN_LIST_TFS ( V ) \ <nl> BUILTIN_LIST ( IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , V , \ <nl> - IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> + IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> <nl> # define BUILTIN_LIST_C ( V ) \ <nl> BUILTIN_LIST ( V , V , IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , \ <nl> - IGNORE_BUILTIN , IGNORE_BUILTIN ) <nl> + IGNORE_BUILTIN ) <nl> <nl> # define BUILTIN_LIST_A ( V ) \ <nl> BUILTIN_LIST ( IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , \ <nl> - V , V , V ) <nl> + V , V ) <nl> <nl> # define BUILTIN_LIST_DBG ( V ) \ <nl> BUILTIN_LIST ( IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , IGNORE_BUILTIN , \ <nl> - IGNORE_BUILTIN , IGNORE_BUILTIN , V ) <nl> + IGNORE_BUILTIN , V ) <nl> <nl> # define BUILTINS_WITH_UNTAGGED_PARAMS ( V ) V ( WasmCompileLazy ) <nl> <nl> class Builtins { <nl> static void Generate_ # # Name ( compiler : : CodeAssemblerState * state ) ; <nl> <nl> BUILTIN_LIST ( IGNORE_BUILTIN , IGNORE_BUILTIN , DECLARE_TF , DECLARE_TF , <nl> - DECLARE_ASM , DECLARE_ASM , DECLARE_ASM ) <nl> + DECLARE_ASM , DECLARE_ASM ) <nl> <nl> # undef DECLARE_ASM <nl> # undef DECLARE_TF <nl>
|
[ builtins ] Remove ASH builtin macro in favor of ASM macro .
|
v8/v8
|
6777eecf4aa3f93c3047ab668c09eadb4b4f0390
|
2017-03-28T11:33:05Z
|
mmm a / hphp / hack / src / typing / typing_enum . ml <nl> ppp b / hphp / hack / src / typing / typing_enum . ml <nl> let enum_check_const env ty_exp ( _ , ( p , _ ) , _ ) t = <nl> | Tprim Tint | Tprim Tstring - > ( ) <nl> ( * Need to allow Tany , since we might not have the types * ) <nl> | Tany - > ( ) <nl> - | _ - > Errors . enum_constant_type_bad ( Reason . to_pos r ) <nl> + | _ - > Errors . enum_constant_type_bad p ( Reason . to_pos r ) <nl> ( Typing_print . error t ' ) trail ) <nl> <nl> <nl> mmm a / hphp / hack / src / utils / errors . ml <nl> ppp b / hphp / hack / src / utils / errors . ml <nl> let missing_constructor pos = <nl> <nl> let typedef_trail_entry pos = pos , " Typedef definition comes from here " <nl> <nl> - let add_with_trail pos s trail = <nl> - add_list ( ( pos , s ) : : List . map typedef_trail_entry trail ) <nl> + let add_with_trail errs trail = <nl> + add_list ( errs @ List . map typedef_trail_entry trail ) <nl> <nl> - let enum_constant_type_bad pos ty trail = <nl> - add_with_trail pos ( " Enum constants must be an int or string , not " ^ ty ) <nl> + let enum_constant_type_bad pos ty_pos ty trail = <nl> + add_with_trail <nl> + [ pos , " Enum constants must be an int or string " ; <nl> + ty_pos , " Not " ^ ty ] <nl> trail <nl> <nl> let enum_type_bad pos ty trail = <nl> - add_with_trail pos <nl> - ( " Enums must have int , string , or mixed type , not " ^ ty ) <nl> + add_with_trail <nl> + [ pos , " Enums must have int , string , or mixed type , not " ^ ty ] <nl> trail <nl> <nl> let enum_type_typedef_mixed pos = <nl> mmm a / hphp / hack / src / utils / errors . mli <nl> ppp b / hphp / hack / src / utils / errors . mli <nl> val visibility_extends : string - > Pos . t - > Pos . t - > string - > unit <nl> val member_not_implemented : string - > Pos . t - > Pos . t - > Pos . t - > unit <nl> val override : Pos . t - > string - > Pos . t - > string - > error - > unit <nl> val missing_constructor : Pos . t - > unit <nl> - val enum_constant_type_bad : Pos . t - > string - > Pos . t list - > unit <nl> + val enum_constant_type_bad : Pos . t - > Pos . t - > string - > Pos . t list - > unit <nl> val enum_type_bad : Pos . t - > string - > Pos . t list - > unit <nl> val enum_type_typedef_mixed : Pos . t - > unit <nl> val invalid_shape_field_name : Pos . t - > unit <nl> mmm a / hphp / hack / test / typecheck / enum_7 . php <nl> ppp b / hphp / hack / test / typecheck / enum_7 . php <nl> <nl> - < ? hh / / strict <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> + < ? hh <nl> <nl> - abstract class Enum < T > { <nl> + abstract class Enum < T > { } <nl> + <nl> + / / Should fail because the bool const is bogus <nl> + class Bar { <nl> + const bool BAZ = true ; <nl> } <nl> <nl> / / Should fail because the bool const is bogus <nl> class Foo extends Enum < mixed > { <nl> const int FOO = 0 ; <nl> const string BAR = " lol " ; <nl> - const bool BAZ = true ; <nl> + const BAZ = Bar : : BAZ ; <nl> } <nl> mmm a / hphp / hack / test / typecheck / enum_7 . php . exp <nl> ppp b / hphp / hack / test / typecheck / enum_7 . php . exp <nl> <nl> - File " enum_7 . php " , line 11 , characters 20 - 23 : <nl> - Enum constants must be an int or string , not a bool <nl> + File " enum_7 . php " , line 14 , characters 9 - 11 : <nl> + Enum constants must be an int or string <nl> + File " enum_7 . php " , line 7 , characters 9 - 12 : <nl> + Not a bool <nl>
|
Improve positions on enum error messages
|
facebook/hhvm
|
64e3ff8db5090d7abb2b609a262f1dcd725c557c
|
2014-07-23T18:00:20Z
|
mmm a / lib / AST / PlatformKind . cpp <nl> ppp b / lib / AST / PlatformKind . cpp <nl> bool swift : : isPlatformActive ( PlatformKind Platform , LangOptions & LangOpts ) { <nl> return LangOpts . Target . isMacOSX ( ) ; <nl> case PlatformKind : : iOS : <nl> case PlatformKind : : iOSApplicationExtension : <nl> + return LangOpts . Target . isiOS ( ) & & ! LangOpts . Target . isTvOS ( ) ; <nl> case PlatformKind : : tvOS : <nl> case PlatformKind : : tvOSApplicationExtension : <nl> - return LangOpts . Target . isiOS ( ) ; <nl> + return LangOpts . Target . isTvOS ( ) ; <nl> case PlatformKind : : watchOS : <nl> case PlatformKind : : watchOSApplicationExtension : <nl> return LangOpts . Target . isWatchOS ( ) ; <nl> PlatformKind swift : : targetPlatform ( LangOptions & LangOpts ) { <nl> : PlatformKind : : OSX ) ; <nl> } <nl> <nl> + if ( LangOpts . Target . isTvOS ( ) ) { <nl> + return ( LangOpts . EnableAppExtensionRestrictions <nl> + ? PlatformKind : : tvOSApplicationExtension <nl> + : PlatformKind : : tvOS ) ; <nl> + } <nl> + <nl> + / / We need to handle watchOS here , as well . <nl> + / / rdar : / / problem / 20774229 <nl> + <nl> if ( LangOpts . Target . isiOS ( ) ) { <nl> return ( LangOpts . EnableAppExtensionRestrictions <nl> ? PlatformKind : : iOSApplicationExtension <nl> mmm a / lib / ClangImporter / ClangImporter . cpp <nl> ppp b / lib / ClangImporter / ClangImporter . cpp <nl> ClangImporter : : Implementation : : Implementation ( ASTContext & ctx , <nl> / / Add filters to determine if a Clang availability attribute <nl> / / applies in Swift , and if so , what is the cutoff for deprecated <nl> / / declarations that are now considered unavailable in Swift . <nl> - if ( ctx . LangOpts . Target . isiOS ( ) ) { <nl> + <nl> + / / We need to handle watchOS here , as well . <nl> + / / rdar : / / problem / 20774229 <nl> + if ( ctx . LangOpts . Target . isiOS ( ) & & ! ctx . LangOpts . Target . isTvOS ( ) ) { <nl> if ( ! ctx . LangOpts . EnableAppExtensionRestrictions ) { <nl> PlatformAvailabilityFilter = <nl> [ ] ( StringRef Platform ) { return Platform = = " ios " ; } ; <nl> ClangImporter : : Implementation : : Implementation ( ASTContext & ctx , <nl> DeprecatedAsUnavailableMessage = <nl> " APIs deprecated as of iOS 7 and earlier are unavailable in Swift " ; <nl> } <nl> + else if ( ctx . LangOpts . Target . isTvOS ( ) ) { <nl> + if ( ! ctx . LangOpts . EnableAppExtensionRestrictions ) { <nl> + PlatformAvailabilityFilter = <nl> + [ ] ( StringRef Platform ) { return Platform = = " tvos " ; } ; <nl> + } <nl> + else { <nl> + PlatformAvailabilityFilter = <nl> + [ ] ( StringRef Platform ) { <nl> + return Platform = = " tvos " | | <nl> + Platform = = " tvos_app_extension " ; } ; <nl> + } <nl> + / / Anything deprecated in iOS 7 . x and earlier is unavailable in Swift . <nl> + DeprecatedAsUnavailableFilter = <nl> + [ ] ( unsigned major , llvm : : Optional < unsigned > minor ) { return major < = 7 ; } ; <nl> + DeprecatedAsUnavailableMessage = <nl> + " APIs deprecated as of iOS 7 and earlier are unavailable in Swift " ; <nl> + } <nl> else if ( ctx . LangOpts . Target . isMacOSX ( ) ) { <nl> if ( ! ctx . LangOpts . EnableAppExtensionRestrictions ) { <nl> PlatformAvailabilityFilter = <nl> mmm a / lib / ClangImporter / ImportDecl . cpp <nl> ppp b / lib / ClangImporter / ImportDecl . cpp <nl> void ClangImporter : : Implementation : : importAttributes ( <nl> continue ; <nl> <nl> / / Translate from Clang platform strings to known Swift platforms . <nl> + / / We need to handle watchOS here , as well . <nl> + / / rdar : / / problem / 20774229 <nl> auto platformK = <nl> llvm : : StringSwitch < Optional < PlatformKind > > ( Platform ) <nl> . Case ( " ios " , PlatformKind : : iOS ) <nl> . Case ( " macosx " , PlatformKind : : OSX ) <nl> + . Case ( " tvos " , PlatformKind : : tvOS ) <nl> . Case ( " ios_app_extension " , PlatformKind : : iOSApplicationExtension ) <nl> . Case ( " macosx_app_extension " , <nl> PlatformKind : : OSXApplicationExtension ) <nl> + . Case ( " tvos_app_extension " , <nl> + PlatformKind : : tvOSApplicationExtension ) <nl> . Default ( None ) ; <nl> if ( ! platformK ) <nl> continue ; <nl> mmm a / test / attr / attr_availability_tvos . swift <nl> ppp b / test / attr / attr_availability_tvos . swift <nl> class DeprecatedClassIn8_0 { } <nl> <nl> / / Elements deprecated later than the minimum deployment target ( which is 9 . 0 , in this case ) should not generate warnings <nl> func functionWithDeprecatedLaterParameter ( p : DeprecatedClassIn8_0 ) { } <nl> + <nl> + / / Treat tvOS as distinct from iOS in availability queries <nl> + <nl> + @ availability ( tvOS , introduced = 9 . 2 ) <nl> + func functionIntroducedOntvOS9_2 ( ) { } <nl> + <nl> + if # available ( iOS > = 9 . 3 , * ) { <nl> + functionIntroducedOntvOS9_2 ( ) / / expected - error { { ' functionIntroducedOntvOS9_2 ( ) ' is only available on tvOS 9 . 2 or newer } } <nl> + / / expected - note @ - 1 { { guard with version check } } <nl> + } <nl> + <nl> + if # available ( iOS > = 9 . 3 , tvOS > = 9 . 1 , * ) { <nl> + functionIntroducedOntvOS9_2 ( ) / / expected - error { { ' functionIntroducedOntvOS9_2 ( ) ' is only available on tvOS 9 . 2 or newer } } <nl> + / / expected - note @ - 1 { { guard with version check } } <nl> + } <nl> + <nl> + if # available ( iOS > = 9 . 1 , tvOS > = 9 . 2 , * ) { <nl> + functionIntroducedOntvOS9_2 ( ) <nl> + } <nl> + <nl> + if # available ( iOS > = 8 . 0 , tvOS > = 9 . 2 , * ) { <nl> + } <nl> + <nl> + if # available ( iOS > = 9 . 2 , tvOS > = 8 . 0 , * ) { / / expected - warning { { unnecessary check for ' tvOS ' ; minimum deployment target ensures guard will always be true } } <nl> + } <nl> + <nl> + <nl> + / / Swift - originated iOS availability attributes should not be transcribed to tvOS <nl> + <nl> + @ availability ( iOS , unavailable ) <nl> + func swiftOriginatedFunctionUnavailableOnIOS ( ) { } <nl> + <nl> + @ availability ( iOS , introduced = 6 . 0 , deprecated = 9 . 0 ) <nl> + func swiftOriginatedFunctionDeprecatedOnIOS ( ) { } <nl> + <nl> + @ availability ( iOS , introduced = 10 . 0 ) <nl> + func swiftOriginatedFunctionPotentiallyUnavailableOnIOS ( ) { } <nl> + <nl> + func useSwiftOriginatedFunctions ( ) { <nl> + / / We do not expect diagnostics here because iOS availability attributes coming from <nl> + / / Swift should not be transcribed to tvOS . <nl> + swiftOriginatedFunctionUnavailableOnIOS ( ) <nl> + swiftOriginatedFunctionDeprecatedOnIOS ( ) <nl> + swiftOriginatedFunctionPotentiallyUnavailableOnIOS ( ) <nl> + } <nl>
|
Do not treat iOS as active on tvOS .
|
apple/swift
|
4f366b1ff6ae3aecb5c3938cf92d25fb3deb92b7
|
2015-05-01T01:54:24Z
|
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> NOTE ( availability_protocol_requirement_here , none , <nl> " protocol requirement here " , ( ) ) <nl> <nl> WARNING ( public_decl_needs_availability , none , <nl> - " public declarations should have an availability attribute with - require - explicit - availability " , ( ) ) <nl> + " public declarations should have an availability attribute when building " <nl> + " with - require - explicit - availability " , ( ) ) <nl> <nl> / / This doesn ' t display as an availability diagnostic , but it ' s <nl> / / implemented there and fires when these subscripts are marked <nl> / / unavailable , so it seems appropriate to put it here . <nl> ERROR ( availabilty_string_subscript_migration , none , <nl> - " subscripts returning String were obsoleted in Swift 4 ; explicitly construct a String from subscripted result " , ( ) ) <nl> + " subscripts returning String were obsoleted in Swift 4 ; explicitly " <nl> + " construct a String from subscripted result " , ( ) ) <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / MARK : @ discardableResult <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> WARNING ( discardable_result_on_void_never_function , none , <nl> - " @ discardableResult declared on a function returning % select { Never | Void } 0 is unnecessary " , <nl> - ( bool ) ) <nl> + " @ discardableResult declared on a function returning % select { Never | Void } 0 " <nl> + " is unnecessary " , ( bool ) ) <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / MARK : Resilience diagnostics <nl> mmm a / lib / Driver / ToolChains . cpp <nl> ppp b / lib / Driver / ToolChains . cpp <nl> static void addCommonFrontendArgs ( const ToolChain & TC , const OutputInfo & OI , <nl> inputArgs . AddLastArg ( arguments , options : : OPT_typo_correction_limit ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_app_extension ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_library_evolution ) ; <nl> + inputArgs . AddLastArg ( arguments , options : : OPT_require_explicit_availability ) ; <nl> + inputArgs . AddLastArg ( arguments , options : : OPT_require_explicit_availability_target ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_testing ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_private_imports ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_cxx_interop ) ; <nl> mmm a / test / attr / require_explicit_availability . swift <nl> ppp b / test / attr / require_explicit_availability . swift <nl> <nl> - / / RUN : % swift - typecheck - parse - stdlib - target x86_64 - apple - macosx10 . 10 - verify - require - explicit - availability - require - explicit - availability - target " macOS 10 . 10 " % s <nl> - / / RUN : % swift - typecheck - parse - stdlib - target x86_64 - apple - macosx10 . 10 - warnings - as - errors % s <nl> + / / RUN : % swiftc_driver - typecheck - parse - stdlib - target x86_64 - apple - macosx10 . 10 - Xfrontend - verify - require - explicit - availability - require - explicit - availability - target " macOS 10 . 10 " % s <nl> + / / RUN : % swiftc_driver - typecheck - parse - stdlib - target x86_64 - apple - macosx10 . 10 - warnings - as - errors % s <nl> <nl> - public struct S { / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } <nl> + public struct S { / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } <nl> public func method ( ) { } <nl> } <nl> <nl> - public func foo ( ) { bar ( ) } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public func foo ( ) { bar ( ) } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> @ usableFromInline <nl> - func bar ( ) { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + func bar ( ) { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> @ available ( macOS 10 . 1 , * ) <nl> public func ok ( ) { } <nl> public func ok ( ) { } <nl> public func unavailableOk ( ) { } <nl> <nl> @ available ( macOS , deprecated : 10 . 10 ) <nl> - public func missingIntro ( ) { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public func missingIntro ( ) { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> @ available ( iOS 9 . 0 , * ) <nl> - public func missingTargetPlatform ( ) { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public func missingTargetPlatform ( ) { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> func privateFunc ( ) { } <nl> <nl> struct SOk { <nl> precedencegroup MediumPrecedence { } <nl> infix operator + : MediumPrecedence <nl> <nl> - public func + ( lhs : S , rhs : S ) - > S { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public func + ( lhs : S , rhs : S ) - > S { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> - public enum E { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public enum E { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> - public class C { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public class C { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> - public protocol P { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + public protocol P { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> - extension S { / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + extension S { / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> func ok ( ) { } <nl> } <nl> <nl> - open class OpenClass { } / / expected - warning { { public declarations should have an availability attribute with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> + open class OpenClass { } / / expected - warning { { public declarations should have an availability attribute when building with - require - explicit - availability } } { { 1 - 1 = @ available ( macOS 10 . 10 , * ) \ n } } <nl> <nl> private class PrivateClass { } <nl> <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
c7bc66003ef47b7fe0887d175fbdba052de8c34f
|
2020-01-14T05:17:58Z
|
mmm a / src / lookup - inl . h <nl> ppp b / src / lookup - inl . h <nl> JSReceiver * LookupIterator : : NextHolder ( Map * map ) { <nl> next - > map ( ) - > is_hidden_prototype ( ) ) ; <nl> <nl> if ( ! check_derived ( ) & & <nl> - ! ( check_hidden ( ) & & next - > map ( ) - > is_hidden_prototype ( ) ) ) { <nl> + ! ( check_hidden ( ) & & next - > map ( ) - > is_hidden_prototype ( ) ) & & <nl> + / / Always lookup behind the JSGlobalProxy into the JSGlobalObject , even <nl> + / / when not checking other hidden prototypes . <nl> + ! ( map - > IsJSGlobalProxyMap ( ) & & next - > IsJSGlobalObject ( ) ) ) { <nl> return NULL ; <nl> } <nl> <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> bool JSArray : : WouldChangeReadOnlyLength ( Handle < JSArray > array , <nl> uint32_t length = 0 ; <nl> CHECK ( array - > length ( ) - > ToArrayIndex ( & length ) ) ; <nl> if ( length < = index ) { <nl> - Isolate * isolate = array - > GetIsolate ( ) ; <nl> - LookupResult lookup ( isolate ) ; <nl> - Handle < Name > length_string = isolate - > factory ( ) - > length_string ( ) ; <nl> - array - > LookupOwnRealNamedProperty ( length_string , & lookup ) ; <nl> - return lookup . IsReadOnly ( ) ; <nl> + LookupIterator it ( array , array - > GetIsolate ( ) - > factory ( ) - > length_string ( ) , <nl> + LookupIterator : : CHECK_PROPERTY ) ; <nl> + CHECK ( it . IsFound ( ) ) ; <nl> + CHECK ( it . HasProperty ( ) ) ; <nl> + return it . IsReadOnly ( ) ; <nl> } <nl> return false ; <nl> } <nl> MaybeHandle < JSObject > JSObject : : GetKeysForIndexedInterceptor ( <nl> <nl> Maybe < bool > JSObject : : HasRealNamedProperty ( Handle < JSObject > object , <nl> Handle < Name > key ) { <nl> - Isolate * isolate = object - > GetIsolate ( ) ; <nl> - SealHandleScope shs ( isolate ) ; <nl> - / / Check access rights if needed . <nl> - if ( object - > IsAccessCheckNeeded ( ) ) { <nl> - if ( ! isolate - > MayNamedAccess ( object , key , v8 : : ACCESS_HAS ) ) { <nl> - isolate - > ReportFailedAccessCheck ( object , v8 : : ACCESS_HAS ) ; <nl> - RETURN_VALUE_IF_SCHEDULED_EXCEPTION ( isolate , Maybe < bool > ( ) ) ; <nl> - return maybe ( false ) ; <nl> - } <nl> - } <nl> - <nl> - LookupResult result ( isolate ) ; <nl> - object - > LookupOwnRealNamedProperty ( key , & result ) ; <nl> - return maybe ( result . IsFound ( ) & & ! result . IsInterceptor ( ) ) ; <nl> + LookupIterator it ( object , key , LookupIterator : : CHECK_ACCESS_CHECK ) ; <nl> + Maybe < PropertyAttributes > maybe_result = GetPropertyAttributes ( & it ) ; <nl> + if ( ! maybe_result . has_value ) return Maybe < bool > ( ) ; <nl> + return maybe ( it . IsFound ( ) ) ; <nl> } <nl> <nl> <nl> Maybe < bool > JSObject : : HasRealElementProperty ( Handle < JSObject > object , <nl> <nl> Maybe < bool > JSObject : : HasRealNamedCallbackProperty ( Handle < JSObject > object , <nl> Handle < Name > key ) { <nl> - Isolate * isolate = object - > GetIsolate ( ) ; <nl> - SealHandleScope shs ( isolate ) ; <nl> - / / Check access rights if needed . <nl> - if ( object - > IsAccessCheckNeeded ( ) ) { <nl> - if ( ! isolate - > MayNamedAccess ( object , key , v8 : : ACCESS_HAS ) ) { <nl> - isolate - > ReportFailedAccessCheck ( object , v8 : : ACCESS_HAS ) ; <nl> - RETURN_VALUE_IF_SCHEDULED_EXCEPTION ( isolate , Maybe < bool > ( ) ) ; <nl> - return maybe ( false ) ; <nl> - } <nl> - } <nl> - <nl> - LookupResult result ( isolate ) ; <nl> - object - > LookupOwnRealNamedProperty ( key , & result ) ; <nl> - return maybe ( result . IsPropertyCallbacks ( ) ) ; <nl> + LookupIterator it ( object , key , LookupIterator : : CHECK_ACCESS_CHECK ) ; <nl> + Maybe < PropertyAttributes > maybe_result = GetPropertyAttributes ( & it ) ; <nl> + if ( ! maybe_result . has_value ) return Maybe < bool > ( ) ; <nl> + return maybe ( it . IsFound ( ) & & it . property_kind ( ) = = LookupIterator : : ACCESSOR ) ; <nl> } <nl> <nl> <nl> mmm a / test / cctest / test - api . cc <nl> ppp b / test / cctest / test - api . cc <nl> TEST ( AccessCheckThrows ) { <nl> <nl> / / Create a context and set an x property on it ' s global object . <nl> LocalContext context0 ( NULL , global_template ) ; <nl> - context0 - > Global ( ) - > Set ( v8_str ( " x " ) , v8_num ( 42 ) ) ; <nl> v8 : : Handle < v8 : : Object > global0 = context0 - > Global ( ) ; <nl> <nl> / / Create a context with a different security token so that the <nl>
|
Get rid of all non - IC uses of LookupOwnRealNamedProperty
|
v8/v8
|
2d2396a8a8bf4815e877fb4f7e988b28caeecda1
|
2014-08-21T08:26:42Z
|
mmm a / arangod / Agency / AsyncAgencyComm . h <nl> ppp b / arangod / Agency / AsyncAgencyComm . h <nl> struct AsyncAgencyCommResult { <nl> / / switched off . And since warnings are considered to be errors , we must <nl> / / switch the warning off : <nl> <nl> - # if defined ( __GNUC__ ) & & ( __GNUC___ > 9 | | ( __GNUC__ = = 9 & & __GNUC_MINOR__ > = 3 ) ) <nl> + # if defined ( __GNUC__ ) & & ( __GNUC__ > 9 | | ( __GNUC__ = = 9 & & __GNUC_MINOR__ > = 3 ) ) <nl> # pragma GCC diagnostic push <nl> # pragma GCC diagnostic ignored " - Wmaybe - uninitialized " <nl> # endif <nl>
|
support gcc - 10 ( )
|
arangodb/arangodb
|
eaf95ff0140b4714ff74b29f60945ba75fa2f7f7
|
2020-05-15T09:34:35Z
|
mmm a / tools / shared . py <nl> ppp b / tools / shared . py <nl> def load ( self , args = [ ] ) : <nl> if args [ i ] = = ' - s ' : <nl> exec ' Settings . ' + args [ i + 1 ] in globals ( ) # execute the setting <nl> <nl> - # Save the defaults for later comparisons , including the - O changes . This way <nl> - # we only pass the relevant - s flags that actually change things after - O to emcc <nl> - # in the test runner <nl> - Settings . defaults = copy . copy ( Settings . __dict__ ) <nl> - <nl> # Transforms the Settings information into emcc - compatible args ( - s X = Y , etc . ) . Basically <nl> # the reverse of load_settings , except for - Ox which is relevant there but not here <nl> @ classmethod <nl> def serialize ( self ) : <nl> for key , value in Settings . __dict__ . iteritems ( ) : <nl> if key = = key . upper ( ) : # this is a hack . all of our settings are ALL_CAPS , python internals are not <nl> jsoned = json . dumps ( value ) <nl> - # Only add if it actually modifies a default <nl> - if key not in Settings . defaults or jsoned ! = json . dumps ( Settings . defaults [ key ] ) : <nl> - ret + = [ ' - s ' , key + ' = ' + jsoned ] <nl> + ret + = [ ' - s ' , key + ' = ' + jsoned ] <nl> return ret <nl> <nl> @ classmethod <nl>
|
disable pruning of emcc - s opts from test runner - it ' s too buggy
|
emscripten-core/emscripten
|
f5d18e37bf343f1f7968c9cc6bba2babc00d2e6b
|
2012-01-21T18:16:48Z
|
mmm a / tools / dockerfile / grpc_python / Dockerfile <nl> ppp b / tools / dockerfile / grpc_python / Dockerfile <nl> RUN cd / var / local / git / grpc \ <nl> & & pip install src / python / interop <nl> <nl> # Run Python GRPC ' s tests <nl> + # TODO ( nathaniel ) : It would be nice for these to be auto - discoverable ? <nl> RUN cd / var / local / git / grpc \ <nl> - # TODO ( nathaniel ) : It would be nice for these to be auto - discoverable ? <nl> - & & python2 . 7 - B - m grpc . _adapter . _blocking_invocation_inline_service_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _c_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _event_invocation_synchronous_event_service_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _future_invocation_asynchronous_event_service_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _links_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _lonely_rear_link_test <nl> - & & python2 . 7 - B - m grpc . _adapter . _low_test <nl> - & & python2 . 7 - B - m grpc . framework . assembly . implementations_test <nl> - & & python2 . 7 - B - m grpc . framework . base . packets . implementations_test <nl> - & & python2 . 7 - B - m grpc . framework . face . blocking_invocation_inline_service_test <nl> - & & python2 . 7 - B - m grpc . framework . face . event_invocation_synchronous_event_service_test <nl> - & & python2 . 7 - B - m grpc . framework . face . future_invocation_asynchronous_event_service_test <nl> - & & python2 . 7 - B - m grpc . framework . foundation . _later_test <nl> + & & python2 . 7 - B - m grpc . _adapter . _blocking_invocation_inline_service_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _c_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _event_invocation_synchronous_event_service_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _future_invocation_asynchronous_event_service_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _links_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _lonely_rear_link_test \ <nl> + & & python2 . 7 - B - m grpc . _adapter . _low_test \ <nl> + & & python2 . 7 - B - m grpc . framework . assembly . implementations_test \ <nl> + & & python2 . 7 - B - m grpc . framework . base . packets . implementations_test \ <nl> + & & python2 . 7 - B - m grpc . framework . face . blocking_invocation_inline_service_test \ <nl> + & & python2 . 7 - B - m grpc . framework . face . event_invocation_synchronous_event_service_test \ <nl> + & & python2 . 7 - B - m grpc . framework . face . future_invocation_asynchronous_event_service_test \ <nl> + & & python2 . 7 - B - m grpc . framework . foundation . _later_test \ <nl> & & python2 . 7 - B - m grpc . framework . foundation . _logging_pool_test <nl> <nl> # Add a cacerts directory containing the Google root pem file , allowing the interop client to access the production test instance <nl>
|
Fix backslash line endings for grpc_python / Dockerfile .
|
grpc/grpc
|
093a4ebd3e0bb307af0738ba4e53d5aed28b15f4
|
2015-03-03T16:13:56Z
|
mmm a / src / rdb_protocol / terms / db_table . hpp <nl> ppp b / src / rdb_protocol / terms / db_table . hpp <nl> class table_term_t : public op_term_t { <nl> db = arg ( 0 ) - > as_db ( ) ; <nl> name = arg ( 1 ) - > as_str ( ) ; <nl> } <nl> + virtual bool is_deterministic_impl ( ) const { return false ; } <nl> return new_val ( new table_t ( env , db , name , use_outdated , this ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " table " ; } <nl>
|
fixed crashing bug discovered while fixing issue 579
|
rethinkdb/rethinkdb
|
8541a505a1fc46a280030afd51760f741d3daf76
|
2013-04-09T20:16:35Z
|
mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> void PrintAST : : printOneParameter ( const Pattern * BodyPattern , <nl> <nl> / / If the parameter is autoclosure , or noescape , print it . This is stored <nl> / / on the type of the pattern , not on the typerepr . <nl> - auto bodyCanType = BodyPattern - > getType ( ) - > getCanonicalType ( ) ; <nl> - if ( auto patternType = dyn_cast_or_null < AnyFunctionType > ( bodyCanType ) ) { <nl> - switch ( patternType - > isAutoClosure ( ) * 2 + patternType - > isNoEscape ( ) ) { <nl> - case 0 : break ; / / neither . <nl> - case 1 : Printer < < " @ noescape " ; break ; <nl> - case 2 : Printer < < " @ autoclosure ( escaping ) " ; break ; <nl> - case 3 : Printer < < " @ autoclosure " ; break ; <nl> + if ( BodyPattern - > hasType ( ) ) { <nl> + auto bodyCanType = BodyPattern - > getType ( ) - > getCanonicalType ( ) ; <nl> + if ( auto patternType = dyn_cast < AnyFunctionType > ( bodyCanType ) ) { <nl> + switch ( patternType - > isAutoClosure ( ) * 2 + patternType - > isNoEscape ( ) ) { <nl> + case 0 : break ; / / neither . <nl> + case 1 : Printer < < " @ noescape " ; break ; <nl> + case 2 : Printer < < " @ autoclosure ( escaping ) " ; break ; <nl> + case 3 : Printer < < " @ autoclosure " ; break ; <nl> + } <nl> } <nl> } <nl> <nl>
|
Fix for a testcase problem , this goes with r25406
|
apple/swift
|
c4f4dddb1f98b78af7c334b5aa074cd9851e693a
|
2015-02-20T02:13:30Z
|
mmm a / flow / IndexedSet . h <nl> ppp b / flow / IndexedSet . h <nl> struct IndexedSet { <nl> static IteratorT lastItem ( SetT & ) ; <nl> } ; <nl> <nl> + using ConstImpl = Impl < true > ; <nl> + using NonConstImpl = Impl < false > ; <nl> + <nl> public : <nl> using iterator = IteratorImpl < false > ; <nl> using const_iterator = IteratorImpl < true > ; <nl> struct IndexedSet { <nl> IndexedSet ( IndexedSet & & r ) BOOST_NOEXCEPT : root ( r . root ) { r . root = NULL ; } <nl> IndexedSet & operator = ( IndexedSet & & r ) BOOST_NOEXCEPT { delete root ; root = r . root ; r . root = 0 ; return * this ; } <nl> <nl> - const_iterator begin ( ) const { return Impl < true > : : begin ( * this ) ; } ; <nl> - iterator begin ( ) { return Impl < false > : : begin ( * this ) ; } ; <nl> - const_iterator end ( ) const { return Impl < true > : : end ( * this ) ; } <nl> - iterator end ( ) { return Impl < false > : : end ( * this ) ; } <nl> + const_iterator begin ( ) const { return ConstImpl : : begin ( * this ) ; } ; <nl> + iterator begin ( ) { return NonConstImpl : : begin ( * this ) ; } ; <nl> + const_iterator end ( ) const { return ConstImpl : : end ( * this ) ; } <nl> + iterator end ( ) { return NonConstImpl : : end ( * this ) ; } <nl> <nl> - const_iterator previous ( const_iterator i ) const { return Impl < true > : : previous ( * this , i ) ; } <nl> + const_iterator previous ( const_iterator i ) const { return ConstImpl : : previous ( * this , i ) ; } <nl> template < bool constIterator > <nl> IteratorImpl < constIterator > previous ( IteratorImpl < constIterator > i ) { <nl> - return Impl < false > : : previous ( * this , i ) ; <nl> + return NonConstImpl : : previous ( * this , i ) ; <nl> } ; <nl> <nl> - const_iterator lastItem ( ) const { return Impl < true > : : lastItem ( * this ) ; } <nl> - iterator lastItem ( ) { return Impl < false > : : lastItem ( * this ) ; } <nl> + const_iterator lastItem ( ) const { return ConstImpl : : lastItem ( * this ) ; } <nl> + iterator lastItem ( ) { return NonConstImpl : : lastItem ( * this ) ; } <nl> <nl> bool empty ( ) const { return ! root ; } <nl> void clear ( ) { delete root ; root = NULL ; } <nl> struct IndexedSet { <nl> / / Returns x such that key = = * x , or end ( ) <nl> template < class Key > <nl> const_iterator find ( const Key & key ) const { <nl> - return Impl < true > : : find ( * this , key ) ; <nl> + return ConstImpl : : find ( * this , key ) ; <nl> } <nl> <nl> template < class Key > <nl> iterator find ( const Key & key ) { <nl> - return Impl < false > : : find ( * this , key ) ; <nl> + return NonConstImpl : : find ( * this , key ) ; <nl> } <nl> <nl> / / Returns the smallest x such that * x > = key , or end ( ) <nl> template < class Key > <nl> const_iterator lower_bound ( const Key & key ) const { <nl> - return Impl < true > : : lower_bound ( * this , key ) ; <nl> + return ConstImpl : : lower_bound ( * this , key ) ; <nl> } <nl> <nl> template < class Key > <nl> iterator lower_bound ( const Key & key ) { <nl> - return Impl < false > : : lower_bound ( * this , key ) ; <nl> + return NonConstImpl : : lower_bound ( * this , key ) ; <nl> } ; <nl> <nl> / / Returns the smallest x such that * x > key , or end ( ) <nl> template < class Key > <nl> const_iterator upper_bound ( const Key & key ) const { <nl> - return Impl < true > : : upper_bound ( * this , key ) ; <nl> + return ConstImpl : : upper_bound ( * this , key ) ; <nl> } <nl> <nl> template < class Key > <nl> iterator upper_bound ( const Key & key ) { <nl> - return Impl < false > : : upper_bound ( * this , key ) ; <nl> + return NonConstImpl : : upper_bound ( * this , key ) ; <nl> } ; <nl> <nl> / / Returns the largest x such that * x < = key , or end ( ) <nl> template < class Key > <nl> const_iterator lastLessOrEqual ( const Key & key ) const { <nl> - return Impl < true > : : lastLessOrEqual ( * this , key ) ; <nl> + return ConstImpl : : lastLessOrEqual ( * this , key ) ; <nl> } ; <nl> <nl> template < class Key > <nl> iterator lastLessOrEqual ( const Key & key ) { <nl> - return Impl < false > : : lastLessOrEqual ( * this , key ) ; <nl> + return NonConstImpl : : lastLessOrEqual ( * this , key ) ; <nl> } <nl> <nl> / / Returns smallest x such that sumTo ( x + 1 ) > metric , or end ( ) <nl> template < class M > <nl> const_iterator index ( M const & metric ) const { <nl> - return Impl < true > : : index ( * this , metric ) ; <nl> + return ConstImpl : : index ( * this , metric ) ; <nl> } ; <nl> <nl> template < class M > <nl> iterator index ( M const & metric ) { <nl> - return Impl < false > : : index ( * this , metric ) ; <nl> + return NonConstImpl : : index ( * this , metric ) ; <nl> } <nl> <nl> / / Return the metric inserted with item x <nl>
|
Added IndexedSet : : ConstImpl and IndexedSet : : NonConstImpl
|
apple/foundationdb
|
e11ba12da70b587df58db157df43804a3d6cb465
|
2020-05-17T01:38:02Z
|
mmm a / objectivec / GPBCodedInputStream . h <nl> ppp b / objectivec / GPBCodedInputStream . h <nl> <nl> <nl> NS_ASSUME_NONNULL_BEGIN <nl> <nl> + CF_EXTERN_C_BEGIN <nl> + <nl> + / / / GPBCodedInputStream exception name . Exceptions raised from <nl> + / / / GPBCodedInputStream contain an underlying error in the userInfo dictionary <nl> + / / / under the GPBCodedInputStreamUnderlyingErrorKey key . <nl> + extern NSString * const GPBCodedInputStreamException ; <nl> + <nl> + / / / The key under which the underlying NSError from the exception is stored . <nl> + extern NSString * const GPBCodedInputStreamUnderlyingErrorKey ; <nl> + <nl> + / / / NSError domain used for GPBCodedInputStream errors . <nl> + extern NSString * const GPBCodedInputStreamErrorDomain ; <nl> + <nl> + / / / Error code for NSError with GPBCodedInputStreamErrorDomain . <nl> + typedef NS_ENUM ( NSInteger , GPBCodedInputStreamErrorCode ) { <nl> + / / / The size does not fit in the remaining bytes to be read . <nl> + GPBCodedInputStreamErrorInvalidSize = - 100 , <nl> + / / / Attempted to read beyond the subsection limit . <nl> + GPBCodedInputStreamErrorSubsectionLimitReached = - 101 , <nl> + / / / The requested subsection limit is invalid . <nl> + GPBCodedInputStreamErrorInvalidSubsectionLimit = - 102 , <nl> + / / / Invalid tag read . <nl> + GPBCodedInputStreamErrorInvalidTag = - 103 , <nl> + / / / Invalid UTF - 8 character in a string . <nl> + GPBCodedInputStreamErrorInvalidUTF8 = - 104 , <nl> + / / / Invalid VarInt read . <nl> + GPBCodedInputStreamErrorInvalidVarInt = - 105 , <nl> + / / / The maximum recursion depth of messages was exceeded . <nl> + GPBCodedInputStreamErrorRecursionDepthExceeded = - 106 , <nl> + } ; <nl> + <nl> + CF_EXTERN_C_END <nl> + <nl> / / / Reads and decodes protocol message fields . <nl> / / / <nl> / / / The common uses of protocol buffers shouldn ' t need to use this class . <nl> mmm a / objectivec / GPBCodedInputStream . m <nl> ppp b / objectivec / GPBCodedInputStream . m <nl> <nl> # import " GPBUtilities_PackagePrivate . h " <nl> # import " GPBWireFormat . h " <nl> <nl> + NSString * const GPBCodedInputStreamException = <nl> + GPBNSStringifySymbol ( GPBCodedInputStreamException ) ; <nl> + <nl> + NSString * const GPBCodedInputStreamUnderlyingErrorKey = <nl> + GPBNSStringifySymbol ( GPBCodedInputStreamUnderlyingErrorKey ) ; <nl> + <nl> + NSString * const GPBCodedInputStreamErrorDomain = <nl> + GPBNSStringifySymbol ( GPBCodedInputStreamErrorDomain ) ; <nl> + <nl> static const NSUInteger kDefaultRecursionLimit = 64 ; <nl> <nl> + static void RaiseException ( NSInteger code , NSString * reason ) { <nl> + NSDictionary * errorInfo = nil ; <nl> + if ( [ reason length ] ) { <nl> + errorInfo = @ { GPBErrorReasonKey : reason } ; <nl> + } <nl> + NSError * error = [ NSError errorWithDomain : GPBCodedInputStreamErrorDomain <nl> + code : code <nl> + userInfo : errorInfo ] ; <nl> + <nl> + NSDictionary * exceptionInfo = <nl> + @ { GPBCodedInputStreamUnderlyingErrorKey : error } ; <nl> + [ [ [ NSException alloc ] initWithName : GPBCodedInputStreamException <nl> + reason : reason <nl> + userInfo : exceptionInfo ] raise ] ; <nl> + } <nl> + <nl> static void CheckSize ( GPBCodedInputStreamState * state , size_t size ) { <nl> size_t newSize = state - > bufferPos + size ; <nl> if ( newSize > state - > bufferSize ) { <nl> - [ NSException raise : NSParseErrorException format : @ " " ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidSize , nil ) ; <nl> } <nl> if ( newSize > state - > currentLimit ) { <nl> / / Fast forward to end of currentLimit ; <nl> state - > bufferPos = state - > currentLimit ; <nl> - [ NSException raise : NSParseErrorException format : @ " " ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorSubsectionLimitReached , nil ) ; <nl> } <nl> } <nl> <nl> static int32_t ReadRawVarint32 ( GPBCodedInputStreamState * state ) { <nl> return result ; <nl> } <nl> } <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " Unable to read varint32 " ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidVarInt , <nl> + @ " Invalid VarInt32 " ) ; <nl> } <nl> } <nl> } <nl> static int64_t ReadRawVarint64 ( GPBCodedInputStreamState * state ) { <nl> } <nl> shift + = 7 ; <nl> } <nl> - [ NSException raise : NSParseErrorException format : @ " Unable to read varint64 " ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidVarInt , @ " Invalid VarInt64 " ) ; <nl> return 0 ; <nl> } <nl> <nl> int32_t GPBCodedInputStreamReadTag ( GPBCodedInputStreamState * state ) { <nl> state - > lastTag = ReadRawVarint32 ( state ) ; <nl> if ( state - > lastTag = = 0 ) { <nl> / / If we actually read zero , that ' s not a valid tag . <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " Invalid last tag % d " , state - > lastTag ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidTag , @ " Last tag can ' t be 0 " ) ; <nl> } <nl> return state - > lastTag ; <nl> } <nl> int32_t GPBCodedInputStreamReadTag ( GPBCodedInputStreamState * state ) { <nl> NSLog ( @ " UTF - 8 failure , is some field type ' string ' when it should be " <nl> @ " ' bytes ' ? " ) ; <nl> # endif <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " Invalid UTF - 8 for a ' string ' " ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidUTF8 , nil ) ; <nl> } <nl> } <nl> return result ; <nl> size_t GPBCodedInputStreamPushLimit ( GPBCodedInputStreamState * state , <nl> byteLimit + = state - > bufferPos ; <nl> size_t oldLimit = state - > currentLimit ; <nl> if ( byteLimit > oldLimit ) { <nl> - [ NSException raise : NSInvalidArgumentException <nl> - format : @ " byteLimit > oldLimit : % tu > % tu " , byteLimit , oldLimit ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidSubsectionLimit , nil ) ; <nl> } <nl> state - > currentLimit = byteLimit ; <nl> return oldLimit ; <nl> BOOL GPBCodedInputStreamIsAtEnd ( GPBCodedInputStreamState * state ) { <nl> void GPBCodedInputStreamCheckLastTagWas ( GPBCodedInputStreamState * state , <nl> int32_t value ) { <nl> if ( state - > lastTag ! = value ) { <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " Last tag : % d should be % d " , state - > lastTag , value ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidTag , @ " Unexpected tag read " ) ; <nl> } <nl> } <nl> <nl> - ( BOOL ) skipField : ( int32_t ) tag { <nl> SkipRawData ( & state_ , sizeof ( int32_t ) ) ; <nl> return YES ; <nl> } <nl> - [ NSException raise : NSParseErrorException format : @ " Invalid tag % d " , tag ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorInvalidTag , nil ) ; <nl> return NO ; <nl> } <nl> <nl> - ( void ) readGroup : ( int32_t ) fieldNumber <nl> message : ( GPBMessage * ) message <nl> extensionRegistry : ( GPBExtensionRegistry * ) extensionRegistry { <nl> if ( state_ . recursionDepth > = kDefaultRecursionLimit ) { <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " recursionDepth ( % tu ) > = % tu " , state_ . recursionDepth , <nl> - kDefaultRecursionLimit ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorRecursionDepthExceeded , nil ) ; <nl> } <nl> + + state_ . recursionDepth ; <nl> [ message mergeFromCodedInputStream : self extensionRegistry : extensionRegistry ] ; <nl> - ( void ) readGroup : ( int32_t ) fieldNumber <nl> - ( void ) readUnknownGroup : ( int32_t ) fieldNumber <nl> message : ( GPBUnknownFieldSet * ) message { <nl> if ( state_ . recursionDepth > = kDefaultRecursionLimit ) { <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " recursionDepth ( % tu ) > = % tu " , state_ . recursionDepth , <nl> - kDefaultRecursionLimit ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorRecursionDepthExceeded , nil ) ; <nl> } <nl> + + state_ . recursionDepth ; <nl> [ message mergeFromCodedInputStream : self ] ; <nl> - ( void ) readMessage : ( GPBMessage * ) message <nl> extensionRegistry : ( GPBExtensionRegistry * ) extensionRegistry { <nl> int32_t length = ReadRawVarint32 ( & state_ ) ; <nl> if ( state_ . recursionDepth > = kDefaultRecursionLimit ) { <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " recursionDepth ( % tu ) > = % tu " , state_ . recursionDepth , <nl> - kDefaultRecursionLimit ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorRecursionDepthExceeded , nil ) ; <nl> } <nl> size_t oldLimit = GPBCodedInputStreamPushLimit ( & state_ , length ) ; <nl> + + state_ . recursionDepth ; <nl> - ( void ) readMapEntry : ( id ) mapDictionary <nl> parentMessage : ( GPBMessage * ) parentMessage { <nl> int32_t length = ReadRawVarint32 ( & state_ ) ; <nl> if ( state_ . recursionDepth > = kDefaultRecursionLimit ) { <nl> - [ NSException raise : NSParseErrorException <nl> - format : @ " recursionDepth ( % tu ) > = % tu " , state_ . recursionDepth , <nl> - kDefaultRecursionLimit ] ; <nl> + RaiseException ( GPBCodedInputStreamErrorRecursionDepthExceeded , nil ) ; <nl> } <nl> size_t oldLimit = GPBCodedInputStreamPushLimit ( & state_ , length ) ; <nl> + + state_ . recursionDepth ; <nl> mmm a / objectivec / GPBMessage . h <nl> ppp b / objectivec / GPBMessage . h <nl> extern NSString * const GPBMessageErrorDomain ; <nl> <nl> / / / Error code for NSError with GPBMessageErrorDomain . <nl> typedef NS_ENUM ( NSInteger , GPBMessageErrorCode ) { <nl> - / / / The data being parsed is bad and a message can not be created from it . <nl> - GPBMessageErrorCodeMalformedData = - 100 , <nl> + / / / Uncategorized error . <nl> + GPBMessageErrorCodeOther = - 100 , <nl> / / / A message can ' t be serialized because it is missing required fields . <nl> GPBMessageErrorCodeMissingRequiredField = - 101 , <nl> } ; <nl> <nl> + / / / Key under which the error ' s reason is stored inside the userInfo dictionary . <nl> + extern NSString * const GPBErrorReasonKey ; <nl> + <nl> CF_EXTERN_C_END <nl> <nl> / / / Base class for all of the generated message classes . <nl> CF_EXTERN_C_END <nl> / / / @ note In DEBUG builds , the parsed message is checked to be sure all required <nl> / / / fields were provided , and the parse will fail if some are missing . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param data The data to parse . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure reason if <nl> / / / the data can not be parsed . <nl> CF_EXTERN_C_END <nl> / / / @ note In DEBUG builds , the parsed message is checked to be sure all required <nl> / / / fields were provided , and the parse will fail if some are missing . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param data The data to parse . <nl> / / / @ param extensionRegistry The extension registry to use to look up extensions . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure <nl> CF_EXTERN_C_END <nl> / / / @ note In DEBUG builds , the parsed message is checked to be sure all required <nl> / / / fields were provided , and the parse will fail if some are missing . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param input The stream to read data from . <nl> / / / @ param extensionRegistry The extension registry to use to look up extensions . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure <nl> CF_EXTERN_C_END <nl> / / / the required fields are set . So this method can be used to reload <nl> / / / messages that may not be complete . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param input The stream to read data from . <nl> / / / @ param extensionRegistry The extension registry to use to look up extensions . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure <nl> CF_EXTERN_C_END <nl> / / / @ note In DEBUG builds , the parsed message is checked to be sure all required <nl> / / / fields were provided , and the parse will fail if some are missing . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param data The data to parse . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure reason if <nl> / / / the data can not be parsed . <nl> CF_EXTERN_C_END <nl> / / / @ note In DEBUG builds , the parsed message is checked to be sure all required <nl> / / / fields were provided , and the parse will fail if some are missing . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param data The data to parse . <nl> / / / @ param extensionRegistry The extension registry to use to look up extensions . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure <nl> CF_EXTERN_C_END <nl> / / / the required fields are set . So this method can be used to reload <nl> / / / messages that may not be complete . <nl> / / / <nl> + / / / @ note The errors returned are likely coming from the domain and codes listed <nl> + / / / at the top of this file and GPBCodedInputStream . h . <nl> + / / / <nl> / / / @ param input The stream to read data from . <nl> / / / @ param extensionRegistry The extension registry to use to look up extensions . <nl> / / / @ param errorPtr An optional error pointer to fill in with a failure <nl> mmm a / objectivec / GPBMessage . m <nl> ppp b / objectivec / GPBMessage . m <nl> <nl> NSString * const GPBMessageErrorDomain = <nl> GPBNSStringifySymbol ( GPBMessageErrorDomain ) ; <nl> <nl> + NSString * const GPBErrorReasonKey = @ " Reason " ; <nl> + <nl> static NSString * const kGPBDataCoderKey = @ " GPBData " ; <nl> <nl> / / <nl> static id GetOrCreateMapIvarWithField ( GPBMessage * self , <nl> NSZone * zone ) <nl> __attribute__ ( ( ns_returns_retained ) ) ; <nl> <nl> + # ifdef DEBUG <nl> static NSError * MessageError ( NSInteger code , NSDictionary * userInfo ) { <nl> return [ NSError errorWithDomain : GPBMessageErrorDomain <nl> code : code <nl> userInfo : userInfo ] ; <nl> } <nl> + # endif <nl> <nl> - static NSError * MessageErrorWithReason ( NSInteger code , NSString * reason ) { <nl> - NSDictionary * userInfo = nil ; <nl> - if ( [ reason length ] ) { <nl> - userInfo = @ { @ " Reason " : reason } ; <nl> + static NSError * ErrorFromException ( NSException * exception ) { <nl> + NSError * error = nil ; <nl> + <nl> + if ( [ exception . name isEqual : GPBCodedInputStreamException ] ) { <nl> + NSDictionary * exceptionInfo = exception . userInfo ; <nl> + error = exceptionInfo [ GPBCodedInputStreamUnderlyingErrorKey ] ; <nl> } <nl> - return MessageError ( code , userInfo ) ; <nl> - } <nl> <nl> + if ( ! error ) { <nl> + NSString * reason = exception . reason ; <nl> + NSDictionary * userInfo = nil ; <nl> + if ( [ reason length ] ) { <nl> + userInfo = @ { GPBErrorReasonKey : reason } ; <nl> + } <nl> + <nl> + error = [ NSError errorWithDomain : GPBMessageErrorDomain <nl> + code : GPBMessageErrorCodeOther <nl> + userInfo : userInfo ] ; <nl> + } <nl> + return error ; <nl> + } <nl> <nl> static void CheckExtension ( GPBMessage * self , <nl> GPBExtensionDescriptor * extension ) { <nl> - ( instancetype ) initWithData : ( NSData * ) data <nl> [ self release ] ; <nl> self = nil ; <nl> if ( errorPtr ) { <nl> - * errorPtr = MessageErrorWithReason ( GPBMessageErrorCodeMalformedData , <nl> - exception . reason ) ; <nl> + * errorPtr = ErrorFromException ( exception ) ; <nl> } <nl> } <nl> # ifdef DEBUG <nl> - ( instancetype ) initWithCodedInputStream : ( GPBCodedInputStream * ) input <nl> [ self release ] ; <nl> self = nil ; <nl> if ( errorPtr ) { <nl> - * errorPtr = MessageErrorWithReason ( GPBMessageErrorCodeMalformedData , <nl> - exception . reason ) ; <nl> + * errorPtr = ErrorFromException ( exception ) ; <nl> } <nl> } <nl> # ifdef DEBUG <nl> + ( instancetype ) parseDelimitedFromCodedInputStream : ( GPBCodedInputStream * ) input <nl> @ catch ( NSException * exception ) { <nl> message = nil ; <nl> if ( errorPtr ) { <nl> - * errorPtr = MessageErrorWithReason ( GPBMessageErrorCodeMalformedData , <nl> - exception . reason ) ; <nl> + * errorPtr = ErrorFromException ( exception ) ; <nl> } <nl> } <nl> # ifdef DEBUG <nl> mmm a / objectivec / Tests / GPBMessageTests + Serialization . m <nl> ppp b / objectivec / Tests / GPBMessageTests + Serialization . m <nl> - ( void ) testUnpackedExtensionVsFieldParsing { <nl> XCTAssertEqualObjects ( extsParse , extsOrig ) ; <nl> } <nl> <nl> + - ( void ) testErrorSubsectionInvalidLimit { <nl> + NSData * data = DataFromCStr ( <nl> + " \ x0A \ x08 \ x0A \ x07 \ x12 \ x04 \ x72 \ x02 \ x4B \ x50 \ x12 \ x04 \ x72 \ x02 \ x4B \ x50 " ) ; <nl> + NSError * error = nil ; <nl> + NestedTestAllTypes * msg = [ NestedTestAllTypes parseFromData : data <nl> + error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidSubsectionLimit ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorSubsectionLimitReached { <nl> + NSData * data = DataFromCStr ( " \ x0A \ x06 \ x12 \ x03 \ x72 \ x02 \ x4B \ x50 " ) ; <nl> + NSError * error = nil ; <nl> + NestedTestAllTypes * msg = [ NestedTestAllTypes parseFromData : data <nl> + error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorSubsectionLimitReached ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorInvalidVarint { <nl> + NSData * data = DataFromCStr ( " \ x72 \ xFF \ xFF \ xFF \ xFF \ xFF \ xFF \ xFF \ xFF \ xFF \ xFF " ) ; <nl> + NSError * error = nil ; <nl> + TestAllTypes * msg = [ TestAllTypes parseFromData : data error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidVarInt ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorInvalidUTF8 { <nl> + NSData * data = DataFromCStr ( " \ x72 \ x04 \ xF4 \ xFF \ xFF \ xFF " ) ; <nl> + NSError * error = nil ; <nl> + TestAllTypes * msg = [ TestAllTypes parseFromData : data error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidUTF8 ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorInvalidSize { <nl> + NSData * data = DataFromCStr ( " \ x72 \ x03 \ x4B \ x50 " ) ; <nl> + NSError * error = nil ; <nl> + NestedTestAllTypes * msg = [ NestedTestAllTypes parseFromData : data <nl> + error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidSize ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorInvalidTag { <nl> + NSData * data = DataFromCStr ( " \ x0F " ) ; <nl> + NSError * error = nil ; <nl> + NestedTestAllTypes * msg = [ NestedTestAllTypes parseFromData : data <nl> + error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidTag ) ; <nl> + } <nl> + <nl> + - ( void ) testErrorRecursionDepthReached { <nl> + NSData * data = DataFromCStr ( <nl> + " \ x0A \ x86 \ x01 \ x0A \ x83 \ x01 \ x0A \ x80 \ x01 \ x0A \ x7E \ x0A \ x7C \ x0A \ x7A \ x0A \ x78 " <nl> + " \ x0A \ x76 \ x0A \ x74 \ x0A \ x72 \ x0A \ x70 \ x0A \ x6E \ x0A \ x6C \ x0A \ x6A \ x0A \ x68 " <nl> + " \ x0A \ x66 \ x0A \ x64 \ x0A \ x62 \ x0A \ x60 \ x0A \ x5E \ x0A \ x5C \ x0A \ x5A \ x0A \ x58 " <nl> + " \ x0A \ x56 \ x0A \ x54 \ x0A \ x52 \ x0A \ x50 \ x0A \ x4E \ x0A \ x4C \ x0A \ x4A \ x0A \ x48 " <nl> + " \ x0A \ x46 \ x0A \ x44 \ x0A \ x42 \ x0A \ x40 \ x0A \ x3E \ x0A \ x3C \ x0A \ x3A \ x0A \ x38 " <nl> + " \ x0A \ x36 \ x0A \ x34 \ x0A \ x32 \ x0A \ x30 \ x0A \ x2E \ x0A \ x2C \ x0A \ x2A \ x0A \ x28 " <nl> + " \ x0A \ x26 \ x0A \ x24 \ x0A \ x22 \ x0A \ x20 \ x0A \ x1E \ x0A \ x1C \ x0A \ x1A \ x0A \ x18 " <nl> + " \ x0A \ x16 \ x0A \ x14 \ x0A \ x12 \ x0A \ x10 \ x0A \ x0E \ x0A \ x0C \ x0A \ x0A \ x0A \ x08 " <nl> + " \ x0A \ x06 \ x12 \ x04 \ x72 \ x02 \ x4B \ x50 " ) ; <nl> + NSError * error = nil ; <nl> + NestedTestAllTypes * msg = [ NestedTestAllTypes parseFromData : data <nl> + error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorRecursionDepthExceeded ) ; <nl> + } <nl> + <nl> + # ifdef DEBUG <nl> + - ( void ) testErrorMissingRequiredField { <nl> + NSData * data = DataFromCStr ( " " ) ; <nl> + NSError * error = nil ; <nl> + TestRequired * msg = [ TestRequired parseFromData : data error : & error ] ; <nl> + XCTAssertNil ( msg ) ; <nl> + XCTAssertNotNil ( error ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBMessageErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBMessageErrorCodeMissingRequiredField ) ; <nl> + } <nl> + # endif <nl> + <nl> # pragma mark - Subset from from map_tests . cc <nl> <nl> / / TEST ( GeneratedMapFieldTest , StandardWireFormat ) <nl> - ( void ) testMap_CorruptedWireFormat { <nl> TestMap * msg = [ TestMap parseFromData : data error : & error ] ; <nl> XCTAssertNil ( msg ) ; <nl> XCTAssertNotNil ( error ) ; <nl> - XCTAssertEqualObjects ( error . domain , GPBMessageErrorDomain ) ; <nl> - XCTAssertEqual ( error . code , GPBMessageErrorCodeMalformedData ) ; <nl> + XCTAssertEqualObjects ( error . domain , GPBCodedInputStreamErrorDomain ) ; <nl> + XCTAssertEqual ( error . code , GPBCodedInputStreamErrorInvalidSubsectionLimit ) ; <nl> } <nl> <nl> / / TEST ( GeneratedMapFieldTest , Proto2UnknownEnum ) <nl>
|
Improving the granularity parsing errors ( )
|
protocolbuffers/protobuf
|
e34c09182ebe0ed2958aefa809159498923743d3
|
2016-06-02T18:14:26Z
|
mmm a / dbms / programs / server / Server . cpp <nl> ppp b / dbms / programs / server / Server . cpp <nl> int Server : : main ( const std : : vector < std : : string > & / * args * / ) <nl> { <nl> / / / DDL worker should be started after all tables were loaded <nl> String ddl_zookeeper_path = config ( ) . getString ( " distributed_ddl . path " , " / clickhouse / task_queue / ddl / " ) ; <nl> - global_context - > setDDLWorker ( std : : make_shared < DDLWorker > ( ddl_zookeeper_path , * global_context , & config ( ) , " distributed_ddl " ) ) ; <nl> + global_context - > setDDLWorker ( std : : make_unique < DDLWorker > ( ddl_zookeeper_path , * global_context , & config ( ) , " distributed_ddl " ) ) ; <nl> } <nl> <nl> std : : unique_ptr < DNSCacheUpdater > dns_cache_updater ; <nl> mmm a / dbms / src / Interpreters / Context . cpp <nl> ppp b / dbms / src / Interpreters / Context . cpp <nl> <nl> # include < Interpreters / QueryThreadLog . h > <nl> # include < Interpreters / PartLog . h > <nl> # include < Interpreters / Context . h > <nl> + # include < Interpreters / DDLWorker . h > <nl> # include < Common / DNSResolver . h > <nl> # include < IO / ReadBufferFromFile . h > <nl> # include < IO / UncompressedCache . h > <nl> struct ContextShared <nl> std : : optional < BackgroundSchedulePool > schedule_pool ; / / / A thread pool that can run different jobs in background ( used in replicated tables ) <nl> MultiVersion < Macros > macros ; / / / Substitutions extracted from config . <nl> std : : optional < Compiler > compiler ; / / / Used for dynamic compilation of queries ' parts if it necessary . <nl> - std : : shared_ptr < DDLWorker > ddl_worker ; / / / Process ddl commands from zk . <nl> + std : : unique_ptr < DDLWorker > ddl_worker ; / / / Process ddl commands from zk . <nl> / / / Rules for selecting the compression settings , depending on the size of the part . <nl> mutable std : : unique_ptr < CompressionCodecSelector > compression_codec_selector ; <nl> std : : optional < MergeTreeSettings > merge_tree_settings ; / / / Settings of MergeTree * engines . <nl> struct ContextShared <nl> external_models . reset ( ) ; <nl> background_pool . reset ( ) ; <nl> schedule_pool . reset ( ) ; <nl> + ddl_worker . reset ( ) ; <nl> } <nl> <nl> private : <nl> BackgroundSchedulePool & Context : : getSchedulePool ( ) <nl> return * shared - > schedule_pool ; <nl> } <nl> <nl> - void Context : : setDDLWorker ( std : : shared_ptr < DDLWorker > ddl_worker ) <nl> + void Context : : setDDLWorker ( std : : unique_ptr < DDLWorker > ddl_worker ) <nl> { <nl> auto lock = getLock ( ) ; <nl> if ( shared - > ddl_worker ) <nl> throw Exception ( " DDL background thread has already been initialized . " , ErrorCodes : : LOGICAL_ERROR ) ; <nl> - shared - > ddl_worker = ddl_worker ; <nl> + shared - > ddl_worker = std : : move ( ddl_worker ) ; <nl> } <nl> <nl> DDLWorker & Context : : getDDLWorker ( ) const <nl> mmm a / dbms / src / Interpreters / Context . h <nl> ppp b / dbms / src / Interpreters / Context . h <nl> class Context <nl> BackgroundProcessingPool & getBackgroundPool ( ) ; <nl> BackgroundSchedulePool & getSchedulePool ( ) ; <nl> <nl> - void setDDLWorker ( std : : shared_ptr < DDLWorker > ddl_worker ) ; <nl> + void setDDLWorker ( std : : unique_ptr < DDLWorker > ddl_worker ) ; <nl> DDLWorker & getDDLWorker ( ) const ; <nl> <nl> Clusters & getClusters ( ) const ; <nl>
|
manually reset DDLWorker in shared context to prevent reference cycles
|
ClickHouse/ClickHouse
|
73f852ae8294920ceb52d65934a2f964d0592236
|
2019-02-21T16:41:27Z
|
mmm a / src / core / lib / iomgr / ev_epoll_linux . c <nl> ppp b / src / core / lib / iomgr / ev_epoll_linux . c <nl> void pi_unref_dbg ( polling_island * pi , int ref_cnt , char * reason , char * file , <nl> # endif <nl> <nl> long pi_add_ref ( polling_island * pi , int ref_cnt ) { <nl> - return gpr_atm_no_barrier_fetch_add ( & pi - > ref_count , ref_cnt ) ; <nl> + return gpr_atm_full_fetch_add ( & pi - > ref_count , ref_cnt ) ; <nl> } <nl> <nl> long pi_unref ( polling_island * pi , int ref_cnt ) { <nl> - long old_cnt = gpr_atm_no_barrier_fetch_add ( & pi - > ref_count , - ref_cnt ) ; <nl> + long old_cnt = gpr_atm_full_fetch_add ( & pi - > ref_count , - ref_cnt ) ; <nl> <nl> / * If ref count went to zero , delete the polling island . Note that this need <nl> not be done under a lock . Once the ref count goes to zero , we are <nl> long pi_unref ( polling_island * pi , int ref_cnt ) { <nl> if ( next ! = NULL ) { <nl> PI_UNREF ( next , " pi_delete " ) ; / * Recursive call * / <nl> } <nl> + } else { <nl> + GPR_ASSERT ( old_cnt > ref_cnt ) ; <nl> } <nl> <nl> return old_cnt ; <nl> static polling_island * polling_island_create ( grpc_fd * initial_fd ) { <nl> pi - > fds = NULL ; <nl> } <nl> <nl> - gpr_atm_no_barrier_store ( & pi - > ref_count , 0 ) ; <nl> - gpr_atm_no_barrier_store ( & pi - > merged_to , NULL ) ; <nl> + gpr_atm_rel_store ( & pi - > ref_count , 0 ) ; <nl> + gpr_atm_rel_store ( & pi - > merged_to , NULL ) ; <nl> <nl> pi - > epoll_fd = epoll_create1 ( EPOLL_CLOEXEC ) ; <nl> <nl> static void pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> <nl> static void pollset_add_fd ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> grpc_fd * fd ) { <nl> - / * TODO sreek - Double check if we need to get a pollset - > mu lock here * / <nl> + gpr_mu_lock ( & pollset - > mu ) ; <nl> gpr_mu_lock ( & pollset - > pi_mu ) ; <nl> gpr_mu_lock ( & fd - > pi_mu ) ; <nl> <nl> static void pollset_add_fd ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> <nl> gpr_mu_unlock ( & fd - > pi_mu ) ; <nl> gpr_mu_unlock ( & pollset - > pi_mu ) ; <nl> + gpr_mu_unlock ( & pollset - > mu ) ; <nl> } <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl>
|
Fix refcounting tsan failures and grab pollset lock in the function
|
grpc/grpc
|
cddf697ab44a7bab1821915e1e3f6a0f08ca1706
|
2016-06-21T15:27:07Z
|
mmm a / src / arm / full - codegen - arm . cc <nl> ppp b / src / arm / full - codegen - arm . cc <nl> void FullCodeGenerator : : VisitVariableDeclaration ( <nl> __ mov ( r0 , Operand ( Smi : : FromInt ( 0 ) ) ) ; / / Indicates no initial value . <nl> __ Push ( cp , r2 , r1 , r0 ) ; <nl> } <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : VisitFunctionDeclaration ( <nl> __ Push ( cp , r2 , r1 ) ; <nl> / / Push initial value for function declaration . <nl> VisitForStackValue ( declaration - > fun ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : EmitStoreToStackLocalOrContextSlot ( <nl> } <nl> <nl> <nl> - void FullCodeGenerator : : EmitCallStoreContextSlot ( <nl> - Handle < String > name , StrictMode strict_mode ) { <nl> - __ push ( r0 ) ; / / Value . <nl> - __ mov ( r1 , Operand ( name ) ) ; <nl> - __ mov ( r0 , Operand ( Smi : : FromInt ( strict_mode ) ) ) ; <nl> - __ Push ( cp , r1 , r0 ) ; / / Context , name , strict mode . <nl> - __ CallRuntime ( Runtime : : kStoreContextSlot , 4 ) ; <nl> - } <nl> - <nl> - <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , Token : : Value op ) { <nl> if ( var - > IsUnallocated ( ) ) { <nl> / / Global var , const , or let . <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , Token : : Value op ) { <nl> __ push ( r0 ) ; <nl> __ mov ( r0 , Operand ( var - > name ( ) ) ) ; <nl> __ Push ( cp , r0 ) ; / / Context and name . <nl> - __ CallRuntime ( Runtime : : kInitializeConstContextSlot , 3 ) ; <nl> + __ CallRuntime ( Runtime : : kInitializeLegacyConstLookupSlot , 3 ) ; <nl> } else { <nl> ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> Label skip ; <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , Token : : Value op ) { <nl> <nl> } else if ( var - > mode ( ) = = LET & & op ! = Token : : INIT_LET ) { <nl> / / Non - initializing assignment to let variable needs a write barrier . <nl> - if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> - } else { <nl> - ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> - Label assign ; <nl> - MemOperand location = VarOperand ( var , r1 ) ; <nl> - __ ldr ( r3 , location ) ; <nl> - __ CompareRoot ( r3 , Heap : : kTheHoleValueRootIndex ) ; <nl> - __ b ( ne , & assign ) ; <nl> - __ mov ( r3 , Operand ( var - > name ( ) ) ) ; <nl> - __ push ( r3 ) ; <nl> - __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> - / / Perform the assignment . <nl> - __ bind ( & assign ) ; <nl> - EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> - } <nl> + ASSERT ( ! var - > IsLookupSlot ( ) ) ; <nl> + ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> + Label assign ; <nl> + MemOperand location = VarOperand ( var , r1 ) ; <nl> + __ ldr ( r3 , location ) ; <nl> + __ CompareRoot ( r3 , Heap : : kTheHoleValueRootIndex ) ; <nl> + __ b ( ne , & assign ) ; <nl> + __ mov ( r3 , Operand ( var - > name ( ) ) ) ; <nl> + __ push ( r3 ) ; <nl> + __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> + / / Perform the assignment . <nl> + __ bind ( & assign ) ; <nl> + EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> <nl> } else if ( ! var - > is_const_mode ( ) | | op = = Token : : INIT_CONST ) { <nl> - / / Assignment to var or initializing assignment to let / const <nl> - / / in harmony mode . <nl> if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> + ASSERT ( op = = Token : : ASSIGN | | op = = Token : : INIT_VAR | | <nl> + op = = Token : : ASSIGN_ADD ) ; <nl> + / / Assignment to var . <nl> + __ push ( r0 ) ; / / Value . <nl> + __ mov ( r1 , Operand ( var - > name ( ) ) ) ; <nl> + __ mov ( r0 , Operand ( Smi : : FromInt ( strict_mode ( ) ) ) ) ; <nl> + __ Push ( cp , r1 , r0 ) ; / / Context , name , strict mode . <nl> + __ CallRuntime ( Runtime : : kStoreLookupSlot , 4 ) ; <nl> } else { <nl> + / / Assignment to var or initializing assignment to let / const in harmony <nl> + / / mode . <nl> ASSERT ( ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ) ; <nl> MemOperand location = VarOperand ( var , r1 ) ; <nl> if ( generate_debug_code_ & & op = = Token : : INIT_LET ) { <nl> mmm a / src / arm64 / full - codegen - arm64 . cc <nl> ppp b / src / arm64 / full - codegen - arm64 . cc <nl> void FullCodeGenerator : : VisitVariableDeclaration ( <nl> / / Pushing 0 ( xzr ) indicates no initial value . <nl> __ Push ( cp , x2 , x1 , xzr ) ; <nl> } <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : VisitFunctionDeclaration ( <nl> __ Push ( cp , x2 , x1 ) ; <nl> / / Push initial value for function declaration . <nl> VisitForStackValue ( declaration - > fun ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : EmitStoreToStackLocalOrContextSlot ( <nl> } <nl> <nl> <nl> - void FullCodeGenerator : : EmitCallStoreContextSlot ( <nl> - Handle < String > name , StrictMode strict_mode ) { <nl> - __ Mov ( x11 , Operand ( name ) ) ; <nl> - __ Mov ( x10 , Smi : : FromInt ( strict_mode ) ) ; <nl> - / / jssp [ 0 ] : mode . <nl> - / / jssp [ 8 ] : name . <nl> - / / jssp [ 16 ] : context . <nl> - / / jssp [ 24 ] : value . <nl> - __ Push ( x0 , cp , x11 , x10 ) ; <nl> - __ CallRuntime ( Runtime : : kStoreContextSlot , 4 ) ; <nl> - } <nl> - <nl> - <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> Token : : Value op ) { <nl> ASM_LOCATION ( " FullCodeGenerator : : EmitVariableAssignment " ) ; <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> if ( var - > IsLookupSlot ( ) ) { <nl> __ Mov ( x1 , Operand ( var - > name ( ) ) ) ; <nl> __ Push ( x0 , cp , x1 ) ; <nl> - __ CallRuntime ( Runtime : : kInitializeConstContextSlot , 3 ) ; <nl> + __ CallRuntime ( Runtime : : kInitializeLegacyConstLookupSlot , 3 ) ; <nl> } else { <nl> ASSERT ( var - > IsStackLocal ( ) | | var - > IsContextSlot ( ) ) ; <nl> Label skip ; <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> <nl> } else if ( var - > mode ( ) = = LET & & op ! = Token : : INIT_LET ) { <nl> / / Non - initializing assignment to let variable needs a write barrier . <nl> - if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> - } else { <nl> - ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> - Label assign ; <nl> - MemOperand location = VarOperand ( var , x1 ) ; <nl> - __ Ldr ( x10 , location ) ; <nl> - __ JumpIfNotRoot ( x10 , Heap : : kTheHoleValueRootIndex , & assign ) ; <nl> - __ Mov ( x10 , Operand ( var - > name ( ) ) ) ; <nl> - __ Push ( x10 ) ; <nl> - __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> - / / Perform the assignment . <nl> - __ Bind ( & assign ) ; <nl> - EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> - } <nl> + ASSERT ( ! var - > IsLookupSlot ( ) ) ; <nl> + ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> + Label assign ; <nl> + MemOperand location = VarOperand ( var , x1 ) ; <nl> + __ Ldr ( x10 , location ) ; <nl> + __ JumpIfNotRoot ( x10 , Heap : : kTheHoleValueRootIndex , & assign ) ; <nl> + __ Mov ( x10 , Operand ( var - > name ( ) ) ) ; <nl> + __ Push ( x10 ) ; <nl> + __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> + / / Perform the assignment . <nl> + __ Bind ( & assign ) ; <nl> + EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> <nl> } else if ( ! var - > is_const_mode ( ) | | op = = Token : : INIT_CONST ) { <nl> - / / Assignment to var or initializing assignment to let / const <nl> - / / in harmony mode . <nl> if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> + ASSERT ( op = = Token : : ASSIGN | | op = = Token : : INIT_VAR | | <nl> + op = = Token : : ASSIGN_ADD ) ; <nl> + / / Assignment to var . <nl> + __ Mov ( x11 , Operand ( var - > name ( ) ) ) ; <nl> + __ Mov ( x10 , Smi : : FromInt ( strict_mode ( ) ) ) ; <nl> + / / jssp [ 0 ] : mode . <nl> + / / jssp [ 8 ] : name . <nl> + / / jssp [ 16 ] : context . <nl> + / / jssp [ 24 ] : value . <nl> + __ Push ( x0 , cp , x11 , x10 ) ; <nl> + __ CallRuntime ( Runtime : : kStoreLookupSlot , 4 ) ; <nl> } else { <nl> + / / Assignment to var or initializing assignment to let / const in harmony <nl> + / / mode . <nl> ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> MemOperand location = VarOperand ( var , x1 ) ; <nl> if ( FLAG_debug_code & & op = = Token : : INIT_LET ) { <nl> mmm a / src / full - codegen . h <nl> ppp b / src / full - codegen . h <nl> class FullCodeGenerator : public AstVisitor { <nl> / / Helper functions to EmitVariableAssignment <nl> void EmitStoreToStackLocalOrContextSlot ( Variable * var , <nl> MemOperand location ) ; <nl> - void EmitCallStoreContextSlot ( Handle < String > name , StrictMode strict_mode ) ; <nl> <nl> / / Complete a named property assignment . The receiver is expected on top <nl> / / of the stack and the right - hand - side value in the accumulator . <nl> mmm a / src / ia32 / full - codegen - ia32 . cc <nl> ppp b / src / ia32 / full - codegen - ia32 . cc <nl> void FullCodeGenerator : : VisitVariableDeclaration ( <nl> } else { <nl> __ push ( Immediate ( Smi : : FromInt ( 0 ) ) ) ; / / Indicates no initial value . <nl> } <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : VisitFunctionDeclaration ( <nl> __ push ( Immediate ( variable - > name ( ) ) ) ; <nl> __ push ( Immediate ( Smi : : FromInt ( NONE ) ) ) ; <nl> VisitForStackValue ( declaration - > fun ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : EmitStoreToStackLocalOrContextSlot ( <nl> } <nl> <nl> <nl> - void FullCodeGenerator : : EmitCallStoreContextSlot ( <nl> - Handle < String > name , StrictMode strict_mode ) { <nl> - __ push ( eax ) ; / / Value . <nl> - __ push ( esi ) ; / / Context . <nl> - __ push ( Immediate ( name ) ) ; <nl> - __ push ( Immediate ( Smi : : FromInt ( strict_mode ) ) ) ; <nl> - __ CallRuntime ( Runtime : : kStoreContextSlot , 4 ) ; <nl> - } <nl> - <nl> - <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> Token : : Value op ) { <nl> if ( var - > IsUnallocated ( ) ) { <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> __ push ( eax ) ; <nl> __ push ( esi ) ; <nl> __ push ( Immediate ( var - > name ( ) ) ) ; <nl> - __ CallRuntime ( Runtime : : kInitializeConstContextSlot , 3 ) ; <nl> + __ CallRuntime ( Runtime : : kInitializeLegacyConstLookupSlot , 3 ) ; <nl> } else { <nl> ASSERT ( var - > IsStackLocal ( ) | | var - > IsContextSlot ( ) ) ; <nl> Label skip ; <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> <nl> } else if ( var - > mode ( ) = = LET & & op ! = Token : : INIT_LET ) { <nl> / / Non - initializing assignment to let variable needs a write barrier . <nl> - if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> - } else { <nl> - ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> - Label assign ; <nl> - MemOperand location = VarOperand ( var , ecx ) ; <nl> - __ mov ( edx , location ) ; <nl> - __ cmp ( edx , isolate ( ) - > factory ( ) - > the_hole_value ( ) ) ; <nl> - __ j ( not_equal , & assign , Label : : kNear ) ; <nl> - __ push ( Immediate ( var - > name ( ) ) ) ; <nl> - __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> - __ bind ( & assign ) ; <nl> - EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> - } <nl> + ASSERT ( ! var - > IsLookupSlot ( ) ) ; <nl> + ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> + Label assign ; <nl> + MemOperand location = VarOperand ( var , ecx ) ; <nl> + __ mov ( edx , location ) ; <nl> + __ cmp ( edx , isolate ( ) - > factory ( ) - > the_hole_value ( ) ) ; <nl> + __ j ( not_equal , & assign , Label : : kNear ) ; <nl> + __ push ( Immediate ( var - > name ( ) ) ) ; <nl> + __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> + __ bind ( & assign ) ; <nl> + EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> <nl> } else if ( ! var - > is_const_mode ( ) | | op = = Token : : INIT_CONST ) { <nl> - / / Assignment to var or initializing assignment to let / const <nl> - / / in harmony mode . <nl> if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> + ASSERT ( op = = Token : : ASSIGN | | op = = Token : : INIT_VAR | | <nl> + op = = Token : : ASSIGN_ADD ) ; <nl> + / / Assignment to var . <nl> + __ push ( eax ) ; / / Value . <nl> + __ push ( esi ) ; / / Context . <nl> + __ push ( Immediate ( var - > name ( ) ) ) ; <nl> + __ push ( Immediate ( Smi : : FromInt ( strict_mode ( ) ) ) ) ; <nl> + __ CallRuntime ( Runtime : : kStoreLookupSlot , 4 ) ; <nl> } else { <nl> + / / Assignment to var or initializing assignment to let / const in harmony <nl> + / / mode . <nl> ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> MemOperand location = VarOperand ( var , ecx ) ; <nl> if ( generate_debug_code_ & & op = = Token : : INIT_LET ) { <nl> mmm a / src / parser . cc <nl> ppp b / src / parser . cc <nl> void Parser : : Declare ( Declaration * declaration , bool resolve , bool * ok ) { <nl> / / same variable if it is declared several times . This is not a <nl> / / semantic issue as long as we keep the source order , but it may be <nl> / / a performance issue since it may lead to repeated <nl> - / / RuntimeHidden_DeclareContextSlot calls . <nl> + / / RuntimeHidden_DeclareLookupSlot calls . <nl> declaration_scope - > AddDeclaration ( declaration ) ; <nl> <nl> if ( mode = = CONST_LEGACY & & declaration_scope - > is_global_scope ( ) ) { <nl> void Parser : : Declare ( Declaration * declaration , bool resolve , bool * ok ) { <nl> declaration_scope - > strict_mode ( ) = = SLOPPY ) { <nl> / / For variable declarations in a sloppy eval scope the proxy is bound <nl> / / to a lookup variable to force a dynamic declaration using the <nl> - / / DeclareContextSlot runtime function . <nl> + / / DeclareLookupSlot runtime function . <nl> Variable : : Kind kind = Variable : : NORMAL ; <nl> var = new ( zone ( ) ) Variable ( <nl> declaration_scope , name , mode , true , kind , <nl> Block * Parser : : ParseVariableDeclarations ( <nl> if ( value ! = NULL & & ! inside_with ( ) ) { <nl> arguments - > Add ( value , zone ( ) ) ; <nl> value = NULL ; / / zap the value to avoid the unnecessary assignment <nl> + / / Construct the call to Runtime_InitializeVarGlobal <nl> + / / and add it to the initialization statement block . <nl> + initialize = factory ( ) - > NewCallRuntime ( <nl> + ast_value_factory_ - > initialize_var_global_string ( ) , <nl> + Runtime : : FunctionForId ( Runtime : : kInitializeVarGlobal ) , arguments , <nl> + pos ) ; <nl> + } else { <nl> + initialize = NULL ; <nl> } <nl> - <nl> - / / Construct the call to Runtime_InitializeVarGlobal <nl> - / / and add it to the initialization statement block . <nl> - / / Note that the function does different things depending on <nl> - / / the number of arguments ( 2 or 3 ) . <nl> - initialize = factory ( ) - > NewCallRuntime ( <nl> - ast_value_factory_ - > initialize_var_global_string ( ) , <nl> - Runtime : : FunctionForId ( Runtime : : kInitializeVarGlobal ) , <nl> - arguments , pos ) ; <nl> } <nl> <nl> - block - > AddStatement ( <nl> - factory ( ) - > NewExpressionStatement ( initialize , RelocInfo : : kNoPosition ) , <nl> - zone ( ) ) ; <nl> + if ( initialize ! = NULL ) { <nl> + block - > AddStatement ( factory ( ) - > NewExpressionStatement ( <nl> + initialize , RelocInfo : : kNoPosition ) , <nl> + zone ( ) ) ; <nl> + } <nl> } else if ( needs_init ) { <nl> / / Constant initializations always assign to the declared constant which <nl> / / is always at the function scope level . This is only relevant for <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> RUNTIME_FUNCTION ( Runtime_CreateGlobalPrivateSymbol ) { <nl> ASSERT ( symbol - > IsUndefined ( ) ) ; <nl> symbol = isolate - > factory ( ) - > NewPrivateSymbol ( ) ; <nl> Handle < Symbol > : : cast ( symbol ) - > set_name ( * name ) ; <nl> - JSObject : : SetProperty ( Handle < JSObject > : : cast ( privates ) , <nl> - name , symbol , NONE , STRICT ) . Assert ( ) ; <nl> + JSObject : : SetProperty ( Handle < JSObject > : : cast ( privates ) , name , symbol , NONE , <nl> + STRICT ) . Assert ( ) ; <nl> } <nl> return * symbol ; <nl> } <nl> static Object * ThrowRedeclarationError ( Isolate * isolate , Handle < String > name ) { <nl> } <nl> <nl> <nl> + / / May throw a RedeclarationError . <nl> + static Object * DeclareGlobals ( Isolate * isolate , Handle < GlobalObject > global , <nl> + Handle < String > name , Handle < Object > value , <nl> + PropertyAttributes attr , bool is_var , <nl> + bool is_const , bool is_function ) { <nl> + / / Do the lookup own properties only , see ES5 erratum . <nl> + LookupIterator it ( global , name , LookupIterator : : CHECK_HIDDEN ) ; <nl> + PropertyAttributes old_attributes = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> + <nl> + if ( old_attributes ! = ABSENT ) { <nl> + / / The name was declared before ; check for conflicting re - declarations . <nl> + if ( is_const ) return ThrowRedeclarationError ( isolate , name ) ; <nl> + <nl> + / / Skip var re - declarations . <nl> + if ( is_var ) return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + <nl> + ASSERT ( is_function ) ; <nl> + if ( ( old_attributes & DONT_DELETE ) ! = 0 ) { <nl> + / / Only allow reconfiguring globals to functions in user code ( no <nl> + / / natives , which are marked as read - only ) . <nl> + ASSERT ( ( attr & READ_ONLY ) = = 0 ) ; <nl> + <nl> + / / Check whether we can reconfigure the existing property into a <nl> + / / function . <nl> + PropertyDetails old_details = it . property_details ( ) ; <nl> + / / TODO ( verwaest ) : CALLBACKS invalidly includes ExecutableAccessInfo , <nl> + / / which are actually data properties , not accessor properties . <nl> + if ( old_details . IsReadOnly ( ) | | old_details . IsDontEnum ( ) | | <nl> + old_details . type ( ) = = CALLBACKS ) { <nl> + return ThrowRedeclarationError ( isolate , name ) ; <nl> + } <nl> + / / If the existing property is not configurable , keep its attributes . Do <nl> + attr = old_attributes ; <nl> + } <nl> + } <nl> + <nl> + / / Define or redefine own property . <nl> + RETURN_FAILURE_ON_EXCEPTION ( isolate , JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> + global , name , value , attr ) ) ; <nl> + <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> RUNTIME_FUNCTION ( Runtime_DeclareGlobals ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 3 ) ; <nl> RUNTIME_FUNCTION ( Runtime_DeclareGlobals ) { <nl> for ( int i = 0 ; i < length ; i + = 2 ) { <nl> HandleScope scope ( isolate ) ; <nl> Handle < String > name ( String : : cast ( pairs - > get ( i ) ) ) ; <nl> - Handle < Object > value ( pairs - > get ( i + 1 ) , isolate ) ; <nl> + Handle < Object > initial_value ( pairs - > get ( i + 1 ) , isolate ) ; <nl> <nl> / / We have to declare a global const property . To capture we only <nl> / / assign to it when evaluating the assignment for " const x = <nl> / / < expr > " the initial value is the hole . <nl> - bool is_var = value - > IsUndefined ( ) ; <nl> - bool is_const = value - > IsTheHole ( ) ; <nl> - bool is_function = value - > IsSharedFunctionInfo ( ) ; <nl> + bool is_var = initial_value - > IsUndefined ( ) ; <nl> + bool is_const = initial_value - > IsTheHole ( ) ; <nl> + bool is_function = initial_value - > IsSharedFunctionInfo ( ) ; <nl> ASSERT ( is_var + is_const + is_function = = 1 ) ; <nl> <nl> - if ( is_var | | is_const ) { <nl> - / / Lookup the property in the global object , and don ' t set the <nl> - / / value of the variable if the property is already there . <nl> - / / Do the lookup own properties only , see ES5 erratum . <nl> - LookupResult lookup ( isolate ) ; <nl> - global - > LookupOwn ( name , & lookup , true ) ; <nl> - if ( lookup . IsFound ( ) ) { <nl> - / / We found an existing property . Unless it was an interceptor <nl> - / / that claims the property is absent , skip this declaration . <nl> - if ( ! lookup . IsInterceptor ( ) ) continue ; <nl> - if ( JSReceiver : : GetPropertyAttributes ( global , name ) ! = ABSENT ) continue ; <nl> - / / Fall - through and introduce the absent property by using <nl> - / / SetProperty . <nl> - } <nl> - } else if ( is_function ) { <nl> + Handle < Object > value ; <nl> + if ( is_function ) { <nl> / / Copy the function and update its context . Use it as value . <nl> Handle < SharedFunctionInfo > shared = <nl> - Handle < SharedFunctionInfo > : : cast ( value ) ; <nl> + Handle < SharedFunctionInfo > : : cast ( initial_value ) ; <nl> Handle < JSFunction > function = <nl> - isolate - > factory ( ) - > NewFunctionFromSharedFunctionInfo ( <nl> - shared , context , TENURED ) ; <nl> + isolate - > factory ( ) - > NewFunctionFromSharedFunctionInfo ( shared , context , <nl> + TENURED ) ; <nl> value = function ; <nl> + } else { <nl> + value = isolate - > factory ( ) - > undefined_value ( ) ; <nl> } <nl> <nl> - LookupResult lookup ( isolate ) ; <nl> - global - > LookupOwn ( name , & lookup , true ) ; <nl> - <nl> / / Compute the property attributes . According to ECMA - 262 , <nl> / / the property must be non - configurable except in eval . <nl> - int attr = NONE ; <nl> - bool is_eval = DeclareGlobalsEvalFlag : : decode ( flags ) ; <nl> - if ( ! is_eval ) { <nl> - attr | = DONT_DELETE ; <nl> - } <nl> bool is_native = DeclareGlobalsNativeFlag : : decode ( flags ) ; <nl> - if ( is_const | | ( is_native & & is_function ) ) { <nl> - attr | = READ_ONLY ; <nl> - } <nl> - <nl> - StrictMode strict_mode = DeclareGlobalsStrictMode : : decode ( flags ) ; <nl> - <nl> - if ( ! lookup . IsFound ( ) | | is_function ) { <nl> - / / If the own property exists , check that we can reconfigure it <nl> - / / as required for function declarations . <nl> - if ( lookup . IsFound ( ) & & lookup . IsDontDelete ( ) ) { <nl> - if ( lookup . IsReadOnly ( ) | | lookup . IsDontEnum ( ) | | <nl> - lookup . IsPropertyCallbacks ( ) ) { <nl> - return ThrowRedeclarationError ( isolate , name ) ; <nl> - } <nl> - / / If the existing property is not configurable , keep its attributes . <nl> - attr = lookup . GetAttributes ( ) ; <nl> - } <nl> - / / Define or redefine own property . <nl> - RETURN_FAILURE_ON_EXCEPTION ( isolate , <nl> - JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> - global , name , value , static_cast < PropertyAttributes > ( attr ) ) ) ; <nl> - } else { <nl> - / / Do a [ [ Put ] ] on the existing ( own ) property . <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSObject : : SetProperty ( <nl> - global , name , value , static_cast < PropertyAttributes > ( attr ) , <nl> - strict_mode ) ) ; <nl> - } <nl> - } <nl> - <nl> - ASSERT ( ! isolate - > has_pending_exception ( ) ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_DeclareContextSlot ) { <nl> - HandleScope scope ( isolate ) ; <nl> - ASSERT ( args . length ( ) = = 4 ) ; <nl> - <nl> - / / Declarations are always made in a function or native context . In the <nl> - / / case of eval code , the context passed is the context of the caller , <nl> - / / which may be some nested context and not the declaration context . <nl> - CONVERT_ARG_HANDLE_CHECKED ( Context , context_arg , 0 ) ; <nl> - Handle < Context > context ( context_arg - > declaration_context ( ) ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( String , name , 1 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( mode_arg , 2 ) ; <nl> - PropertyAttributes mode = static_cast < PropertyAttributes > ( mode_arg ) ; <nl> - RUNTIME_ASSERT ( mode = = READ_ONLY | | mode = = NONE ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , initial_value , 3 ) ; <nl> - <nl> - int index ; <nl> - PropertyAttributes attributes ; <nl> - ContextLookupFlags flags = DONT_FOLLOW_CHAINS ; <nl> - BindingFlags binding_flags ; <nl> - Handle < Object > holder = <nl> - context - > Lookup ( name , flags , & index , & attributes , & binding_flags ) ; <nl> - <nl> - if ( attributes ! = ABSENT ) { <nl> - / / The name was declared before ; check for conflicting re - declarations . <nl> - / / Note : this is actually inconsistent with what happens for globals ( where <nl> - / / we silently ignore such declarations ) . <nl> - if ( ( ( attributes & READ_ONLY ) ! = 0 ) | | ( mode = = READ_ONLY ) ) { <nl> - / / Functions are not read - only . <nl> - ASSERT ( mode ! = READ_ONLY | | initial_value - > IsTheHole ( ) ) ; <nl> - return ThrowRedeclarationError ( isolate , name ) ; <nl> - } <nl> - <nl> - / / Initialize it if necessary . <nl> - if ( * initial_value ! = NULL ) { <nl> - if ( index > = 0 ) { <nl> - ASSERT ( holder . is_identical_to ( context ) ) ; <nl> - if ( ( ( attributes & READ_ONLY ) = = 0 ) | | <nl> - context - > get ( index ) - > IsTheHole ( ) ) { <nl> - context - > set ( index , * initial_value ) ; <nl> - } <nl> - } else { <nl> - / / Slow case : The property is in the context extension object of a <nl> - / / function context or the global object of a native context . <nl> - Handle < JSObject > object = Handle < JSObject > : : cast ( holder ) ; <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSReceiver : : SetProperty ( object , name , initial_value , mode , SLOPPY ) ) ; <nl> - } <nl> - } <nl> + bool is_eval = DeclareGlobalsEvalFlag : : decode ( flags ) ; <nl> + int attr = NONE ; <nl> + if ( is_const ) attr | = READ_ONLY ; <nl> + if ( is_function & & is_native ) attr | = READ_ONLY ; <nl> + if ( ! is_const & & ! is_eval ) attr | = DONT_DELETE ; <nl> <nl> - } else { <nl> - / / The property is not in the function context . It needs to be <nl> - / / " declared " in the function context ' s extension context or as a <nl> - / / property of the the global object . <nl> - Handle < JSObject > object ; <nl> - if ( context - > has_extension ( ) ) { <nl> - object = Handle < JSObject > ( JSObject : : cast ( context - > extension ( ) ) ) ; <nl> - } else { <nl> - / / Context extension objects are allocated lazily . <nl> - ASSERT ( context - > IsFunctionContext ( ) ) ; <nl> - object = isolate - > factory ( ) - > NewJSObject ( <nl> - isolate - > context_extension_function ( ) ) ; <nl> - context - > set_extension ( * object ) ; <nl> - } <nl> - ASSERT ( * object ! = NULL ) ; <nl> - <nl> - / / Declare the property by setting it to the initial value if provided , <nl> - / / or undefined , and use the correct mode ( e . g . READ_ONLY attribute for <nl> - / / constant declarations ) . <nl> - ASSERT ( ! JSReceiver : : HasOwnProperty ( object , name ) ) ; <nl> - Handle < Object > value ( isolate - > heap ( ) - > undefined_value ( ) , isolate ) ; <nl> - if ( * initial_value ! = NULL ) value = initial_value ; <nl> - / / Declaring a const context slot is a conflicting declaration if <nl> - / / there is a callback with that name in a prototype . It is <nl> - / / allowed to introduce const variables in <nl> - / / JSContextExtensionObjects . They are treated specially in <nl> - / / SetProperty and no setters are invoked for those since they are <nl> - / / not real JSObjects . <nl> - if ( initial_value - > IsTheHole ( ) & & <nl> - ! object - > IsJSContextExtensionObject ( ) ) { <nl> - LookupResult lookup ( isolate ) ; <nl> - object - > Lookup ( name , & lookup ) ; <nl> - if ( lookup . IsPropertyCallbacks ( ) ) { <nl> - return ThrowRedeclarationError ( isolate , name ) ; <nl> - } <nl> - } <nl> - if ( object - > IsJSGlobalObject ( ) ) { <nl> - / / Define own property on the global object . <nl> - RETURN_FAILURE_ON_EXCEPTION ( isolate , <nl> - JSObject : : SetOwnPropertyIgnoreAttributes ( object , name , value , mode ) ) ; <nl> - } else { <nl> - RETURN_FAILURE_ON_EXCEPTION ( isolate , <nl> - JSReceiver : : SetProperty ( object , name , value , mode , SLOPPY ) ) ; <nl> - } <nl> + Object * result = DeclareGlobals ( isolate , global , name , value , <nl> + static_cast < PropertyAttributes > ( attr ) , <nl> + is_var , is_const , is_function ) ; <nl> + if ( isolate - > has_pending_exception ( ) ) return result ; <nl> } <nl> <nl> return isolate - > heap ( ) - > undefined_value ( ) ; <nl> RUNTIME_FUNCTION ( Runtime_InitializeVarGlobal ) { <nl> <nl> / / Determine if we need to assign to the variable if it already <nl> / / exists ( based on the number of arguments ) . <nl> - RUNTIME_ASSERT ( args . length ( ) = = 2 | | args . length ( ) = = 3 ) ; <nl> - bool assign = args . length ( ) = = 3 ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 3 ) ; <nl> <nl> CONVERT_ARG_HANDLE_CHECKED ( String , name , 0 ) ; <nl> CONVERT_STRICT_MODE_ARG_CHECKED ( strict_mode , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> <nl> - / / According to ECMA - 262 , section 12 . 2 , page 62 , the property must <nl> - / / not be deletable . <nl> - PropertyAttributes attributes = DONT_DELETE ; <nl> - <nl> - / / Lookup the property as own on the global object . If it isn ' t <nl> - / / there , there is a property with this name in the prototype chain . <nl> - / / We follow Safari and Firefox behavior and only set the property <nl> - / / if there is an explicit initialization value that we have <nl> - / / to assign to the property . <nl> - / / Note that objects can have hidden prototypes , so we need to traverse <nl> - / / the whole chain of hidden prototypes to do an ' own ' lookup . <nl> - LookupResult lookup ( isolate ) ; <nl> - isolate - > context ( ) - > global_object ( ) - > LookupOwn ( name , & lookup , true ) ; <nl> - if ( lookup . IsInterceptor ( ) ) { <nl> - Handle < JSObject > holder ( lookup . holder ( ) ) ; <nl> - PropertyAttributes intercepted = <nl> - JSReceiver : : GetPropertyAttributes ( holder , name ) ; <nl> - if ( intercepted ! = ABSENT & & ( intercepted & READ_ONLY ) = = 0 ) { <nl> - / / Found an interceptor that ' s not read only . <nl> - if ( assign ) { <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - JSObject : : SetPropertyForResult ( <nl> - holder , & lookup , name , value , attributes , strict_mode ) ) ; <nl> - return * result ; <nl> - } else { <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( assign ) { <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - Handle < GlobalObject > global ( isolate - > context ( ) - > global_object ( ) ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - JSReceiver : : SetProperty ( global , name , value , attributes , strict_mode ) ) ; <nl> - return * result ; <nl> - } <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + Handle < GlobalObject > global ( isolate - > context ( ) - > global_object ( ) ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + JSReceiver : : SetProperty ( global , name , value , NONE , strict_mode ) ) ; <nl> + return * result ; <nl> } <nl> <nl> <nl> RUNTIME_FUNCTION ( Runtime_InitializeConstGlobal ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> + HandleScope handle_scope ( isolate ) ; <nl> / / All constants are declared with an initial value . The name <nl> / / of the constant is the first argument and the initial value <nl> / / is the second . <nl> RUNTIME_FUNCTION ( Runtime_InitializeConstGlobal ) { <nl> CONVERT_ARG_HANDLE_CHECKED ( String , name , 0 ) ; <nl> CONVERT_ARG_HANDLE_CHECKED ( Object , value , 1 ) ; <nl> <nl> - / / Get the current global object from top . <nl> - GlobalObject * global = isolate - > context ( ) - > global_object ( ) ; <nl> + Handle < GlobalObject > global = isolate - > global_object ( ) ; <nl> <nl> - / / According to ECMA - 262 , section 12 . 2 , page 62 , the property must <nl> - / / not be deletable . Since it ' s a const , it must be READ_ONLY too . <nl> - PropertyAttributes attributes = <nl> - static_cast < PropertyAttributes > ( DONT_DELETE | READ_ONLY ) ; <nl> + / / Lookup the property as own on the global object . <nl> + LookupIterator it ( global , name , LookupIterator : : CHECK_HIDDEN ) ; <nl> + PropertyAttributes old_attributes = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> <nl> - / / Lookup the property as own on the global object . If it isn ' t <nl> - / / there , we add the property and take special precautions to always <nl> - / / add it even in case of callbacks in the prototype chain ( this rules <nl> - / / out using SetProperty ) . We use SetOwnPropertyIgnoreAttributes instead <nl> - LookupResult lookup ( isolate ) ; <nl> - global - > LookupOwn ( name , & lookup ) ; <nl> - if ( ! lookup . IsFound ( ) ) { <nl> - HandleScope handle_scope ( isolate ) ; <nl> - Handle < GlobalObject > global ( isolate - > context ( ) - > global_object ( ) ) ; <nl> - JSObject : : AddProperty ( global , name , value , attributes ) ; <nl> - return * value ; <nl> + PropertyAttributes attr = <nl> + static_cast < PropertyAttributes > ( DONT_DELETE | READ_ONLY ) ; <nl> + / / Set the value if the property is either missing , or the property attributes <nl> + / / allow setting the value without invoking an accessor . <nl> + if ( it . IsFound ( ) ) { <nl> + / / Ignore if we can ' t reconfigure the value . <nl> + if ( ( old_attributes & DONT_DELETE ) ! = 0 ) { <nl> + if ( ( old_attributes & READ_ONLY ) ! = 0 | | <nl> + it . property_kind ( ) = = LookupIterator : : ACCESSOR ) { <nl> + return * value ; <nl> + } <nl> + attr = static_cast < PropertyAttributes > ( old_attributes | READ_ONLY ) ; <nl> + } <nl> } <nl> <nl> - if ( ! lookup . IsReadOnly ( ) ) { <nl> - / / Restore global object from context ( in case of GC ) and continue <nl> - / / with setting the value . <nl> - HandleScope handle_scope ( isolate ) ; <nl> - Handle < GlobalObject > global ( isolate - > context ( ) - > global_object ( ) ) ; <nl> + RETURN_FAILURE_ON_EXCEPTION ( isolate , JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> + global , name , value , attr ) ) ; <nl> <nl> - / / BUG 1213575 : Handle the case where we have to set a read - only <nl> - / / property through an interceptor and only do it if it ' s <nl> - / / uninitialized , e . g . the hole . Nirk . . . <nl> - / / Passing sloppy mode because the property is writable . <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSReceiver : : SetProperty ( global , name , value , attributes , SLOPPY ) ) ; <nl> - return * value ; <nl> + return * value ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_DeclareLookupSlot ) { <nl> + HandleScope scope ( isolate ) ; <nl> + ASSERT ( args . length ( ) = = 4 ) ; <nl> + <nl> + / / Declarations are always made in a function , native , or global context . In <nl> + / / the case of eval code , the context passed is the context of the caller , <nl> + / / which may be some nested context and not the declaration context . <nl> + CONVERT_ARG_HANDLE_CHECKED ( Context , context_arg , 0 ) ; <nl> + Handle < Context > context ( context_arg - > declaration_context ( ) ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( String , name , 1 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( attr_arg , 2 ) ; <nl> + PropertyAttributes attr = static_cast < PropertyAttributes > ( attr_arg ) ; <nl> + RUNTIME_ASSERT ( attr = = READ_ONLY | | attr = = NONE ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , initial_value , 3 ) ; <nl> + <nl> + / / TODO ( verwaest ) : Unify the encoding indicating " var " with DeclareGlobals . <nl> + bool is_var = * initial_value = = NULL ; <nl> + bool is_const = initial_value - > IsTheHole ( ) ; <nl> + bool is_function = initial_value - > IsJSFunction ( ) ; <nl> + ASSERT ( is_var + is_const + is_function = = 1 ) ; <nl> + <nl> + int index ; <nl> + PropertyAttributes attributes ; <nl> + ContextLookupFlags flags = DONT_FOLLOW_CHAINS ; <nl> + BindingFlags binding_flags ; <nl> + Handle < Object > holder = <nl> + context - > Lookup ( name , flags , & index , & attributes , & binding_flags ) ; <nl> + <nl> + Handle < JSObject > object ; <nl> + Handle < Object > value = <nl> + is_function ? initial_value <nl> + : Handle < Object > : : cast ( isolate - > factory ( ) - > undefined_value ( ) ) ; <nl> + <nl> + / / TODO ( verwaest ) : This case should probably not be covered by this function , <nl> + / / but by DeclareGlobals instead . <nl> + if ( ( attributes ! = ABSENT & & holder - > IsJSGlobalObject ( ) ) | | <nl> + ( context_arg - > has_extension ( ) & & <nl> + context_arg - > extension ( ) - > IsJSGlobalObject ( ) ) ) { <nl> + return DeclareGlobals ( isolate , Handle < JSGlobalObject > : : cast ( holder ) , name , <nl> + value , attr , is_var , is_const , is_function ) ; <nl> } <nl> <nl> - / / Set the value , but only if we ' re assigning the initial value to a <nl> - / / constant . For now , we determine this by checking if the <nl> - / / current value is the hole . <nl> - / / Strict mode handling not needed ( const is disallowed in strict mode ) . <nl> - if ( lookup . IsField ( ) ) { <nl> - FixedArray * properties = global - > properties ( ) ; <nl> - int index = lookup . GetFieldIndex ( ) . outobject_array_index ( ) ; <nl> - if ( properties - > get ( index ) - > IsTheHole ( ) | | ! lookup . IsReadOnly ( ) ) { <nl> - properties - > set ( index , * value ) ; <nl> + if ( attributes ! = ABSENT ) { <nl> + / / The name was declared before ; check for conflicting re - declarations . <nl> + if ( is_const | | ( attributes & READ_ONLY ) ! = 0 ) { <nl> + return ThrowRedeclarationError ( isolate , name ) ; <nl> } <nl> - } else if ( lookup . IsNormal ( ) ) { <nl> - if ( global - > GetNormalizedProperty ( & lookup ) - > IsTheHole ( ) | | <nl> - ! lookup . IsReadOnly ( ) ) { <nl> - HandleScope scope ( isolate ) ; <nl> - JSObject : : SetNormalizedProperty ( Handle < JSObject > ( global ) , & lookup , value ) ; <nl> + <nl> + / / Skip var re - declarations . <nl> + if ( is_var ) return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + <nl> + ASSERT ( is_function ) ; <nl> + if ( index > = 0 ) { <nl> + ASSERT ( holder . is_identical_to ( context ) ) ; <nl> + context - > set ( index , * initial_value ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> } <nl> + <nl> + object = Handle < JSObject > : : cast ( holder ) ; <nl> + <nl> + } else if ( context - > has_extension ( ) ) { <nl> + object = handle ( JSObject : : cast ( context - > extension ( ) ) ) ; <nl> + ASSERT ( object - > IsJSContextExtensionObject ( ) | | object - > IsJSGlobalObject ( ) ) ; <nl> } else { <nl> - / / Ignore re - initialization of constants that have already been <nl> - / / assigned a constant value . <nl> - ASSERT ( lookup . IsReadOnly ( ) & & lookup . IsConstant ( ) ) ; <nl> + ASSERT ( context - > IsFunctionContext ( ) ) ; <nl> + object = <nl> + isolate - > factory ( ) - > NewJSObject ( isolate - > context_extension_function ( ) ) ; <nl> + context - > set_extension ( * object ) ; <nl> } <nl> <nl> - / / Use the set value as the result of the operation . <nl> - return * value ; <nl> + RETURN_FAILURE_ON_EXCEPTION ( isolate , JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> + object , name , value , attr ) ) ; <nl> + <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> } <nl> <nl> <nl> - RUNTIME_FUNCTION ( Runtime_InitializeConstContextSlot ) { <nl> + RUNTIME_FUNCTION ( Runtime_InitializeLegacyConstLookupSlot ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 3 ) ; <nl> <nl> RUNTIME_FUNCTION ( Runtime_InitializeConstContextSlot ) { <nl> <nl> int index ; <nl> PropertyAttributes attributes ; <nl> - ContextLookupFlags flags = FOLLOW_CHAINS ; <nl> + ContextLookupFlags flags = DONT_FOLLOW_CHAINS ; <nl> BindingFlags binding_flags ; <nl> Handle < Object > holder = <nl> context - > Lookup ( name , flags , & index , & attributes , & binding_flags ) ; <nl> <nl> if ( index > = 0 ) { <nl> ASSERT ( holder - > IsContext ( ) ) ; <nl> - / / Property was found in a context . Perform the assignment if we <nl> - / / found some non - constant or an uninitialized constant . <nl> + / / Property was found in a context . Perform the assignment if the constant <nl> + / / was uninitialized . <nl> Handle < Context > context = Handle < Context > : : cast ( holder ) ; <nl> - if ( ( attributes & READ_ONLY ) = = 0 | | context - > get ( index ) - > IsTheHole ( ) ) { <nl> - context - > set ( index , * value ) ; <nl> - } <nl> + ASSERT ( ( attributes & READ_ONLY ) ! = 0 ) ; <nl> + if ( context - > get ( index ) - > IsTheHole ( ) ) context - > set ( index , * value ) ; <nl> return * value ; <nl> } <nl> <nl> - / / The property could not be found , we introduce it as a property of the <nl> - / / global object . <nl> - if ( attributes = = ABSENT ) { <nl> - Handle < JSObject > global = Handle < JSObject > ( <nl> - isolate - > context ( ) - > global_object ( ) ) ; <nl> - / / Strict mode not needed ( const disallowed in strict mode ) . <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSReceiver : : SetProperty ( global , name , value , NONE , SLOPPY ) ) ; <nl> - return * value ; <nl> - } <nl> + PropertyAttributes attr = <nl> + static_cast < PropertyAttributes > ( DONT_DELETE | READ_ONLY ) ; <nl> <nl> - / / The property was present in some function ' s context extension object , <nl> - / / as a property on the subject of a with , or as a property of the global <nl> - / / object . <nl> - / / <nl> - / / In most situations , eval - introduced consts should still be present in <nl> - / / the context extension object . However , because declaration and <nl> - / / initialization are separate , the property might have been deleted <nl> - / / before we reach the initialization point . <nl> - / / <nl> - / / Example : <nl> - / / <nl> - / / function f ( ) { eval ( " delete x ; const x ; " ) ; } <nl> - / / <nl> - / / In that case , the initialization behaves like a normal assignment . <nl> - Handle < JSObject > object = Handle < JSObject > : : cast ( holder ) ; <nl> + / / Strict mode handling not needed ( legacy const is disallowed in strict <nl> + / / mode ) . <nl> <nl> - if ( * object = = context - > extension ( ) ) { <nl> - / / This is the property that was introduced by the const declaration . <nl> - / / Set it if it hasn ' t been set before . NOTE : We cannot use <nl> - / / GetProperty ( ) to get the current value as it ' unholes ' the value . <nl> - LookupResult lookup ( isolate ) ; <nl> - object - > LookupOwnRealNamedProperty ( name , & lookup ) ; <nl> - ASSERT ( lookup . IsFound ( ) ) ; / / the property was declared <nl> - ASSERT ( lookup . IsReadOnly ( ) ) ; / / and it was declared as read - only <nl> - <nl> - if ( lookup . IsField ( ) ) { <nl> - FixedArray * properties = object - > properties ( ) ; <nl> - FieldIndex index = lookup . GetFieldIndex ( ) ; <nl> - ASSERT ( ! index . is_inobject ( ) ) ; <nl> - if ( properties - > get ( index . outobject_array_index ( ) ) - > IsTheHole ( ) ) { <nl> - properties - > set ( index . outobject_array_index ( ) , * value ) ; <nl> - } <nl> - } else if ( lookup . IsNormal ( ) ) { <nl> - if ( object - > GetNormalizedProperty ( & lookup ) - > IsTheHole ( ) ) { <nl> - JSObject : : SetNormalizedProperty ( object , & lookup , value ) ; <nl> - } <nl> - } else { <nl> - / / We should not reach here . Any real , named property should be <nl> - / / either a field or a dictionary slot . <nl> - UNREACHABLE ( ) ; <nl> - } <nl> + / / The declared const was configurable , and may have been deleted in the <nl> + / / meanwhile . If so , re - introduce the variable in the context extension . <nl> + ASSERT ( context_arg - > has_extension ( ) ) ; <nl> + if ( attributes = = ABSENT ) { <nl> + holder = handle ( context_arg - > extension ( ) , isolate ) ; <nl> } else { <nl> - / / The property was found on some other object . Set it if it is not a <nl> - / / read - only property . <nl> - if ( ( attributes & READ_ONLY ) = = 0 ) { <nl> - / / Strict mode not needed ( const disallowed in strict mode ) . <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSReceiver : : SetProperty ( object , name , value , attributes , SLOPPY ) ) ; <nl> + / / For JSContextExtensionObjects , the initializer can be run multiple times <nl> + / / if in a for loop : for ( var i = 0 ; i < 2 ; i + + ) { const x = i ; } . Only the <nl> + / / first assignment should go through . For JSGlobalObjects , additionally any <nl> + / / code can run in between that modifies the declared property . <nl> + ASSERT ( holder - > IsJSGlobalObject ( ) | | holder - > IsJSContextExtensionObject ( ) ) ; <nl> + <nl> + LookupIterator it ( holder , name , LookupIterator : : CHECK_HIDDEN ) ; <nl> + PropertyAttributes old_attributes = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> + <nl> + / / Ignore if we can ' t reconfigure the value . <nl> + if ( ( old_attributes & DONT_DELETE ) ! = 0 ) { <nl> + if ( ( old_attributes & READ_ONLY ) ! = 0 | | <nl> + it . property_kind ( ) = = LookupIterator : : ACCESSOR ) { <nl> + return * value ; <nl> + } <nl> + attr = static_cast < PropertyAttributes > ( old_attributes | READ_ONLY ) ; <nl> } <nl> } <nl> <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> + Handle < JSObject > : : cast ( holder ) , name , value , attr ) ) ; <nl> + <nl> return * value ; <nl> } <nl> <nl> RUNTIME_FUNCTION_RETURN_PAIR ( Runtime_LoadContextSlotNoReferenceError ) { <nl> } <nl> <nl> <nl> - RUNTIME_FUNCTION ( Runtime_StoreContextSlot ) { <nl> + RUNTIME_FUNCTION ( Runtime_StoreLookupSlot ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 4 ) ; <nl> <nl> RUNTIME_FUNCTION ( Runtime_StoreContextSlot ) { <nl> & index , <nl> & attributes , <nl> & binding_flags ) ; <nl> + / / In case of JSProxy , an exception might have been thrown . <nl> if ( isolate - > has_pending_exception ( ) ) return isolate - > heap ( ) - > exception ( ) ; <nl> <nl> + / / The property was found in a context slot . <nl> if ( index > = 0 ) { <nl> - / / The property was found in a context slot . <nl> - Handle < Context > context = Handle < Context > : : cast ( holder ) ; <nl> - if ( binding_flags = = MUTABLE_CHECK_INITIALIZED & & <nl> - context - > get ( index ) - > IsTheHole ( ) ) { <nl> - Handle < Object > error = <nl> - isolate - > factory ( ) - > NewReferenceError ( " not_defined " , <nl> - HandleVector ( & name , 1 ) ) ; <nl> - return isolate - > Throw ( * error ) ; <nl> - } <nl> - / / Ignore if read_only variable . <nl> if ( ( attributes & READ_ONLY ) = = 0 ) { <nl> - / / Context is a fixed array and set cannot fail . <nl> - context - > set ( index , * value ) ; <nl> + Handle < Context > : : cast ( holder ) - > set ( index , * value ) ; <nl> } else if ( strict_mode = = STRICT ) { <nl> / / Setting read only property in strict mode . <nl> Handle < Object > error = <nl> RUNTIME_FUNCTION ( Runtime_StoreContextSlot ) { <nl> / / context extension object , a property of the subject of a with , or a <nl> / / property of the global object . <nl> Handle < JSReceiver > object ; <nl> - <nl> - if ( ! holder . is_null ( ) ) { <nl> + if ( attributes ! = ABSENT ) { <nl> / / The property exists on the holder . <nl> object = Handle < JSReceiver > : : cast ( holder ) ; <nl> + } else if ( strict_mode = = STRICT ) { <nl> + / / If absent in strict mode : throw . <nl> + Handle < Object > error = isolate - > factory ( ) - > NewReferenceError ( <nl> + " not_defined " , HandleVector ( & name , 1 ) ) ; <nl> + return isolate - > Throw ( * error ) ; <nl> } else { <nl> - / / The property was not found . <nl> - ASSERT ( attributes = = ABSENT ) ; <nl> - <nl> - if ( strict_mode = = STRICT ) { <nl> - / / Throw in strict mode ( assignment to undefined variable ) . <nl> - Handle < Object > error = <nl> - isolate - > factory ( ) - > NewReferenceError ( <nl> - " not_defined " , HandleVector ( & name , 1 ) ) ; <nl> - return isolate - > Throw ( * error ) ; <nl> - } <nl> - / / In sloppy mode , the property is added to the global object . <nl> - attributes = NONE ; <nl> - object = Handle < JSReceiver > ( isolate - > context ( ) - > global_object ( ) ) ; <nl> + / / If absent in sloppy mode : add the property to the global object . <nl> + object = Handle < JSReceiver > ( context - > global_object ( ) ) ; <nl> } <nl> <nl> - / / Set the property if it ' s not read only or doesn ' t yet exist . <nl> - if ( ( attributes & READ_ONLY ) = = 0 | | <nl> - ( JSReceiver : : GetOwnPropertyAttributes ( object , name ) = = ABSENT ) ) { <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , <nl> - JSReceiver : : SetProperty ( object , name , value , NONE , strict_mode ) ) ; <nl> - } else if ( strict_mode = = STRICT & & ( attributes & READ_ONLY ) ! = 0 ) { <nl> - / / Setting read only property in strict mode . <nl> - Handle < Object > error = <nl> - isolate - > factory ( ) - > NewTypeError ( <nl> - " strict_cannot_assign " , HandleVector ( & name , 1 ) ) ; <nl> - return isolate - > Throw ( * error ) ; <nl> - } <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , JSReceiver : : SetProperty ( object , name , value , NONE , strict_mode ) ) ; <nl> + <nl> return * value ; <nl> } <nl> <nl> mmm a / src / runtime . h <nl> ppp b / src / runtime . h <nl> namespace internal { <nl> F ( IsValidSmi , 1 , 1 ) <nl> <nl> <nl> - # define RUNTIME_FUNCTION_LIST_ALWAYS_2 ( F ) \ <nl> - / * Reflection * / \ <nl> - F ( FunctionSetInstanceClassName , 2 , 1 ) \ <nl> - F ( FunctionSetLength , 2 , 1 ) \ <nl> - F ( FunctionSetPrototype , 2 , 1 ) \ <nl> - F ( FunctionGetName , 1 , 1 ) \ <nl> - F ( FunctionSetName , 2 , 1 ) \ <nl> - F ( FunctionNameShouldPrintAsAnonymous , 1 , 1 ) \ <nl> - F ( FunctionMarkNameShouldPrintAsAnonymous , 1 , 1 ) \ <nl> - F ( FunctionIsGenerator , 1 , 1 ) \ <nl> - F ( FunctionBindArguments , 4 , 1 ) \ <nl> - F ( BoundFunctionGetBindings , 1 , 1 ) \ <nl> - F ( FunctionRemovePrototype , 1 , 1 ) \ <nl> - F ( FunctionGetSourceCode , 1 , 1 ) \ <nl> - F ( FunctionGetScript , 1 , 1 ) \ <nl> - F ( FunctionGetScriptSourcePosition , 1 , 1 ) \ <nl> - F ( FunctionGetPositionForOffset , 2 , 1 ) \ <nl> - F ( FunctionIsAPIFunction , 1 , 1 ) \ <nl> - F ( FunctionIsBuiltin , 1 , 1 ) \ <nl> - F ( GetScript , 1 , 1 ) \ <nl> - F ( CollectStackTrace , 2 , 1 ) \ <nl> - F ( GetV8Version , 0 , 1 ) \ <nl> - \ <nl> - F ( SetCode , 2 , 1 ) \ <nl> - \ <nl> - F ( CreateApiFunction , 2 , 1 ) \ <nl> - F ( IsTemplate , 1 , 1 ) \ <nl> - F ( GetTemplateField , 2 , 1 ) \ <nl> - F ( DisableAccessChecks , 1 , 1 ) \ <nl> - F ( EnableAccessChecks , 1 , 1 ) \ <nl> - \ <nl> - / * Dates * / \ <nl> - F ( DateCurrentTime , 0 , 1 ) \ <nl> - F ( DateParseString , 2 , 1 ) \ <nl> - F ( DateLocalTimezone , 1 , 1 ) \ <nl> - F ( DateToUTC , 1 , 1 ) \ <nl> - F ( DateMakeDay , 2 , 1 ) \ <nl> - F ( DateSetValue , 3 , 1 ) \ <nl> - F ( DateCacheVersion , 0 , 1 ) \ <nl> - \ <nl> - / * Globals * / \ <nl> - F ( CompileString , 2 , 1 ) \ <nl> - \ <nl> - / * Eval * / \ <nl> - F ( GlobalProxy , 1 , 1 ) \ <nl> - F ( IsAttachedGlobal , 1 , 1 ) \ <nl> - \ <nl> - F ( AddProperty , 4 , 1 ) \ <nl> - F ( AddPropertyForTemplate , 4 , 1 ) \ <nl> - F ( SetProperty , 4 , 1 ) \ <nl> - F ( DefineDataPropertyUnchecked , 4 , 1 ) \ <nl> - F ( DefineAccessorPropertyUnchecked , 5 , 1 ) \ <nl> - F ( GetDataProperty , 2 , 1 ) \ <nl> - F ( SetHiddenProperty , 3 , 1 ) \ <nl> - \ <nl> - / * Arrays * / \ <nl> - F ( RemoveArrayHoles , 2 , 1 ) \ <nl> - F ( GetArrayKeys , 2 , 1 ) \ <nl> - F ( MoveArrayContents , 2 , 1 ) \ <nl> - F ( EstimateNumberOfElements , 1 , 1 ) \ <nl> - \ <nl> - / * Getters and Setters * / \ <nl> - F ( LookupAccessor , 3 , 1 ) \ <nl> - \ <nl> - / * ES5 * / \ <nl> - F ( ObjectFreeze , 1 , 1 ) \ <nl> - \ <nl> - / * Harmony modules * / \ <nl> - F ( IsJSModule , 1 , 1 ) \ <nl> - \ <nl> - / * Harmony symbols * / \ <nl> - F ( CreateSymbol , 1 , 1 ) \ <nl> - F ( CreatePrivateSymbol , 1 , 1 ) \ <nl> - F ( CreateGlobalPrivateSymbol , 1 , 1 ) \ <nl> - F ( NewSymbolWrapper , 1 , 1 ) \ <nl> - F ( SymbolDescription , 1 , 1 ) \ <nl> - F ( SymbolRegistry , 0 , 1 ) \ <nl> - F ( SymbolIsPrivate , 1 , 1 ) \ <nl> - \ <nl> - / * Harmony proxies * / \ <nl> - F ( CreateJSProxy , 2 , 1 ) \ <nl> - F ( CreateJSFunctionProxy , 4 , 1 ) \ <nl> - F ( IsJSProxy , 1 , 1 ) \ <nl> - F ( IsJSFunctionProxy , 1 , 1 ) \ <nl> - F ( GetHandler , 1 , 1 ) \ <nl> - F ( GetCallTrap , 1 , 1 ) \ <nl> - F ( GetConstructTrap , 1 , 1 ) \ <nl> - F ( Fix , 1 , 1 ) \ <nl> - \ <nl> - / * Harmony sets * / \ <nl> - F ( SetInitialize , 1 , 1 ) \ <nl> - F ( SetAdd , 2 , 1 ) \ <nl> - F ( SetHas , 2 , 1 ) \ <nl> - F ( SetDelete , 2 , 1 ) \ <nl> - F ( SetClear , 1 , 1 ) \ <nl> - F ( SetGetSize , 1 , 1 ) \ <nl> - \ <nl> - F ( SetIteratorInitialize , 3 , 1 ) \ <nl> - F ( SetIteratorNext , 2 , 1 ) \ <nl> - \ <nl> - / * Harmony maps * / \ <nl> - F ( MapInitialize , 1 , 1 ) \ <nl> - F ( MapGet , 2 , 1 ) \ <nl> - F ( MapHas , 2 , 1 ) \ <nl> - F ( MapDelete , 2 , 1 ) \ <nl> - F ( MapClear , 1 , 1 ) \ <nl> - F ( MapSet , 3 , 1 ) \ <nl> - F ( MapGetSize , 1 , 1 ) \ <nl> - \ <nl> - F ( MapIteratorInitialize , 3 , 1 ) \ <nl> - F ( MapIteratorNext , 2 , 1 ) \ <nl> - \ <nl> - / * Harmony weak maps and sets * / \ <nl> - F ( WeakCollectionInitialize , 1 , 1 ) \ <nl> - F ( WeakCollectionGet , 2 , 1 ) \ <nl> - F ( WeakCollectionHas , 2 , 1 ) \ <nl> - F ( WeakCollectionDelete , 2 , 1 ) \ <nl> - F ( WeakCollectionSet , 3 , 1 ) \ <nl> - \ <nl> - / * Harmony events * / \ <nl> - F ( EnqueueMicrotask , 1 , 1 ) \ <nl> - F ( RunMicrotasks , 0 , 1 ) \ <nl> - \ <nl> - / * Harmony observe * / \ <nl> - F ( IsObserved , 1 , 1 ) \ <nl> - F ( SetIsObserved , 1 , 1 ) \ <nl> - F ( GetObservationState , 0 , 1 ) \ <nl> - F ( ObservationWeakMapCreate , 0 , 1 ) \ <nl> - F ( ObserverObjectAndRecordHaveSameOrigin , 3 , 1 ) \ <nl> - F ( ObjectWasCreatedInCurrentOrigin , 1 , 1 ) \ <nl> - F ( GetObjectContextObjectObserve , 1 , 1 ) \ <nl> - F ( GetObjectContextObjectGetNotifier , 1 , 1 ) \ <nl> - F ( GetObjectContextNotifierPerformChange , 1 , 1 ) \ <nl> - \ <nl> - / * Harmony typed arrays * / \ <nl> - F ( ArrayBufferInitialize , 2 , 1 ) \ <nl> - F ( ArrayBufferSliceImpl , 3 , 1 ) \ <nl> - F ( ArrayBufferIsView , 1 , 1 ) \ <nl> - F ( ArrayBufferNeuter , 1 , 1 ) \ <nl> - \ <nl> - F ( TypedArrayInitializeFromArrayLike , 4 , 1 ) \ <nl> - F ( TypedArrayGetBuffer , 1 , 1 ) \ <nl> - F ( TypedArraySetFastCases , 3 , 1 ) \ <nl> - \ <nl> - F ( DataViewGetBuffer , 1 , 1 ) \ <nl> - F ( DataViewGetInt8 , 3 , 1 ) \ <nl> - F ( DataViewGetUint8 , 3 , 1 ) \ <nl> - F ( DataViewGetInt16 , 3 , 1 ) \ <nl> - F ( DataViewGetUint16 , 3 , 1 ) \ <nl> - F ( DataViewGetInt32 , 3 , 1 ) \ <nl> - F ( DataViewGetUint32 , 3 , 1 ) \ <nl> - F ( DataViewGetFloat32 , 3 , 1 ) \ <nl> - F ( DataViewGetFloat64 , 3 , 1 ) \ <nl> - \ <nl> - F ( DataViewSetInt8 , 4 , 1 ) \ <nl> - F ( DataViewSetUint8 , 4 , 1 ) \ <nl> - F ( DataViewSetInt16 , 4 , 1 ) \ <nl> - F ( DataViewSetUint16 , 4 , 1 ) \ <nl> - F ( DataViewSetInt32 , 4 , 1 ) \ <nl> - F ( DataViewSetUint32 , 4 , 1 ) \ <nl> - F ( DataViewSetFloat32 , 4 , 1 ) \ <nl> - F ( DataViewSetFloat64 , 4 , 1 ) \ <nl> - \ <nl> - / * Statements * / \ <nl> - F ( NewObjectFromBound , 1 , 1 ) \ <nl> - \ <nl> - / * Declarations and initialization * / \ <nl> - F ( InitializeVarGlobal , - 1 / * 2 or 3 * / , 1 ) \ <nl> - F ( OptimizeObjectForAddingMultipleProperties , 2 , 1 ) \ <nl> - \ <nl> - / * Debugging * / \ <nl> - F ( DebugPrint , 1 , 1 ) \ <nl> - F ( GlobalPrint , 1 , 1 ) \ <nl> - F ( DebugTrace , 0 , 1 ) \ <nl> - F ( TraceEnter , 0 , 1 ) \ <nl> - F ( TraceExit , 1 , 1 ) \ <nl> - F ( Abort , 1 , 1 ) \ <nl> - F ( AbortJS , 1 , 1 ) \ <nl> - / * ES5 * / \ <nl> - F ( OwnKeys , 1 , 1 ) \ <nl> - \ <nl> - / * Message objects * / \ <nl> - F ( MessageGetStartPosition , 1 , 1 ) \ <nl> - F ( MessageGetScript , 1 , 1 ) \ <nl> - \ <nl> + # define RUNTIME_FUNCTION_LIST_ALWAYS_2 ( F ) \ <nl> + / * Reflection * / \ <nl> + F ( FunctionSetInstanceClassName , 2 , 1 ) \ <nl> + F ( FunctionSetLength , 2 , 1 ) \ <nl> + F ( FunctionSetPrototype , 2 , 1 ) \ <nl> + F ( FunctionGetName , 1 , 1 ) \ <nl> + F ( FunctionSetName , 2 , 1 ) \ <nl> + F ( FunctionNameShouldPrintAsAnonymous , 1 , 1 ) \ <nl> + F ( FunctionMarkNameShouldPrintAsAnonymous , 1 , 1 ) \ <nl> + F ( FunctionIsGenerator , 1 , 1 ) \ <nl> + F ( FunctionBindArguments , 4 , 1 ) \ <nl> + F ( BoundFunctionGetBindings , 1 , 1 ) \ <nl> + F ( FunctionRemovePrototype , 1 , 1 ) \ <nl> + F ( FunctionGetSourceCode , 1 , 1 ) \ <nl> + F ( FunctionGetScript , 1 , 1 ) \ <nl> + F ( FunctionGetScriptSourcePosition , 1 , 1 ) \ <nl> + F ( FunctionGetPositionForOffset , 2 , 1 ) \ <nl> + F ( FunctionIsAPIFunction , 1 , 1 ) \ <nl> + F ( FunctionIsBuiltin , 1 , 1 ) \ <nl> + F ( GetScript , 1 , 1 ) \ <nl> + F ( CollectStackTrace , 2 , 1 ) \ <nl> + F ( GetV8Version , 0 , 1 ) \ <nl> + \ <nl> + F ( SetCode , 2 , 1 ) \ <nl> + \ <nl> + F ( CreateApiFunction , 2 , 1 ) \ <nl> + F ( IsTemplate , 1 , 1 ) \ <nl> + F ( GetTemplateField , 2 , 1 ) \ <nl> + F ( DisableAccessChecks , 1 , 1 ) \ <nl> + F ( EnableAccessChecks , 1 , 1 ) \ <nl> + \ <nl> + / * Dates * / \ <nl> + F ( DateCurrentTime , 0 , 1 ) \ <nl> + F ( DateParseString , 2 , 1 ) \ <nl> + F ( DateLocalTimezone , 1 , 1 ) \ <nl> + F ( DateToUTC , 1 , 1 ) \ <nl> + F ( DateMakeDay , 2 , 1 ) \ <nl> + F ( DateSetValue , 3 , 1 ) \ <nl> + F ( DateCacheVersion , 0 , 1 ) \ <nl> + \ <nl> + / * Globals * / \ <nl> + F ( CompileString , 2 , 1 ) \ <nl> + \ <nl> + / * Eval * / \ <nl> + F ( GlobalProxy , 1 , 1 ) \ <nl> + F ( IsAttachedGlobal , 1 , 1 ) \ <nl> + \ <nl> + F ( AddProperty , 4 , 1 ) \ <nl> + F ( AddPropertyForTemplate , 4 , 1 ) \ <nl> + F ( SetProperty , 4 , 1 ) \ <nl> + F ( DefineDataPropertyUnchecked , 4 , 1 ) \ <nl> + F ( DefineAccessorPropertyUnchecked , 5 , 1 ) \ <nl> + F ( GetDataProperty , 2 , 1 ) \ <nl> + F ( SetHiddenProperty , 3 , 1 ) \ <nl> + \ <nl> + / * Arrays * / \ <nl> + F ( RemoveArrayHoles , 2 , 1 ) \ <nl> + F ( GetArrayKeys , 2 , 1 ) \ <nl> + F ( MoveArrayContents , 2 , 1 ) \ <nl> + F ( EstimateNumberOfElements , 1 , 1 ) \ <nl> + \ <nl> + / * Getters and Setters * / \ <nl> + F ( LookupAccessor , 3 , 1 ) \ <nl> + \ <nl> + / * ES5 * / \ <nl> + F ( ObjectFreeze , 1 , 1 ) \ <nl> + \ <nl> + / * Harmony modules * / \ <nl> + F ( IsJSModule , 1 , 1 ) \ <nl> + \ <nl> + / * Harmony symbols * / \ <nl> + F ( CreateSymbol , 1 , 1 ) \ <nl> + F ( CreatePrivateSymbol , 1 , 1 ) \ <nl> + F ( CreateGlobalPrivateSymbol , 1 , 1 ) \ <nl> + F ( NewSymbolWrapper , 1 , 1 ) \ <nl> + F ( SymbolDescription , 1 , 1 ) \ <nl> + F ( SymbolRegistry , 0 , 1 ) \ <nl> + F ( SymbolIsPrivate , 1 , 1 ) \ <nl> + \ <nl> + / * Harmony proxies * / \ <nl> + F ( CreateJSProxy , 2 , 1 ) \ <nl> + F ( CreateJSFunctionProxy , 4 , 1 ) \ <nl> + F ( IsJSProxy , 1 , 1 ) \ <nl> + F ( IsJSFunctionProxy , 1 , 1 ) \ <nl> + F ( GetHandler , 1 , 1 ) \ <nl> + F ( GetCallTrap , 1 , 1 ) \ <nl> + F ( GetConstructTrap , 1 , 1 ) \ <nl> + F ( Fix , 1 , 1 ) \ <nl> + \ <nl> + / * Harmony sets * / \ <nl> + F ( SetInitialize , 1 , 1 ) \ <nl> + F ( SetAdd , 2 , 1 ) \ <nl> + F ( SetHas , 2 , 1 ) \ <nl> + F ( SetDelete , 2 , 1 ) \ <nl> + F ( SetClear , 1 , 1 ) \ <nl> + F ( SetGetSize , 1 , 1 ) \ <nl> + \ <nl> + F ( SetIteratorInitialize , 3 , 1 ) \ <nl> + F ( SetIteratorNext , 2 , 1 ) \ <nl> + \ <nl> + / * Harmony maps * / \ <nl> + F ( MapInitialize , 1 , 1 ) \ <nl> + F ( MapGet , 2 , 1 ) \ <nl> + F ( MapHas , 2 , 1 ) \ <nl> + F ( MapDelete , 2 , 1 ) \ <nl> + F ( MapClear , 1 , 1 ) \ <nl> + F ( MapSet , 3 , 1 ) \ <nl> + F ( MapGetSize , 1 , 1 ) \ <nl> + \ <nl> + F ( MapIteratorInitialize , 3 , 1 ) \ <nl> + F ( MapIteratorNext , 2 , 1 ) \ <nl> + \ <nl> + / * Harmony weak maps and sets * / \ <nl> + F ( WeakCollectionInitialize , 1 , 1 ) \ <nl> + F ( WeakCollectionGet , 2 , 1 ) \ <nl> + F ( WeakCollectionHas , 2 , 1 ) \ <nl> + F ( WeakCollectionDelete , 2 , 1 ) \ <nl> + F ( WeakCollectionSet , 3 , 1 ) \ <nl> + \ <nl> + / * Harmony events * / \ <nl> + F ( EnqueueMicrotask , 1 , 1 ) \ <nl> + F ( RunMicrotasks , 0 , 1 ) \ <nl> + \ <nl> + / * Harmony observe * / \ <nl> + F ( IsObserved , 1 , 1 ) \ <nl> + F ( SetIsObserved , 1 , 1 ) \ <nl> + F ( GetObservationState , 0 , 1 ) \ <nl> + F ( ObservationWeakMapCreate , 0 , 1 ) \ <nl> + F ( ObserverObjectAndRecordHaveSameOrigin , 3 , 1 ) \ <nl> + F ( ObjectWasCreatedInCurrentOrigin , 1 , 1 ) \ <nl> + F ( GetObjectContextObjectObserve , 1 , 1 ) \ <nl> + F ( GetObjectContextObjectGetNotifier , 1 , 1 ) \ <nl> + F ( GetObjectContextNotifierPerformChange , 1 , 1 ) \ <nl> + \ <nl> + / * Harmony typed arrays * / \ <nl> + F ( ArrayBufferInitialize , 2 , 1 ) \ <nl> + F ( ArrayBufferSliceImpl , 3 , 1 ) \ <nl> + F ( ArrayBufferIsView , 1 , 1 ) \ <nl> + F ( ArrayBufferNeuter , 1 , 1 ) \ <nl> + \ <nl> + F ( TypedArrayInitializeFromArrayLike , 4 , 1 ) \ <nl> + F ( TypedArrayGetBuffer , 1 , 1 ) \ <nl> + F ( TypedArraySetFastCases , 3 , 1 ) \ <nl> + \ <nl> + F ( DataViewGetBuffer , 1 , 1 ) \ <nl> + F ( DataViewGetInt8 , 3 , 1 ) \ <nl> + F ( DataViewGetUint8 , 3 , 1 ) \ <nl> + F ( DataViewGetInt16 , 3 , 1 ) \ <nl> + F ( DataViewGetUint16 , 3 , 1 ) \ <nl> + F ( DataViewGetInt32 , 3 , 1 ) \ <nl> + F ( DataViewGetUint32 , 3 , 1 ) \ <nl> + F ( DataViewGetFloat32 , 3 , 1 ) \ <nl> + F ( DataViewGetFloat64 , 3 , 1 ) \ <nl> + \ <nl> + F ( DataViewSetInt8 , 4 , 1 ) \ <nl> + F ( DataViewSetUint8 , 4 , 1 ) \ <nl> + F ( DataViewSetInt16 , 4 , 1 ) \ <nl> + F ( DataViewSetUint16 , 4 , 1 ) \ <nl> + F ( DataViewSetInt32 , 4 , 1 ) \ <nl> + F ( DataViewSetUint32 , 4 , 1 ) \ <nl> + F ( DataViewSetFloat32 , 4 , 1 ) \ <nl> + F ( DataViewSetFloat64 , 4 , 1 ) \ <nl> + \ <nl> + / * Statements * / \ <nl> + F ( NewObjectFromBound , 1 , 1 ) \ <nl> + \ <nl> + / * Declarations and initialization * / \ <nl> + F ( InitializeVarGlobal , 3 , 1 ) \ <nl> + F ( OptimizeObjectForAddingMultipleProperties , 2 , 1 ) \ <nl> + \ <nl> + / * Debugging * / \ <nl> + F ( DebugPrint , 1 , 1 ) \ <nl> + F ( GlobalPrint , 1 , 1 ) \ <nl> + F ( DebugTrace , 0 , 1 ) \ <nl> + F ( TraceEnter , 0 , 1 ) \ <nl> + F ( TraceExit , 1 , 1 ) \ <nl> + F ( Abort , 1 , 1 ) \ <nl> + F ( AbortJS , 1 , 1 ) \ <nl> + / * ES5 * / \ <nl> + F ( OwnKeys , 1 , 1 ) \ <nl> + \ <nl> + / * Message objects * / \ <nl> + F ( MessageGetStartPosition , 1 , 1 ) \ <nl> + F ( MessageGetScript , 1 , 1 ) \ <nl> + \ <nl> / * Pseudo functions - handled as macros by parser * / \ <nl> - F ( IS_VAR , 1 , 1 ) \ <nl> - \ <nl> - / * expose boolean functions from objects - inl . h * / \ <nl> - F ( HasFastSmiElements , 1 , 1 ) \ <nl> - F ( HasFastSmiOrObjectElements , 1 , 1 ) \ <nl> - F ( HasFastObjectElements , 1 , 1 ) \ <nl> - F ( HasFastDoubleElements , 1 , 1 ) \ <nl> - F ( HasFastHoleyElements , 1 , 1 ) \ <nl> - F ( HasDictionaryElements , 1 , 1 ) \ <nl> - F ( HasSloppyArgumentsElements , 1 , 1 ) \ <nl> - F ( HasExternalUint8ClampedElements , 1 , 1 ) \ <nl> - F ( HasExternalArrayElements , 1 , 1 ) \ <nl> - F ( HasExternalInt8Elements , 1 , 1 ) \ <nl> - F ( HasExternalUint8Elements , 1 , 1 ) \ <nl> - F ( HasExternalInt16Elements , 1 , 1 ) \ <nl> - F ( HasExternalUint16Elements , 1 , 1 ) \ <nl> - F ( HasExternalInt32Elements , 1 , 1 ) \ <nl> - F ( HasExternalUint32Elements , 1 , 1 ) \ <nl> - F ( HasExternalFloat32Elements , 1 , 1 ) \ <nl> - F ( HasExternalFloat64Elements , 1 , 1 ) \ <nl> - F ( HasFixedUint8ClampedElements , 1 , 1 ) \ <nl> - F ( HasFixedInt8Elements , 1 , 1 ) \ <nl> - F ( HasFixedUint8Elements , 1 , 1 ) \ <nl> - F ( HasFixedInt16Elements , 1 , 1 ) \ <nl> - F ( HasFixedUint16Elements , 1 , 1 ) \ <nl> - F ( HasFixedInt32Elements , 1 , 1 ) \ <nl> - F ( HasFixedUint32Elements , 1 , 1 ) \ <nl> - F ( HasFixedFloat32Elements , 1 , 1 ) \ <nl> - F ( HasFixedFloat64Elements , 1 , 1 ) \ <nl> - F ( HasFastProperties , 1 , 1 ) \ <nl> - F ( TransitionElementsKind , 2 , 1 ) \ <nl> - F ( HaveSameMap , 2 , 1 ) \ <nl> + F ( IS_VAR , 1 , 1 ) \ <nl> + \ <nl> + / * expose boolean functions from objects - inl . h * / \ <nl> + F ( HasFastSmiElements , 1 , 1 ) \ <nl> + F ( HasFastSmiOrObjectElements , 1 , 1 ) \ <nl> + F ( HasFastObjectElements , 1 , 1 ) \ <nl> + F ( HasFastDoubleElements , 1 , 1 ) \ <nl> + F ( HasFastHoleyElements , 1 , 1 ) \ <nl> + F ( HasDictionaryElements , 1 , 1 ) \ <nl> + F ( HasSloppyArgumentsElements , 1 , 1 ) \ <nl> + F ( HasExternalUint8ClampedElements , 1 , 1 ) \ <nl> + F ( HasExternalArrayElements , 1 , 1 ) \ <nl> + F ( HasExternalInt8Elements , 1 , 1 ) \ <nl> + F ( HasExternalUint8Elements , 1 , 1 ) \ <nl> + F ( HasExternalInt16Elements , 1 , 1 ) \ <nl> + F ( HasExternalUint16Elements , 1 , 1 ) \ <nl> + F ( HasExternalInt32Elements , 1 , 1 ) \ <nl> + F ( HasExternalUint32Elements , 1 , 1 ) \ <nl> + F ( HasExternalFloat32Elements , 1 , 1 ) \ <nl> + F ( HasExternalFloat64Elements , 1 , 1 ) \ <nl> + F ( HasFixedUint8ClampedElements , 1 , 1 ) \ <nl> + F ( HasFixedInt8Elements , 1 , 1 ) \ <nl> + F ( HasFixedUint8Elements , 1 , 1 ) \ <nl> + F ( HasFixedInt16Elements , 1 , 1 ) \ <nl> + F ( HasFixedUint16Elements , 1 , 1 ) \ <nl> + F ( HasFixedInt32Elements , 1 , 1 ) \ <nl> + F ( HasFixedUint32Elements , 1 , 1 ) \ <nl> + F ( HasFixedFloat32Elements , 1 , 1 ) \ <nl> + F ( HasFixedFloat64Elements , 1 , 1 ) \ <nl> + F ( HasFastProperties , 1 , 1 ) \ <nl> + F ( TransitionElementsKind , 2 , 1 ) \ <nl> + F ( HaveSameMap , 2 , 1 ) \ <nl> F ( IsJSGlobalProxy , 1 , 1 ) <nl> <nl> <nl> - # define RUNTIME_FUNCTION_LIST_ALWAYS_3 ( F ) \ <nl> - / * String and Regexp * / \ <nl> - F ( NumberToStringRT , 1 , 1 ) \ <nl> - F ( RegExpConstructResult , 3 , 1 ) \ <nl> - F ( RegExpExecRT , 4 , 1 ) \ <nl> - F ( StringAdd , 2 , 1 ) \ <nl> - F ( SubString , 3 , 1 ) \ <nl> - F ( InternalizeString , 1 , 1 ) \ <nl> - F ( StringCompare , 2 , 1 ) \ <nl> - F ( StringCharCodeAtRT , 2 , 1 ) \ <nl> - F ( GetFromCache , 2 , 1 ) \ <nl> - \ <nl> - / * Compilation * / \ <nl> - F ( CompileUnoptimized , 1 , 1 ) \ <nl> - F ( CompileOptimized , 2 , 1 ) \ <nl> - F ( TryInstallOptimizedCode , 1 , 1 ) \ <nl> - F ( NotifyDeoptimized , 1 , 1 ) \ <nl> - F ( NotifyStubFailure , 0 , 1 ) \ <nl> - \ <nl> - / * Utilities * / \ <nl> - F ( AllocateInNewSpace , 1 , 1 ) \ <nl> - F ( AllocateInTargetSpace , 2 , 1 ) \ <nl> - F ( AllocateHeapNumber , 0 , 1 ) \ <nl> - F ( NumberToSmi , 1 , 1 ) \ <nl> - F ( NumberToStringSkipCache , 1 , 1 ) \ <nl> - \ <nl> - F ( NewSloppyArguments , 3 , 1 ) \ <nl> - F ( NewStrictArguments , 3 , 1 ) \ <nl> - \ <nl> - / * Harmony generators * / \ <nl> - F ( CreateJSGeneratorObject , 0 , 1 ) \ <nl> - F ( SuspendJSGeneratorObject , 1 , 1 ) \ <nl> - F ( ResumeJSGeneratorObject , 3 , 1 ) \ <nl> - F ( ThrowGeneratorStateError , 1 , 1 ) \ <nl> - \ <nl> - / * Arrays * / \ <nl> - F ( ArrayConstructor , - 1 , 1 ) \ <nl> - F ( InternalArrayConstructor , - 1 , 1 ) \ <nl> - \ <nl> - / * Literals * / \ <nl> - F ( MaterializeRegExpLiteral , 4 , 1 ) \ <nl> - F ( CreateObjectLiteral , 4 , 1 ) \ <nl> - F ( CreateArrayLiteral , 4 , 1 ) \ <nl> - F ( CreateArrayLiteralStubBailout , 3 , 1 ) \ <nl> - \ <nl> - / * Statements * / \ <nl> - F ( NewClosure , 3 , 1 ) \ <nl> - F ( NewClosureFromStubFailure , 1 , 1 ) \ <nl> - F ( NewObject , 1 , 1 ) \ <nl> - F ( NewObjectWithAllocationSite , 2 , 1 ) \ <nl> - F ( FinalizeInstanceSize , 1 , 1 ) \ <nl> - F ( Throw , 1 , 1 ) \ <nl> - F ( ReThrow , 1 , 1 ) \ <nl> - F ( ThrowReferenceError , 1 , 1 ) \ <nl> - F ( ThrowNotDateError , 0 , 1 ) \ <nl> - F ( StackGuard , 0 , 1 ) \ <nl> - F ( Interrupt , 0 , 1 ) \ <nl> - F ( PromoteScheduledException , 0 , 1 ) \ <nl> - \ <nl> - / * Contexts * / \ <nl> - F ( NewGlobalContext , 2 , 1 ) \ <nl> - F ( NewFunctionContext , 1 , 1 ) \ <nl> - F ( PushWithContext , 2 , 1 ) \ <nl> - F ( PushCatchContext , 3 , 1 ) \ <nl> - F ( PushBlockContext , 2 , 1 ) \ <nl> - F ( PushModuleContext , 2 , 1 ) \ <nl> - F ( DeleteContextSlot , 2 , 1 ) \ <nl> - F ( LoadContextSlot , 2 , 2 ) \ <nl> + # define RUNTIME_FUNCTION_LIST_ALWAYS_3 ( F ) \ <nl> + / * String and Regexp * / \ <nl> + F ( NumberToStringRT , 1 , 1 ) \ <nl> + F ( RegExpConstructResult , 3 , 1 ) \ <nl> + F ( RegExpExecRT , 4 , 1 ) \ <nl> + F ( StringAdd , 2 , 1 ) \ <nl> + F ( SubString , 3 , 1 ) \ <nl> + F ( InternalizeString , 1 , 1 ) \ <nl> + F ( StringCompare , 2 , 1 ) \ <nl> + F ( StringCharCodeAtRT , 2 , 1 ) \ <nl> + F ( GetFromCache , 2 , 1 ) \ <nl> + \ <nl> + / * Compilation * / \ <nl> + F ( CompileUnoptimized , 1 , 1 ) \ <nl> + F ( CompileOptimized , 2 , 1 ) \ <nl> + F ( TryInstallOptimizedCode , 1 , 1 ) \ <nl> + F ( NotifyDeoptimized , 1 , 1 ) \ <nl> + F ( NotifyStubFailure , 0 , 1 ) \ <nl> + \ <nl> + / * Utilities * / \ <nl> + F ( AllocateInNewSpace , 1 , 1 ) \ <nl> + F ( AllocateInTargetSpace , 2 , 1 ) \ <nl> + F ( AllocateHeapNumber , 0 , 1 ) \ <nl> + F ( NumberToSmi , 1 , 1 ) \ <nl> + F ( NumberToStringSkipCache , 1 , 1 ) \ <nl> + \ <nl> + F ( NewSloppyArguments , 3 , 1 ) \ <nl> + F ( NewStrictArguments , 3 , 1 ) \ <nl> + \ <nl> + / * Harmony generators * / \ <nl> + F ( CreateJSGeneratorObject , 0 , 1 ) \ <nl> + F ( SuspendJSGeneratorObject , 1 , 1 ) \ <nl> + F ( ResumeJSGeneratorObject , 3 , 1 ) \ <nl> + F ( ThrowGeneratorStateError , 1 , 1 ) \ <nl> + \ <nl> + / * Arrays * / \ <nl> + F ( ArrayConstructor , - 1 , 1 ) \ <nl> + F ( InternalArrayConstructor , - 1 , 1 ) \ <nl> + \ <nl> + / * Literals * / \ <nl> + F ( MaterializeRegExpLiteral , 4 , 1 ) \ <nl> + F ( CreateObjectLiteral , 4 , 1 ) \ <nl> + F ( CreateArrayLiteral , 4 , 1 ) \ <nl> + F ( CreateArrayLiteralStubBailout , 3 , 1 ) \ <nl> + \ <nl> + / * Statements * / \ <nl> + F ( NewClosure , 3 , 1 ) \ <nl> + F ( NewClosureFromStubFailure , 1 , 1 ) \ <nl> + F ( NewObject , 1 , 1 ) \ <nl> + F ( NewObjectWithAllocationSite , 2 , 1 ) \ <nl> + F ( FinalizeInstanceSize , 1 , 1 ) \ <nl> + F ( Throw , 1 , 1 ) \ <nl> + F ( ReThrow , 1 , 1 ) \ <nl> + F ( ThrowReferenceError , 1 , 1 ) \ <nl> + F ( ThrowNotDateError , 0 , 1 ) \ <nl> + F ( StackGuard , 0 , 1 ) \ <nl> + F ( Interrupt , 0 , 1 ) \ <nl> + F ( PromoteScheduledException , 0 , 1 ) \ <nl> + \ <nl> + / * Contexts * / \ <nl> + F ( NewGlobalContext , 2 , 1 ) \ <nl> + F ( NewFunctionContext , 1 , 1 ) \ <nl> + F ( PushWithContext , 2 , 1 ) \ <nl> + F ( PushCatchContext , 3 , 1 ) \ <nl> + F ( PushBlockContext , 2 , 1 ) \ <nl> + F ( PushModuleContext , 2 , 1 ) \ <nl> + F ( DeleteContextSlot , 2 , 1 ) \ <nl> + F ( LoadContextSlot , 2 , 2 ) \ <nl> F ( LoadContextSlotNoReferenceError , 2 , 2 ) \ <nl> - F ( StoreContextSlot , 4 , 1 ) \ <nl> - \ <nl> - / * Declarations and initialization * / \ <nl> - F ( DeclareGlobals , 3 , 1 ) \ <nl> - F ( DeclareModules , 1 , 1 ) \ <nl> - F ( DeclareContextSlot , 4 , 1 ) \ <nl> - F ( InitializeConstGlobal , 2 , 1 ) \ <nl> - F ( InitializeConstContextSlot , 3 , 1 ) \ <nl> - \ <nl> - / * Eval * / \ <nl> - F ( ResolvePossiblyDirectEval , 5 , 2 ) \ <nl> - \ <nl> - / * Maths * / \ <nl> - F ( MathPowSlow , 2 , 1 ) \ <nl> + F ( StoreLookupSlot , 4 , 1 ) \ <nl> + \ <nl> + / * Declarations and initialization * / \ <nl> + F ( DeclareGlobals , 3 , 1 ) \ <nl> + F ( DeclareModules , 1 , 1 ) \ <nl> + F ( DeclareLookupSlot , 4 , 1 ) \ <nl> + F ( InitializeConstGlobal , 2 , 1 ) \ <nl> + F ( InitializeLegacyConstLookupSlot , 3 , 1 ) \ <nl> + \ <nl> + / * Eval * / \ <nl> + F ( ResolvePossiblyDirectEval , 5 , 2 ) \ <nl> + \ <nl> + / * Maths * / \ <nl> + F ( MathPowSlow , 2 , 1 ) \ <nl> F ( MathPowRT , 2 , 1 ) <nl> <nl> <nl> mmm a / src / x64 / full - codegen - x64 . cc <nl> ppp b / src / x64 / full - codegen - x64 . cc <nl> void FullCodeGenerator : : VisitVariableDeclaration ( <nl> } else { <nl> __ Push ( Smi : : FromInt ( 0 ) ) ; / / Indicates no initial value . <nl> } <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : VisitFunctionDeclaration ( <nl> __ Push ( variable - > name ( ) ) ; <nl> __ Push ( Smi : : FromInt ( NONE ) ) ; <nl> VisitForStackValue ( declaration - > fun ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kDeclareContextSlot , 4 ) ; <nl> + __ CallRuntime ( Runtime : : kDeclareLookupSlot , 4 ) ; <nl> break ; <nl> } <nl> } <nl> void FullCodeGenerator : : EmitStoreToStackLocalOrContextSlot ( <nl> } <nl> <nl> <nl> - void FullCodeGenerator : : EmitCallStoreContextSlot ( <nl> - Handle < String > name , StrictMode strict_mode ) { <nl> - __ Push ( rax ) ; / / Value . <nl> - __ Push ( rsi ) ; / / Context . <nl> - __ Push ( name ) ; <nl> - __ Push ( Smi : : FromInt ( strict_mode ) ) ; <nl> - __ CallRuntime ( Runtime : : kStoreContextSlot , 4 ) ; <nl> - } <nl> - <nl> - <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> Token : : Value op ) { <nl> if ( var - > IsUnallocated ( ) ) { <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> __ Push ( rax ) ; <nl> __ Push ( rsi ) ; <nl> __ Push ( var - > name ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kInitializeConstContextSlot , 3 ) ; <nl> + __ CallRuntime ( Runtime : : kInitializeLegacyConstLookupSlot , 3 ) ; <nl> } else { <nl> ASSERT ( var - > IsStackLocal ( ) | | var - > IsContextSlot ( ) ) ; <nl> Label skip ; <nl> void FullCodeGenerator : : EmitVariableAssignment ( Variable * var , <nl> <nl> } else if ( var - > mode ( ) = = LET & & op ! = Token : : INIT_LET ) { <nl> / / Non - initializing assignment to let variable needs a write barrier . <nl> - if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> - } else { <nl> - ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> - Label assign ; <nl> - MemOperand location = VarOperand ( var , rcx ) ; <nl> - __ movp ( rdx , location ) ; <nl> - __ CompareRoot ( rdx , Heap : : kTheHoleValueRootIndex ) ; <nl> - __ j ( not_equal , & assign , Label : : kNear ) ; <nl> - __ Push ( var - > name ( ) ) ; <nl> - __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> - __ bind ( & assign ) ; <nl> - EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> - } <nl> + ASSERT ( ! var - > IsLookupSlot ( ) ) ; <nl> + ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> + Label assign ; <nl> + MemOperand location = VarOperand ( var , rcx ) ; <nl> + __ movp ( rdx , location ) ; <nl> + __ CompareRoot ( rdx , Heap : : kTheHoleValueRootIndex ) ; <nl> + __ j ( not_equal , & assign , Label : : kNear ) ; <nl> + __ Push ( var - > name ( ) ) ; <nl> + __ CallRuntime ( Runtime : : kThrowReferenceError , 1 ) ; <nl> + __ bind ( & assign ) ; <nl> + EmitStoreToStackLocalOrContextSlot ( var , location ) ; <nl> <nl> } else if ( ! var - > is_const_mode ( ) | | op = = Token : : INIT_CONST ) { <nl> - / / Assignment to var or initializing assignment to let / const <nl> - / / in harmony mode . <nl> if ( var - > IsLookupSlot ( ) ) { <nl> - EmitCallStoreContextSlot ( var - > name ( ) , strict_mode ( ) ) ; <nl> + ASSERT ( op = = Token : : ASSIGN | | op = = Token : : INIT_VAR | | <nl> + op = = Token : : ASSIGN_ADD ) ; <nl> + / / Assignment to var . <nl> + __ Push ( rax ) ; / / Value . <nl> + __ Push ( rsi ) ; / / Context . <nl> + __ Push ( var - > name ( ) ) ; <nl> + __ Push ( Smi : : FromInt ( strict_mode ( ) ) ) ; <nl> + __ CallRuntime ( Runtime : : kStoreLookupSlot , 4 ) ; <nl> } else { <nl> + / / Assignment to var or initializing assignment to let / const in harmony <nl> + / / mode . <nl> ASSERT ( var - > IsStackAllocated ( ) | | var - > IsContextSlot ( ) ) ; <nl> MemOperand location = VarOperand ( var , rcx ) ; <nl> if ( generate_debug_code_ & & op = = Token : : INIT_LET ) { <nl> mmm a / test / cctest / test - decls . cc <nl> ppp b / test / cctest / test - decls . cc <nl> TEST ( Unknown ) { <nl> { DeclarationContext context ; <nl> context . Check ( " var x ; x " , <nl> 1 , / / access <nl> - 1 , / / declaration <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> { DeclarationContext context ; <nl> context . Check ( " var x = 0 ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> + 1 , / / initialization <nl> + 0 , EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> <nl> { DeclarationContext context ; <nl> TEST ( Unknown ) { <nl> { DeclarationContext context ; <nl> context . Check ( " const x ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> { DeclarationContext context ; <nl> - / / SB 0 - BUG 1213579 <nl> context . Check ( " const x = 0 ; x " , <nl> - 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - <nl> - class PresentPropertyContext : public DeclarationContext { <nl> - protected : <nl> - virtual v8 : : Handle < Integer > Query ( Local < String > key ) { <nl> - return Integer : : New ( isolate ( ) , v8 : : None ) ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - <nl> - TEST ( Present ) { <nl> - HandleScope scope ( CcTest : : isolate ( ) ) ; <nl> - <nl> - { PresentPropertyContext context ; <nl> - context . Check ( " var x ; x " , <nl> - 1 , / / access <nl> - 0 , <nl> - 2 , / / declaration + initialization <nl> - EXPECT_EXCEPTION ) ; / / x is not defined ! <nl> - } <nl> - <nl> - { PresentPropertyContext context ; <nl> - context . Check ( " var x = 0 ; x " , <nl> - 1 , / / access <nl> - 1 , / / initialization <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> - } <nl> - <nl> - { PresentPropertyContext context ; <nl> - context . Check ( " function x ( ) { } ; x " , <nl> 1 , / / access <nl> 0 , <nl> 0 , <nl> - EXPECT_RESULT ) ; <nl> - } <nl> - <nl> - { PresentPropertyContext context ; <nl> - context . Check ( " const x ; x " , <nl> - 1 , / / access <nl> - 1 , / / initialization <nl> - 1 , / / ( re - ) declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> - } <nl> - <nl> - { PresentPropertyContext context ; <nl> - context . Check ( " const x = 0 ; x " , <nl> - 1 , / / access <nl> - 1 , / / initialization <nl> - 1 , / / ( re - ) declaration <nl> EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> } <nl> <nl> <nl> - <nl> class AbsentPropertyContext : public DeclarationContext { <nl> protected : <nl> virtual v8 : : Handle < Integer > Query ( Local < String > key ) { <nl> TEST ( Absent ) { <nl> { AbsentPropertyContext context ; <nl> context . Check ( " var x ; x " , <nl> 1 , / / access <nl> - 1 , / / declaration <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> } <nl> <nl> { AbsentPropertyContext context ; <nl> context . Check ( " var x = 0 ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Number : : New ( isolate , 0 ) ) ; <nl> + 1 , / / initialization <nl> + 0 , EXPECT_RESULT , Number : : New ( isolate , 0 ) ) ; <nl> } <nl> <nl> { AbsentPropertyContext context ; <nl> TEST ( Absent ) { <nl> { AbsentPropertyContext context ; <nl> context . Check ( " const x ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> } <nl> <nl> { AbsentPropertyContext context ; <nl> context . Check ( " const x = 0 ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( isolate ) ) ; / / SB 0 - BUG 1213579 <nl> + 0 , 0 , EXPECT_RESULT , Number : : New ( isolate , 0 ) ) ; <nl> } <nl> <nl> { AbsentPropertyContext context ; <nl> context . Check ( " if ( false ) { var x = 0 } ; x " , <nl> 1 , / / access <nl> - 1 , / / declaration <nl> - 1 , / / declaration + initialization <nl> - EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( isolate ) ) ; <nl> } <nl> } <nl> <nl> TEST ( Appearing ) { <nl> { AppearingPropertyContext context ; <nl> context . Check ( " var x ; x " , <nl> 1 , / / access <nl> - 1 , / / declaration <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> { AppearingPropertyContext context ; <nl> context . Check ( " var x = 0 ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> + 1 , / / initialization <nl> + 0 , EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> <nl> { AppearingPropertyContext context ; <nl> TEST ( Appearing ) { <nl> { AppearingPropertyContext context ; <nl> context . Check ( " const x ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> { AppearingPropertyContext context ; <nl> context . Check ( " const x = 0 ; x " , <nl> 1 , / / access <nl> - 2 , / / declaration + initialization <nl> - 1 , / / declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> - / / Result is undefined because declaration succeeded but <nl> - / / initialization to 0 failed ( due to context behavior ) . <nl> - } <nl> - } <nl> - <nl> - <nl> - <nl> - class ReappearingPropertyContext : public DeclarationContext { <nl> - public : <nl> - enum State { <nl> - DECLARE , <nl> - DONT_DECLARE , <nl> - INITIALIZE , <nl> - UNKNOWN <nl> - } ; <nl> - <nl> - ReappearingPropertyContext ( ) : state_ ( DECLARE ) { } <nl> - <nl> - protected : <nl> - virtual v8 : : Handle < Integer > Query ( Local < String > key ) { <nl> - switch ( state_ ) { <nl> - case DECLARE : <nl> - / / Force the first declaration by returning that <nl> - / / the property is absent . <nl> - state_ = DONT_DECLARE ; <nl> - return Handle < Integer > ( ) ; <nl> - case DONT_DECLARE : <nl> - / / Ignore the second declaration by returning <nl> - / / that the property is already there . <nl> - state_ = INITIALIZE ; <nl> - return Integer : : New ( isolate ( ) , v8 : : None ) ; <nl> - case INITIALIZE : <nl> - / / Force an initialization by returning that <nl> - / / the property is absent . This will make sure <nl> - / / that the setter is called and it will not <nl> - / / lead to redeclaration conflicts ( yet ) . <nl> - state_ = UNKNOWN ; <nl> - return Handle < Integer > ( ) ; <nl> - default : <nl> - CHECK ( state_ = = UNKNOWN ) ; <nl> - break ; <nl> - } <nl> - / / Do the lookup in the object . <nl> - return Handle < Integer > ( ) ; <nl> - } <nl> - <nl> - private : <nl> - State state_ ; <nl> - } ; <nl> - <nl> - <nl> - TEST ( Reappearing ) { <nl> - v8 : : V8 : : Initialize ( ) ; <nl> - HandleScope scope ( CcTest : : isolate ( ) ) ; <nl> - <nl> - { ReappearingPropertyContext context ; <nl> - context . Check ( " const x ; var x = 0 " , <nl> - 0 , <nl> - 3 , / / const declaration + initialization , var initialization <nl> - 3 , / / 2 x declaration + var initialization <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + 0 , 0 , EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> } <nl> <nl> TEST ( ExistsInHiddenPrototype ) { <nl> HandleScope scope ( CcTest : : isolate ( ) ) ; <nl> <nl> { ExistsInHiddenPrototypeContext context ; <nl> - context . Check ( " var x ; x " , <nl> - 1 , / / access <nl> - 0 , <nl> - 2 , / / declaration + initialization <nl> - EXPECT_EXCEPTION ) ; / / x is not defined ! <nl> + context . Check ( " var x ; x " , 0 , 0 , 0 , EXPECT_RESULT , <nl> + Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> { ExistsInHiddenPrototypeContext context ; <nl> - context . Check ( " var x = 0 ; x " , <nl> - 1 , / / access <nl> - 1 , / / initialization <nl> - 2 , / / declaration + initialization <nl> - EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> + context . Check ( " var x = 0 ; x " , 0 , 0 , 0 , EXPECT_RESULT , <nl> + Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> <nl> { ExistsInHiddenPrototypeContext context ; <nl> TEST ( ExistsInHiddenPrototype ) { <nl> <nl> / / TODO ( mstarzinger ) : The semantics of global const is vague . <nl> { ExistsInHiddenPrototypeContext context ; <nl> - context . Check ( " const x ; x " , <nl> - 0 , <nl> - 0 , <nl> - 1 , / / ( re - ) declaration <nl> - EXPECT_RESULT , Undefined ( CcTest : : isolate ( ) ) ) ; <nl> + context . Check ( " const x ; x " , 0 , 0 , 0 , EXPECT_RESULT , <nl> + Undefined ( CcTest : : isolate ( ) ) ) ; <nl> } <nl> <nl> / / TODO ( mstarzinger ) : The semantics of global const is vague . <nl> { ExistsInHiddenPrototypeContext context ; <nl> - context . Check ( " const x = 0 ; x " , <nl> - 0 , <nl> - 0 , <nl> - 1 , / / ( re - ) declaration <nl> - EXPECT_RESULT , Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> + context . Check ( " const x = 0 ; x " , 0 , 0 , 0 , EXPECT_RESULT , <nl> + Number : : New ( CcTest : : isolate ( ) , 0 ) ) ; <nl> } <nl> } <nl> <nl> TEST ( CrossScriptReferences ) { <nl> EXPECT_RESULT , Number : : New ( isolate , 1 ) ) ; <nl> context . Check ( " var x = 2 ; x " , <nl> EXPECT_RESULT , Number : : New ( isolate , 2 ) ) ; <nl> - context . Check ( " const x = 3 ; x " , <nl> - EXPECT_RESULT , Number : : New ( isolate , 3 ) ) ; <nl> - context . Check ( " const x = 4 ; x " , <nl> - EXPECT_RESULT , Number : : New ( isolate , 4 ) ) ; <nl> + context . Check ( " const x = 3 ; x " , EXPECT_EXCEPTION ) ; <nl> + context . Check ( " const x = 4 ; x " , EXPECT_EXCEPTION ) ; <nl> context . Check ( " x = 5 ; x " , <nl> EXPECT_RESULT , Number : : New ( isolate , 5 ) ) ; <nl> context . Check ( " var x = 6 ; x " , <nl> TEST ( CrossScriptReferences ) { <nl> EXPECT_RESULT , Number : : New ( isolate , 1 ) ) ; <nl> context . Check ( " var x = 2 ; x " , / / assignment ignored <nl> EXPECT_RESULT , Number : : New ( isolate , 1 ) ) ; <nl> - context . Check ( " const x = 3 ; x " , <nl> - EXPECT_RESULT , Number : : New ( isolate , 1 ) ) ; <nl> + context . Check ( " const x = 3 ; x " , EXPECT_EXCEPTION ) ; <nl> context . Check ( " x = 4 ; x " , / / assignment ignored <nl> EXPECT_RESULT , Number : : New ( isolate , 1 ) ) ; <nl> context . Check ( " var x = 5 ; x " , / / assignment ignored <nl> mmm a / test / mjsunit / const - eval - init . js <nl> ppp b / test / mjsunit / const - eval - init . js <nl> function testIntroduceGlobal ( ) { <nl> var source = <nl> / / Deleting ' x ' removes the local const property . <nl> " delete x ; " + <nl> - / / Initialization turns into assignment to global ' x ' . <nl> + / / Initialization redefines global ' x ' . <nl> " const x = 3 ; assertEquals ( 3 , x ) ; " + <nl> - / / No constness of the global ' x ' . <nl> - " x = 4 ; assertEquals ( 4 , x ) ; " ; <nl> + / / Test constness of the global ' x ' . <nl> + " x = 4 ; assertEquals ( 3 , x ) ; " ; <nl> eval ( source ) ; <nl> } <nl> <nl> testIntroduceGlobal ( ) ; <nl> - assertEquals ( 4 , x ) ; <nl> + assertEquals ( " undefined " , typeof x ) ; <nl> <nl> function testAssignExistingGlobal ( ) { <nl> var source = <nl> / / Delete ' x ' to remove the local const property . <nl> " delete x ; " + <nl> - / / Initialization turns into assignment to global ' x ' . <nl> + / / Initialization redefines global ' x ' . <nl> " const x = 5 ; assertEquals ( 5 , x ) ; " + <nl> - / / No constness of the global ' x ' . <nl> - " x = 6 ; assertEquals ( 6 , x ) ; " ; <nl> + / / Test constness of the global ' x ' . <nl> + " x = 6 ; assertEquals ( 5 , x ) ; " ; <nl> eval ( source ) ; <nl> } <nl> <nl> testAssignExistingGlobal ( ) ; <nl> - assertEquals ( 6 , x ) ; <nl> + assertEquals ( " undefined " , typeof x ) ; <nl> <nl> function testAssignmentArgument ( x ) { <nl> function local ( ) { <nl> function testAssignmentArgument ( x ) { <nl> eval ( source ) ; <nl> } <nl> local ( ) ; <nl> - assertEquals ( 7 , x ) ; <nl> + assertEquals ( " undefined " , typeof x ) ; <nl> } <nl> <nl> for ( var i = 0 ; i < 5 ; i + + ) { <nl> for ( var i = 0 ; i < 5 ; i + + ) { <nl> } <nl> % OptimizeFunctionOnNextCall ( testAssignmentArgument ) ; <nl> testAssignmentArgument ( ) ; <nl> - assertEquals ( 6 , x ) ; <nl> + assertEquals ( " undefined " , typeof x ) ; <nl> <nl> __defineSetter__ ( ' x ' , function ( ) { throw 42 ; } ) ; <nl> - function testAssignGlobalThrows ( ) { <nl> - / / Initialization turns into assignment to global ' x ' which <nl> - / / throws an exception . <nl> - var source = " delete x ; const x = 8 " ; <nl> + var finished = false ; <nl> + function testRedefineGlobal ( ) { <nl> + / / Initialization redefines global ' x ' . <nl> + var source = " delete x ; const x = 8 ; finished = true ; " ; <nl> eval ( source ) ; <nl> } <nl> <nl> - assertThrows ( " testAssignGlobalThrows ( ) " ) ; <nl> + testRedefineGlobal ( ) ; <nl> + assertTrue ( finished ) ; <nl> <nl> function testInitFastCaseExtension ( ) { <nl> var source = " const x = 9 ; assertEquals ( 9 , x ) ; x = 10 ; assertEquals ( 9 , x ) " ; <nl> function testAssignSurroundingContextSlot ( ) { <nl> eval ( source ) ; <nl> } <nl> local ( ) ; <nl> - assertEquals ( 13 , x ) ; <nl> + assertEquals ( 12 , x ) ; <nl> } <nl> <nl> testAssignSurroundingContextSlot ( ) ; <nl> mmm a / test / mjsunit / const - redecl . js <nl> ppp b / test / mjsunit / const - redecl . js <nl> function TestLocal ( s , e ) { <nl> } <nl> <nl> <nl> - / / NOTE : TestGlobal usually only tests the given string in the context <nl> - / / of a global object in dictionary mode . This is because we use <nl> - / / delete to get rid of any added properties . <nl> - function TestGlobal ( s , e ) { <nl> - / / Collect the global properties before the call . <nl> - var properties = [ ] ; <nl> - for ( var key in this ) properties . push ( key ) ; <nl> - / / Compute the result . <nl> - var result ; <nl> - try { <nl> - var code = s + ( e ? " ; $ $ $ result = " + e : " " ) ; <nl> - if ( this . execScript ) { <nl> - execScript ( code ) ; <nl> - } else { <nl> - this . eval ( code ) ; <nl> - } <nl> - / / Avoid issues if $ $ $ result is not defined by <nl> - / / reading it through this . <nl> - result = this . $ $ $ result ; <nl> - } catch ( x ) { <nl> - result = CheckException ( x ) ; <nl> - } <nl> - / / Get rid of any introduced global properties before <nl> - / / returning the result . <nl> - for ( var key in this ) { <nl> - if ( properties . indexOf ( key ) = = - 1 ) delete this [ key ] ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - <nl> function TestContext ( s , e ) { <nl> try { <nl> / / Use a with - statement to force the system to do dynamic <nl> function TestAll ( expected , s , opt_e ) { <nl> var msg = s ; <nl> if ( opt_e ) { e = opt_e ; msg + = " ; " + opt_e ; } <nl> assertEquals ( expected , TestLocal ( s , e ) , " local : ' " + msg + " ' " ) ; <nl> - / / Redeclarations of global consts do not throw , they are silently ignored . <nl> - assertEquals ( 42 , TestGlobal ( s , 42 ) , " global : ' " + msg + " ' " ) ; <nl> assertEquals ( expected , TestContext ( s , e ) , " context : ' " + msg + " ' " ) ; <nl> } <nl> <nl> function TestConflict ( def0 , def1 ) { <nl> / / Eval first definition . <nl> TestAll ( " TypeError " , ' eval ( " ' + def0 + ' " ) ; ' + def1 ) ; <nl> / / Eval second definition . <nl> - TestAll ( " TypeError " , def0 + ' ; eval ( " ' + def1 + ' " ) ' ) ; <nl> + TestAll ( " TypeError " , def0 + ' ; eval ( " ' + def1 + ' " ) ' ) ; <nl> / / Eval both definitions separately . <nl> TestAll ( " TypeError " , ' eval ( " ' + def0 + ' " ) ; eval ( " ' + def1 + ' " ) ' ) ; <nl> } <nl> var undefined = 1 ; / / Should be silently ignored . <nl> assertEquals ( original_undef , undefined , " undefined got overwritten " ) ; <nl> undefined = original_undef ; <nl> <nl> - var a ; const a ; const a = 1 ; <nl> - assertEquals ( 1 , a , " a has wrong value " ) ; <nl> - a = 2 ; <nl> - assertEquals ( 2 , a , " a should be writable " ) ; <nl> - <nl> - var b = 1 ; const b = 2 ; <nl> - assertEquals ( 2 , b , " b has wrong value " ) ; <nl> - <nl> - var c = 1 ; const c = 2 ; const c = 3 ; <nl> - assertEquals ( 3 , c , " c has wrong value " ) ; <nl> - <nl> - const d = 1 ; const d = 2 ; <nl> - assertEquals ( 1 , d , " d has wrong value " ) ; <nl> - <nl> - const e = 1 ; var e = 2 ; <nl> + const e = 1 ; eval ( ' var e = 2 ' ) ; <nl> assertEquals ( 1 , e , " e has wrong value " ) ; <nl> <nl> - const f = 1 ; const f ; <nl> - assertEquals ( 1 , f , " f has wrong value " ) ; <nl> - <nl> - var g ; const g = 1 ; <nl> - assertEquals ( 1 , g , " g has wrong value " ) ; <nl> - g = 2 ; <nl> - assertEquals ( 2 , g , " g should be writable " ) ; <nl> - <nl> - const h ; var h = 1 ; <nl> - assertEquals ( undefined , h , " h has wrong value " ) ; <nl> + const h ; eval ( ' var h = 1 ' ) ; <nl> + assertEquals ( undefined , h , " h has wrong value " ) ; <nl> <nl> eval ( " Object . defineProperty ( this , ' i ' , { writable : true } ) ; " <nl> + " const i = 7 ; " <nl> + " assertEquals ( 7 , i , \ " i has wrong value \ " ) ; " ) ; <nl> <nl> var global = this ; <nl> - assertThrows ( function ( ) { <nl> - Object . defineProperty ( global , ' j ' , { writable : true } ) <nl> - } , TypeError ) ; <nl> - const j = 2 ; / / This is what makes the function above throw , because the <nl> - / / const declaration gets hoisted and makes the property non - configurable . <nl> + Object . defineProperty ( global , ' j ' , { value : 100 , writable : true } ) ; <nl> + assertEquals ( 100 , j ) ; <nl> + / / The const declaration stays configurable , so the declaration above goes <nl> + / / through even though the const declaration is hoisted above . <nl> + const j = 2 ; <nl> assertEquals ( 2 , j , " j has wrong value " ) ; <nl> <nl> - var k = 1 ; const k ; <nl> - / / You could argue about the expected result here . For now , the winning <nl> - / / argument is that " const k ; " is equivalent to " const k = undefined ; " . <nl> - assertEquals ( undefined , k , " k has wrong value " ) ; <nl> + var k = 1 ; <nl> + try { eval ( ' const k ' ) ; } catch ( e ) { } <nl> + assertEquals ( 1 , k , " k has wrong value " ) ; <nl> + try { eval ( ' const k = 10 ' ) ; } catch ( e ) { } <nl> + assertEquals ( 1 , k , " k has wrong value " ) ; <nl> mmm a / test / mjsunit / global - const - var - conflicts . js <nl> ppp b / test / mjsunit / global - const - var - conflicts . js <nl> try { eval ( " var b " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; <nl> assertEquals ( 0 , b ) ; <nl> try { eval ( " var b = 1 " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; } <nl> assertEquals ( 0 , b ) ; <nl> + assertEquals ( 0 , caught ) ; <nl> <nl> eval ( " var c " ) ; <nl> try { eval ( " const c " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; } <nl> assertTrue ( typeof c = = ' undefined ' ) ; <nl> + assertEquals ( 1 , caught ) ; <nl> try { eval ( " const c = 1 " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; } <nl> - assertEquals ( 1 , c ) ; <nl> + assertEquals ( undefined , c ) ; <nl> + assertEquals ( 2 , caught ) ; <nl> <nl> eval ( " var d = 0 " ) ; <nl> try { eval ( " const d " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; } <nl> - assertEquals ( undefined , d ) ; <nl> + assertEquals ( 0 , d ) ; <nl> + assertEquals ( 3 , caught ) ; <nl> try { eval ( " const d = 1 " ) ; } catch ( e ) { caught + + ; assertTrue ( e instanceof TypeError ) ; } <nl> - assertEquals ( 1 , d ) ; <nl> - <nl> - assertEquals ( 0 , caught ) ; <nl> + assertEquals ( 0 , d ) ; <nl> + assertEquals ( 4 , caught ) ; <nl> mmm a / test / mjsunit / regress / regress - 1170 . js <nl> ppp b / test / mjsunit / regress / regress - 1170 . js <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> - / / Flags : - - es52_globals <nl> - <nl> var setter_value = 0 ; <nl> <nl> this . __defineSetter__ ( " a " , function ( v ) { setter_value = v ; } ) ; <nl> assertEquals ( 1 , setter_value ) ; <nl> assertFalse ( " value " in Object . getOwnPropertyDescriptor ( this , " a " ) ) ; <nl> <nl> eval ( " with ( { } ) { eval ( ' var a = 2 ' ) } " ) ; <nl> - assertEquals ( 2 , setter_value ) ; <nl> + assertTrue ( " get " in Object . getOwnPropertyDescriptor ( this , " a " ) ) ; <nl> assertFalse ( " value " in Object . getOwnPropertyDescriptor ( this , " a " ) ) ; <nl> + assertEquals ( 2 , setter_value ) ; <nl> <nl> / / Function declarations are treated specially to match Safari . We do <nl> / / not call setters for them . <nl> assertTrue ( " value " in Object . getOwnPropertyDescriptor ( this , " a " ) ) ; <nl> this . __defineSetter__ ( " b " , function ( v ) { setter_value = v ; } ) ; <nl> try { <nl> eval ( " const b = 3 " ) ; <nl> - } catch ( e ) { <nl> - assertUnreachable ( ) ; <nl> - } <nl> - assertEquals ( 3 , setter_value ) ; <nl> + } catch ( e ) { } <nl> + assertEquals ( 2 , setter_value ) ; <nl> <nl> try { <nl> eval ( " with ( { } ) { eval ( ' const b = 23 ' ) } " ) ; <nl> mmm a / test / mjsunit / regress / regress - 1213575 . js <nl> ppp b / test / mjsunit / regress / regress - 1213575 . js <nl> try { <nl> assertTrue ( e instanceof TypeError ) ; <nl> caught = true ; <nl> } <nl> - assertFalse ( caught ) ; <nl> + assertTrue ( caught ) ; <nl> similarity index 68 % <nl> rename from test / mjsunit / regress / regress - global - freeze - const . js <nl> rename to test / mjsunit / regress / regress - freeze - setter . js <nl> mmm a / test / mjsunit / regress / regress - global - freeze - const . js <nl> ppp b / test / mjsunit / regress / regress - freeze - setter . js <nl> <nl> / / Use of this source code is governed by a BSD - style license that can be <nl> / / found in the LICENSE file . <nl> <nl> - __defineSetter__ ( ' x ' , function ( ) { } ) ; <nl> + Object . defineProperty ( this , ' x ' , { set : function ( ) { } } ) ; <nl> Object . freeze ( this ) ; <nl> - eval ( ' const x = 1 ' ) ; <nl> + eval ( ' " use strict " ; x = 20 ; ' ) ; <nl> mmm a / test / mozilla / mozilla . status <nl> ppp b / test / mozilla / mozilla . status <nl> <nl> # We do not correctly handle assignments within " with " <nl> ' ecma_3 / Statements / 12 . 10 - 01 ' : [ FAIL ] , <nl> <nl> - # We do not throw an exception when a const is redeclared . <nl> - # ( We only fail section 1 of the test . ) <nl> - ' js1_5 / Regress / regress - 103602 ' : [ FAIL ] , <nl> - <nl> # # # # # # # # # # # # # # # # # # # # # MOZILLA EXTENSION TESTS # # # # # # # # # # # # # # # # # # # # # <nl> <nl> ' ecma / extensions / 15 . 1 . 2 . 1 - 1 ' : [ FAIL_OK ] , <nl> mmm a / tools / generate - runtime - tests . py <nl> ppp b / tools / generate - runtime - tests . py <nl> <nl> # to parse them ! <nl> EXPECTED_FUNCTION_COUNT = 417 <nl> EXPECTED_FUZZABLE_COUNT = 332 <nl> - EXPECTED_CCTEST_COUNT = 6 <nl> + EXPECTED_CCTEST_COUNT = 9 <nl> EXPECTED_UNKNOWN_COUNT = 4 <nl> EXPECTED_BUILTINS_COUNT = 810 <nl> <nl>
|
This CL simplifies var / const by ensuring the behavior is consistent in itself , and with regular JS semantics ; between regular var / const and eval - ed var / const .
|
v8/v8
|
aa7198dfdda4faf69d3e7b87dc8f25e376100fca
|
2014-07-14T14:01:04Z
|
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class AbstractStorageDecl : public ValueDecl { <nl> / / / property from the given module ? <nl> bool isResilient ( ModuleDecl * M , ResilienceExpansion expansion ) const ; <nl> <nl> - / / / Returns the interface type of elements of storage represented by this <nl> - / / / declaration . <nl> - / / / <nl> - / / / For variables , this is the type of the variable itself . <nl> - / / / For subscripts , this is the type of the subscript element . <nl> - Type getStorageInterfaceType ( ) const ; <nl> - <nl> / / / Does the storage use a behavior ? <nl> bool hasBehavior ( ) const { <nl> return BehaviorInfo . getPointer ( ) ! = nullptr ; <nl> mmm a / lib / AST / ASTContext . cpp <nl> ppp b / lib / AST / ASTContext . cpp <nl> getGenericFunctionRecursiveProperties ( Type Input , Type Result ) { <nl> static_assert ( RecursiveTypeProperties : : BitWidth = = 10 , <nl> " revisit this if you add new recursive type properties " ) ; <nl> RecursiveTypeProperties properties ; <nl> + if ( Input - > getRecursiveProperties ( ) . hasError ( ) ) <nl> + properties | = RecursiveTypeProperties : : HasError ; <nl> if ( Result - > getRecursiveProperties ( ) . hasDynamicSelf ( ) ) <nl> properties | = RecursiveTypeProperties : : HasDynamicSelf ; <nl> if ( Result - > getRecursiveProperties ( ) . hasError ( ) ) <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> SourceLoc AbstractStorageDecl : : getOverrideLoc ( ) const { <nl> <nl> Type AbstractStorageDecl : : getValueInterfaceType ( ) const { <nl> if ( auto var = dyn_cast < VarDecl > ( this ) ) <nl> - return var - > getInterfaceType ( ) ; <nl> + return var - > getInterfaceType ( ) - > getReferenceStorageReferent ( ) ; <nl> return cast < SubscriptDecl > ( this ) - > getElementInterfaceType ( ) ; <nl> } <nl> <nl> void AbstractFunctionDecl : : computeType ( AnyFunctionType : : ExtInfo info ) { <nl> } else if ( auto ctor = dyn_cast < ConstructorDecl > ( this ) ) { <nl> auto * dc = ctor - > getDeclContext ( ) ; <nl> <nl> - if ( hasSelf ) <nl> - resultTy = dc - > getSelfInterfaceType ( ) ; <nl> - <nl> - if ( ! resultTy ) <nl> - resultTy = ErrorType : : get ( ctx ) ; <nl> + if ( hasSelf ) { <nl> + if ( ! dc - > isTypeContext ( ) ) <nl> + resultTy = ErrorType : : get ( ctx ) ; <nl> + else <nl> + resultTy = dc - > getSelfInterfaceType ( ) ; <nl> + } <nl> <nl> / / Adjust result type for failability . <nl> if ( ctor - > getFailability ( ) ! = OTK_None ) <nl> Type FuncDecl : : getResultInterfaceType ( ) const { <nl> return nullptr ; <nl> <nl> Type resultTy = getInterfaceType ( ) ; <nl> - if ( resultTy - > hasError ( ) ) <nl> + if ( resultTy - > is < ErrorType > ( ) ) <nl> return resultTy ; <nl> <nl> if ( hasImplicitSelfDecl ( ) ) <nl> mmm a / lib / AST / NameLookup . cpp <nl> ppp b / lib / AST / NameLookup . cpp <nl> void ClassDecl : : recordObjCMethod ( AbstractFunctionDecl * method ) { <nl> vec . push_back ( method ) ; <nl> } <nl> <nl> - Type AbstractStorageDecl : : getStorageInterfaceType ( ) const { <nl> - if ( auto var = dyn_cast < VarDecl > ( this ) ) { <nl> - return var - > getInterfaceType ( ) ; <nl> - } <nl> - <nl> - if ( auto sub = dyn_cast < SubscriptDecl > ( this ) ) { <nl> - return sub - > getElementInterfaceType ( ) ; <nl> - } <nl> - <nl> - llvm_unreachable ( " unhandled storage decl kind " ) ; <nl> - } <nl> - <nl> / / / Configure name lookup for the given declaration context and options . <nl> / / / <nl> / / / This utility is used by qualified name lookup . <nl> mmm a / lib / ClangImporter / ImporterImpl . h <nl> ppp b / lib / ClangImporter / ImporterImpl . h <nl> class LLVM_LIBRARY_VISIBILITY ClangImporter : : Implementation <nl> assert ( CD - > getInterfaceType ( ) ) ; <nl> ty = CD - > getResultInterfaceType ( ) ; <nl> } else { <nl> - ty = cast < AbstractStorageDecl > ( decl ) - > getValueInterfaceType ( ) <nl> - - > getReferenceStorageReferent ( ) ; <nl> + ty = cast < AbstractStorageDecl > ( decl ) - > getValueInterfaceType ( ) ; <nl> } <nl> # endif <nl> <nl> mmm a / lib / SIL / SILVerifier . cpp <nl> ppp b / lib / SIL / SILVerifier . cpp <nl> void SILProperty : : verify ( const SILModule & M ) const { <nl> auto sig = dc - > getGenericSignatureOfContext ( ) ; <nl> auto baseTy = dc - > getInnermostTypeContext ( ) - > getSelfInterfaceType ( ) <nl> - > getCanonicalType ( sig ) ; <nl> - auto leafTy = decl - > getStorageInterfaceType ( ) - > getReferenceStorageReferent ( ) <nl> - - > getCanonicalType ( sig ) ; <nl> + auto leafTy = decl - > getValueInterfaceType ( ) - > getCanonicalType ( sig ) ; <nl> SubstitutionMap subs ; <nl> if ( sig ) { <nl> auto env = dc - > getGenericEnvironmentOfContext ( ) ; <nl> mmm a / lib / SILGen / SILGen . cpp <nl> ppp b / lib / SILGen / SILGen . cpp <nl> TypeConverter : : canStorageUseStoredKeyPathComponent ( AbstractStorageDecl * decl ) { <nl> M . getSwiftModule ( ) ) ; <nl> switch ( strategy . getKind ( ) ) { <nl> case AccessStrategy : : Storage : { <nl> - / / If the stored value would need to be reabstracted in fully opaque <nl> - / / context , then we have to treat the component as computed . <nl> - auto componentObjTy = decl - > getStorageInterfaceType ( ) <nl> - - > getWithoutSpecifierType ( ) ; <nl> / / Keypaths rely on accessors to handle the special behavior of weak or <nl> / / unowned properties . <nl> - if ( componentObjTy - > is < ReferenceStorageType > ( ) ) <nl> + if ( decl - > getInterfaceType ( ) - > is < ReferenceStorageType > ( ) ) <nl> return false ; <nl> + / / If the stored value would need to be reabstracted in fully opaque <nl> + / / context , then we have to treat the component as computed . <nl> + auto componentObjTy = decl - > getValueInterfaceType ( ) ; <nl> if ( auto genericEnv = <nl> decl - > getInnermostDeclContext ( ) - > getGenericEnvironmentOfContext ( ) ) <nl> componentObjTy = genericEnv - > mapTypeIntoContext ( componentObjTy ) ; <nl> mmm a / lib / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SILGen / SILGenExpr . cpp <nl> SILGenModule : : emitKeyPathComponentForDecl ( SILLocation loc , <nl> if ( auto var = dyn_cast < VarDecl > ( storage ) ) { <nl> CanType componentTy ; <nl> if ( ! var - > getDeclContext ( ) - > isTypeContext ( ) ) { <nl> - componentTy = storage - > getStorageInterfaceType ( ) - > getCanonicalType ( ) ; <nl> + componentTy = var - > getInterfaceType ( ) - > getCanonicalType ( ) ; <nl> } else { <nl> componentTy = <nl> GenericEnvironment : : mapTypeIntoContext ( genericEnv , baseTy ) <nl> mmm a / lib / Sema / CodeSynthesis . cpp <nl> ppp b / lib / Sema / CodeSynthesis . cpp <nl> ConstructorDecl * swift : : createImplicitConstructor ( TypeChecker & tc , <nl> <nl> auto varType = var - > getType ( ) <nl> - > getReferenceStorageReferent ( ) ; <nl> - auto varInterfaceType = var - > getInterfaceType ( ) <nl> - - > getReferenceStorageReferent ( ) ; <nl> + auto varInterfaceType = var - > getValueInterfaceType ( ) ; <nl> <nl> / / If var is a lazy property , its value is provided for the underlying <nl> / / storage . We thus take an optional of the properties type . We only <nl> mmm a / lib / Sema / TypeCheckDecl . cpp <nl> ppp b / lib / Sema / TypeCheckDecl . cpp <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> <nl> void visitSubscriptDecl ( SubscriptDecl * SD ) { <nl> TC . validateDecl ( SD ) ; <nl> + <nl> + if ( ! SD - > isInvalid ( ) ) { <nl> + TC . checkReferencedGenericParams ( SD ) ; <nl> + TC . checkProtocolSelfRequirements ( SD ) ; <nl> + } <nl> + <nl> TC . checkDeclAttributes ( SD ) ; <nl> <nl> AccessControlChecker : : checkAccessControl ( TC , SD ) ; <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> void visitFuncDecl ( FuncDecl * FD ) { <nl> TC . validateDecl ( FD ) ; <nl> <nl> + / / We get bogus errors here with generic subscript materializeForSet . <nl> + if ( ! FD - > isInvalid ( ) ) { <nl> + if ( ! isa < AccessorDecl > ( FD ) | | <nl> + ! cast < AccessorDecl > ( FD ) - > isMaterializeForSet ( ) ) { <nl> + TC . checkReferencedGenericParams ( FD ) ; <nl> + TC . checkProtocolSelfRequirements ( FD ) ; <nl> + } <nl> + } <nl> + <nl> AccessControlChecker : : checkAccessControl ( TC , FD ) ; <nl> UsableFromInlineChecker : : checkUsableFromInline ( TC , FD ) ; <nl> <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> void visitConstructorDecl ( ConstructorDecl * CD ) { <nl> TC . validateDecl ( CD ) ; <nl> <nl> + if ( ! CD - > isInvalid ( ) ) { <nl> + TC . checkReferencedGenericParams ( CD ) ; <nl> + TC . checkProtocolSelfRequirements ( CD ) ; <nl> + } <nl> + <nl> / / Check whether this initializer overrides an initializer in its <nl> / / superclass . <nl> if ( ! checkOverrides ( CD ) ) { <nl> void checkMemberOperator ( TypeChecker & TC , FuncDecl * FD ) { <nl> isProtocol , FD - > getFullName ( ) ) ; <nl> } <nl> <nl> - bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func , <nl> + bool checkDynamicSelfReturn ( FuncDecl * func , <nl> TypeRepr * typeRepr , <nl> unsigned optionalDepth ) { <nl> / / Look through parentheses . <nl> if ( auto parenRepr = dyn_cast < TupleTypeRepr > ( typeRepr ) ) { <nl> if ( ! parenRepr - > isParenType ( ) ) return false ; <nl> - return checkDynamicSelfReturn ( TC , func , parenRepr - > getElementType ( 0 ) , <nl> + return checkDynamicSelfReturn ( func , parenRepr - > getElementType ( 0 ) , <nl> optionalDepth ) ; <nl> } <nl> <nl> bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func , <nl> TypeAttributes attrs = attrRepr - > getAttrs ( ) ; <nl> if ( ! attrs . empty ( ) ) <nl> return false ; <nl> - return checkDynamicSelfReturn ( TC , func , attrRepr - > getTypeRepr ( ) , <nl> + return checkDynamicSelfReturn ( func , attrRepr - > getTypeRepr ( ) , <nl> optionalDepth ) ; <nl> + <nl> } <nl> <nl> / / Look through optional types . <nl> bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func , <nl> if ( base ) { <nl> / / But only one level . <nl> if ( optionalDepth ! = 0 ) return false ; <nl> - return checkDynamicSelfReturn ( TC , func , base , optionalDepth + 1 ) ; <nl> + return checkDynamicSelfReturn ( func , base , optionalDepth + 1 ) ; <nl> } <nl> <nl> / / Check whether we have a simple identifier type . <nl> bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func , <nl> return false ; <nl> <nl> / / Check whether it is ' Self ' . <nl> - if ( simpleRepr - > getIdentifier ( ) ! = TC . Context . Id_Self ) <nl> + if ( simpleRepr - > getIdentifier ( ) ! = func - > getASTContext ( ) . Id_Self ) <nl> return false ; <nl> <nl> / / Note that the function has a dynamic Self return type and set <nl> / / the return type component to the dynamic self type . <nl> - func - > setDynamicSelf ( true ) ; <nl> - return false ; <nl> + return true ; <nl> } <nl> <nl> / / / Check for methods that return ' DynamicResult ' . <nl> - bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func ) { <nl> + bool checkDynamicSelfReturn ( FuncDecl * func ) { <nl> / / Check whether we have a specified result type . <nl> auto typeRepr = func - > getBodyResultTypeLoc ( ) . getTypeRepr ( ) ; <nl> if ( ! typeRepr ) <nl> bool checkDynamicSelfReturn ( TypeChecker & TC , FuncDecl * func ) { <nl> if ( isa < AccessorDecl > ( func ) ) <nl> return false ; <nl> <nl> - return checkDynamicSelfReturn ( TC , func , typeRepr , 0 ) ; <nl> + return checkDynamicSelfReturn ( func , typeRepr , 0 ) ; <nl> } <nl> <nl> Type buildAddressorResultType ( TypeChecker & TC , <nl> void TypeChecker : : validateDecl ( ValueDecl * D ) { <nl> validateSelfAccessKind ( * this , FD ) ; <nl> <nl> / / Check whether the return type is dynamic ' Self ' . <nl> - if ( checkDynamicSelfReturn ( * this , FD ) ) <nl> - FD - > setInvalid ( ) ; <nl> + FD - > setDynamicSelf ( checkDynamicSelfReturn ( FD ) ) ; <nl> <nl> / / Accessors should pick up various parts of their type signatures <nl> / / directly from the storage declaration instead of re - deriving them . <nl> mmm a / lib / Sema / TypeCheckGeneric . cpp <nl> ppp b / lib / Sema / TypeCheckGeneric . cpp <nl> static bool isSelfDerivedOrConcrete ( Type protoSelf , Type type ) { <nl> <nl> / / For a generic requirement in a protocol , make sure that the requirement <nl> / / set didn ' t add any requirements to Self or its associated types . <nl> - static bool checkProtocolSelfRequirements ( GenericSignature * sig , <nl> - ValueDecl * decl , <nl> - TypeChecker & TC ) { <nl> + void TypeChecker : : checkProtocolSelfRequirements ( ValueDecl * decl ) { <nl> / / For a generic requirement in a protocol , make sure that the requirement <nl> / / set didn ' t add any requirements to Self or its associated types . <nl> if ( auto * proto = dyn_cast < ProtocolDecl > ( decl - > getDeclContext ( ) ) ) { <nl> auto protoSelf = proto - > getSelfInterfaceType ( ) ; <nl> + auto * sig = decl - > getInnermostDeclContext ( ) - > getGenericSignatureOfContext ( ) ; <nl> for ( auto req : sig - > getRequirements ( ) ) { <nl> / / If one of the types in the requirement is dependent on a non - Self <nl> / / type parameter , this requirement is okay . <nl> static bool checkProtocolSelfRequirements ( GenericSignature * sig , <nl> req . getFirstType ( ) - > is < GenericTypeParamType > ( ) ) <nl> continue ; <nl> <nl> - TC . diagnose ( decl , <nl> - TC . Context . LangOpts . EffectiveLanguageVersion [ 0 ] > = 4 <nl> - ? diag : : requirement_restricts_self <nl> - : diag : : requirement_restricts_self_swift3 , <nl> - decl - > getDescriptiveKind ( ) , decl - > getFullName ( ) , <nl> - req . getFirstType ( ) . getString ( ) , <nl> - static_cast < unsigned > ( req . getKind ( ) ) , <nl> - req . getSecondType ( ) . getString ( ) ) ; <nl> - <nl> - if ( TC . Context . LangOpts . EffectiveLanguageVersion [ 0 ] > = 4 ) <nl> - return true ; <nl> + diagnose ( decl , <nl> + Context . isSwiftVersion3 ( ) <nl> + ? diag : : requirement_restricts_self_swift3 <nl> + : diag : : requirement_restricts_self , <nl> + decl - > getDescriptiveKind ( ) , decl - > getFullName ( ) , <nl> + req . getFirstType ( ) . getString ( ) , <nl> + static_cast < unsigned > ( req . getKind ( ) ) , <nl> + req . getSecondType ( ) . getString ( ) ) ; <nl> } <nl> } <nl> - <nl> - return false ; <nl> } <nl> <nl> / / / All generic parameters of a generic function must be referenced in the <nl> / / / declaration ' s type , otherwise we have no way to infer them . <nl> - static void checkReferencedGenericParams ( GenericContext * dc , <nl> - TypeChecker & TC ) { <nl> + void TypeChecker : : checkReferencedGenericParams ( GenericContext * dc ) { <nl> auto * genericParams = dc - > getGenericParams ( ) ; <nl> auto * genericSig = dc - > getGenericSignatureOfContext ( ) ; <nl> if ( ! genericParams ) <nl> static void checkReferencedGenericParams ( GenericContext * dc , <nl> continue ; <nl> } <nl> / / Produce an error that this generic parameter cannot be bound . <nl> - TC . diagnose ( paramDecl - > getLoc ( ) , diag : : unreferenced_generic_parameter , <nl> - paramDecl - > getNameStr ( ) ) ; <nl> - decl - > setInterfaceType ( ErrorType : : get ( TC . Context ) ) ; <nl> + diagnose ( paramDecl - > getLoc ( ) , diag : : unreferenced_generic_parameter , <nl> + paramDecl - > getNameStr ( ) ) ; <nl> + decl - > setInterfaceType ( ErrorType : : get ( Context ) ) ; <nl> decl - > setInvalid ( ) ; <nl> } <nl> } <nl> void TypeChecker : : validateGenericFuncSignature ( AbstractFunctionDecl * func ) { <nl> if ( checkGenericFuncSignature ( * this , nullptr , func , completeResolver ) ) <nl> invalid = true ; <nl> <nl> - if ( ! invalid ) <nl> - invalid = checkProtocolSelfRequirements ( sig , func , * this ) ; <nl> - <nl> if ( invalid ) { <nl> func - > setInterfaceType ( ErrorType : : get ( Context ) ) ; <nl> func - > setInvalid ( ) ; <nl> void TypeChecker : : validateGenericFuncSignature ( AbstractFunctionDecl * func ) { <nl> <nl> func - > computeType ( ) ; <nl> <nl> - / / We get bogus errors here with generic subscript materializeForSet . <nl> - if ( ! isa < AccessorDecl > ( func ) | | <nl> - ! cast < AccessorDecl > ( func ) - > isMaterializeForSet ( ) ) <nl> - checkReferencedGenericParams ( func , * this ) ; <nl> - <nl> - / / Make sure that there are no unresolved <nl> - / / dependent types in the generic signature . <nl> - assert ( func - > getInterfaceType ( ) - > hasError ( ) | | <nl> - ! func - > getInterfaceType ( ) - > findUnresolvedDependentMemberType ( ) ) ; <nl> + / / Make sure that there are no unresolved dependent types in the <nl> + / / generic signature . <nl> + assert ( ! func - > getInterfaceType ( ) - > findUnresolvedDependentMemberType ( ) ) ; <nl> } <nl> <nl> / / / <nl> TypeChecker : : validateGenericSubscriptSignature ( SubscriptDecl * subscript ) { <nl> CompleteGenericTypeResolver completeResolver ( * this , sig ) ; <nl> if ( checkGenericSubscriptSignature ( * this , nullptr , subscript , completeResolver ) ) <nl> invalid = true ; <nl> - <nl> - if ( ! invalid ) <nl> - invalid = checkProtocolSelfRequirements ( sig , subscript , * this ) ; <nl> - <nl> if ( invalid ) { <nl> subscript - > setInterfaceType ( ErrorType : : get ( Context ) ) ; <nl> subscript - > setInvalid ( ) ; <nl> TypeChecker : : validateGenericSubscriptSignature ( SubscriptDecl * subscript ) { <nl> } <nl> <nl> subscript - > computeType ( ) ; <nl> - <nl> - checkReferencedGenericParams ( subscript , * this ) ; <nl> } <nl> <nl> / / / <nl> mmm a / lib / Sema / TypeChecker . h <nl> ppp b / lib / Sema / TypeChecker . h <nl> class TypeChecker final : public LazyResolver { <nl> / / / of a generic subscript . <nl> void validateGenericSubscriptSignature ( SubscriptDecl * subscript ) ; <nl> <nl> + / / / For a generic requirement in a protocol , make sure that the requirement <nl> + / / / set didn ' t add any requirements to Self or its associated types . <nl> + void checkProtocolSelfRequirements ( ValueDecl * decl ) ; <nl> + <nl> + / / / All generic parameters of a generic function must be referenced in the <nl> + / / / declaration ' s type , otherwise we have no way to infer them . <nl> + void checkReferencedGenericParams ( GenericContext * dc ) ; <nl> + <nl> / / / Construct a new generic environment for the given declaration context . <nl> / / / <nl> / / / \ param genericParams The generic parameters to validate . <nl> mmm a / test / Parse / init_deinit . swift <nl> ppp b / test / Parse / init_deinit . swift <nl> struct FooStructConstructorB { <nl> struct FooStructConstructorC { <nl> init { } / / expected - error { { expected ' ( ' } } { { 7 - 7 = ( ) } } <nl> init < T > { } / / expected - error { { expected ' ( ' } } { { 10 - 10 = ( ) } } <nl> - / / expected - error @ - 1 { { generic parameter ' T ' is not used in function signature } } <nl> init ? { self . init ( ) } / / expected - error { { expected ' ( ' } } { { 8 - 8 = ( ) } } <nl> } <nl> <nl> mmm a / test / decl / protocol / req / unsatisfiable . swift <nl> ppp b / test / decl / protocol / req / unsatisfiable . swift <nl> protocol P { <nl> associatedtype B <nl> <nl> func f < T : P > ( _ : T ) where T . A = = Self . A , T . A = = Self . B / / expected - error { { instance method requirement ' f ' cannot add constraint ' Self . A = = Self . B ' on ' Self ' } } <nl> + / / expected - note @ - 1 { { protocol requires function ' f ' with type ' < T > ( T ) - > ( ) ' ; do you want to add a stub ? } } <nl> } <nl> <nl> extension P { <nl> func f < T : P > ( _ : T ) where T . A = = Self . A , T . A = = Self . B { } <nl> + / / expected - note @ - 1 { { candidate has non - matching type ' < Self , T > ( T ) - > ( ) ' } } <nl> } <nl> <nl> - struct X : P { <nl> + struct X : P { / / expected - error { { type ' X ' does not conform to protocol ' P ' } } <nl> typealias A = X <nl> typealias B = Int <nl> } <nl>
|
Merge pull request from slavapestov / error - type - cleanup
|
apple/swift
|
d71ebcd317d18dd8532b599bc51df5ead2457bb7
|
2018-07-31T18:14:27Z
|
mmm a / Telegram / SourceFiles / platform / linux / main_window_linux . cpp <nl> ppp b / Telegram / SourceFiles / platform / linux / main_window_linux . cpp <nl> bool IsIndicatorApplication ( ) { <nl> <nl> std : : unique_ptr < QTemporaryFile > TrayIconFile ( <nl> const QIcon & icon , <nl> - int size , <nl> - QObject * parent ) { <nl> + QObject * parent = nullptr ) { <nl> static const auto templateName = AppRuntimeDirectory ( ) <nl> + kTrayIconFilename . utf16 ( ) ; <nl> <nl> - const auto desiredSize = QSize ( size , size ) ; <nl> + const auto dpr = style : : DevicePixelRatio ( ) ; <nl> + const auto desiredSize = QSize ( 22 * dpr , 22 * dpr ) ; <nl> <nl> auto ret = std : : make_unique < QTemporaryFile > ( <nl> templateName , <nl> void MainWindow : : setSNITrayIcon ( int counter , bool muted ) { <nl> } <nl> <nl> const auto icon = TrayIconGen ( counter , muted ) ; <nl> - _trayIconFile = TrayIconFile ( icon , 22 , this ) ; <nl> + _trayIconFile = TrayIconFile ( icon , this ) ; <nl> <nl> if ( _trayIconFile ) { <nl> / / indicator - application doesn ' t support tooltips <nl>
|
Follow device pixel ratio in TrayIconFile
|
telegramdesktop/tdesktop
|
e081ed4b4a8501e0cd4a170d028bfeab2a1e1330
|
2020-07-13T02:53:45Z
|
mmm a / src / ia32 / lithium - codegen - ia32 . cc <nl> ppp b / src / ia32 / lithium - codegen - ia32 . cc <nl> void LCodeGen : : DoStoreNamedField ( LStoreNamedField * instr ) { <nl> if ( instr - > value ( ) - > IsConstantOperand ( ) ) { <nl> LConstantOperand * operand_value = LConstantOperand : : cast ( instr - > value ( ) ) ; <nl> if ( IsInteger32 ( operand_value ) ) { <nl> - int const_value = ToInteger32 ( operand_value ) ; <nl> - __ mov ( FieldOperand ( write_register , offset ) , Immediate ( const_value ) ) ; <nl> + / / In lithium register preparation , we made sure that the constant integer <nl> + / / operand fits into smi range . <nl> + Smi * smi_value = Smi : : FromInt ( ToInteger32 ( operand_value ) ) ; <nl> + __ mov ( FieldOperand ( write_register , offset ) , Immediate ( smi_value ) ) ; <nl> + } else if ( operand_value - > IsRegister ( ) ) { <nl> + __ mov ( FieldOperand ( write_register , offset ) , ToRegister ( operand_value ) ) ; <nl> } else { <nl> - if ( operand_value - > IsRegister ( ) ) { <nl> - __ mov ( FieldOperand ( write_register , offset ) , ToRegister ( operand_value ) ) ; <nl> - } else { <nl> - Handle < Object > handle_value = ToHandle ( operand_value ) ; <nl> - __ mov ( FieldOperand ( write_register , offset ) , handle_value ) ; <nl> - } <nl> + Handle < Object > handle_value = ToHandle ( operand_value ) ; <nl> + __ mov ( FieldOperand ( write_register , offset ) , handle_value ) ; <nl> } <nl> } else { <nl> __ mov ( FieldOperand ( write_register , offset ) , ToRegister ( instr - > value ( ) ) ) ; <nl> mmm a / src / ia32 / lithium - ia32 . cc <nl> ppp b / src / ia32 / lithium - ia32 . cc <nl> LOperand * LChunkBuilder : : GetStoreKeyedValueOperand ( HStoreKeyed * instr ) { <nl> } <nl> <nl> <nl> + / / DoStoreKeyed and DoStoreNamedField have special considerations for allowing <nl> + / / use of a constant instead of a register . <nl> + static bool StoreConstantValueAllowed ( HValue * value ) { <nl> + if ( value - > IsConstant ( ) ) { <nl> + HConstant * constant_value = HConstant : : cast ( value ) ; <nl> + return constant_value - > HasSmiValue ( ) <nl> + | | constant_value - > HasDoubleValue ( ) <nl> + | | constant_value - > ImmortalImmovable ( ) ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + <nl> LInstruction * LChunkBuilder : : DoStoreKeyed ( HStoreKeyed * instr ) { <nl> if ( ! instr - > is_external ( ) ) { <nl> ASSERT ( instr - > elements ( ) - > representation ( ) . IsTagged ( ) ) ; <nl> LInstruction * LChunkBuilder : : DoStoreKeyed ( HStoreKeyed * instr ) { <nl> val = UseTempRegister ( instr - > value ( ) ) ; <nl> key = UseTempRegister ( instr - > key ( ) ) ; <nl> } else { <nl> - val = UseRegisterOrConstantAtStart ( instr - > value ( ) ) ; <nl> - key = UseRegisterOrConstantAtStart ( instr - > key ( ) ) ; <nl> + if ( StoreConstantValueAllowed ( instr - > value ( ) ) ) { <nl> + val = UseRegisterOrConstantAtStart ( instr - > value ( ) ) ; <nl> + } else { <nl> + val = UseRegisterAtStart ( instr - > value ( ) ) ; <nl> + } <nl> + <nl> + if ( StoreConstantValueAllowed ( instr - > key ( ) ) ) { <nl> + key = UseRegisterOrConstantAtStart ( instr - > key ( ) ) ; <nl> + } else { <nl> + key = UseRegisterAtStart ( instr - > key ( ) ) ; <nl> + } <nl> } <nl> return new ( zone ( ) ) LStoreKeyed ( obj , key , val ) ; <nl> } <nl> LInstruction * LChunkBuilder : : DoStoreNamedField ( HStoreNamedField * instr ) { <nl> : UseRegisterAtStart ( instr - > object ( ) ) ; <nl> } <nl> <nl> - bool register_or_constant = false ; <nl> - if ( instr - > value ( ) - > IsConstant ( ) ) { <nl> - HConstant * constant_value = HConstant : : cast ( instr - > value ( ) ) ; <nl> - register_or_constant = constant_value - > HasInteger32Value ( ) <nl> - | | constant_value - > HasDoubleValue ( ) <nl> - | | constant_value - > ImmortalImmovable ( ) ; <nl> - } <nl> - <nl> LOperand * val ; <nl> if ( needs_write_barrier ) { <nl> val = UseTempRegister ( instr - > value ( ) ) ; <nl> - } else if ( register_or_constant ) { <nl> + } else if ( StoreConstantValueAllowed ( instr - > value ( ) ) ) { <nl> val = UseRegisterOrConstant ( instr - > value ( ) ) ; <nl> } else { <nl> val = UseRegister ( instr - > value ( ) ) ; <nl> mmm a / src / x64 / lithium - codegen - x64 . cc <nl> ppp b / src / x64 / lithium - codegen - x64 . cc <nl> void LCodeGen : : DoStoreNamedField ( LStoreNamedField * instr ) { <nl> if ( instr - > value ( ) - > IsConstantOperand ( ) ) { <nl> LConstantOperand * operand_value = LConstantOperand : : cast ( instr - > value ( ) ) ; <nl> if ( IsInteger32Constant ( operand_value ) ) { <nl> - int const_value = ToInteger32 ( operand_value ) ; <nl> - __ movq ( FieldOperand ( write_register , offset ) , Immediate ( const_value ) ) ; <nl> + / / In lithium register preparation , we made sure that the constant integer <nl> + / / operand fits into smi range . <nl> + Smi * smi_value = Smi : : FromInt ( ToInteger32 ( operand_value ) ) ; <nl> + __ Move ( FieldOperand ( write_register , offset ) , smi_value ) ; <nl> + } else if ( operand_value - > IsRegister ( ) ) { <nl> + __ movq ( FieldOperand ( write_register , offset ) , <nl> + ToRegister ( operand_value ) ) ; <nl> } else { <nl> - if ( operand_value - > IsRegister ( ) ) { <nl> - __ movq ( FieldOperand ( write_register , offset ) , <nl> - ToRegister ( operand_value ) ) ; <nl> - } else { <nl> - Handle < Object > handle_value = ToHandle ( operand_value ) ; <nl> - __ Move ( FieldOperand ( write_register , offset ) , handle_value ) ; <nl> - } <nl> + Handle < Object > handle_value = ToHandle ( operand_value ) ; <nl> + __ Move ( FieldOperand ( write_register , offset ) , handle_value ) ; <nl> } <nl> } else { <nl> __ movq ( FieldOperand ( write_register , offset ) , ToRegister ( instr - > value ( ) ) ) ; <nl> mmm a / src / x64 / lithium - x64 . cc <nl> ppp b / src / x64 / lithium - x64 . cc <nl> LInstruction * LChunkBuilder : : DoLoadKeyedGeneric ( HLoadKeyedGeneric * instr ) { <nl> } <nl> <nl> <nl> + / / DoStoreKeyed and DoStoreNamedField have special considerations for allowing <nl> + / / use of a constant instead of a register . <nl> + static bool StoreConstantValueAllowed ( HValue * value ) { <nl> + if ( value - > IsConstant ( ) ) { <nl> + HConstant * constant_value = HConstant : : cast ( value ) ; <nl> + return constant_value - > HasSmiValue ( ) <nl> + | | constant_value - > HasDoubleValue ( ) <nl> + | | constant_value - > ImmortalImmovable ( ) ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + <nl> LInstruction * LChunkBuilder : : DoStoreKeyed ( HStoreKeyed * instr ) { <nl> ElementsKind elements_kind = instr - > elements_kind ( ) ; <nl> bool clobbers_key = instr - > key ( ) - > representation ( ) . IsTagged ( ) ; <nl> LInstruction * LChunkBuilder : : DoStoreKeyed ( HStoreKeyed * instr ) { <nl> } else { <nl> ASSERT ( instr - > value ( ) - > representation ( ) . IsTagged ( ) ) ; <nl> object = UseTempRegister ( instr - > elements ( ) ) ; <nl> - val = needs_write_barrier ? UseTempRegister ( instr - > value ( ) ) <nl> - : UseRegisterOrConstantAtStart ( instr - > value ( ) ) ; <nl> - key = ( clobbers_key | | needs_write_barrier ) <nl> - ? UseTempRegister ( instr - > key ( ) ) <nl> - : UseRegisterOrConstantAtStart ( instr - > key ( ) ) ; <nl> + if ( needs_write_barrier ) { <nl> + val = UseTempRegister ( instr - > value ( ) ) ; <nl> + key = UseTempRegister ( instr - > key ( ) ) ; <nl> + } else { <nl> + if ( StoreConstantValueAllowed ( instr - > value ( ) ) ) { <nl> + val = UseRegisterOrConstantAtStart ( instr - > value ( ) ) ; <nl> + } else { <nl> + val = UseRegisterAtStart ( instr - > value ( ) ) ; <nl> + } <nl> + <nl> + if ( clobbers_key ) { <nl> + key = UseTempRegister ( instr - > key ( ) ) ; <nl> + } else if ( StoreConstantValueAllowed ( instr - > key ( ) ) ) { <nl> + key = UseRegisterOrConstantAtStart ( instr - > key ( ) ) ; <nl> + } else { <nl> + key = UseRegisterAtStart ( instr - > key ( ) ) ; <nl> + } <nl> + } <nl> } <nl> <nl> return new ( zone ( ) ) LStoreKeyed ( object , key , val ) ; <nl> LInstruction * LChunkBuilder : : DoStoreNamedField ( HStoreNamedField * instr ) { <nl> : UseRegisterAtStart ( instr - > object ( ) ) ; <nl> } <nl> <nl> - bool register_or_constant = false ; <nl> - if ( instr - > value ( ) - > IsConstant ( ) ) { <nl> - HConstant * constant_value = HConstant : : cast ( instr - > value ( ) ) ; <nl> - register_or_constant = constant_value - > HasInteger32Value ( ) <nl> - | | constant_value - > HasDoubleValue ( ) <nl> - | | constant_value - > ImmortalImmovable ( ) ; <nl> - } <nl> - <nl> LOperand * val ; <nl> if ( needs_write_barrier ) { <nl> val = UseTempRegister ( instr - > value ( ) ) ; <nl> - } else if ( register_or_constant ) { <nl> + } else if ( StoreConstantValueAllowed ( instr - > value ( ) ) ) { <nl> val = UseRegisterOrConstant ( instr - > value ( ) ) ; <nl> } else { <nl> val = UseRegister ( instr - > value ( ) ) ; <nl>
|
Fixed issue in StoreNamedField codegen where integer32 constants were not converted to a smi .
|
v8/v8
|
54a11734acf7f04e893c91f91f2c69c4974649d7
|
2013-04-22T15:35:23Z
|
mmm a / example / Makefile <nl> ppp b / example / Makefile <nl> <nl> - CXX ? = g + + <nl> - CXXFLAGS = <nl> - CXX_FLAGS = - Wall - Wshadow - Wextra - pedantic - std = c + + 11 - pthread - I . . / include <nl> - CXX_RELEASE_FLAGS = - O3 - march = native <nl> - CXX_DEBUG_FLAGS = - g <nl> - <nl> - <nl> - all : example bench <nl> - debug : example - debug bench - debug <nl> - <nl> - example : example . cpp <nl> - $ ( CXX ) example . cpp - o example $ ( CXX_FLAGS ) $ ( CXX_RELEASE_FLAGS ) $ ( CXXFLAGS ) <nl> - <nl> - bench : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench $ ( CXX_FLAGS ) $ ( CXX_RELEASE_FLAGS ) $ ( CXXFLAGS ) <nl> - <nl> - <nl> - example - debug : example . cpp <nl> - $ ( CXX ) example . cpp - o example - debug $ ( CXX_FLAGS ) $ ( CXX_DEBUG_FLAGS ) $ ( CXXFLAGS ) <nl> - <nl> - bench - debug : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench - debug $ ( CXX_FLAGS ) $ ( CXX_DEBUG_FLAGS ) $ ( CXXFLAGS ) <nl> - <nl> - clean : <nl> - rm - f * . o logs / * . txt example example - debug bench bench - debug <nl> - <nl> - <nl> - rebuild : clean all <nl> - rebuild - debug : clean debug <nl> + CXX ? = g + + <nl> + CXXFLAGS = <nl> + CXX_FLAGS = - Wall - Wshadow - Wextra - pedantic - std = c + + 11 - pthread - I . . / include <nl> + CXX_RELEASE_FLAGS = - O3 - march = native <nl> + CXX_DEBUG_FLAGS = - g <nl> + <nl> + <nl> + all : example bench <nl> + debug : example - debug bench - debug <nl> + <nl> + example : example . cpp <nl> + $ ( CXX ) example . cpp - o example $ ( CXX_FLAGS ) $ ( CXX_RELEASE_FLAGS ) $ ( CXXFLAGS ) <nl> + <nl> + bench : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench $ ( CXX_FLAGS ) $ ( CXX_RELEASE_FLAGS ) $ ( CXXFLAGS ) <nl> + <nl> + <nl> + example - debug : example . cpp <nl> + $ ( CXX ) example . cpp - o example - debug $ ( CXX_FLAGS ) $ ( CXX_DEBUG_FLAGS ) $ ( CXXFLAGS ) <nl> + <nl> + bench - debug : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench - debug $ ( CXX_FLAGS ) $ ( CXX_DEBUG_FLAGS ) $ ( CXXFLAGS ) <nl> + <nl> + clean : <nl> + rm - f * . o logs / * . txt example example - debug bench bench - debug <nl> + <nl> + <nl> + rebuild : clean all <nl> + rebuild - debug : clean debug <nl> mmm a / example / Makefile . clang <nl> ppp b / example / Makefile . clang <nl> <nl> - CXX ? = clang + + <nl> - CXXFLAGS = - march = native - Wall - Wextra - Wshadow - pedantic - std = c + + 11 - pthread - I . . / include <nl> - CXX_RELEASE_FLAGS = - O2 <nl> - CXX_DEBUG_FLAGS = - g <nl> - <nl> - <nl> - all : example bench <nl> - debug : example - debug bench - debug <nl> - <nl> - example : example . cpp <nl> - $ ( CXX ) example . cpp - o example - clang $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> - <nl> - bench : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench - clang $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> - <nl> - <nl> - example - debug : example . cpp <nl> - $ ( CXX ) example . cpp - o example - clang - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> - <nl> - bench - debug : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench - clang - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> - <nl> - <nl> - <nl> - clean : <nl> - rm - f * . o logs / * . txt example - clang example - clang - debug bench - clang bench - clang - debug <nl> - <nl> - <nl> - rebuild : clean all <nl> - rebuild - debug : clean debug <nl> - <nl> - <nl> + CXX = clang + + <nl> + CXXFLAGS = - march = native - Wall - Wextra - Wshadow - pedantic - std = c + + 11 - pthread - I . . / include <nl> + CXX_RELEASE_FLAGS = - O2 <nl> + CXX_DEBUG_FLAGS = - g <nl> + <nl> + <nl> + all : example bench <nl> + debug : example - debug bench - debug <nl> + <nl> + example : example . cpp <nl> + $ ( CXX ) example . cpp - o example - clang $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> + <nl> + bench : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench - clang $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> + <nl> + <nl> + example - debug : example . cpp <nl> + $ ( CXX ) example . cpp - o example - clang - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> + <nl> + bench - debug : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench - clang - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> + <nl> + <nl> + <nl> + clean : <nl> + rm - f * . o logs / * . txt example - clang example - clang - debug bench - clang bench - clang - debug <nl> + <nl> + <nl> + rebuild : clean all <nl> + rebuild - debug : clean debug <nl> + <nl> + <nl> mmm a / example / Makefile . mingw <nl> ppp b / example / Makefile . mingw <nl> <nl> - CXX ? = g + + <nl> - CXXFLAGS = - D_WIN32_WINNT = 0x600 - march = native - Wall - Wextra - Wshadow - pedantic - std = gnu + + 0x - pthread - Wl , - - no - as - needed - I . . / include <nl> - CXX_RELEASE_FLAGS = - O3 <nl> - CXX_DEBUG_FLAGS = - g <nl> - <nl> - <nl> - all : example bench <nl> - debug : example - debug bench - debug <nl> - <nl> - example : example . cpp <nl> - $ ( CXX ) example . cpp - o example $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> - <nl> - bench : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> - <nl> - <nl> - example - debug : example . cpp <nl> - $ ( CXX ) example . cpp - o example - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> - <nl> - bench - debug : bench . cpp <nl> - $ ( CXX ) bench . cpp - o bench - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> - <nl> - <nl> - <nl> - clean : <nl> - rm - f * . o logs / * . txt example example - debug bench bench - debug <nl> - <nl> - <nl> - rebuild : clean all <nl> - rebuild - debug : clean debug <nl> - <nl> - <nl> + CXX ? = g + + <nl> + CXXFLAGS = - D_WIN32_WINNT = 0x600 - march = native - Wall - Wextra - Wshadow - pedantic - std = gnu + + 0x - pthread - Wl , - - no - as - needed - I . . / include <nl> + CXX_RELEASE_FLAGS = - O3 <nl> + CXX_DEBUG_FLAGS = - g <nl> + <nl> + <nl> + all : example bench <nl> + debug : example - debug bench - debug <nl> + <nl> + example : example . cpp <nl> + $ ( CXX ) example . cpp - o example $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> + <nl> + bench : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench $ ( CXXFLAGS ) $ ( CXX_RELEASE_FLAGS ) <nl> + <nl> + <nl> + example - debug : example . cpp <nl> + $ ( CXX ) example . cpp - o example - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> + <nl> + bench - debug : bench . cpp <nl> + $ ( CXX ) bench . cpp - o bench - debug $ ( CXXFLAGS ) $ ( CXX_DEBUG_FLAGS ) <nl> + <nl> + <nl> + <nl> + clean : <nl> + rm - f * . o logs / * . txt example example - debug bench bench - debug <nl> + <nl> + <nl> + rebuild : clean all <nl> + rebuild - debug : clean debug <nl> + <nl> + <nl>
|
Fixed example makefile for clang
|
gabime/spdlog
|
309327187a397dae3db9c8766904fc02cc32c053
|
2018-04-06T01:36:22Z
|
mmm a / src / core / lib / surface / server . cc <nl> ppp b / src / core / lib / surface / server . cc <nl> static void request_matcher_kill_requests ( grpc_exec_ctx * exec_ctx , <nl> grpc_error * error ) { <nl> requested_call * rc ; <nl> for ( size_t i = 0 ; i < server - > cq_count ; i + + ) { <nl> - / * Here we know : <nl> - 1 . no requests are being added ( since the server is shut down ) <nl> - 2 . no other threads are pulling ( since the shut down process is single <nl> - threaded ) <nl> - So , we can ignore the queue lock and just pop , with the guarantee that a <nl> - NULL returned here truly means that the queue is empty * / <nl> - while ( ( rc = ( requested_call * ) gpr_mpscq_pop ( <nl> - & rm - > requests_per_cq [ i ] . queue ) ) ! = nullptr ) { <nl> + while ( ( rc = ( requested_call * ) gpr_locked_mpscq_pop ( <nl> + & rm - > requests_per_cq [ i ] ) ) ! = nullptr ) { <nl> fail_call ( exec_ctx , server , i , rc , GRPC_ERROR_REF ( error ) ) ; <nl> } <nl> } <nl>
|
Merge pull request from kpayson64 / quic_tsan_fix
|
grpc/grpc
|
c35a660300610c14910dfc6d006b86eff0d2039d
|
2017-11-17T02:35:01Z
|
mmm a / include / swoole . h <nl> ppp b / include / swoole . h <nl> static sw_inline int swReactor_del_event ( swReactor * reactor , int fd , enum swEven <nl> return SW_OK ; <nl> } <nl> <nl> - static sw_inline void swReactor_remove_read_event ( swReactor * reactor , int fd ) <nl> + static sw_inline int swReactor_remove_read_event ( swReactor * reactor , int fd ) <nl> { <nl> swConnection * conn = swReactor_get ( reactor , fd ) ; <nl> if ( conn - > events & SW_EVENT_WRITE ) <nl> { <nl> conn - > events & = ( ~ SW_EVENT_READ ) ; <nl> - if ( SwooleG . main_reactor - > set ( SwooleG . main_reactor , fd , conn - > fdtype | conn - > events ) < 0 ) <nl> - { <nl> - swSysError ( " reactor - > set ( % d , SW_EVENT_READ ) failed . " , fd ) ; <nl> - } <nl> + return reactor - > set ( reactor , fd , conn - > fdtype | conn - > events ) ; <nl> } <nl> else <nl> { <nl> - if ( SwooleG . main_reactor - > del ( SwooleG . main_reactor , fd ) < 0 ) <nl> - { <nl> - swSysError ( " reactor - > del ( % d ) failed . " , fd ) ; <nl> - } <nl> + return reactor - > del ( reactor , fd ) ; <nl> } <nl> } <nl> <nl> mmm a / php_swoole . h <nl> ppp b / php_swoole . h <nl> <nl> # include " Client . h " <nl> # include " async . h " <nl> <nl> - # define PHP_SWOOLE_VERSION " 1 . 9 . 17 " <nl> + # define PHP_SWOOLE_VERSION " 1 . 9 . 18 " <nl> # define PHP_SWOOLE_CHECK_CALLBACK <nl> # define PHP_SWOOLE_ENABLE_FASTCALL <nl> <nl>
|
update version , fix compile error .
|
swoole/swoole-src
|
8ea7ae6b482ef1090c2fe7b00e3ee0337e540163
|
2017-08-01T09:45:48Z
|
mmm a / doc / classes / OS . xml <nl> ppp b / doc / classes / OS . xml <nl> <nl> < return type = " String " > <nl> < / return > <nl> < description > <nl> - Returns the name of the host OS . Possible values are : [ code ] " Android " [ / code ] , [ code ] " Haiku " [ / code ] , [ code ] " iOS " [ / code ] , [ code ] " HTML5 " [ / code ] , [ code ] " OSX " [ / code ] , [ code ] " Server " [ / code ] , [ code ] " Windows " [ / code ] , [ code ] " UWP " [ / code ] , [ code ] " X11 " [ / code ] . <nl> + Returns the name of the host OS . Possible values are : [ code ] " Android " [ / code ] , [ code ] " iOS " [ / code ] , [ code ] " HTML5 " [ / code ] , [ code ] " OSX " [ / code ] , [ code ] " Server " [ / code ] , [ code ] " Windows " [ / code ] , [ code ] " UWP " [ / code ] , [ code ] " X11 " [ / code ] . <nl> < / description > <nl> < / method > <nl> < method name = " get_process_id " qualifiers = " const " > <nl> deleted file mode 100644 <nl> index dbff6c5ae97 . . 00000000000 <nl> mmm a / platform / haiku / SCsub <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - Import ( " env " ) <nl> - <nl> - common_haiku = [ <nl> - " os_haiku . cpp " , <nl> - " context_gl_haiku . cpp " , <nl> - " haiku_application . cpp " , <nl> - " haiku_direct_window . cpp " , <nl> - " haiku_gl_view . cpp " , <nl> - " key_mapping_haiku . cpp " , <nl> - " audio_driver_media_kit . cpp " , <nl> - ] <nl> - <nl> - target = env . add_program ( " # bin / godot " , [ " godot_haiku . cpp " ] + common_haiku ) <nl> - <nl> - command = env . Command ( " # bin / godot . rsrc " , " # platform / haiku / godot . rdef " , [ " rc - o $ TARGET $ SOURCE " ] ) <nl> - <nl> - <nl> - def addResourcesAction ( target = None , source = None , env = None ) : <nl> - return env . Execute ( " xres - o " + File ( target ) [ 0 ] . path + " bin / godot . rsrc " ) <nl> - <nl> - <nl> - env . AddPostAction ( target , addResourcesAction ) <nl> - env . Depends ( target , command ) <nl> deleted file mode 100644 <nl> index 2fbbeeb1764 . . 00000000000 <nl> mmm a / platform / haiku / audio_driver_media_kit . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * audio_driver_media_kit . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " audio_driver_media_kit . h " <nl> - <nl> - # ifdef MEDIA_KIT_ENABLED <nl> - <nl> - # include " core / project_settings . h " <nl> - <nl> - int32_t * AudioDriverMediaKit : : samples_in = nullptr ; <nl> - <nl> - Error AudioDriverMediaKit : : init ( ) { <nl> - active = false ; <nl> - <nl> - mix_rate = GLOBAL_GET ( " audio / mix_rate " ) ; <nl> - speaker_mode = SPEAKER_MODE_STEREO ; <nl> - channels = 2 ; <nl> - <nl> - int latency = GLOBAL_GET ( " audio / output_latency " ) ; <nl> - buffer_size = next_power_of_2 ( latency * mix_rate / 1000 ) ; <nl> - samples_in = memnew_arr ( int32_t , buffer_size * channels ) ; <nl> - <nl> - media_raw_audio_format format ; <nl> - format = media_raw_audio_format : : wildcard ; <nl> - format . frame_rate = mix_rate ; <nl> - format . channel_count = channels ; <nl> - format . format = media_raw_audio_format : : B_AUDIO_INT ; <nl> - format . byte_order = B_MEDIA_LITTLE_ENDIAN ; <nl> - format . buffer_size = buffer_size * sizeof ( int32_t ) * channels ; <nl> - <nl> - player = new BSoundPlayer ( <nl> - & format , <nl> - " godot_sound_server " , <nl> - AudioDriverMediaKit : : PlayBuffer , <nl> - nullptr , <nl> - this ) ; <nl> - <nl> - if ( player - > InitCheck ( ) ! = B_OK ) { <nl> - fprintf ( stderr , " MediaKit ERR : can not create a BSoundPlayer instance \ n " ) ; <nl> - ERR_FAIL_COND_V ( player = = nullptr , ERR_CANT_OPEN ) ; <nl> - } <nl> - <nl> - player - > Start ( ) ; <nl> - <nl> - return OK ; <nl> - } <nl> - <nl> - void AudioDriverMediaKit : : PlayBuffer ( void * cookie , void * buffer , size_t size , const media_raw_audio_format & format ) { <nl> - AudioDriverMediaKit * ad = ( AudioDriverMediaKit * ) cookie ; <nl> - int32_t * buf = ( int32_t * ) buffer ; <nl> - <nl> - if ( ! ad - > active ) { <nl> - for ( unsigned int i = 0 ; i < ad - > buffer_size * ad - > channels ; i + + ) { <nl> - AudioDriverMediaKit : : samples_in [ i ] = 0 ; <nl> - } <nl> - } else { <nl> - ad - > lock ( ) ; <nl> - ad - > audio_server_process ( ad - > buffer_size , AudioDriverMediaKit : : samples_in ) ; <nl> - ad - > unlock ( ) ; <nl> - } <nl> - <nl> - for ( unsigned int i = 0 ; i < ad - > buffer_size * ad - > channels ; i + + ) { <nl> - buf [ i ] = AudioDriverMediaKit : : samples_in [ i ] ; <nl> - } <nl> - } <nl> - <nl> - void AudioDriverMediaKit : : start ( ) { <nl> - active = true ; <nl> - } <nl> - <nl> - int AudioDriverMediaKit : : get_mix_rate ( ) const { <nl> - return mix_rate ; <nl> - } <nl> - <nl> - AudioDriverMediaKit : : SpeakerMode AudioDriverMediaKit : : get_speaker_mode ( ) const { <nl> - return speaker_mode ; <nl> - } <nl> - <nl> - void AudioDriverMediaKit : : lock ( ) { <nl> - if ( ! mutex ) <nl> - return ; <nl> - <nl> - mutex . lock ( ) ; <nl> - } <nl> - <nl> - void AudioDriverMediaKit : : unlock ( ) { <nl> - if ( ! mutex ) <nl> - return ; <nl> - <nl> - mutex . unlock ( ) ; <nl> - } <nl> - <nl> - void AudioDriverMediaKit : : finish ( ) { <nl> - delete player ; <nl> - <nl> - if ( samples_in ) { <nl> - memdelete_arr ( samples_in ) ; <nl> - } ; <nl> - } <nl> - <nl> - AudioDriverMediaKit : : AudioDriverMediaKit ( ) { <nl> - player = nullptr ; <nl> - } <nl> - <nl> - AudioDriverMediaKit : : ~ AudioDriverMediaKit ( ) { <nl> - } <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 8272780fa7b . . 00000000000 <nl> mmm a / platform / haiku / audio_driver_media_kit . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * audio_driver_media_kit . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " servers / audio_server . h " <nl> - <nl> - # ifdef MEDIA_KIT_ENABLED <nl> - <nl> - # include " core / os / mutex . h " <nl> - # include " core / os / thread . h " <nl> - <nl> - # include < kernel / image . h > / / needed for image_id <nl> - <nl> - # include < SoundPlayer . h > <nl> - <nl> - class AudioDriverMediaKit : public AudioDriver { <nl> - Mutex mutex ; <nl> - <nl> - BSoundPlayer * player ; <nl> - static int32_t * samples_in ; <nl> - <nl> - static void PlayBuffer ( void * cookie , void * buffer , size_t size , const media_raw_audio_format & format ) ; <nl> - <nl> - unsigned int mix_rate ; <nl> - SpeakerMode speaker_mode ; <nl> - unsigned int buffer_size ; <nl> - int channels ; <nl> - <nl> - bool active ; <nl> - <nl> - public : <nl> - const char * get_name ( ) const { <nl> - return " MediaKit " ; <nl> - } ; <nl> - <nl> - virtual Error init ( ) ; <nl> - virtual void start ( ) ; <nl> - virtual int get_mix_rate ( ) const ; <nl> - virtual SpeakerMode get_speaker_mode ( ) const ; <nl> - virtual void lock ( ) ; <nl> - virtual void unlock ( ) ; <nl> - virtual void finish ( ) ; <nl> - <nl> - AudioDriverMediaKit ( ) ; <nl> - ~ AudioDriverMediaKit ( ) ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 3c4d43ff717 . . 00000000000 <nl> mmm a / platform / haiku / context_gl_haiku . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * context_gl_haiku . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " context_gl_haiku . h " <nl> - <nl> - # if defined ( OPENGL_ENABLED ) <nl> - <nl> - ContextGL_Haiku : : ContextGL_Haiku ( HaikuDirectWindow * p_window ) { <nl> - window = p_window ; <nl> - <nl> - uint32 type = BGL_RGB | BGL_DOUBLE | BGL_DEPTH ; <nl> - view = new HaikuGLView ( window - > Bounds ( ) , type ) ; <nl> - <nl> - use_vsync = false ; <nl> - } <nl> - <nl> - ContextGL_Haiku : : ~ ContextGL_Haiku ( ) { <nl> - delete view ; <nl> - } <nl> - <nl> - Error ContextGL_Haiku : : initialize ( ) { <nl> - window - > AddChild ( view ) ; <nl> - window - > SetHaikuGLView ( view ) ; <nl> - <nl> - return OK ; <nl> - } <nl> - <nl> - void ContextGL_Haiku : : release_current ( ) { <nl> - view - > UnlockGL ( ) ; <nl> - } <nl> - <nl> - void ContextGL_Haiku : : make_current ( ) { <nl> - view - > LockGL ( ) ; <nl> - } <nl> - <nl> - void ContextGL_Haiku : : swap_buffers ( ) { <nl> - view - > SwapBuffers ( use_vsync ) ; <nl> - } <nl> - <nl> - int ContextGL_Haiku : : get_window_width ( ) { <nl> - return window - > Bounds ( ) . IntegerWidth ( ) ; <nl> - } <nl> - <nl> - int ContextGL_Haiku : : get_window_height ( ) { <nl> - return window - > Bounds ( ) . IntegerHeight ( ) ; <nl> - } <nl> - <nl> - void ContextGL_Haiku : : set_use_vsync ( bool p_use ) { <nl> - use_vsync = p_use ; <nl> - } <nl> - <nl> - bool ContextGL_Haiku : : is_using_vsync ( ) const { <nl> - return use_vsync ; <nl> - } <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index c5d258915d1 . . 00000000000 <nl> mmm a / platform / haiku / context_gl_haiku . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * context_gl_haiku . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef CONTEXT_GL_HAIKU_H <nl> - # define CONTEXT_GL_HAIKU_H <nl> - <nl> - # if defined ( OPENGL_ENABLED ) <nl> - <nl> - # include " haiku_direct_window . h " <nl> - # include " haiku_gl_view . h " <nl> - <nl> - class ContextGL_Haiku { <nl> - private : <nl> - HaikuGLView * view ; <nl> - HaikuDirectWindow * window ; <nl> - <nl> - bool use_vsync ; <nl> - <nl> - public : <nl> - Error initialize ( ) ; <nl> - void release_current ( ) ; <nl> - void make_current ( ) ; <nl> - void swap_buffers ( ) ; <nl> - int get_window_width ( ) ; <nl> - int get_window_height ( ) ; <nl> - <nl> - void set_use_vsync ( bool p_use ) ; <nl> - bool is_using_vsync ( ) const ; <nl> - <nl> - ContextGL_Haiku ( HaikuDirectWindow * p_window ) ; <nl> - ~ ContextGL_Haiku ( ) ; <nl> - } ; <nl> - <nl> - # endif <nl> - # endif <nl> deleted file mode 100644 <nl> index 0b84df8f9bd . . 00000000000 <nl> mmm a / platform / haiku / detect . py <nl> ppp / dev / null <nl> <nl> - import os <nl> - import sys <nl> - <nl> - <nl> - def is_active ( ) : <nl> - return True <nl> - <nl> - <nl> - def get_name ( ) : <nl> - return " Haiku " <nl> - <nl> - <nl> - def can_build ( ) : <nl> - <nl> - if os . name ! = " posix " or sys . platform = = " darwin " : <nl> - return False <nl> - <nl> - return True <nl> - <nl> - <nl> - def get_opts ( ) : <nl> - from SCons . Variables import EnumVariable <nl> - <nl> - return [ <nl> - EnumVariable ( " debug_symbols " , " Add debugging symbols to release builds " , " yes " , ( " yes " , " no " , " full " ) ) , <nl> - ] <nl> - <nl> - <nl> - def get_flags ( ) : <nl> - <nl> - return [ ] <nl> - <nl> - <nl> - def configure ( env ) : <nl> - <nl> - # # Build type <nl> - <nl> - if env [ " target " ] = = " release " : <nl> - env . Prepend ( CCFLAGS = [ " - O3 " ] ) <nl> - if env [ " debug_symbols " ] = = " yes " : <nl> - env . Prepend ( CCFLAGS = [ " - g1 " ] ) <nl> - if env [ " debug_symbols " ] = = " full " : <nl> - env . Prepend ( CCFLAGS = [ " - g2 " ] ) <nl> - <nl> - elif env [ " target " ] = = " release_debug " : <nl> - env . Prepend ( CCFLAGS = [ " - O2 " , " - DDEBUG_ENABLED " ] ) <nl> - if env [ " debug_symbols " ] = = " yes " : <nl> - env . Prepend ( CCFLAGS = [ " - g1 " ] ) <nl> - if env [ " debug_symbols " ] = = " full " : <nl> - env . Prepend ( CCFLAGS = [ " - g2 " ] ) <nl> - <nl> - elif env [ " target " ] = = " debug " : <nl> - env . Prepend ( CCFLAGS = [ " - g3 " , " - DDEBUG_ENABLED " , " - DDEBUG_MEMORY_ENABLED " ] ) <nl> - <nl> - # # Architecture <nl> - <nl> - is64 = sys . maxsize > 2 * * 32 <nl> - if env [ " bits " ] = = " default " : <nl> - env [ " bits " ] = " 64 " if is64 else " 32 " <nl> - <nl> - # # Compiler configuration <nl> - <nl> - env [ " CC " ] = " gcc - x86 " <nl> - env [ " CXX " ] = " g + + - x86 " <nl> - <nl> - # # Dependencies <nl> - <nl> - if not env [ " builtin_libwebp " ] : <nl> - env . ParseConfig ( " pkg - config libwebp - - cflags - - libs " ) <nl> - <nl> - # freetype depends on libpng and zlib , so bundling one of them while keeping others <nl> - # as shared libraries leads to weird issues <nl> - if env [ " builtin_freetype " ] or env [ " builtin_libpng " ] or env [ " builtin_zlib " ] : <nl> - env [ " builtin_freetype " ] = True <nl> - env [ " builtin_libpng " ] = True <nl> - env [ " builtin_zlib " ] = True <nl> - <nl> - if not env [ " builtin_freetype " ] : <nl> - env . ParseConfig ( " pkg - config freetype2 - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_libpng " ] : <nl> - env . ParseConfig ( " pkg - config libpng16 - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_bullet " ] : <nl> - # We need at least version 2 . 88 <nl> - import subprocess <nl> - <nl> - bullet_version = subprocess . check_output ( [ " pkg - config " , " bullet " , " - - modversion " ] ) . strip ( ) <nl> - if bullet_version < " 2 . 88 " : <nl> - # Abort as system bullet was requested but too old <nl> - print ( <nl> - " Bullet : System version { 0 } does not match minimal requirements ( { 1 } ) . Aborting . " . format ( <nl> - bullet_version , " 2 . 88 " <nl> - ) <nl> - ) <nl> - sys . exit ( 255 ) <nl> - env . ParseConfig ( " pkg - config bullet - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_enet " ] : <nl> - env . ParseConfig ( " pkg - config libenet - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_squish " ] : <nl> - env . ParseConfig ( " pkg - config libsquish - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_zstd " ] : <nl> - env . ParseConfig ( " pkg - config libzstd - - cflags - - libs " ) <nl> - <nl> - # Sound and video libraries <nl> - # Keep the order as it triggers chained dependencies ( ogg needed by others , etc . ) <nl> - <nl> - if not env [ " builtin_libtheora " ] : <nl> - env [ " builtin_libogg " ] = False # Needed to link against system libtheora <nl> - env [ " builtin_libvorbis " ] = False # Needed to link against system libtheora <nl> - env . ParseConfig ( " pkg - config theora theoradec - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_libvpx " ] : <nl> - env . ParseConfig ( " pkg - config vpx - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_libvorbis " ] : <nl> - env [ " builtin_libogg " ] = False # Needed to link against system libvorbis <nl> - env . ParseConfig ( " pkg - config vorbis vorbisfile - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_opus " ] : <nl> - env [ " builtin_libogg " ] = False # Needed to link against system opus <nl> - env . ParseConfig ( " pkg - config opus opusfile - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_libogg " ] : <nl> - env . ParseConfig ( " pkg - config ogg - - cflags - - libs " ) <nl> - <nl> - if env [ " builtin_libtheora " ] : <nl> - list_of_x86 = [ " x86_64 " , " x86 " , " i386 " , " i586 " ] <nl> - if any ( platform . machine ( ) in s for s in list_of_x86 ) : <nl> - env [ " x86_libtheora_opt_gcc " ] = True <nl> - <nl> - if not env [ " builtin_wslay " ] : <nl> - env . ParseConfig ( " pkg - config libwslay - - cflags - - libs " ) <nl> - <nl> - if not env [ " builtin_mbedtls " ] : <nl> - # mbedTLS does not provide a pkgconfig config yet . See https : / / github . com / ARMmbed / mbedtls / issues / 228 <nl> - env . Append ( LIBS = [ " mbedtls " , " mbedcrypto " , " mbedx509 " ] ) <nl> - <nl> - if not env [ " builtin_miniupnpc " ] : <nl> - # No pkgconfig file so far , hardcode default paths . <nl> - env . Prepend ( CPPPATH = [ " / system / develop / headers / x86 / miniupnpc " ] ) <nl> - env . Append ( LIBS = [ " miniupnpc " ] ) <nl> - <nl> - # On Linux wchar_t should be 32 - bits <nl> - # 16 - bit library shouldn ' t be required due to compiler optimisations <nl> - if not env [ " builtin_pcre2 " ] : <nl> - env . ParseConfig ( " pkg - config libpcre2 - 32 - - cflags - - libs " ) <nl> - <nl> - # # Flags <nl> - <nl> - env . Prepend ( CPPPATH = [ " # platform / haiku " ] ) <nl> - env . Append ( CPPDEFINES = [ " UNIX_ENABLED " , " OPENGL_ENABLED " , " GLES_ENABLED " ] ) <nl> - env . Append ( CPPDEFINES = [ " MEDIA_KIT_ENABLED " ] ) <nl> - env . Append ( CPPDEFINES = [ " PTHREAD_NO_RENAME " ] ) # TODO : enable when we have pthread_setname_np <nl> - env . Append ( LIBS = [ " be " , " game " , " media " , " network " , " bnetapi " , " z " , " GL " ] ) <nl> deleted file mode 100644 <nl> index a55cddbf0d2 . . 00000000000 <nl> mmm a / platform / haiku / godot . rdef <nl> ppp / dev / null <nl> <nl> - resource app_version { <nl> - major = 2 , <nl> - middle = 0 , <nl> - minor = 0 , <nl> - <nl> - variety = B_APPV_FINAL , <nl> - internal = 0 , <nl> - <nl> - short_info = " Godot Game Engine " , <nl> - long_info = " An advanced , feature packed , multi - platform 2D and 3D game engine . " <nl> - } ; <nl> - <nl> - resource app_signature " application / x - vnd . godot " ; <nl> - <nl> - resource vector_icon { <nl> - $ " 6E6369660403A39F9F05FF03478CBF03414042090A04B37FB379CC26B379CC26 " <nl> - $ " CC20B37FCC200A09B5E9C41B2AC240B8E1BDFBBFA1BDA4C6A7BDFFCA1AC45CC9 " <nl> - $ " 7AC607C01CC75BB6F4C65A062AFE9FFF9F69FE7FFEDFCF0FC95FC3D7C95FC51E " <nl> - $ " C95FC51EC95FC53EC92BC565C94AC55BC92BC565C728C60BC728C60BC712C612 " <nl> - $ " C6E6C600C6F9C60EC6D3C5F2C6C7C5C4C6C7C5DCC6C7C5C4C460C4E5C4BCC4E5 " <nl> - $ " C626C4E5C626C4E5C64BC4A5C670C4CAC66BC4A5C670C1EDC6CFC1EDC6CFC1E9 " <nl> - $ " C6CFC1E2C6D0C1E6C6D0C1D1C6D0C1B2C6BEC1BFC6C9C1A2C6AFC19851C198C6 " <nl> - $ " 9BC19851C505C031C507C507C016C507BFFCC507C507BE94C505BE9451BE9451 " <nl> - $ " BE94C69BBE7BC6BEBE8BC6AFBE6DC6C9BE4AC6D0BE5CC6D0BE47C6D0BE40C6CF " <nl> - $ " BE44C6CFBE40C6CFBB87C670BB87C670BB63C66BBB47C626BB47C64BBB47C626 " <nl> - $ " C4BCB965C460B965C5C4B965C5C4B965C5DCB947C600B95AC5F2B934C60EB904 " <nl> - $ " C60BB91BC612B904C60BB701C565B701C565B6E3C55BB6CEC51EB6CEC53EB6CE " <nl> - $ " C51EC3D7B590C36CB590C36CB581C3B0B578C43AB578C3F5B578C78FBFF8CA27 " <nl> - $ " BA2ACA22BFF8CA27BFFABFFCCA27BFFCCA27C5CACA22CA7CC43ACA7CC78FCA7C " <nl> - $ " C3FBCA67C37ECA754ACA67C37E0639F6F97FFEF8E7FFF9F6FFFFFFFFFF03B67D " <nl> - $ " BDEEC31FB730C35CB730C35CB74EC3662BC3A22BC3822BC3A2C4E8B8D1C55EB8 " <nl> - $ " D1C406B8D1C406B8D1C3F0B8ECC3CDB8DBC3DBB8FDC3BFB929C3BDB913C3B9B9 " <nl> - $ " 29C3BDBB9FC436BB9FC436BBC2C43CBBDCC47EBBDCC45BBBDCC47EC5E6BE00C6 " <nl> - $ " 31BE00C4BBBE00C4BBBE00C4A7BE16C486BE08C494BE24C479BE4AC471BE37C4 " <nl> - $ " 71BE4AC471BE4BC016C473C1E2C471C1E2C471C1F6C471C217C486C209C479C2 " <nl> - $ " 25C494C22DC4BBC22DC4A7C22DC4BBC631C451C5E6C451C47EC451C47EC451C4 " <nl> - $ " 5BC48DC436C46AC43CC48DC436C704C3BDC704C3BDC719C3B9C741C3CDC730C3 " <nl> - $ " BF53C3DBC75CC406C75CC3F0C75CC406C55EC8CAC4E8C8CAC3A2C8CAC3A2C8CA " <nl> - $ " C382C8FDC35CC8DFC366C8FDC35CC977C333BDEEC97ABDEEC97ABDEEC9F1BD56 " <nl> - $ " CAC9BC0BCA60BCB6CA3DBB1CC8D9B981C991BA47C82FB9D7C6EDBAA0C789BA38 " <nl> - $ " C69FBA52C5F0B9D0C647BA12C59BB98BC4E0B91FC53BB959C4FBB855C50EB6C0 " <nl> - $ " C509B78FC424B64AC22DB5C4C32AB5FCC1C8B66DC11BB7D9C16BB725C0BCB7C9 " <nl> - $ " BFFCB7C2C05CB7C3BFFCB7C2BFFCB7C2BFFCB7C2BFFBB7C2BFFAB7C2BFFAB7C2 " <nl> - $ " BFF9B7C2BFF8B7C2BFF9B7C2BFF8B7C2BFF8B7C2BFF8B7C2BF98B7C3BED9B7D9 " <nl> - $ " BF38B7C9BE88B725BDC7B5C4BE2CB66DBCCAB5FCBAE6B6C0BBD0B64ABAEBB78F " <nl> - $ " BB13B91F34B855BAB8B959BA04B9D0BA59B98BB9ADBA12B907BAA0B955BA52B8 " <nl> - $ " 6ABA38B71AB981B7C5B9D7B663BA47B52BBC0BB5B7BB1CB594BCB6B679BDEEB6 " <nl> - $ " 02BD56B679BDEE0005BD3EC06CBD3EC06CBD3EC197BB2147BC4C47B9F647B904 " <nl> - $ " C06CB904C197B904BF41BB21BE4FB9F6BE4FBC4CBE4FBD3EC06CBD3EBF41BD3E " <nl> - $ " C06C0005BCBC42BCBC42BCBCC153BB55C1F3BC1BC1F3BA8EC1F3B9ED42B9EDC1 " <nl> - $ " 53B9EDBFC6BB55BF25BA8EBF25BC1BBF25BCBC42BCBCBFC6BCBC420007C01BC2 " <nl> - $ " BBC01BC2BBBFBAC2BBBF6CC21CBF6CC274BF6CC21CBF6CC02ABF6CC02ABF6CBF " <nl> - $ " D3C01BBF8CBFBABF8CC07BBF8CC0C9C02AC0C9BFD3C0C9C02AC0C9C21CC0C9C2 " <nl> - $ " 1CC0C9C274C01BC2BBC07BC2BBC01BC2BB0005C2F7C06CC2F7C06CC2F7C197C5 " <nl> - $ " 1547C3E947C64047C732C06CC732C197C732BF41C515BE4FC640BE4FC3E9BE4F " <nl> - $ " C2F7C06CC2F7BF41C2F7C06C0005C37942C37942C379C153C4E1C1F3C41AC1F3 " <nl> - $ " C5A7C1F3C64842C648C153C648BFC6C4E1BF25C5A7BF25C41ABF25C37942C379 " <nl> - $ " BFC6C37942090A0000000A010101000A020102000A020103000A010104000A03 " <nl> - $ " 0105000A010106000A010107000A03010800 " <nl> - } ; <nl> deleted file mode 100644 <nl> index 0657f4c0527 . . 00000000000 <nl> mmm a / platform / haiku / godot_haiku . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * godot_haiku . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " main / main . h " <nl> - # include " os_haiku . h " <nl> - <nl> - int main ( int argc , char * argv [ ] ) { <nl> - OS_Haiku os ; <nl> - <nl> - Error error = Main : : setup ( argv [ 0 ] , argc - 1 , & argv [ 1 ] ) ; <nl> - if ( error ! = OK ) { <nl> - return 255 ; <nl> - } <nl> - <nl> - if ( Main : : start ( ) ) { <nl> - os . run ( ) ; <nl> - } <nl> - <nl> - Main : : cleanup ( ) ; <nl> - <nl> - return os . get_exit_code ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 82d9c093e13 . . 00000000000 <nl> mmm a / platform / haiku / haiku_application . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_application . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " haiku_application . h " <nl> - <nl> - HaikuApplication : : HaikuApplication ( ) : <nl> - BApplication ( " application / x - vnd . godot " ) { <nl> - } <nl> deleted file mode 100644 <nl> index 2e04d921bfa . . 00000000000 <nl> mmm a / platform / haiku / haiku_application . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_application . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef HAIKU_APPLICATION_H <nl> - # define HAIKU_APPLICATION_H <nl> - <nl> - # include < kernel / image . h > / / needed for image_id <nl> - <nl> - # include < Application . h > <nl> - <nl> - class HaikuApplication : public BApplication { <nl> - public : <nl> - HaikuApplication ( ) ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 0a40f847f4f . . 00000000000 <nl> mmm a / platform / haiku / haiku_direct_window . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_direct_window . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include < UnicodeChar . h > <nl> - <nl> - # include " core / os / keyboard . h " <nl> - # include " haiku_direct_window . h " <nl> - # include " key_mapping_haiku . h " <nl> - # include " main / main . h " <nl> - <nl> - HaikuDirectWindow : : HaikuDirectWindow ( BRect p_frame ) : <nl> - BDirectWindow ( p_frame , " Godot " , B_TITLED_WINDOW , B_QUIT_ON_WINDOW_CLOSE ) { <nl> - last_mouse_pos_valid = false ; <nl> - last_buttons_state = 0 ; <nl> - last_button_mask = 0 ; <nl> - last_key_modifier_state = 0 ; <nl> - <nl> - view = nullptr ; <nl> - update_runner = nullptr ; <nl> - input = nullptr ; <nl> - main_loop = nullptr ; <nl> - } <nl> - <nl> - HaikuDirectWindow : : ~ HaikuDirectWindow ( ) { <nl> - } <nl> - <nl> - void HaikuDirectWindow : : SetHaikuGLView ( HaikuGLView * p_view ) { <nl> - view = p_view ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : StartMessageRunner ( ) { <nl> - update_runner = new BMessageRunner ( BMessenger ( this ) , <nl> - new BMessage ( REDRAW_MSG ) , 1000000 / 60 / * 60 fps * / ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : StopMessageRunner ( ) { <nl> - delete update_runner ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : SetInput ( InputDefault * p_input ) { <nl> - input = p_input ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : SetMainLoop ( MainLoop * p_main_loop ) { <nl> - main_loop = p_main_loop ; <nl> - } <nl> - <nl> - bool HaikuDirectWindow : : QuitRequested ( ) { <nl> - StopMessageRunner ( ) ; <nl> - main_loop - > notification ( NOTIFICATION_WM_CLOSE_REQUEST ) ; <nl> - return false ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : DirectConnected ( direct_buffer_info * info ) { <nl> - view - > DirectConnected ( info ) ; <nl> - view - > EnableDirectMode ( true ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : MessageReceived ( BMessage * message ) { <nl> - switch ( message - > what ) { <nl> - case REDRAW_MSG : <nl> - if ( Main : : iteration ( ) ) { <nl> - view - > EnableDirectMode ( false ) ; <nl> - Quit ( ) ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - BDirectWindow : : MessageReceived ( message ) ; <nl> - } <nl> - } <nl> - <nl> - void HaikuDirectWindow : : DispatchMessage ( BMessage * message , BHandler * handler ) { <nl> - switch ( message - > what ) { <nl> - case B_MOUSE_DOWN : <nl> - case B_MOUSE_UP : <nl> - HandleMouseButton ( message ) ; <nl> - break ; <nl> - <nl> - case B_MOUSE_MOVED : <nl> - HandleMouseMoved ( message ) ; <nl> - break ; <nl> - <nl> - case B_MOUSE_WHEEL_CHANGED : <nl> - HandleMouseWheelChanged ( message ) ; <nl> - break ; <nl> - <nl> - case B_KEY_DOWN : <nl> - case B_KEY_UP : <nl> - HandleKeyboardEvent ( message ) ; <nl> - break ; <nl> - <nl> - case B_MODIFIERS_CHANGED : <nl> - HandleKeyboardModifierEvent ( message ) ; <nl> - break ; <nl> - <nl> - case B_WINDOW_RESIZED : <nl> - HandleWindowResized ( message ) ; <nl> - break ; <nl> - <nl> - case LOCKGL_MSG : <nl> - view - > LockGL ( ) ; <nl> - break ; <nl> - <nl> - case UNLOCKGL_MSG : <nl> - view - > UnlockGL ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - BDirectWindow : : DispatchMessage ( message , handler ) ; <nl> - } <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleMouseButton ( BMessage * message ) { <nl> - BPoint where ; <nl> - if ( message - > FindPoint ( " where " , & where ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - uint32 modifiers = message - > FindInt32 ( " modifiers " ) ; <nl> - uint32 buttons = message - > FindInt32 ( " buttons " ) ; <nl> - uint32 button = buttons ^ last_buttons_state ; <nl> - last_buttons_state = buttons ; <nl> - <nl> - / / TODO : implement the mouse_mode checks <nl> - / * <nl> - if ( mouse_mode = = MOUSE_MODE_CAPTURED ) { <nl> - event . xbutton . x = last_mouse_pos . x ; <nl> - event . xbutton . y = last_mouse_pos . y ; <nl> - } <nl> - * / <nl> - <nl> - Ref < InputEventMouseButton > mouse_event ; <nl> - mouse_event . instance ( ) ; <nl> - <nl> - mouse_event - > set_button_mask ( GetMouseButtonState ( buttons ) ) ; <nl> - mouse_event - > set_position ( { where . x , where . y } ) ; <nl> - mouse_event - > set_global_position ( { where . x , where . y } ) ; <nl> - GetKeyModifierState ( mouse_event , modifiers ) ; <nl> - <nl> - switch ( button ) { <nl> - default : <nl> - case B_PRIMARY_MOUSE_BUTTON : <nl> - mouse_event - > set_button_index ( 1 ) ; <nl> - break ; <nl> - <nl> - case B_SECONDARY_MOUSE_BUTTON : <nl> - mouse_event - > set_button_index ( 2 ) ; <nl> - break ; <nl> - <nl> - case B_TERTIARY_MOUSE_BUTTON : <nl> - mouse_event - > set_button_index ( 3 ) ; <nl> - break ; <nl> - } <nl> - <nl> - mouse_event - > set_pressed ( message - > what = = B_MOUSE_DOWN ) ; <nl> - <nl> - if ( message - > what = = B_MOUSE_DOWN & & mouse_event - > get_button_index ( ) = = 1 ) { <nl> - int32 clicks = message - > FindInt32 ( " clicks " ) ; <nl> - <nl> - if ( clicks > 1 ) { <nl> - mouse_event - > set_doubleclick ( true ) ; <nl> - } <nl> - } <nl> - <nl> - input - > parse_input_event ( mouse_event ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleMouseMoved ( BMessage * message ) { <nl> - BPoint where ; <nl> - if ( message - > FindPoint ( " where " , & where ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - Point2i pos ( where . x , where . y ) ; <nl> - uint32 modifiers = message - > FindInt32 ( " modifiers " ) ; <nl> - uint32 buttons = message - > FindInt32 ( " buttons " ) ; <nl> - <nl> - if ( ! last_mouse_pos_valid ) { <nl> - last_mouse_position = pos ; <nl> - last_mouse_pos_valid = true ; <nl> - } <nl> - <nl> - Point2i rel = pos - last_mouse_position ; <nl> - <nl> - Ref < InputEventMouseMotion > motion_event ; <nl> - motion_event . instance ( ) ; <nl> - GetKeyModifierState ( motion_event , modifiers ) ; <nl> - <nl> - motion_event - > set_button_mask ( GetMouseButtonState ( buttons ) ) ; <nl> - motion_event - > set_position ( { pos . x , pos . y } ) ; <nl> - input - > set_mouse_position ( pos ) ; <nl> - motion_event - > set_global_position ( { pos . x , pos . y } ) ; <nl> - motion_event - > set_speed ( { input - > get_last_mouse_speed ( ) . x , <nl> - input - > get_last_mouse_speed ( ) . y } ) ; <nl> - <nl> - motion_event - > set_relative ( { rel . x , rel . y } ) ; <nl> - <nl> - last_mouse_position = pos ; <nl> - <nl> - input - > parse_input_event ( motion_event ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleMouseWheelChanged ( BMessage * message ) { <nl> - float wheel_delta_y = 0 ; <nl> - if ( message - > FindFloat ( " be : wheel_delta_y " , & wheel_delta_y ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - Ref < InputEventMouseButton > mouse_event ; <nl> - mouse_event . instance ( ) ; <nl> - / / GetKeyModifierState ( mouse_event , modifiers ) ; <nl> - <nl> - mouse_event - > set_button_index ( wheel_delta_y < 0 ? 4 : 5 ) ; <nl> - mouse_event - > set_button_mask ( last_button_mask ) ; <nl> - mouse_event - > set_position ( { last_mouse_position . x , <nl> - last_mouse_position . y } ) ; <nl> - mouse_event - > set_global_position ( { last_mouse_position . x , <nl> - last_mouse_position . y } ) ; <nl> - <nl> - mouse_event - > set_pressed ( true ) ; <nl> - input - > parse_input_event ( mouse_event ) ; <nl> - <nl> - mouse_event - > set_pressed ( false ) ; <nl> - input - > parse_input_event ( mouse_event ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleKeyboardEvent ( BMessage * message ) { <nl> - int32 raw_char = 0 ; <nl> - int32 key = 0 ; <nl> - int32 modifiers = 0 ; <nl> - <nl> - if ( message - > FindInt32 ( " raw_char " , & raw_char ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - if ( message - > FindInt32 ( " key " , & key ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - if ( message - > FindInt32 ( " modifiers " , & modifiers ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - Ref < InputEventKey > event ; <nl> - event . instance ( ) ; <nl> - GetKeyModifierState ( event , modifiers ) ; <nl> - event - > set_pressed ( message - > what = = B_KEY_DOWN ) ; <nl> - event - > set_keycode ( KeyMappingHaiku : : get_keysym ( raw_char , key ) ) ; <nl> - event - > set_physical_keycode ( KeyMappingHaiku : : get_keysym ( raw_char , key ) ) ; <nl> - event - > set_echo ( message - > HasInt32 ( " be : key_repeat " ) ) ; <nl> - event - > set_unicode ( 0 ) ; <nl> - <nl> - const char * bytes = nullptr ; <nl> - if ( message - > FindString ( " bytes " , & bytes ) = = B_OK ) { <nl> - event - > set_unicode ( BUnicodeChar : : FromUTF8 ( & bytes ) ) ; <nl> - } <nl> - <nl> - / / make it consistent across platforms . <nl> - if ( event - > get_keycode ( ) = = KEY_BACKTAB ) { <nl> - event - > set_keycode ( KEY_TAB ) ; <nl> - event - > set_physical_keycode ( KEY_TAB ) ; <nl> - event - > set_shift ( true ) ; <nl> - } <nl> - <nl> - input - > parse_input_event ( event ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleKeyboardModifierEvent ( BMessage * message ) { <nl> - int32 old_modifiers = 0 ; <nl> - int32 modifiers = 0 ; <nl> - <nl> - if ( message - > FindInt32 ( " be : old_modifiers " , & old_modifiers ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - if ( message - > FindInt32 ( " modifiers " , & modifiers ) ! = B_OK ) { <nl> - return ; <nl> - } <nl> - <nl> - int32 key = old_modifiers ^ modifiers ; <nl> - <nl> - Ref < InputEventWithModifiers > event ; <nl> - event . instance ( ) ; <nl> - GetKeyModifierState ( event , modifiers ) ; <nl> - <nl> - event - > set_shift ( key & B_SHIFT_KEY ) ; <nl> - event - > set_alt ( key & B_OPTION_KEY ) ; <nl> - event - > set_control ( key & B_CONTROL_KEY ) ; <nl> - event - > set_command ( key & B_COMMAND_KEY ) ; <nl> - <nl> - input - > parse_input_event ( event ) ; <nl> - } <nl> - <nl> - void HaikuDirectWindow : : HandleWindowResized ( BMessage * message ) { <nl> - int32 width = 0 ; <nl> - int32 height = 0 ; <nl> - <nl> - if ( ( message - > FindInt32 ( " width " , & width ) ! = B_OK ) | | ( message - > FindInt32 ( " height " , & height ) ! = B_OK ) ) { <nl> - return ; <nl> - } <nl> - <nl> - current_video_mode - > width = width ; <nl> - current_video_mode - > height = height ; <nl> - } <nl> - <nl> - inline void HaikuDirectWindow : : GetKeyModifierState ( Ref < InputEventWithModifiers > event , uint32 p_state ) { <nl> - last_key_modifier_state = p_state ; <nl> - <nl> - event - > set_shift ( p_state & B_SHIFT_KEY ) ; <nl> - event - > set_control ( p_state & B_CONTROL_KEY ) ; <nl> - event - > set_alt ( p_state & B_OPTION_KEY ) ; <nl> - event - > set_metakey ( p_state & B_COMMAND_KEY ) ; <nl> - <nl> - return state ; <nl> - } <nl> - <nl> - inline int HaikuDirectWindow : : GetMouseButtonState ( uint32 p_state ) { <nl> - int state = 0 ; <nl> - <nl> - if ( p_state & B_PRIMARY_MOUSE_BUTTON ) { <nl> - state | = 1 < < 0 ; <nl> - } <nl> - <nl> - if ( p_state & B_SECONDARY_MOUSE_BUTTON ) { <nl> - state | = 1 < < 1 ; <nl> - } <nl> - <nl> - if ( p_state & B_TERTIARY_MOUSE_BUTTON ) { <nl> - state | = 1 < < 2 ; <nl> - } <nl> - <nl> - last_button_mask = state ; <nl> - <nl> - return state ; <nl> - } <nl> deleted file mode 100644 <nl> index 4817abbb7a4 . . 00000000000 <nl> mmm a / platform / haiku / haiku_direct_window . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_direct_window . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef HAIKU_DIRECT_WINDOW_H <nl> - # define HAIKU_DIRECT_WINDOW_H <nl> - <nl> - # include < kernel / image . h > / / needed for image_id <nl> - <nl> - # include < DirectWindow . h > <nl> - <nl> - # include " core / input / input . h " <nl> - # include " core / os / os . h " <nl> - <nl> - # include " haiku_gl_view . h " <nl> - <nl> - # define REDRAW_MSG ' rdrw ' <nl> - # define LOCKGL_MSG ' glck ' <nl> - # define UNLOCKGL_MSG ' ulck ' <nl> - <nl> - class HaikuDirectWindow : public BDirectWindow { <nl> - private : <nl> - Point2i last_mouse_position ; <nl> - bool last_mouse_pos_valid ; <nl> - uint32 last_buttons_state ; <nl> - uint32 last_key_modifier_state ; <nl> - int last_button_mask ; <nl> - OS : : VideoMode * current_video_mode ; <nl> - <nl> - MainLoop * main_loop ; <nl> - InputDefault * input ; <nl> - HaikuGLView * view ; <nl> - BMessageRunner * update_runner ; <nl> - <nl> - void HandleMouseButton ( BMessage * message ) ; <nl> - void HandleMouseMoved ( BMessage * message ) ; <nl> - void HandleMouseWheelChanged ( BMessage * message ) ; <nl> - void HandleWindowResized ( BMessage * message ) ; <nl> - void HandleKeyboardEvent ( BMessage * message ) ; <nl> - void HandleKeyboardModifierEvent ( BMessage * message ) ; <nl> - inline void GetKeyModifierState ( Ref < InputEventWithModifiers > event , uint32 p_state ) ; <nl> - inline int GetMouseButtonState ( uint32 p_state ) ; <nl> - <nl> - public : <nl> - HaikuDirectWindow ( BRect p_frame ) ; <nl> - ~ HaikuDirectWindow ( ) ; <nl> - <nl> - void SetHaikuGLView ( HaikuGLView * p_view ) ; <nl> - void StartMessageRunner ( ) ; <nl> - void StopMessageRunner ( ) ; <nl> - void SetInput ( InputDefault * p_input ) ; <nl> - void SetMainLoop ( MainLoop * p_main_loop ) ; <nl> - inline void SetVideoMode ( OS : : VideoMode * video_mode ) { current_video_mode = video_mode ; } ; <nl> - virtual bool QuitRequested ( ) ; <nl> - virtual void DirectConnected ( direct_buffer_info * info ) ; <nl> - virtual void MessageReceived ( BMessage * message ) ; <nl> - virtual void DispatchMessage ( BMessage * message , BHandler * handler ) ; <nl> - <nl> - inline Point2i GetLastMousePosition ( ) { return last_mouse_position ; } ; <nl> - inline int GetLastButtonMask ( ) { return last_button_mask ; } ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 970a1276fda . . 00000000000 <nl> mmm a / platform / haiku / haiku_gl_view . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_gl_view . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " haiku_gl_view . h " <nl> - # include " main / main . h " <nl> - <nl> - HaikuGLView : : HaikuGLView ( BRect frame , uint32 type ) : <nl> - BGLView ( frame , " GodotGLView " , B_FOLLOW_ALL_SIDES , 0 , type ) { <nl> - } <nl> - <nl> - void HaikuGLView : : AttachedToWindow ( void ) { <nl> - LockGL ( ) ; <nl> - BGLView : : AttachedToWindow ( ) ; <nl> - UnlockGL ( ) ; <nl> - MakeFocus ( ) ; <nl> - } <nl> - <nl> - void HaikuGLView : : Draw ( BRect updateRect ) { <nl> - Main : : force_redraw ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 59e02d2367c . . 00000000000 <nl> mmm a / platform / haiku / haiku_gl_view . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * haiku_gl_view . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef HAIKU_GL_VIEW_H <nl> - # define HAIKU_GL_VIEW_H <nl> - <nl> - # include < kernel / image . h > / / needed for image_id <nl> - <nl> - # include < GLView . h > <nl> - <nl> - class HaikuGLView : public BGLView { <nl> - public : <nl> - HaikuGLView ( BRect frame , uint32 type ) ; <nl> - virtual void AttachedToWindow ( void ) ; <nl> - virtual void Draw ( BRect updateRect ) ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 692a1e5a78a . . 00000000000 <nl> mmm a / platform / haiku / key_mapping_haiku . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * key_mapping_haiku . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include < InterfaceDefs . h > <nl> - <nl> - # include " core / os / keyboard . h " <nl> - # include " key_mapping_haiku . h " <nl> - <nl> - struct _HaikuTranslatePair { <nl> - unsigned int keysym ; <nl> - int32 keycode ; <nl> - } ; <nl> - <nl> - static _HaikuTranslatePair _mod_to_keycode [ ] = { <nl> - { KEY_SHIFT , B_SHIFT_KEY } , <nl> - { KEY_ALT , B_COMMAND_KEY } , <nl> - { KEY_CONTROL , B_CONTROL_KEY } , <nl> - { KEY_CAPSLOCK , B_CAPS_LOCK } , <nl> - { KEY_SCROLLLOCK , B_SCROLL_LOCK } , <nl> - { KEY_NUMLOCK , B_NUM_LOCK } , <nl> - { KEY_SUPER_L , B_OPTION_KEY } , <nl> - { KEY_MENU , B_MENU_KEY } , <nl> - { KEY_SHIFT , B_LEFT_SHIFT_KEY } , <nl> - { KEY_SHIFT , B_RIGHT_SHIFT_KEY } , <nl> - { KEY_ALT , B_LEFT_COMMAND_KEY } , <nl> - { KEY_ALT , B_RIGHT_COMMAND_KEY } , <nl> - { KEY_CONTROL , B_LEFT_CONTROL_KEY } , <nl> - { KEY_CONTROL , B_RIGHT_CONTROL_KEY } , <nl> - { KEY_SUPER_L , B_LEFT_OPTION_KEY } , <nl> - { KEY_SUPER_R , B_RIGHT_OPTION_KEY } , <nl> - { KEY_UNKNOWN , 0 } <nl> - } ; <nl> - <nl> - static _HaikuTranslatePair _fn_to_keycode [ ] = { <nl> - { KEY_F1 , B_F1_KEY } , <nl> - { KEY_F2 , B_F2_KEY } , <nl> - { KEY_F3 , B_F3_KEY } , <nl> - { KEY_F4 , B_F4_KEY } , <nl> - { KEY_F5 , B_F5_KEY } , <nl> - { KEY_F6 , B_F6_KEY } , <nl> - { KEY_F7 , B_F7_KEY } , <nl> - { KEY_F8 , B_F8_KEY } , <nl> - { KEY_F9 , B_F9_KEY } , <nl> - { KEY_F10 , B_F10_KEY } , <nl> - { KEY_F11 , B_F11_KEY } , <nl> - { KEY_F12 , B_F12_KEY } , <nl> - / / { KEY_F13 , ? } , <nl> - / / { KEY_F14 , ? } , <nl> - / / { KEY_F15 , ? } , <nl> - / / { KEY_F16 , ? } , <nl> - { KEY_PRINT , B_PRINT_KEY } , <nl> - { KEY_SCROLLLOCK , B_SCROLL_KEY } , <nl> - { KEY_PAUSE , B_PAUSE_KEY } , <nl> - { KEY_UNKNOWN , 0 } <nl> - } ; <nl> - <nl> - static _HaikuTranslatePair _hb_to_keycode [ ] = { <nl> - { KEY_BACKSPACE , B_BACKSPACE } , <nl> - { KEY_TAB , B_TAB } , <nl> - { KEY_ENTER , B_RETURN } , <nl> - { KEY_CAPSLOCK , B_CAPS_LOCK } , <nl> - { KEY_ESCAPE , B_ESCAPE } , <nl> - { KEY_SPACE , B_SPACE } , <nl> - { KEY_PAGEUP , B_PAGE_UP } , <nl> - { KEY_PAGEDOWN , B_PAGE_DOWN } , <nl> - { KEY_END , B_END } , <nl> - { KEY_HOME , B_HOME } , <nl> - { KEY_LEFT , B_LEFT_ARROW } , <nl> - { KEY_UP , B_UP_ARROW } , <nl> - { KEY_RIGHT , B_RIGHT_ARROW } , <nl> - { KEY_DOWN , B_DOWN_ARROW } , <nl> - { KEY_PRINT , B_PRINT_KEY } , <nl> - { KEY_INSERT , B_INSERT } , <nl> - { KEY_DELETE , B_DELETE } , <nl> - / / { KEY_HELP , ? ? ? } , <nl> - <nl> - { KEY_0 , ( 0x30 ) } , <nl> - { KEY_1 , ( 0x31 ) } , <nl> - { KEY_2 , ( 0x32 ) } , <nl> - { KEY_3 , ( 0x33 ) } , <nl> - { KEY_4 , ( 0x34 ) } , <nl> - { KEY_5 , ( 0x35 ) } , <nl> - { KEY_6 , ( 0x36 ) } , <nl> - { KEY_7 , ( 0x37 ) } , <nl> - { KEY_8 , ( 0x38 ) } , <nl> - { KEY_9 , ( 0x39 ) } , <nl> - { KEY_A , ( 0x61 ) } , <nl> - { KEY_B , ( 0x62 ) } , <nl> - { KEY_C , ( 0x63 ) } , <nl> - { KEY_D , ( 0x64 ) } , <nl> - { KEY_E , ( 0x65 ) } , <nl> - { KEY_F , ( 0x66 ) } , <nl> - { KEY_G , ( 0x67 ) } , <nl> - { KEY_H , ( 0x68 ) } , <nl> - { KEY_I , ( 0x69 ) } , <nl> - { KEY_J , ( 0x6A ) } , <nl> - { KEY_K , ( 0x6B ) } , <nl> - { KEY_L , ( 0x6C ) } , <nl> - { KEY_M , ( 0x6D ) } , <nl> - { KEY_N , ( 0x6E ) } , <nl> - { KEY_O , ( 0x6F ) } , <nl> - { KEY_P , ( 0x70 ) } , <nl> - { KEY_Q , ( 0x71 ) } , <nl> - { KEY_R , ( 0x72 ) } , <nl> - { KEY_S , ( 0x73 ) } , <nl> - { KEY_T , ( 0x74 ) } , <nl> - { KEY_U , ( 0x75 ) } , <nl> - { KEY_V , ( 0x76 ) } , <nl> - { KEY_W , ( 0x77 ) } , <nl> - { KEY_X , ( 0x78 ) } , <nl> - { KEY_Y , ( 0x79 ) } , <nl> - { KEY_Z , ( 0x7A ) } , <nl> - <nl> - / * <nl> - { KEY_PLAY , VK_PLAY } , / / ( 0xFA ) <nl> - { KEY_STANDBY , VK_SLEEP } , / / ( 0x5F ) <nl> - { KEY_BACK , VK_BROWSER_BACK } , / / ( 0xA6 ) <nl> - { KEY_FORWARD , VK_BROWSER_FORWARD } , / / ( 0xA7 ) <nl> - { KEY_REFRESH , VK_BROWSER_REFRESH } , / / ( 0xA8 ) <nl> - { KEY_STOP , VK_BROWSER_STOP } , / / ( 0xA9 ) <nl> - { KEY_SEARCH , VK_BROWSER_SEARCH } , / / ( 0xAA ) <nl> - { KEY_FAVORITES , VK_BROWSER_FAVORITES } , / / ( 0xAB ) <nl> - { KEY_HOMEPAGE , VK_BROWSER_HOME } , / / ( 0xAC ) <nl> - { KEY_VOLUMEMUTE , VK_VOLUME_MUTE } , / / ( 0xAD ) <nl> - { KEY_VOLUMEDOWN , VK_VOLUME_DOWN } , / / ( 0xAE ) <nl> - { KEY_VOLUMEUP , VK_VOLUME_UP } , / / ( 0xAF ) <nl> - { KEY_MEDIANEXT , VK_MEDIA_NEXT_TRACK } , / / ( 0xB0 ) <nl> - { KEY_MEDIAPREVIOUS , VK_MEDIA_PREV_TRACK } , / / ( 0xB1 ) <nl> - { KEY_MEDIASTOP , VK_MEDIA_STOP } , / / ( 0xB2 ) <nl> - { KEY_LAUNCHMAIL , VK_LAUNCH_MAIL } , / / ( 0xB4 ) <nl> - { KEY_LAUNCHMEDIA , VK_LAUNCH_MEDIA_SELECT } , / / ( 0xB5 ) <nl> - { KEY_LAUNCH0 , VK_LAUNCH_APP1 } , / / ( 0xB6 ) <nl> - { KEY_LAUNCH1 , VK_LAUNCH_APP2 } , / / ( 0xB7 ) <nl> - * / <nl> - <nl> - { KEY_SEMICOLON , 0x3B } , <nl> - { KEY_EQUAL , 0x3D } , <nl> - { KEY_COLON , 0x2C } , <nl> - { KEY_MINUS , 0x2D } , <nl> - { KEY_PERIOD , 0x2E } , <nl> - { KEY_SLASH , 0x2F } , <nl> - { KEY_KP_MULTIPLY , 0x2A } , <nl> - { KEY_KP_ADD , 0x2B } , <nl> - <nl> - { KEY_QUOTELEFT , 0x60 } , <nl> - { KEY_BRACKETLEFT , 0x5B } , <nl> - { KEY_BACKSLASH , 0x5C } , <nl> - { KEY_BRACKETRIGHT , 0x5D } , <nl> - { KEY_APOSTROPHE , 0x27 } , <nl> - <nl> - { KEY_UNKNOWN , 0 } <nl> - } ; <nl> - <nl> - unsigned int KeyMappingHaiku : : get_keysym ( int32 raw_char , int32 key ) { <nl> - if ( raw_char = = B_INSERT & & key = = 0x64 ) { <nl> - return KEY_KP_0 ; <nl> - } <nl> - if ( raw_char = = B_END & & key = = 0x58 ) { <nl> - return KEY_KP_1 ; <nl> - } <nl> - if ( raw_char = = B_DOWN_ARROW & & key = = 0x59 ) { <nl> - return KEY_KP_2 ; <nl> - } <nl> - if ( raw_char = = B_PAGE_DOWN & & key = = 0x5A ) { <nl> - return KEY_KP_3 ; <nl> - } <nl> - if ( raw_char = = B_LEFT_ARROW & & key = = 0x48 ) { <nl> - return KEY_KP_4 ; <nl> - } <nl> - if ( raw_char = = 0x35 & & key = = 0x49 ) { <nl> - return KEY_KP_5 ; <nl> - } <nl> - if ( raw_char = = B_RIGHT_ARROW & & key = = 0x4A ) { <nl> - return KEY_KP_6 ; <nl> - } <nl> - if ( raw_char = = B_HOME & & key = = 0x37 ) { <nl> - return KEY_KP_7 ; <nl> - } <nl> - if ( raw_char = = B_UP_ARROW & & key = = 0x38 ) { <nl> - return KEY_KP_8 ; <nl> - } <nl> - if ( raw_char = = B_PAGE_UP & & key = = 0x39 ) { <nl> - return KEY_KP_9 ; <nl> - } <nl> - if ( raw_char = = 0x2F & & key = = 0x23 ) { <nl> - return KEY_KP_DIVIDE ; <nl> - } <nl> - if ( raw_char = = 0x2D & & key = = 0x25 ) { <nl> - return KEY_KP_SUBTRACT ; <nl> - } <nl> - if ( raw_char = = B_DELETE & & key = = 0x65 ) { <nl> - return KEY_KP_PERIOD ; <nl> - } <nl> - <nl> - if ( raw_char = = 0x10 ) { <nl> - for ( int i = 0 ; _fn_to_keycode [ i ] . keysym ! = KEY_UNKNOWN ; i + + ) { <nl> - if ( _fn_to_keycode [ i ] . keycode = = key ) { <nl> - return _fn_to_keycode [ i ] . keysym ; <nl> - } <nl> - } <nl> - <nl> - return KEY_UNKNOWN ; <nl> - } <nl> - <nl> - for ( int i = 0 ; _hb_to_keycode [ i ] . keysym ! = KEY_UNKNOWN ; i + + ) { <nl> - if ( _hb_to_keycode [ i ] . keycode = = raw_char ) { <nl> - return _hb_to_keycode [ i ] . keysym ; <nl> - } <nl> - } <nl> - <nl> - return KEY_UNKNOWN ; <nl> - } <nl> - <nl> - unsigned int KeyMappingHaiku : : get_modifier_keysym ( int32 key ) { <nl> - for ( int i = 0 ; _mod_to_keycode [ i ] . keysym ! = KEY_UNKNOWN ; i + + ) { <nl> - if ( ( _mod_to_keycode [ i ] . keycode & key ) ! = 0 ) { <nl> - return _mod_to_keycode [ i ] . keysym ; <nl> - } <nl> - } <nl> - <nl> - return KEY_UNKNOWN ; <nl> - } <nl> deleted file mode 100644 <nl> index e735108e440 . . 00000000000 <nl> mmm a / platform / haiku / key_mapping_haiku . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * key_mapping_haiku . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef KEY_MAPPING_HAIKU_H <nl> - # define KEY_MAPPING_HAIKU_H <nl> - <nl> - class KeyMappingHaiku { <nl> - KeyMappingHaiku ( ) { } <nl> - <nl> - public : <nl> - static unsigned int get_keysym ( int32 raw_char , int32 key ) ; <nl> - static unsigned int get_modifier_keysym ( int32 key ) ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index a2d8e242a65 . . 00000000000 <nl> Binary files a / platform / haiku / logo . png and / dev / null differ <nl> deleted file mode 100644 <nl> index 7a2591784fc . . 00000000000 <nl> mmm a / platform / haiku / os_haiku . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * os_haiku . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " os_haiku . h " <nl> - <nl> - # include " drivers / gles2 / rasterizer_gles2 . h " <nl> - # include " main / main . h " <nl> - # include " servers / physics_3d / physics_server_3d_sw . h " <nl> - # include " servers / rendering / rendering_server_raster . h " <nl> - # include " servers / rendering / rendering_server_wrap_mt . h " <nl> - <nl> - # include < Screen . h > <nl> - <nl> - OS_Haiku : : OS_Haiku ( ) { <nl> - # ifdef MEDIA_KIT_ENABLED <nl> - AudioDriverManager : : add_driver ( & driver_media_kit ) ; <nl> - # endif <nl> - } ; <nl> - <nl> - void OS_Haiku : : run ( ) { <nl> - if ( ! main_loop ) { <nl> - return ; <nl> - } <nl> - <nl> - main_loop - > init ( ) ; <nl> - context_gl - > release_current ( ) ; <nl> - <nl> - / / TODO : clean up <nl> - BMessenger * bms = new BMessenger ( window ) ; <nl> - BMessage * msg = new BMessage ( ) ; <nl> - bms - > SendMessage ( LOCKGL_MSG , msg ) ; <nl> - <nl> - window - > StartMessageRunner ( ) ; <nl> - app - > Run ( ) ; <nl> - window - > StopMessageRunner ( ) ; <nl> - <nl> - delete app ; <nl> - <nl> - delete bms ; <nl> - delete msg ; <nl> - main_loop - > finish ( ) ; <nl> - } <nl> - <nl> - String OS_Haiku : : get_name ( ) const { <nl> - return " Haiku " ; <nl> - } <nl> - <nl> - int OS_Haiku : : get_video_driver_count ( ) const { <nl> - return 1 ; <nl> - } <nl> - <nl> - const char * OS_Haiku : : get_video_driver_name ( int p_driver ) const { <nl> - return " GLES2 " ; <nl> - } <nl> - <nl> - int OS_Haiku : : get_current_video_driver ( ) const { <nl> - return video_driver_index ; <nl> - } <nl> - <nl> - Error OS_Haiku : : initialize ( const VideoMode & p_desired , int p_video_driver , int p_audio_driver ) { <nl> - main_loop = nullptr ; <nl> - current_video_mode = p_desired ; <nl> - <nl> - app = new HaikuApplication ( ) ; <nl> - <nl> - BRect frame ; <nl> - frame . Set ( 50 , 50 , 50 + current_video_mode . width - 1 , 50 + current_video_mode . height - 1 ) ; <nl> - <nl> - window = new HaikuDirectWindow ( frame ) ; <nl> - window - > SetVideoMode ( & current_video_mode ) ; <nl> - <nl> - if ( current_video_mode . fullscreen ) { <nl> - window - > SetFullScreen ( true ) ; <nl> - } <nl> - <nl> - if ( ! current_video_mode . resizable ) { <nl> - uint32 flags = window - > Flags ( ) ; <nl> - flags | = B_NOT_RESIZABLE ; <nl> - window - > SetFlags ( flags ) ; <nl> - } <nl> - <nl> - # if defined ( OPENGL_ENABLED ) <nl> - context_gl = memnew ( ContextGL_Haiku ( window ) ) ; <nl> - context_gl - > initialize ( ) ; <nl> - context_gl - > make_current ( ) ; <nl> - context_gl - > set_use_vsync ( current_video_mode . use_vsync ) ; <nl> - / / FIXME : That ' s not how the rasterizer setup should happen . <nl> - RasterizerGLES2 : : register_config ( ) ; <nl> - RasterizerGLES2 : : make_current ( ) ; <nl> - # endif <nl> - <nl> - rendering_server = memnew ( RenderingServerRaster ) ; <nl> - / / FIXME : Reimplement threaded rendering <nl> - if ( get_render_thread_mode ( ) ! = RENDER_THREAD_UNSAFE ) { <nl> - rendering_server = memnew ( RenderingServerWrapMT ( rendering_server , false ) ) ; <nl> - } <nl> - <nl> - ERR_FAIL_COND_V ( ! rendering_server , ERR_UNAVAILABLE ) ; <nl> - <nl> - video_driver_index = p_video_driver ; <nl> - <nl> - input = memnew ( InputDefault ) ; <nl> - window - > SetInput ( input ) ; <nl> - <nl> - window - > Show ( ) ; <nl> - rendering_server - > init ( ) ; <nl> - <nl> - AudioDriverManager : : initialize ( p_audio_driver ) ; <nl> - <nl> - return OK ; <nl> - } <nl> - <nl> - void OS_Haiku : : finalize ( ) { <nl> - if ( main_loop ) { <nl> - memdelete ( main_loop ) ; <nl> - } <nl> - <nl> - main_loop = nullptr ; <nl> - <nl> - rendering_server - > finish ( ) ; <nl> - memdelete ( rendering_server ) ; <nl> - <nl> - memdelete ( input ) ; <nl> - <nl> - # if defined ( OPENGL_ENABLED ) <nl> - memdelete ( context_gl ) ; <nl> - # endif <nl> - } <nl> - <nl> - void OS_Haiku : : set_main_loop ( MainLoop * p_main_loop ) { <nl> - main_loop = p_main_loop ; <nl> - input - > set_main_loop ( p_main_loop ) ; <nl> - window - > SetMainLoop ( p_main_loop ) ; <nl> - } <nl> - <nl> - MainLoop * OS_Haiku : : get_main_loop ( ) const { <nl> - return main_loop ; <nl> - } <nl> - <nl> - void OS_Haiku : : delete_main_loop ( ) { <nl> - if ( main_loop ) { <nl> - memdelete ( main_loop ) ; <nl> - } <nl> - <nl> - main_loop = nullptr ; <nl> - window - > SetMainLoop ( nullptr ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : release_rendering_thread ( ) { <nl> - context_gl - > release_current ( ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : make_rendering_thread ( ) { <nl> - context_gl - > make_current ( ) ; <nl> - } <nl> - <nl> - bool OS_Haiku : : can_draw ( ) const { <nl> - / / TODO : implement <nl> - return true ; <nl> - } <nl> - <nl> - void OS_Haiku : : swap_buffers ( ) { <nl> - context_gl - > swap_buffers ( ) ; <nl> - } <nl> - <nl> - Point2 OS_Haiku : : get_mouse_position ( ) const { <nl> - return window - > GetLastMousePosition ( ) ; <nl> - } <nl> - <nl> - int OS_Haiku : : get_mouse_button_state ( ) const { <nl> - return window - > GetLastButtonMask ( ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_cursor_shape ( CursorShape p_shape ) { <nl> - / / ERR_PRINT ( " set_cursor_shape ( ) NOT IMPLEMENTED " ) ; <nl> - } <nl> - <nl> - OS : : CursorShape OS_Haiku : : get_cursor_shape ( ) const { <nl> - / / TODO : implement get_cursor_shape <nl> - } <nl> - <nl> - void OS_Haiku : : set_custom_mouse_cursor ( const RES & p_cursor , CursorShape p_shape , const Vector2 & p_hotspot ) { <nl> - / / TODO <nl> - } <nl> - <nl> - int OS_Haiku : : get_screen_count ( ) const { <nl> - / / TODO : implement get_screen_count ( ) <nl> - return 1 ; <nl> - } <nl> - <nl> - int OS_Haiku : : get_current_screen ( ) const { <nl> - / / TODO : implement get_current_screen ( ) <nl> - return 0 ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_current_screen ( int p_screen ) { <nl> - / / TODO : implement set_current_screen ( ) <nl> - } <nl> - <nl> - Point2 OS_Haiku : : get_screen_position ( int p_screen ) const { <nl> - / / TODO : make this work with the p_screen parameter <nl> - BScreen * screen = new BScreen ( window ) ; <nl> - BRect frame = screen - > Frame ( ) ; <nl> - delete screen ; <nl> - return Point2i ( frame . left , frame . top ) ; <nl> - } <nl> - <nl> - Size2 OS_Haiku : : get_screen_size ( int p_screen ) const { <nl> - / / TODO : make this work with the p_screen parameter <nl> - BScreen * screen = new BScreen ( window ) ; <nl> - BRect frame = screen - > Frame ( ) ; <nl> - delete screen ; <nl> - return Size2i ( frame . IntegerWidth ( ) + 1 , frame . IntegerHeight ( ) + 1 ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_title ( const String & p_title ) { <nl> - window - > SetTitle ( p_title . utf8 ( ) . get_data ( ) ) ; <nl> - } <nl> - <nl> - Size2 OS_Haiku : : get_window_size ( ) const { <nl> - BSize size = window - > Size ( ) ; <nl> - return Size2i ( size . IntegerWidth ( ) + 1 , size . IntegerHeight ( ) + 1 ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_size ( const Size2 p_size ) { <nl> - / / TODO : why does it stop redrawing after this is called ? <nl> - window - > ResizeTo ( p_size . x , p_size . y ) ; <nl> - } <nl> - <nl> - Point2 OS_Haiku : : get_window_position ( ) const { <nl> - BPoint point ( 0 , 0 ) ; <nl> - window - > ConvertToScreen ( & point ) ; <nl> - return Point2i ( point . x , point . y ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_position ( const Point2 & p_position ) { <nl> - window - > MoveTo ( p_position . x , p_position . y ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_fullscreen ( bool p_enabled ) { <nl> - window - > SetFullScreen ( p_enabled ) ; <nl> - current_video_mode . fullscreen = p_enabled ; <nl> - rendering_server - > init ( ) ; <nl> - } <nl> - <nl> - bool OS_Haiku : : is_window_fullscreen ( ) const { <nl> - return current_video_mode . fullscreen ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_resizable ( bool p_enabled ) { <nl> - uint32 flags = window - > Flags ( ) ; <nl> - <nl> - if ( p_enabled ) { <nl> - flags & = ~ ( B_NOT_RESIZABLE ) ; <nl> - } else { <nl> - flags | = B_NOT_RESIZABLE ; <nl> - } <nl> - <nl> - window - > SetFlags ( flags ) ; <nl> - current_video_mode . resizable = p_enabled ; <nl> - } <nl> - <nl> - bool OS_Haiku : : is_window_resizable ( ) const { <nl> - return current_video_mode . resizable ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_minimized ( bool p_enabled ) { <nl> - window - > Minimize ( p_enabled ) ; <nl> - } <nl> - <nl> - bool OS_Haiku : : is_window_minimized ( ) const { <nl> - return window - > IsMinimized ( ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_window_maximized ( bool p_enabled ) { <nl> - window - > Minimize ( ! p_enabled ) ; <nl> - } <nl> - <nl> - bool OS_Haiku : : is_window_maximized ( ) const { <nl> - return ! window - > IsMinimized ( ) ; <nl> - } <nl> - <nl> - void OS_Haiku : : set_video_mode ( const VideoMode & p_video_mode , int p_screen ) { <nl> - ERR_PRINT ( " set_video_mode ( ) NOT IMPLEMENTED " ) ; <nl> - } <nl> - <nl> - OS : : VideoMode OS_Haiku : : get_video_mode ( int p_screen ) const { <nl> - return current_video_mode ; <nl> - } <nl> - <nl> - void OS_Haiku : : get_fullscreen_mode_list ( List < VideoMode > * p_list , int p_screen ) const { <nl> - ERR_PRINT ( " get_fullscreen_mode_list ( ) NOT IMPLEMENTED " ) ; <nl> - } <nl> - <nl> - String OS_Haiku : : get_executable_path ( ) const { <nl> - return OS : : get_executable_path ( ) ; <nl> - } <nl> - <nl> - bool OS_Haiku : : _check_internal_feature_support ( const String & p_feature ) { <nl> - return p_feature = = " pc " ; <nl> - } <nl> - <nl> - String OS_Haiku : : get_config_path ( ) const { <nl> - if ( has_environment ( " XDG_CONFIG_HOME " ) ) { <nl> - return get_environment ( " XDG_CONFIG_HOME " ) ; <nl> - } else if ( has_environment ( " HOME " ) ) { <nl> - return get_environment ( " HOME " ) . plus_file ( " config / settings " ) ; <nl> - } else { <nl> - return " . " ; <nl> - } <nl> - } <nl> - <nl> - String OS_Haiku : : get_data_path ( ) const { <nl> - if ( has_environment ( " XDG_DATA_HOME " ) ) { <nl> - return get_environment ( " XDG_DATA_HOME " ) ; <nl> - } else if ( has_environment ( " HOME " ) ) { <nl> - return get_environment ( " HOME " ) . plus_file ( " config / data " ) ; <nl> - } else { <nl> - return get_config_path ( ) ; <nl> - } <nl> - } <nl> - <nl> - String OS_Haiku : : get_cache_path ( ) const { <nl> - if ( has_environment ( " XDG_CACHE_HOME " ) ) { <nl> - return get_environment ( " XDG_CACHE_HOME " ) ; <nl> - } else if ( has_environment ( " HOME " ) ) { <nl> - return get_environment ( " HOME " ) . plus_file ( " config / cache " ) ; <nl> - } else { <nl> - return get_config_path ( ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index d3ef9400d47 . . 00000000000 <nl> mmm a / platform / haiku / os_haiku . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * os_haiku . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef OS_HAIKU_H <nl> - # define OS_HAIKU_H <nl> - <nl> - # include " audio_driver_media_kit . h " <nl> - # include " context_gl_haiku . h " <nl> - # include " core / input / input . h " <nl> - # include " drivers / unix / os_unix . h " <nl> - # include " haiku_application . h " <nl> - # include " haiku_direct_window . h " <nl> - # include " servers / audio_server . h " <nl> - # include " servers / rendering_server . h " <nl> - <nl> - class OS_Haiku : public OS_Unix { <nl> - private : <nl> - HaikuApplication * app ; <nl> - HaikuDirectWindow * window ; <nl> - MainLoop * main_loop ; <nl> - InputDefault * input ; <nl> - RenderingServer * rendering_server ; <nl> - VideoMode current_video_mode ; <nl> - int video_driver_index ; <nl> - <nl> - # ifdef MEDIA_KIT_ENABLED <nl> - AudioDriverMediaKit driver_media_kit ; <nl> - # endif <nl> - <nl> - # if defined ( OPENGL_ENABLED ) <nl> - ContextGL_Haiku * context_gl ; <nl> - # endif <nl> - <nl> - virtual void delete_main_loop ( ) ; <nl> - <nl> - protected : <nl> - virtual int get_video_driver_count ( ) const ; <nl> - virtual const char * get_video_driver_name ( int p_driver ) const ; <nl> - virtual int get_current_video_driver ( ) const ; <nl> - <nl> - virtual Error initialize ( const VideoMode & p_desired , int p_video_driver , int p_audio_driver ) ; <nl> - virtual void finalize ( ) ; <nl> - <nl> - virtual void set_main_loop ( MainLoop * p_main_loop ) ; <nl> - <nl> - public : <nl> - OS_Haiku ( ) ; <nl> - void run ( ) ; <nl> - <nl> - virtual String get_name ( ) const ; <nl> - <nl> - virtual MainLoop * get_main_loop ( ) const ; <nl> - <nl> - virtual bool can_draw ( ) const ; <nl> - virtual void release_rendering_thread ( ) ; <nl> - virtual void make_rendering_thread ( ) ; <nl> - virtual void swap_buffers ( ) ; <nl> - <nl> - virtual Point2 get_mouse_position ( ) const ; <nl> - virtual int get_mouse_button_state ( ) const ; <nl> - virtual void set_cursor_shape ( CursorShape p_shape ) ; <nl> - virtual CursorShape get_cursor_shape ( ) const ; <nl> - virtual void set_custom_mouse_cursor ( const RES & p_cursor , CursorShape p_shape , const Vector2 & p_hotspot ) ; <nl> - <nl> - virtual int get_screen_count ( ) const ; <nl> - virtual int get_current_screen ( ) const ; <nl> - virtual void set_current_screen ( int p_screen ) ; <nl> - virtual Point2 get_screen_position ( int p_screen = - 1 ) const ; <nl> - virtual Size2 get_screen_size ( int p_screen = - 1 ) const ; <nl> - virtual void set_window_title ( const String & p_title ) ; <nl> - virtual Size2 get_window_size ( ) const ; <nl> - virtual void set_window_size ( const Size2 p_size ) ; <nl> - virtual Point2 get_window_position ( ) const ; <nl> - virtual void set_window_position ( const Point2 & p_position ) ; <nl> - virtual void set_window_fullscreen ( bool p_enabled ) ; <nl> - virtual bool is_window_fullscreen ( ) const ; <nl> - virtual void set_window_resizable ( bool p_enabled ) ; <nl> - virtual bool is_window_resizable ( ) const ; <nl> - virtual void set_window_minimized ( bool p_enabled ) ; <nl> - virtual bool is_window_minimized ( ) const ; <nl> - virtual void set_window_maximized ( bool p_enabled ) ; <nl> - virtual bool is_window_maximized ( ) const ; <nl> - <nl> - virtual void set_video_mode ( const VideoMode & p_video_mode , int p_screen = 0 ) ; <nl> - virtual VideoMode get_video_mode ( int p_screen = 0 ) const ; <nl> - virtual void get_fullscreen_mode_list ( List < VideoMode > * p_list , int p_screen = 0 ) const ; <nl> - virtual String get_executable_path ( ) const ; <nl> - <nl> - virtual bool _check_internal_feature_support ( const String & p_feature ) ; <nl> - <nl> - virtual String get_config_path ( ) const ; <nl> - virtual String get_data_path ( ) const ; <nl> - virtual String get_cache_path ( ) const ; <nl> - } ; <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index f2d5418adf4 . . 00000000000 <nl> mmm a / platform / haiku / platform_config . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * platform_config . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include < alloca . h > <nl> - <nl> - / / for ifaddrs . h needed in drivers / unix / ip_unix . cpp <nl> - # define _BSD_SOURCE 1 <nl> - <nl> - # define GLES2_INCLUDE_H " thirdparty / glad / glad / glad . h " <nl>
|
Move Haiku platform port to external repository
|
godotengine/godot
|
efcc508ee5c9cf9a6fac0257da7bb36682855e93
|
2020-06-20T15:59:41Z
|
mmm a / core - tests / include / tests . h <nl> ppp b / core - tests / include / tests . h <nl> <nl> # include " client . h " <nl> # include " server . h " <nl> # include " coroutine . h " <nl> - # include " socket . h " <nl> <nl> # include < gtest / gtest . h > <nl> # include < initializer_list > <nl> static inline void coro_test ( coroutine_func_t fn , void * arg = nullptr ) <nl> int complete_num = 0 ; <nl> coro_test_create ( fn , arg , & complete_num ) ; <nl> coro_test_wait ( & complete_num , 1 ) ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl> mmm a / core - tests / src / coroutine / gethostbyname . cpp <nl> ppp b / core - tests / src / coroutine / gethostbyname . cpp <nl> <nl> # include " tests . h " <nl> <nl> - using namespace swoole ; <nl> + # include " coroutine_system . h " <nl> + <nl> using swoole : : coroutine : : System ; <nl> <nl> TEST ( coroutine_gethostbyname , resolve_with_cache ) <nl> mmm a / core - tests / src / coroutine / socket . cpp <nl> ppp b / core - tests / src / coroutine / socket . cpp <nl> <nl> # include " tests . h " <nl> + # include " coroutine_socket . h " <nl> <nl> - using namespace swoole ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> TEST ( coroutine_socket , connect_refused ) <nl> { <nl> mmm a / include / coroutine . h <nl> ppp b / include / coroutine . h <nl> class Coroutine <nl> return cid ; <nl> } <nl> } ; <nl> - <nl> - namespace coroutine <nl> - { <nl> - class System <nl> - { <nl> - public : <nl> - static int sleep ( double sec ) ; <nl> - static swString * read_file ( const char * file , int lock ) ; <nl> - static ssize_t write_file ( const char * file , char * buf , size_t length , int lock , int flags ) ; <nl> - static std : : string gethostbyname ( const std : : string & hostname , int domain , double timeout = - 1 ) ; <nl> - static void set_dns_cache_expire ( time_t expire ) ; <nl> - static void set_dns_cache_capacity ( size_t capacity ) ; <nl> - static void clear_dns_cache ( ) ; <nl> - static bool socket_poll ( std : : unordered_map < int , socket_poll_fd > & fds , double timeout ) ; <nl> - } ; <nl> - } <nl> - ; <nl> - <nl> - struct aio_task <nl> - { <nl> - Coroutine * co ; <nl> - swAio_event * event ; <nl> - } ; <nl> } <nl> <nl> / * * <nl> new file mode 100644 <nl> index 0000000000 . . ce77a9b522 <nl> mmm / dev / null <nl> ppp b / include / coroutine_cxx_api . h <nl> <nl> + # pragma once <nl> + <nl> + # include " coroutine . h " <nl> + # include " coroutine_system . h " <nl> + # include " coroutine_socket . h " <nl> similarity index 96 % <nl> rename from include / socket . h <nl> rename to include / coroutine_socket . h <nl> mmm a / include / socket . h <nl> ppp b / include / coroutine_socket . h <nl> <nl> <nl> # pragma once <nl> <nl> - # include " swoole . h " <nl> # include " coroutine . h " <nl> # include " connection . h " <nl> # include " socks5 . h " <nl> namespace swoole <nl> { <nl> enum swTimeout_type <nl> { <nl> - SW_TIMEOUT_CONNECT = 1u < < 1 , <nl> - SW_TIMEOUT_READ = 1u < < 2 , <nl> - SW_TIMEOUT_WRITE = 1u < < 3 , <nl> - SW_TIMEOUT_RDWR = SW_TIMEOUT_READ | SW_TIMEOUT_WRITE , <nl> - SW_TIMEOUT_ALL = 0xff , <nl> + SW_TIMEOUT_CONNECT = 1u < < 1 , <nl> + SW_TIMEOUT_READ = 1u < < 2 , <nl> + SW_TIMEOUT_WRITE = 1u < < 3 , <nl> + SW_TIMEOUT_RDWR = SW_TIMEOUT_READ | SW_TIMEOUT_WRITE , <nl> + SW_TIMEOUT_ALL = 0xff , <nl> } ; <nl> + } <nl> + <nl> + namespace swoole { namespace coroutine { <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> class Socket <nl> { <nl> public : <nl> class Socket <nl> double startup_time ; <nl> } ; <nl> } ; <nl> - } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + } } <nl> new file mode 100644 <nl> index 0000000000 . . 6cfc4e97a6 <nl> mmm / dev / null <nl> ppp b / include / coroutine_system . h <nl> <nl> + / * <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Swoole | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | This source file is subject to version 2 . 0 of the Apache license , | <nl> + | that is bundled with this package in the file LICENSE , and is | <nl> + | available through the world - wide - web at the following url : | <nl> + | http : / / www . apache . org / licenses / LICENSE - 2 . 0 . html | <nl> + | If you did not receive a copy of the Apache2 . 0 license and are unable | <nl> + | to obtain it through the world - wide - web , please send a note to | <nl> + | license @ swoole . com so we can mail you a copy immediately . | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Author : Tianfeng Han < mikan . tenny @ gmail . com > | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include " coroutine . h " <nl> + <nl> + namespace swoole { namespace coroutine { <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + class System <nl> + { <nl> + public : <nl> + static int sleep ( double sec ) ; <nl> + static swString * read_file ( const char * file , int lock ) ; <nl> + static ssize_t write_file ( const char * file , char * buf , size_t length , int lock , int flags ) ; <nl> + static std : : string gethostbyname ( const std : : string & hostname , int domain , double timeout = - 1 ) ; <nl> + static void set_dns_cache_expire ( time_t expire ) ; <nl> + static void set_dns_cache_capacity ( size_t capacity ) ; <nl> + static void clear_dns_cache ( ) ; <nl> + static bool socket_poll ( std : : unordered_map < int , socket_poll_fd > & fds , double timeout ) ; <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + } } <nl> mmm a / php_swoole_cxx . h <nl> ppp b / php_swoole_cxx . h <nl> <nl> <nl> SW_API bool php_swoole_export_socket ( zval * object , int fd , enum swSocket_type type ) ; <nl> SW_API zend_object * php_swoole_export_socket_ex ( int fd , enum swSocket_type type ) ; <nl> - SW_API void php_swoole_client_set ( swoole : : Socket * cli , zval * zset ) ; <nl> + SW_API void php_swoole_client_set ( swoole : : coroutine : : Socket * cli , zval * zset ) ; <nl> <nl> namespace zend <nl> { <nl> mmm a / src / coroutine / file_lock . cc <nl> ppp b / src / coroutine / file_lock . cc <nl> <nl> * / <nl> <nl> # include " swoole . h " <nl> - <nl> # include " coroutine . h " <nl> - # include " socket . h " <nl> - # include " api . h " <nl> # include " coroutine_c_api . h " <nl> <nl> # include < fcntl . h > <nl> mmm a / src / coroutine / hook . cc <nl> ppp b / src / coroutine / hook . cc <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> * / <nl> <nl> - # include " socket . h " <nl> - # include " async . h " <nl> - # include " coroutine . h " <nl> - <nl> - # ifndef _WIN32 <nl> + # include " swoole . h " <nl> + # include " coroutine_cxx_api . h " <nl> <nl> # include < sys / file . h > <nl> # include < sys / types . h > <nl> <nl> # include < string > <nl> # include < iostream > <nl> <nl> - using namespace swoole ; <nl> + using swoole : : Coroutine ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> extern " C " <nl> { <nl> struct dirent * swoole_coroutine_readdir ( DIR * dirp ) <nl> } <nl> # endif <nl> } <nl> - <nl> - # endif <nl> mmm a / src / coroutine / socket . cc <nl> ppp b / src / coroutine / socket . cc <nl> <nl> - # include " socket . h " <nl> - # include " async . h " <nl> + # include " coroutine . h " <nl> + # include " coroutine_socket . h " <nl> + # include " coroutine_system . h " <nl> # include " buffer . h " <nl> # include " base64 . h " <nl> <nl> <nl> using namespace swoole ; <nl> using namespace std ; <nl> using swoole : : coroutine : : System ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> double Socket : : default_connect_timeout = SW_DEFAULT_SOCKET_CONNECT_TIMEOUT ; <nl> double Socket : : default_read_timeout = SW_DEFAULT_SOCKET_READ_TIMEOUT ; <nl> mmm a / src / coroutine / system . cc <nl> ppp b / src / coroutine / system . cc <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> * / <nl> <nl> - # include " socket . h " <nl> - # include " async . h " <nl> - # include " coroutine . h " <nl> - <nl> + # include " coroutine_system . h " <nl> # include " lru_cache . h " <nl> <nl> - using namespace swoole ; <nl> using namespace std ; <nl> + using namespace swoole ; <nl> using swoole : : coroutine : : System ; <nl> <nl> + struct aio_task <nl> + { <nl> + Coroutine * co ; <nl> + swAio_event * event ; <nl> + } ; <nl> + <nl> static size_t dns_cache_capacity = 1000 ; <nl> static time_t dns_cache_expire = 60 ; <nl> static LRUCache * dns_cache = nullptr ; <nl> mmm a / swoole_async_coro . cc <nl> ppp b / swoole_async_coro . cc <nl> <nl> # include " php_network . h " <nl> <nl> # include " ext / standard / file . h " <nl> - <nl> - # ifdef SW_COROUTINE <nl> - # include " swoole_coroutine . h " <nl> # include " ext / standard / basic_functions . h " <nl> - # endif <nl> <nl> # include < string > <nl> # include < unordered_map > <nl> <nl> - using namespace swoole ; <nl> + using swoole : : PHPCoroutine ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> typedef struct <nl> { <nl> mmm a / swoole_client_coro . cc <nl> ppp b / swoole_client_coro . cc <nl> <nl> <nl> # include " ext / standard / basic_functions . h " <nl> <nl> + using swoole : : coroutine : : Socket ; <nl> + <nl> enum client_property <nl> { <nl> client_property_callback = 0 , <nl> mmm a / swoole_coroutine . cc <nl> ppp b / swoole_coroutine . cc <nl> <nl> * / <nl> <nl> # include " php_swoole_cxx . h " <nl> - # include " swoole_coroutine . h " <nl> <nl> using namespace swoole ; <nl> <nl> mmm a / swoole_coroutine . h <nl> ppp b / swoole_coroutine . h <nl> <nl> # pragma once <nl> <nl> - # include " coroutine . h " <nl> - # include " socket . h " <nl> + # include " coroutine_cxx_api . h " <nl> # include " zend_vm . h " <nl> # include " zend_closures . h " <nl> <nl> mmm a / swoole_coroutine_util . cc <nl> ppp b / swoole_coroutine_util . cc <nl> <nl> # include < string > <nl> # include < unordered_map > <nl> <nl> - using namespace swoole ; <nl> using namespace std ; <nl> using swoole : : coroutine : : System ; <nl> + using swoole : : coroutine : : Socket ; <nl> + using swoole : : Coroutine ; <nl> + using swoole : : PHPCoroutine ; <nl> <nl> typedef struct <nl> { <nl> mmm a / swoole_http_client_coro . cc <nl> ppp b / swoole_http_client_coro . cc <nl> <nl> * / <nl> <nl> # include " php_swoole_cxx . h " <nl> - <nl> - # include " swoole_http_client . h " <nl> - # include " swoole_coroutine . h " <nl> # include " coroutine_c_api . h " <nl> + # include " swoole_http_client . h " <nl> <nl> # include " mime_types . h " <nl> # include " base64 . h " <nl> <nl> using namespace swoole ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> swString * http_client_buffer ; <nl> <nl> mmm a / swoole_http_v2_client_coro . cc <nl> ppp b / swoole_http_v2_client_coro . cc <nl> <nl> # include " swoole_http . h " <nl> <nl> # ifdef SW_USE_HTTP2 <nl> - # include " swoole_coroutine . h " <nl> # include " swoole_http_v2_client . h " <nl> <nl> # include < vector > <nl> <nl> using namespace swoole ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> static zend_class_entry * swoole_http2_client_coro_ce ; <nl> static zend_object_handlers swoole_http2_client_coro_handlers ; <nl> mmm a / swoole_mysql_coro . cc <nl> ppp b / swoole_mysql_coro . cc <nl> <nl> <nl> # include " php_swoole_cxx . h " <nl> <nl> - # include " swoole_coroutine . h " <nl> # include " swoole_mysql_coro . h " <nl> <nl> # include " error . h " <nl> extern " C " { <nl> } <nl> <nl> using namespace swoole ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> static PHP_METHOD ( swoole_mysql_coro , __construct ) ; <nl> static PHP_METHOD ( swoole_mysql_coro , __destruct ) ; <nl> mmm a / swoole_redis_coro . cc <nl> ppp b / swoole_redis_coro . cc <nl> <nl> * / <nl> <nl> # include " php_swoole_cxx . h " <nl> - # include " swoole_coroutine . h " <nl> <nl> # include " thirdparty / hiredis / hiredis . h " <nl> # include " thirdparty / hiredis / async . h " <nl> <nl> # include " ext / standard / php_var . h " <nl> <nl> using namespace swoole ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> # define SW_REDIS_COMMAND_ALLOC_ARGS_ARR zval * z_args = ( zval * ) emalloc ( argc * sizeof ( zval ) ) ; <nl> # define SW_REDIS_COMMAND_ARGS_TYPE ( arg ) Z_TYPE ( arg ) <nl> mmm a / swoole_runtime . cc <nl> ppp b / swoole_runtime . cc <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> * / <nl> # include " php_swoole_cxx . h " <nl> - # include " swoole_coroutine . h " <nl> <nl> # include < unordered_map > <nl> # include < initializer_list > <nl> <nl> using namespace swoole ; <nl> using namespace std ; <nl> using swoole : : coroutine : : System ; <nl> + using swoole : : coroutine : : Socket ; <nl> <nl> extern " C " <nl> { <nl> mmm a / swoole_socket_coro . cc <nl> ppp b / swoole_socket_coro . cc <nl> <nl> * / <nl> <nl> # include " php_swoole_cxx . h " <nl> - # include " swoole_coroutine . h " <nl> <nl> # include " thirdparty / sockets / php_sockets_cxx . h " <nl> <nl> mmm a / thirdparty / sockets / conversions . cc <nl> ppp b / thirdparty / sockets / conversions . cc <nl> struct _ser_context <nl> zend_llist keys , <nl> / * common part to res_context ends here * / <nl> allocations ; <nl> - swoole : : Socket * sock ; <nl> + Socket * sock ; <nl> } ; <nl> <nl> struct _res_context <nl> static void free_from_zval_allocation ( void * alloc_ptr_ptr ) <nl> efree ( * ( void * * ) alloc_ptr_ptr ) ; <nl> } <nl> <nl> - void * from_zval_run_conversions ( const zval * container , swoole : : Socket * sock , from_zval_write_field * writer , <nl> + void * from_zval_run_conversions ( const zval * container , Socket * sock , from_zval_write_field * writer , <nl> size_t struct_size , const char * top_name , zend_llist * * allocations / * out * / , struct err_s * err / * in / out * / ) <nl> { <nl> ser_context ctx ; <nl> mmm a / thirdparty / sockets / conversions . h <nl> ppp b / thirdparty / sockets / conversions . h <nl> void to_zval_read_ucred ( const char * data , zval * zv , res_context * ctx ) ; <nl> void from_zval_write_msghdr_recv ( const zval * container , char * msghdr_c , ser_context * ctx ) ; <nl> <nl> / * ENTRY POINTS FOR CONVERSIONS * / <nl> - void * from_zval_run_conversions ( const zval * container , swoole : : Socket * sock , from_zval_write_field * writer , <nl> + void * from_zval_run_conversions ( const zval * container , Socket * sock , from_zval_write_field * writer , <nl> size_t struct_size , const char * top_name , zend_llist * * allocations / * out * / , struct err_s * err / * in / out * / ) ; <nl> <nl> zval * to_zval_run_conversions ( const char * structure , to_zval_read_field * reader , const char * top_name , <nl> mmm a / thirdparty / sockets / multicast . h <nl> ppp b / thirdparty / sockets / multicast . h <nl> <nl> <nl> # include " php_swoole_cxx . h " <nl> <nl> + using swoole : : coroutine : : Socket ; <nl> + <nl> # if defined ( MCAST_JOIN_GROUP ) & & ! defined ( __APPLE__ ) <nl> # define RFC3678_API 1 <nl> / * has block / unblock and source membership , in this case for both IPv4 and IPv6 * / <nl> <nl> # define PHP_MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP <nl> # endif <nl> <nl> - int php_do_setsockopt_ip_mcast ( swoole : : Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> - int php_do_setsockopt_ipv6_mcast ( swoole : : Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> - int php_if_index_to_addr4 ( unsigned if_index , swoole : : Socket * php_sock , struct in_addr * out_addr ) ; <nl> - int php_add4_to_if_index ( struct in_addr * addr , swoole : : Socket * php_sock , unsigned * if_index ) ; <nl> + int php_do_setsockopt_ip_mcast ( Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> + int php_do_setsockopt_ipv6_mcast ( Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> + int php_if_index_to_addr4 ( unsigned if_index , Socket * php_sock , struct in_addr * out_addr ) ; <nl> + int php_add4_to_if_index ( struct in_addr * addr , Socket * php_sock , unsigned * if_index ) ; <nl> int php_string_to_if_index ( const char * val , unsigned * out ) ; <nl> - int php_mcast_join ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , unsigned int if_index ) ; <nl> + int php_mcast_join ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , unsigned int if_index ) ; <nl> <nl> - int php_mcast_leave ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> + int php_mcast_leave ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> unsigned int if_index ) ; <nl> <nl> # ifdef HAS_MCAST_EXT <nl> - int php_mcast_join_source ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> + int php_mcast_join_source ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> struct sockaddr * source , socklen_t source_len , unsigned int if_index ) ; <nl> <nl> - int php_mcast_leave_source ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> + int php_mcast_leave_source ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> struct sockaddr * source , socklen_t source_len , unsigned int if_index ) ; <nl> <nl> - int php_mcast_block_source ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> + int php_mcast_block_source ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> struct sockaddr * source , socklen_t source_len , unsigned int if_index ) ; <nl> <nl> - int php_mcast_unblock_source ( swoole : : Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> + int php_mcast_unblock_source ( Socket * sock , int level , struct sockaddr * group , socklen_t group_len , <nl> struct sockaddr * source , socklen_t source_len , unsigned int if_index ) ; <nl> # endif <nl> mmm a / thirdparty / sockets / php_sockets_cxx . h <nl> ppp b / thirdparty / sockets / php_sockets_cxx . h <nl> <nl> # include " thirdparty / sockets / multicast . h " <nl> # include " thirdparty / sockets / conversions . h " <nl> <nl> + using swoole : : coroutine : : Socket ; <nl> + <nl> # define PHP_SWOOLE_SOCKET_ERROR ( socket , msg , errn ) \ <nl> do { \ <nl> int _err = ( errn ) ; / * save value to avoid repeated calls to WSAGetLastError ( ) on Windows * / \ <nl> <nl> } \ <nl> } while ( 0 ) <nl> <nl> - int php_do_setsockopt_ipv6_rfc3542 ( swoole : : Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> - int php_do_getsockopt_ipv6_rfc3542 ( swoole : : Socket * php_sock , int level , int optname , zval * result ) ; <nl> + int php_do_setsockopt_ipv6_rfc3542 ( Socket * php_sock , int level , int optname , zval * arg4 ) ; <nl> + int php_do_getsockopt_ipv6_rfc3542 ( Socket * php_sock , int level , int optname , zval * result ) ; <nl> <nl> int php_string_to_if_index ( const char * val , unsigned * out ) ; <nl> <nl> int php_string_to_if_index ( const char * val , unsigned * out ) ; <nl> * The IPv6 literal can be a IPv4 mapped address ( like : : ffff : 127 . 0 . 0 . 1 ) . <nl> * If the hostname yields no IPv6 addresses , a mapped IPv4 address may be returned ( AI_V4MAPPED ) <nl> * / <nl> - int php_set_inet6_addr ( struct sockaddr_in6 * sin6 , char * string , swoole : : Socket * php_sock ) ; <nl> + int php_set_inet6_addr ( struct sockaddr_in6 * sin6 , char * string , Socket * php_sock ) ; <nl> <nl> / * <nl> * Convert an IPv4 literal or a hostname into a sockaddr_in . <nl> * / <nl> - int php_set_inet_addr ( struct sockaddr_in * sin , char * string , swoole : : Socket * php_sock ) ; <nl> + int php_set_inet_addr ( struct sockaddr_in * sin , char * string , Socket * php_sock ) ; <nl> <nl> / * <nl> * Calls either php_set_inet6_addr ( ) or php_set_inet_addr ( ) , depending on the type of the socket . <nl> * / <nl> - int php_set_inet46_addr ( php_sockaddr_storage * ss , socklen_t * ss_len , char * string , swoole : : Socket * php_sock ) ; <nl> + int php_set_inet46_addr ( php_sockaddr_storage * ss , socklen_t * ss_len , char * string , Socket * php_sock ) ; <nl> mmm a / thirdparty / sockets / sendrecvmsg . cc <nl> ppp b / thirdparty / sockets / sendrecvmsg . cc <nl> <nl> } while ( 0 ) <nl> <nl> <nl> - int php_do_setsockopt_ipv6_rfc3542 ( swoole : : Socket * php_sock , int level , int optname , zval * arg4 ) <nl> + int php_do_setsockopt_ipv6_rfc3542 ( Socket * php_sock , int level , int optname , zval * arg4 ) <nl> { <nl> # ifdef IPV6_PKTINFO <nl> struct err_s err = { 0 } ; <nl> int php_do_setsockopt_ipv6_rfc3542 ( swoole : : Socket * php_sock , int level , int optn <nl> return retval ! = 0 ? FAILURE : SUCCESS ; <nl> } <nl> <nl> - int php_do_getsockopt_ipv6_rfc3542 ( swoole : : Socket * php_sock , int level , int optname , zval * result ) <nl> + int php_do_getsockopt_ipv6_rfc3542 ( Socket * php_sock , int level , int optname , zval * result ) <nl> { <nl> struct err_s err = <nl> { 0 } ; <nl> mmm a / thirdparty / sockets / sockaddr_conv . cc <nl> ppp b / thirdparty / sockets / sockaddr_conv . cc <nl> <nl> # include < arpa / inet . h > <nl> <nl> / * Sets addr by hostname , or by ip in string form ( AF_INET6 ) * / <nl> - int php_set_inet6_addr ( struct sockaddr_in6 * sin6 , char * string , swoole : : Socket * php_sock ) / * { { { * / <nl> + int php_set_inet6_addr ( struct sockaddr_in6 * sin6 , char * string , Socket * php_sock ) / * { { { * / <nl> { <nl> struct in6_addr tmp ; <nl> # if HAVE_GETADDRINFO <nl> int php_set_inet6_addr ( struct sockaddr_in6 * sin6 , char * string , swoole : : Socket * <nl> / * } } } * / <nl> <nl> / * Sets addr by hostname , or by ip in string form ( AF_INET ) * / <nl> - int php_set_inet_addr ( struct sockaddr_in * sin , char * string , swoole : : Socket * php_sock ) / * { { { * / <nl> + int php_set_inet_addr ( struct sockaddr_in * sin , char * string , Socket * php_sock ) / * { { { * / <nl> { <nl> struct in_addr tmp ; <nl> struct hostent * host_entry ; <nl> int php_set_inet_addr ( struct sockaddr_in * sin , char * string , swoole : : Socket * php <nl> <nl> / * Sets addr by hostname or by ip in string form ( AF_INET or AF_INET6 , <nl> * depending on the socket ) * / <nl> - int php_set_inet46_addr ( php_sockaddr_storage * ss , socklen_t * ss_len , char * string , swoole : : Socket * php_sock ) / * { { { * / <nl> + int php_set_inet46_addr ( php_sockaddr_storage * ss , socklen_t * ss_len , char * string , Socket * php_sock ) / * { { { * / <nl> { <nl> if ( php_sock - > sock_type = = AF_INET ) { <nl> struct sockaddr_in t = { 0 } ; <nl>
|
Refactoring engineering structure
|
swoole/swoole-src
|
b1f66c95580a648548e14e068e2fbab711ca0914
|
2019-05-08T06:32:13Z
|
mmm a / src / TrackerWatcherCommand . cc <nl> ppp b / src / TrackerWatcherCommand . cc <nl> bool TrackerWatcherCommand : : execute ( ) { <nl> A2_LOG_ERROR_EX ( EX_EXCEPTION_CAUGHT , ex ) ; <nl> } <nl> } <nl> - } else if ( trackerRequestGroup_ - > downloadFinished ( ) ) { <nl> + } else if ( trackerRequestGroup_ - > getNumCommand ( ) = = 0 & & <nl> + trackerRequestGroup_ - > downloadFinished ( ) ) { <nl> + / / We really want to make sure that tracker request has finished <nl> + / / by checking getNumCommand ( ) = = 0 . Because we reset <nl> + / / trackerRequestGroup_ , if it is still used in other Command , we <nl> + / / will get Segmentation fault . <nl> try { <nl> std : : string trackerResponse = getTrackerResponse ( trackerRequestGroup_ ) ; <nl> <nl>
|
Ensure that num of commands is 0 before processing tracker response
|
aria2/aria2
|
e2bf627b17c5a25692a5a4d530e1774d95cc6a46
|
2012-09-02T08:43:26Z
|
mmm a / code / search / src / exponential_search / exponential_search . py <nl> ppp b / code / search / src / exponential_search / exponential_search . py <nl> <nl> ' ' ' <nl> - <nl> - Exponential Search <nl> - <nl> + Part of Cosmos by OpenGenus Foundation <nl> ' ' ' <nl> <nl> <nl> mmm a / code / search / src / jump_search / jump_search . py <nl> ppp b / code / search / src / jump_search / jump_search . py <nl> <nl> + ' ' ' <nl> + Part of Cosmos by OpenGenus Foundation <nl> + ' ' ' <nl> + <nl> + <nl> import math <nl> <nl> <nl>
|
update
|
OpenGenus/cosmos
|
4c9abacfc29bf479e028586b460597248558ba83
|
2018-02-20T06:51:56Z
|
mmm a / xbmc / filesystem / MythDirectory . cpp <nl> ppp b / xbmc / filesystem / MythDirectory . cpp <nl> bool CMythDirectory : : GetRecordings ( const CStdString & base , CFileItemList & items , <nl> m_dll - > ref_release ( program ) ; <nl> } <nl> } <nl> + m_dll - > ref_release ( list ) ; <nl> <nl> / * <nl> * Don ' t sort by name for TV_SHOWS as they all have the same name , so only date sort is useful . <nl> bool CMythDirectory : : GetTvShowFolders ( const CStdString & base , CFileItemList & ite <nl> } <nl> <nl> } <nl> + m_dll - > ref_release ( list ) ; <nl> <nl> if ( g_guiSettings . GetBool ( " filelists . ignorethewhensorting " ) ) <nl> items . AddSortMethod ( SORT_METHOD_LABEL_IGNORE_THE , 551 / * Name * / , LABEL_MASKS ( " " , " " , " % L " , " % J " ) ) ; <nl> mmm a / xbmc / filesystem / MythSession . cpp <nl> ppp b / xbmc / filesystem / MythSession . cpp <nl> void CMythSession : : Process ( ) <nl> break ; <nl> case CMYTH_EVENT_RECORDING_LIST_CHANGE : <nl> CLog : : Log ( LOGDEBUG , " % s - MythTV event RECORDING_LIST_CHANGE " , __FUNCTION__ ) ; <nl> - GetAllRecordedPrograms ( true ) ; <nl> + ResetAllRecordedPrograms ( ) ; <nl> break ; <nl> case CMYTH_EVENT_RECORDING_LIST_CHANGE_ADD : <nl> CLog : : Log ( LOGDEBUG , " % s - MythTV event RECORDING_LIST_CHANGE_ADD : % s " , __FUNCTION__ , buf ) ; <nl> - GetAllRecordedPrograms ( true ) ; <nl> + ResetAllRecordedPrograms ( ) ; <nl> break ; <nl> case CMYTH_EVENT_RECORDING_LIST_CHANGE_UPDATE : <nl> CLog : : Log ( LOGDEBUG , " % s - MythTV event RECORDING_LIST_CHANGE_UPDATE " , __FUNCTION__ ) ; <nl> - GetAllRecordedPrograms ( true ) ; <nl> + ResetAllRecordedPrograms ( ) ; <nl> break ; <nl> case CMYTH_EVENT_RECORDING_LIST_CHANGE_DELETE : <nl> CLog : : Log ( LOGDEBUG , " % s - MythTV event RECORDING_LIST_CHANGE_DELETE : % s " , __FUNCTION__ , buf ) ; <nl> - GetAllRecordedPrograms ( true ) ; <nl> + ResetAllRecordedPrograms ( ) ; <nl> break ; <nl> case CMYTH_EVENT_SCHEDULE_CHANGE : <nl> CLog : : Log ( LOGDEBUG , " % s - MythTV event SCHEDULE_CHANGE " , __FUNCTION__ ) ; <nl> DllLibCMyth * CMythSession : : GetLibrary ( ) <nl> return NULL ; <nl> } <nl> <nl> - cmyth_proglist_t CMythSession : : GetAllRecordedPrograms ( bool force ) <nl> + / * <nl> + * The caller must call m_dll - > ref_release ( ) when finished . <nl> + * / <nl> + cmyth_proglist_t CMythSession : : GetAllRecordedPrograms ( ) <nl> { <nl> - if ( ! m_all_recorded | | force ) <nl> + CSingleLock lock ( m_section ) ; <nl> + if ( ! m_all_recorded ) <nl> { <nl> - CSingleLock lock ( m_section ) ; <nl> if ( m_all_recorded ) <nl> { <nl> m_dll - > ref_release ( m_all_recorded ) ; <nl> cmyth_proglist_t CMythSession : : GetAllRecordedPrograms ( bool force ) <nl> <nl> m_all_recorded = m_dll - > proglist_get_all_recorded ( control ) ; <nl> } <nl> + / * <nl> + * An extra reference is needed to prevent a race condition while resetting the proglist from <nl> + * the Process ( ) thread while it is being read . <nl> + * / <nl> + m_dll - > ref_hold ( m_all_recorded ) ; <nl> + <nl> return m_all_recorded ; <nl> } <nl> <nl> + void CMythSession : : ResetAllRecordedPrograms ( ) <nl> + { <nl> + CSingleLock lock ( m_section ) ; <nl> + if ( m_all_recorded ) <nl> + { <nl> + m_dll - > ref_release ( m_all_recorded ) ; <nl> + m_all_recorded = NULL ; <nl> + } <nl> + return ; <nl> + } <nl> + <nl> void CMythSession : : LogCMyth ( int level , char * msg ) <nl> { <nl> int xbmc_lvl = - 1 ; <nl> mmm a / xbmc / filesystem / MythSession . h <nl> ppp b / xbmc / filesystem / MythSession . h <nl> class CMythSession <nl> cmyth_conn_t GetControl ( ) ; <nl> cmyth_database_t GetDatabase ( ) ; <nl> DllLibCMyth * GetLibrary ( ) ; <nl> - cmyth_proglist_t GetAllRecordedPrograms ( bool force = false ) ; <nl> + cmyth_proglist_t GetAllRecordedPrograms ( ) ; <nl> <nl> void SetFileItemMetaData ( CFileItem & item , cmyth_proginfo_t program ) ; <nl> <nl> class CMythSession <nl> <nl> void SetSeasonAndEpisode ( const cmyth_proginfo_t & program , int * season , int * epsiode ) ; <nl> <nl> + void ResetAllRecordedPrograms ( ) ; <nl> + <nl> IEventListener * m_listener ; <nl> cmyth_conn_t m_control ; <nl> cmyth_conn_t m_event ; <nl>
|
Merge pull request from dteirney / myth
|
xbmc/xbmc
|
8f591da9ed4db3e121801b2fc6f07262d4001822
|
2011-06-12T09:56:59Z
|
mmm a / hphp / hack / src / parser / coroutine / coroutine_lowerer . ml <nl> ppp b / hphp / hack / src / parser / coroutine / coroutine_lowerer . ml <nl> let rewrite_method_or_function <nl> new_header_node in <nl> ( new_header_node , new_body , closure_syntax ) <nl> <nl> - ( * * <nl> - * If the function declaration is for a coroutine , rewrites the declaration <nl> - * header and the function body into a desugared coroutine implementation . <nl> - * Also extracts the coroutine ' s closure . <nl> - * ) <nl> - let maybe_rewrite_classish_body_element <nl> - classish_name <nl> - classish_type_parameters <nl> - classish_body_element_node = <nl> - match syntax classish_body_element_node with <nl> - | MethodishDeclaration ( { <nl> - methodish_function_decl_header = { <nl> - syntax = FunctionDeclarationHeader ( { <nl> - function_coroutine ; <nl> - _ ; <nl> - } as header_node ) ; <nl> - _ ; <nl> - } ; <nl> - methodish_function_body ; <nl> - _ ; <nl> - } as method_node ) when not @ @ is_missing function_coroutine - > <nl> - let ( new_header_node , new_body , closure_syntax ) = <nl> - rewrite_method_or_function <nl> - classish_name <nl> - classish_type_parameters <nl> - header_node <nl> - methodish_function_body in <nl> - let new_method_syntax = <nl> - CoroutineMethodLowerer . rewrite_methodish_declaration <nl> - classish_name <nl> - classish_type_parameters <nl> - method_node <nl> - new_header_node <nl> - new_body in <nl> - Some ( new_method_syntax , closure_syntax ) <nl> - | _ - > <nl> - ( * Irrelevant input . * ) <nl> - None <nl> - <nl> - let compute_body_nodes classish_name classish_type_parameters = <nl> - let gather_rewritten_syntaxes <nl> - classish_body_element_node <nl> - ( classish_body_elements_acc , closures_acc , any_rewritten_acc ) = <nl> - Option . value_map <nl> - ( maybe_rewrite_classish_body_element <nl> - classish_name <nl> - classish_type_parameters <nl> - classish_body_element_node ) <nl> - ~ default : <nl> - ( classish_body_element_node : : classish_body_elements_acc , <nl> - closures_acc , <nl> - any_rewritten_acc ) <nl> - ~ f : ( fun ( rewritten_method_syntax , closure_syntax ) - > <nl> - rewritten_method_syntax : : classish_body_elements_acc , <nl> - closure_syntax : : closures_acc , <nl> - true ) in <nl> - List . fold_right ~ f : gather_rewritten_syntaxes ~ init : ( [ ] , [ ] , false ) <nl> - <nl> - ( * * <nl> - * Rewrites classish body elements . If at least one element is modified , then <nl> - * returns Some with all of the nodes . Otherwise , returns None . <nl> - * ) <nl> - let maybe_rewrite_classish_body_elements <nl> - classish_name <nl> - classish_type_parameters <nl> - classish_body_elements_node = <nl> - let rewritten_nodes , closure_nodes , any_rewritten = <nl> - classish_body_elements_node <nl> - | > syntax_node_to_list <nl> - | > compute_body_nodes classish_name classish_type_parameters in <nl> - Option . some_if any_rewritten ( make_list rewritten_nodes , closure_nodes ) <nl> - <nl> - ( * * <nl> - * If the class contains at least one coroutine method , then those methods are <nl> - * rewritten , and closures are generated as necessary . Otherwise , the <nl> - * class is not transformed . <nl> - * ) <nl> - let maybe_rewrite_class node = <nl> - match syntax node with <nl> - | ClassishDeclaration ( { <nl> - classish_body = { <nl> - syntax = ClassishBody ( { <nl> - classish_body_elements ; <nl> - _ ; <nl> - } as classish_body_node ) ; <nl> - _ ; <nl> - } ; <nl> - classish_name ; <nl> - classish_type_parameters ; <nl> - _ ; <nl> - } as class_node ) - > <nl> - Option . map <nl> - ( maybe_rewrite_classish_body_elements <nl> - classish_name classish_type_parameters classish_body_elements ) <nl> - ~ f : ( fun ( classish_body_elements , closure_nodes ) - > <nl> - make_syntax @ @ ClassishDeclaration { <nl> - class_node with classish_body = make_syntax @ @ ClassishBody { <nl> - classish_body_node with classish_body_elements ; <nl> - } ; <nl> - } , <nl> - closure_nodes ) <nl> - | _ - > <nl> - ( * Irrelevant input . * ) <nl> - None <nl> - <nl> - ( * * <nl> - * Rewrites toplevel classes . The class nodes themselves are transformed <nl> - * directly . Generated closure nodes are collected and written alongside <nl> - * of the class nodes . <nl> - * ) <nl> - let rewrite_classes node ( node_acc , any_rewritten_acc ) = <nl> - Option . value_map <nl> - ( maybe_rewrite_class node ) <nl> - ~ default : ( node : : node_acc , any_rewritten_acc ) <nl> - ~ f : ( fun ( node , closure_nodes ) - > <nl> - node : : ( closure_nodes @ node_acc ) , true ) <nl> - <nl> - ( * * <nl> - * Rewrites classes containing coroutine methods . Additional closure classes <nl> - * may be generated alongside of the original class . <nl> - * ) <nl> - let maybe_rewrite_syntax_list node = <nl> - match syntax node with <nl> - | SyntaxList syntax_list - > <nl> - let rewritten_nodes , any_rewritten = <nl> - List . fold_right <nl> - ~ f : rewrite_classes <nl> - ~ init : ( [ ] , false ) <nl> - syntax_list in <nl> - if any_rewritten then <nl> - Rewriter . Result . Replace ( make_list rewritten_nodes ) <nl> - else <nl> - Rewriter . Result . Keep <nl> - | _ - > <nl> - ( * Irrelevant input . * ) <nl> - Rewriter . Result . Keep <nl> - <nl> let lower_coroutine_function original_header original_body original_function = <nl> let ( new_header_node , new_body , closure_syntax ) = <nl> rewrite_method_or_function <nl> let lower_coroutine_functions_and_types <nl> } when not @ @ is_missing anonymous_coroutine_keyword - > <nl> ( * TODO : rewrite anonymous functions * ) <nl> ( current_acc , Rewriter . Result . Keep ) <nl> - | MethodishDeclaration { <nl> + | MethodishDeclaration ( { <nl> methodish_function_decl_header = { <nl> - syntax = FunctionDeclarationHeader { <nl> + syntax = FunctionDeclarationHeader ( { <nl> function_coroutine ; <nl> _ ; <nl> - } ; <nl> + } as header_node ) ; <nl> _ ; <nl> } ; <nl> + methodish_function_body ; <nl> _ ; <nl> - } when not @ @ is_missing function_coroutine - > <nl> - ( * TODO : deduce class name and parameters from parents * ) <nl> - ( * TODO : rewrite methods * ) <nl> - ( current_acc , Rewriter . Result . Keep ) <nl> + } as method_node ) when not @ @ is_missing function_coroutine - > <nl> + ( * TODO : Plumb the context through rather than tramping around the <nl> + header , class name and class type parameters . * ) <nl> + let context = Coroutine_context . make_from_context parents in <nl> + let classish_name = context . Coroutine_context . classish_name in <nl> + let classish_type_parameters = <nl> + context . Coroutine_context . classish_type_parameters in <nl> + let ( new_header_node , new_body , closure_syntax ) = <nl> + rewrite_method_or_function <nl> + context . Coroutine_context . classish_name <nl> + context . Coroutine_context . classish_type_parameters <nl> + header_node <nl> + methodish_function_body in <nl> + let new_method_syntax = <nl> + CoroutineMethodLowerer . rewrite_methodish_declaration <nl> + classish_name <nl> + classish_type_parameters <nl> + method_node <nl> + new_header_node <nl> + new_body in <nl> + ( ( closure_syntax : : closures , lambda_count ) , <nl> + Rewriter . Result . Replace new_method_syntax ) <nl> | ClosureTypeSpecifier ( { closure_coroutine ; _ ; } as type_node ) <nl> when not @ @ is_missing closure_coroutine - > <nl> let new_type_node = rewrite_coroutine_annotation type_node in <nl> let lower_coroutine_functions_and_types <nl> | _ - > <nl> ( current_acc , Rewriter . Result . Keep ) <nl> <nl> - let append_to_root closures root = <nl> - match syntax root with <nl> + ( * <nl> + We are working around a significant shortcoming of HHVM here . We are supposed <nl> + to have an invariant that the order in which type declarations appear in a <nl> + Hack file is irrelevant , but this is not the case : <nl> + <nl> + interface I { } <nl> + class B implements I { } <nl> + new D ( ) ; / / Crashes here at runtime <nl> + class D extends B { } <nl> + <nl> + The crash is due to a peculiarity in how HHVM handles interfaces . <nl> + <nl> + The closure classes extend the closure base , which implements an interface . <nl> + We can therefore very easily get into this situation when generating closure <nl> + classes at the end of a file . <nl> + <nl> + What we do then is gather up * all * the classes in a file , sort them to the <nl> + top of the file , follow them with the closure classes , and then the rest <nl> + of the code in the file . <nl> + <nl> + This unfortunate code can be removed when the bug is fixed in HHVM , and <nl> + we can simply append the closure classes to the end of the list of <nl> + declarations . <nl> + * ) <nl> + let rewrite_script closures root = <nl> + match closures with <nl> + | [ ] - > root <nl> + | _ - > <nl> + begin match syntax root with <nl> | Script { script_declarations } - > <nl> let script_declarations = syntax_node_to_list script_declarations in <nl> - make_script ( make_list ( script_declarations @ closures ) ) <nl> + let ( types , not_types ) = <nl> + List . partition_tf script_declarations ~ f : is_classish_declaration in <nl> + begin match not_types with <nl> + | h : : t - > make_script ( make_list ( h : : ( types @ closures @ t ) ) ) <nl> + | [ ] - > failwith " How did we get a script with no header element ? " <nl> + end <nl> | _ - > failwith " How did we get a root that is not a script ? " <nl> + end <nl> <nl> let lower_coroutines syntax_tree = <nl> let root = from_tree syntax_tree in <nl> let ( ( closures , _ ) , root ) = Rewriter . parented_aggregating_rewrite_post <nl> lower_coroutine_functions_and_types root ( [ ] , 0 ) in <nl> root <nl> - | > append_to_root closures <nl> - | > Rewriter . rewrite_post maybe_rewrite_syntax_list <nl> + | > rewrite_script ( List . rev closures ) <nl> | > text <nl> | > SourceText . make <nl> | > SyntaxTree . make <nl>
|
Refactor method lowering into parented aggregating rewriting pass
|
facebook/hhvm
|
5d7f783e952fbd14f7868705167b08d1c9c652ea
|
2017-07-13T23:28:12Z
|
mmm a / src / common / device_helpers . cuh <nl> ppp b / src / common / device_helpers . cuh <nl> <nl> # include < sstream > <nl> # include < string > <nl> # include < vector > <nl> + # include " timer . h " <nl> <nl> # ifdef XGBOOST_USE_NCCL <nl> # include " nccl . h " <nl> void Gather ( int device_idx , T * out , const T * in , const int * instId , int nVals ) { <nl> * / <nl> <nl> class AllReducer { <nl> - bool initialised ; <nl> + bool initialised_ ; <nl> + bool debug_verbose_ ; <nl> + size_t allreduce_bytes_ ; / / Keep statistics of the number of bytes communicated <nl> + size_t allreduce_calls_ ; / / Keep statistics of the number of reduce calls <nl> # ifdef XGBOOST_USE_NCCL <nl> std : : vector < ncclComm_t > comms ; <nl> std : : vector < cudaStream_t > streams ; <nl> std : : vector < int > device_ordinals ; <nl> # endif <nl> public : <nl> - AllReducer ( ) : initialised ( false ) { } <nl> + AllReducer ( ) : initialised_ ( false ) , debug_verbose_ ( false ) { } <nl> <nl> / * * <nl> * \ fn void Init ( const std : : vector < int > & device_ordinals ) <nl> class AllReducer { <nl> * \ param device_ordinals The device ordinals . <nl> * / <nl> <nl> - void Init ( const std : : vector < int > & device_ordinals ) { <nl> + void Init ( const std : : vector < int > & device_ordinals , bool debug_verbose ) { <nl> # ifdef XGBOOST_USE_NCCL <nl> + / * * \ brief this > monitor . init . * / <nl> + this - > debug_verbose_ = debug_verbose ; <nl> this - > device_ordinals = device_ordinals ; <nl> comms . resize ( device_ordinals . size ( ) ) ; <nl> dh : : safe_nccl ( ncclCommInitAll ( comms . data ( ) , <nl> class AllReducer { <nl> safe_cuda ( cudaSetDevice ( device_ordinals [ i ] ) ) ; <nl> safe_cuda ( cudaStreamCreate ( & streams [ i ] ) ) ; <nl> } <nl> - initialised = true ; <nl> + initialised_ = true ; <nl> # else <nl> CHECK_EQ ( device_ordinals . size ( ) , 1 ) <nl> < < " XGBoost must be compiled with NCCL to use more than one GPU . " ; <nl> class AllReducer { <nl> } <nl> ~ AllReducer ( ) { <nl> # ifdef XGBOOST_USE_NCCL <nl> - if ( initialised ) { <nl> + if ( initialised_ ) { <nl> for ( auto & stream : streams ) { <nl> dh : : safe_cuda ( cudaStreamDestroy ( stream ) ) ; <nl> } <nl> class AllReducer { <nl> ncclCommDestroy ( comm ) ; <nl> } <nl> } <nl> + if ( debug_verbose_ ) { <nl> + LOG ( CONSOLE ) < < " = = = = = = = = NCCL Statistics = = = = = = = = " ; <nl> + LOG ( CONSOLE ) < < " AllReduce calls : " < < allreduce_calls_ ; <nl> + LOG ( CONSOLE ) < < " AllReduce total MB communicated : " < < allreduce_bytes_ / 1000000 ; <nl> + } <nl> # endif <nl> } <nl> <nl> class AllReducer { <nl> void AllReduceSum ( int communication_group_idx , const double * sendbuff , <nl> double * recvbuff , int count ) { <nl> # ifdef XGBOOST_USE_NCCL <nl> - CHECK ( initialised ) ; <nl> + CHECK ( initialised_ ) ; <nl> dh : : safe_cuda ( cudaSetDevice ( device_ordinals . at ( communication_group_idx ) ) ) ; <nl> dh : : safe_nccl ( ncclAllReduce ( sendbuff , recvbuff , count , ncclDouble , ncclSum , <nl> comms . at ( communication_group_idx ) , <nl> streams . at ( communication_group_idx ) ) ) ; <nl> + if ( communication_group_idx = = 0 ) <nl> + { <nl> + allreduce_bytes_ + = count * sizeof ( double ) ; <nl> + allreduce_calls_ + = 1 ; <nl> + } <nl> # endif <nl> } <nl> <nl> class AllReducer { <nl> void AllReduceSum ( int communication_group_idx , const int64_t * sendbuff , <nl> int64_t * recvbuff , int count ) { <nl> # ifdef XGBOOST_USE_NCCL <nl> - CHECK ( initialised ) ; <nl> + CHECK ( initialised_ ) ; <nl> <nl> dh : : safe_cuda ( cudaSetDevice ( device_ordinals [ communication_group_idx ] ) ) ; <nl> dh : : safe_nccl ( ncclAllReduce ( sendbuff , recvbuff , count , ncclInt64 , ncclSum , <nl> class SaveCudaContext { <nl> } <nl> } ; <nl> <nl> - / * * <nl> - * \ brief Executes some operation on each element of the input vector , using a <nl> - * single controlling thread for each element . <nl> - * <nl> - * \ tparam T Generic type parameter . <nl> - * \ tparam FunctionT Type of the function t . <nl> - * \ param shards The shards . <nl> - * \ param f The func_t to process . <nl> - * / <nl> - <nl> - template < typename T , typename FunctionT > <nl> - void ExecuteShards ( std : : vector < T > * shards , FunctionT f ) { <nl> - SaveCudaContext { <nl> - [ & ] ( ) { <nl> - # pragma omp parallel for schedule ( static , 1 ) if ( shards - > size ( ) > 1 ) <nl> - for ( int shard = 0 ; shard < shards - > size ( ) ; + + shard ) { <nl> - f ( shards - > at ( shard ) ) ; <nl> - } <nl> - } } ; <nl> - } <nl> - <nl> / * * <nl> * \ brief Executes some operation on each element of the input vector , using a <nl> * single controlling thread for each element . In addition , passes the shard index <nl> void ExecuteShards ( std : : vector < T > * shards , FunctionT f ) { <nl> <nl> template < typename T , typename FunctionT > <nl> void ExecuteIndexShards ( std : : vector < T > * shards , FunctionT f ) { <nl> - SaveCudaContext { <nl> - [ & ] ( ) { <nl> + SaveCudaContext { [ & ] ( ) { <nl> # pragma omp parallel for schedule ( static , 1 ) if ( shards - > size ( ) > 1 ) <nl> - for ( int shard = 0 ; shard < shards - > size ( ) ; + + shard ) { <nl> - f ( shard , shards - > at ( shard ) ) ; <nl> - } <nl> - } } ; <nl> + for ( int shard = 0 ; shard < shards - > size ( ) ; + + shard ) { <nl> + f ( shard , shards - > at ( shard ) ) ; <nl> + } <nl> + } } ; <nl> } <nl> <nl> / * * <nl> mmm a / src / common / hist_util . cu <nl> ppp b / src / common / hist_util . cu <nl> struct GPUSketcher { <nl> } ) ; <nl> <nl> / / compute sketches for each shard <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > Init ( batch , info ) ; <nl> shard - > Sketch ( batch , info ) ; <nl> } ) ; <nl> mmm a / src / common / host_device_vector . cu <nl> ppp b / src / common / host_device_vector . cu <nl> struct HostDeviceVectorImpl { <nl> ( end - begin ) * sizeof ( T ) , <nl> cudaMemcpyDeviceToHost ) ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { <nl> shard . ScatterFrom ( begin . get ( ) ) ; <nl> } ) ; <nl> } <nl> struct HostDeviceVectorImpl { <nl> data_h_ . size ( ) * sizeof ( T ) , <nl> cudaMemcpyHostToDevice ) ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { shard . GatherTo ( begin ) ; } ) ; <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { shard . GatherTo ( begin ) ; } ) ; <nl> } <nl> } <nl> <nl> struct HostDeviceVectorImpl { <nl> if ( perm_h_ . CanWrite ( ) ) { <nl> std : : fill ( data_h_ . begin ( ) , data_h_ . end ( ) , v ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { shard . Fill ( v ) ; } ) ; <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { shard . Fill ( v ) ; } ) ; <nl> } <nl> } <nl> <nl> struct HostDeviceVectorImpl { <nl> if ( perm_h_ . CanWrite ( ) ) { <nl> std : : copy ( other . begin ( ) , other . end ( ) , data_h_ . begin ( ) ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { <nl> shard . ScatterFrom ( other . data ( ) ) ; <nl> } ) ; <nl> } <nl> struct HostDeviceVectorImpl { <nl> if ( perm_h_ . CanWrite ( ) ) { <nl> std : : copy ( other . begin ( ) , other . end ( ) , data_h_ . begin ( ) ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { <nl> shard . ScatterFrom ( other . begin ( ) ) ; <nl> } ) ; <nl> } <nl> struct HostDeviceVectorImpl { <nl> if ( perm_h_ . CanAccess ( access ) ) { return ; } <nl> if ( perm_h_ . CanRead ( ) ) { <nl> / / data is present , just need to deny access to the device <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { <nl> shard . perm_d_ . DenyComplementary ( access ) ; <nl> } ) ; <nl> perm_h_ . Grant ( access ) ; <nl> return ; <nl> } <nl> if ( data_h_ . size ( ) ! = size_d_ ) { data_h_ . resize ( size_d_ ) ; } <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( DeviceShard & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , DeviceShard & shard ) { <nl> shard . LazySyncHost ( access ) ; <nl> } ) ; <nl> perm_h_ . Grant ( access ) ; <nl> mmm a / src / common / timer . h <nl> ppp b / src / common / timer . h <nl> struct Timer { <nl> * / <nl> <nl> struct Monitor { <nl> + struct Statistics { <nl> + Timer timer ; <nl> + size_t count { 0 } ; <nl> + } ; <nl> bool debug_verbose = false ; <nl> std : : string label = " " ; <nl> - std : : map < std : : string , Timer > timer_map ; <nl> + std : : map < std : : string , Statistics > statistics_map ; <nl> Timer self_timer ; <nl> <nl> Monitor ( ) { self_timer . Start ( ) ; } <nl> struct Monitor { <nl> if ( ! debug_verbose ) return ; <nl> <nl> LOG ( CONSOLE ) < < " = = = = = = = = Monitor : " < < label < < " = = = = = = = = " ; <nl> - for ( auto & kv : timer_map ) { <nl> - kv . second . PrintElapsed ( kv . first ) ; <nl> + for ( auto & kv : statistics_map ) { <nl> + LOG ( CONSOLE ) < < kv . first < < " : " < < kv . second . timer . ElapsedSeconds ( ) <nl> + < < " s , " < < kv . second . count < < " calls @ " <nl> + < < std : : chrono : : duration_cast < std : : chrono : : microseconds > ( <nl> + kv . second . timer . elapsed / kv . second . count ) <nl> + . count ( ) <nl> + < < " us " ; <nl> } <nl> self_timer . Stop ( ) ; <nl> - self_timer . PrintElapsed ( label + " Lifetime " ) ; <nl> } <nl> void Init ( std : : string label , bool debug_verbose ) { <nl> this - > debug_verbose = debug_verbose ; <nl> this - > label = label ; <nl> } <nl> - void Start ( const std : : string & name ) { timer_map [ name ] . Start ( ) ; } <nl> + void Start ( const std : : string & name ) { statistics_map [ name ] . timer . Start ( ) ; } <nl> void Start ( const std : : string & name , GPUSet devices ) { <nl> if ( debug_verbose ) { <nl> # ifdef __CUDACC__ <nl> - # include " device_helpers . cuh " <nl> - dh : : SynchronizeNDevices ( devices ) ; <nl> + for ( auto device : devices ) { <nl> + cudaSetDevice ( device ) ; <nl> + cudaDeviceSynchronize ( ) ; <nl> + } <nl> # endif <nl> } <nl> - timer_map [ name ] . Start ( ) ; <nl> + statistics_map [ name ] . timer . Start ( ) ; <nl> + } <nl> + void Stop ( const std : : string & name ) { <nl> + statistics_map [ name ] . timer . Stop ( ) ; <nl> + statistics_map [ name ] . count + + ; <nl> } <nl> - void Stop ( const std : : string & name ) { timer_map [ name ] . Stop ( ) ; } <nl> void Stop ( const std : : string & name , GPUSet devices ) { <nl> if ( debug_verbose ) { <nl> # ifdef __CUDACC__ <nl> - # include " device_helpers . cuh " <nl> - dh : : SynchronizeNDevices ( devices ) ; <nl> + for ( auto device : devices ) { <nl> + cudaSetDevice ( device ) ; <nl> + cudaDeviceSynchronize ( ) ; <nl> + } <nl> # endif <nl> } <nl> - timer_map [ name ] . Stop ( ) ; <nl> + this - > Stop ( name ) ; <nl> } <nl> } ; <nl> } / / namespace common <nl> mmm a / src / linear / updater_gpu_coordinate . cu <nl> ppp b / src / linear / updater_gpu_coordinate . cu <nl> class GPUCoordinateUpdater : public LinearUpdater { <nl> <nl> monitor . Start ( " UpdateGpair " ) ; <nl> / / Update gpair <nl> - dh : : ExecuteShards ( & shards , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > UpdateGpair ( in_gpair - > ConstHostVector ( ) , model - > param ) ; <nl> } ) ; <nl> monitor . Stop ( " UpdateGpair " ) ; <nl> class GPUCoordinateUpdater : public LinearUpdater { <nl> model - > bias ( ) [ group_idx ] + = dbias ; <nl> <nl> / / Update residual <nl> - dh : : ExecuteShards ( & shards , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > UpdateBiasResidual ( dbias , group_idx , <nl> model - > param . num_output_group ) ; <nl> } ) ; <nl> class GPUCoordinateUpdater : public LinearUpdater { <nl> param . reg_lambda_denorm ) ) ; <nl> w + = dw ; <nl> <nl> - dh : : ExecuteShards ( & shards , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > UpdateResidual ( dw , group_idx , model - > param . num_output_group , fidx ) ; <nl> } ) ; <nl> } <nl> mmm a / src / predictor / gpu_predictor . cu <nl> ppp b / src / predictor / gpu_predictor . cu <nl> class GPUPredictor : public xgboost : : Predictor { <nl> std : : vector < size_t > device_offsets ; <nl> DeviceOffsets ( batch . offset , & device_offsets ) ; <nl> batch . data . Reshard ( GPUDistribution : : Explicit ( devices_ , device_offsets ) ) ; <nl> - dh : : ExecuteShards ( & shards , [ & ] ( DeviceShard & shard ) { <nl> - shard . PredictInternal ( batch , dmat - > Info ( ) , out_preds , model , h_tree_segments , <nl> - h_nodes , tree_begin , tree_end ) ; <nl> - } ) ; <nl> + dh : : ExecuteIndexShards ( & shards , [ & ] ( int idx , DeviceShard & shard ) { <nl> + shard . PredictInternal ( batch , dmat - > Info ( ) , out_preds , model , <nl> + h_tree_segments , h_nodes , tree_begin , tree_end ) ; <nl> + } ) ; <nl> i_batch + + ; <nl> } <nl> } <nl> mmm a / src / tree / updater_gpu_hist . cu <nl> ppp b / src / tree / updater_gpu_hist . cu <nl> struct DeviceShard { <nl> return best_split ; <nl> } <nl> <nl> - / * * \ brief Builds both left and right hist with subtraction trick if possible . <nl> - * / <nl> - void BuildHistWithSubtractionTrick ( int nidx_parent , int nidx_left , <nl> - int nidx_right ) { <nl> - auto smallest_nidx = <nl> - ridx_segments [ nidx_left ] . Size ( ) < ridx_segments [ nidx_right ] . Size ( ) <nl> - ? nidx_left <nl> - : nidx_right ; <nl> - auto largest_nidx = smallest_nidx = = nidx_left ? nidx_right : nidx_left ; <nl> - this - > BuildHist ( smallest_nidx ) ; <nl> - if ( this - > CanDoSubtractionTrick ( nidx_parent , smallest_nidx , largest_nidx ) ) { <nl> - this - > SubtractionTrick ( nidx_parent , smallest_nidx , largest_nidx ) ; <nl> - } else { <nl> - this - > BuildHist ( largest_nidx ) ; <nl> - } <nl> - } <nl> - <nl> void BuildHist ( int nidx ) { <nl> hist . AllocateHistogram ( nidx ) ; <nl> hist_builder - > Build ( this , nidx ) ; <nl> class GPUHistMaker : public TreeUpdater { <nl> device_list_ [ index ] = device_id ; <nl> } <nl> <nl> - reducer_ . Init ( device_list_ ) ; <nl> + reducer_ . Init ( device_list_ , param_ . debug_verbose ) ; <nl> <nl> auto batch_iter = dmat - > GetRowBatches ( ) . begin ( ) ; <nl> const SparsePage & batch = * batch_iter ; <nl> class GPUHistMaker : public TreeUpdater { <nl> monitor_ . Stop ( " Quantiles " , dist_ . Devices ( ) ) ; <nl> <nl> monitor_ . Start ( " BinningCompression " , dist_ . Devices ( ) ) ; <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > InitCompressedData ( hmat_ , batch ) ; <nl> } ) ; <nl> monitor_ . Stop ( " BinningCompression " , dist_ . Devices ( ) ) ; <nl> class GPUHistMaker : public TreeUpdater { <nl> monitor_ . Start ( " InitDataReset " , dist_ . Devices ( ) ) ; <nl> <nl> gpair - > Reshard ( dist_ ) ; <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > Reset ( gpair ) ; <nl> } ) ; <nl> monitor_ . Stop ( " InitDataReset " , dist_ . Devices ( ) ) ; <nl> class GPUHistMaker : public TreeUpdater { <nl> void AllReduceHist ( int nidx ) { <nl> if ( shards_ . size ( ) = = 1 ) return ; <nl> <nl> - reducer_ . GroupStart ( ) ; <nl> - for ( auto & shard : shards_ ) { <nl> + monitor_ . Start ( " AllReduce " ) ; <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> auto d_node_hist = shard - > hist . GetNodeHistogram ( nidx ) . data ( ) ; <nl> reducer_ . AllReduceSum ( <nl> dist_ . Devices ( ) . Index ( shard - > device_id_ ) , <nl> reinterpret_cast < GradientPairSumT : : ValueT * > ( d_node_hist ) , <nl> reinterpret_cast < GradientPairSumT : : ValueT * > ( d_node_hist ) , <nl> n_bins_ * ( sizeof ( GradientPairSumT ) / sizeof ( GradientPairSumT : : ValueT ) ) ) ; <nl> - } <nl> - reducer_ . GroupEnd ( ) ; <nl> - <nl> - reducer_ . Synchronize ( ) ; <nl> + } ) ; <nl> + monitor_ . Stop ( " AllReduce " ) ; <nl> } <nl> <nl> / * * <nl> * \ brief Build GPU local histograms for the left and right child of some parent node <nl> * / <nl> void BuildHistLeftRight ( int nidx_parent , int nidx_left , int nidx_right ) { <nl> - / / If one GPU <nl> - if ( shards_ . size ( ) = = 1 ) { <nl> - shards_ . back ( ) - > BuildHistWithSubtractionTrick ( nidx_parent , nidx_left , nidx_right ) ; <nl> + size_t left_node_max_elements = 0 ; <nl> + size_t right_node_max_elements = 0 ; <nl> + for ( auto & shard : shards_ ) { <nl> + left_node_max_elements = ( std : : max ) ( <nl> + left_node_max_elements , shard - > ridx_segments [ nidx_left ] . Size ( ) ) ; <nl> + right_node_max_elements = ( std : : max ) ( <nl> + right_node_max_elements , shard - > ridx_segments [ nidx_right ] . Size ( ) ) ; <nl> + } <nl> + <nl> + auto build_hist_nidx = nidx_left ; <nl> + auto subtraction_trick_nidx = nidx_right ; <nl> + <nl> + if ( right_node_max_elements < left_node_max_elements ) { <nl> + build_hist_nidx = nidx_right ; <nl> + subtraction_trick_nidx = nidx_left ; <nl> + } <nl> + <nl> + / / Build histogram for node with the smallest number of training examples <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> + shard - > BuildHist ( build_hist_nidx ) ; <nl> + } ) ; <nl> + <nl> + this - > AllReduceHist ( build_hist_nidx ) ; <nl> + <nl> + / / Check whether we can use the subtraction trick to calculate the other <nl> + bool do_subtraction_trick = true ; <nl> + for ( auto & shard : shards_ ) { <nl> + do_subtraction_trick & = shard - > CanDoSubtractionTrick ( <nl> + nidx_parent , build_hist_nidx , subtraction_trick_nidx ) ; <nl> + } <nl> + <nl> + if ( do_subtraction_trick ) { <nl> + / / Calculate other histogram using subtraction trick <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> + shard - > SubtractionTrick ( nidx_parent , build_hist_nidx , <nl> + subtraction_trick_nidx ) ; <nl> + } ) ; <nl> } else { <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> - shard - > BuildHist ( nidx_left ) ; <nl> - shard - > BuildHist ( nidx_right ) ; <nl> + / / Calculate other histogram manually <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> + shard - > BuildHist ( subtraction_trick_nidx ) ; <nl> } ) ; <nl> - this - > AllReduceHist ( nidx_left ) ; <nl> - this - > AllReduceHist ( nidx_right ) ; <nl> + <nl> + this - > AllReduceHist ( subtraction_trick_nidx ) ; <nl> } <nl> } <nl> <nl> class GPUHistMaker : public TreeUpdater { <nl> std : : accumulate ( tmp_sums . begin ( ) , tmp_sums . end ( ) , GradientPair ( ) ) ; <nl> <nl> / / Generate root histogram <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > BuildHist ( root_nidx ) ; <nl> } ) ; <nl> <nl> class GPUHistMaker : public TreeUpdater { <nl> } <nl> auto is_dense = info_ - > num_nonzero_ = = info_ - > num_row_ * info_ - > num_col_ ; <nl> <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > UpdatePosition ( nidx , left_nidx , right_nidx , fidx , <nl> split_gidx , default_dir_left , <nl> is_dense , fidx_begin , fidx_end ) ; <nl> class GPUHistMaker : public TreeUpdater { <nl> shard - > node_sum_gradients [ parent . LeftChild ( ) ] = candidate . split . left_sum ; <nl> shard - > node_sum_gradients [ parent . RightChild ( ) ] = candidate . split . right_sum ; <nl> } <nl> - this - > UpdatePosition ( candidate , p_tree ) ; <nl> } <nl> <nl> void UpdateTree ( HostDeviceVector < GradientPair > * gpair , DMatrix * p_fmat , <nl> class GPUHistMaker : public TreeUpdater { <nl> qexpand_ - > pop ( ) ; <nl> if ( ! candidate . IsValid ( param_ , num_leaves ) ) continue ; <nl> <nl> - monitor_ . Start ( " ApplySplit " , dist_ . Devices ( ) ) ; <nl> this - > ApplySplit ( candidate , p_tree ) ; <nl> - monitor_ . Stop ( " ApplySplit " , dist_ . Devices ( ) ) ; <nl> + monitor_ . Start ( " UpdatePosition " , dist_ . Devices ( ) ) ; <nl> + this - > UpdatePosition ( candidate , p_tree ) ; <nl> + monitor_ . Stop ( " UpdatePosition " , dist_ . Devices ( ) ) ; <nl> num_leaves + + ; <nl> <nl> int left_child_nidx = tree [ candidate . nid ] . LeftChild ( ) ; <nl> class GPUHistMaker : public TreeUpdater { <nl> if ( shards_ . empty ( ) | | p_last_fmat_ = = nullptr | | p_last_fmat_ ! = data ) <nl> return false ; <nl> p_out_preds - > Reshard ( dist_ . Devices ( ) ) ; <nl> - dh : : ExecuteShards ( & shards_ , [ & ] ( std : : unique_ptr < DeviceShard > & shard ) { <nl> + dh : : ExecuteIndexShards ( & shards_ , [ & ] ( int idx , std : : unique_ptr < DeviceShard > & shard ) { <nl> shard - > UpdatePredictionCache ( <nl> p_out_preds - > DevicePointer ( shard - > device_id_ ) ) ; <nl> } ) ; <nl> mmm a / tests / cpp / tree / test_gpu_hist . cu <nl> ppp b / tests / cpp / tree / test_gpu_hist . cu <nl> TEST ( GpuHist , ApplySplit ) { <nl> <nl> hist_maker . info_ = & info ; <nl> hist_maker . ApplySplit ( candidate_entry , & tree ) ; <nl> + hist_maker . UpdatePosition ( candidate_entry , & tree ) ; <nl> <nl> ASSERT_FALSE ( tree [ nid ] . IsLeaf ( ) ) ; <nl> <nl>
|
GPU performance logging / improvements ( )
|
dmlc/xgboost
|
a9d684db185b1e5ee5a0dd64b646b58da28e6b05
|
2018-11-29T01:36:51Z
|
mmm a / src / gui / Src / BasicView / StdTable . cpp <nl> ppp b / src / gui / Src / BasicView / StdTable . cpp <nl> void StdTable : : copyLineSlot ( ) <nl> Bridge : : CopyToClipboard ( finalText ) ; <nl> } <nl> <nl> - void StdTable : : copyTableSlot ( ) <nl> + void StdTable : : copyTable ( std : : function < int ( int ) > getMaxColumnLength ) <nl> { <nl> int colCount = getColumnCount ( ) ; <nl> int rowCount = getRowCount ( ) ; <nl> void StdTable : : copyTableSlot ( ) <nl> } <nl> else <nl> { <nl> - int charwidth = getCharWidth ( ) ; <nl> + std : : vector < int > colWidths ; <nl> + for ( int i = 0 ; i < colCount ; i + + ) <nl> + colWidths . push_back ( getMaxColumnLength ( i ) ) ; <nl> for ( int i = 0 ; i < colCount ; i + + ) <nl> { <nl> if ( i ) <nl> finalText + = " " ; <nl> - int colWidth = getColumnWidth ( i ) / charwidth ; <nl> + int colWidth = colWidths [ i ] ; <nl> if ( colWidth ) <nl> finalText + = getColTitle ( i ) . leftJustified ( colWidth , QChar ( ' ' ) , true ) ; <nl> else <nl> void StdTable : : copyTableSlot ( ) <nl> if ( j ) <nl> finalRowText + = " " ; <nl> QString cellContent = getCellContent ( i , j ) ; <nl> - int colWidth = getColumnWidth ( j ) / charwidth ; <nl> + int colWidth = colWidths [ j ] ; <nl> if ( colWidth & & j ! = colCount - 1 ) <nl> finalRowText + = cellContent . leftJustified ( colWidth , QChar ( ' ' ) , true ) ; <nl> else <nl> void StdTable : : copyTableSlot ( ) <nl> Bridge : : CopyToClipboard ( finalText ) ; <nl> } <nl> <nl> + void StdTable : : copyTableSlot ( ) <nl> + { <nl> + copyTable ( [ this ] ( int col ) <nl> + { <nl> + return getColumnWidth ( col ) / getCharWidth ( ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + void StdTable : : copyTableResizeSlot ( ) <nl> + { <nl> + copyTable ( [ this ] ( int col ) <nl> + { <nl> + int max = 0 ; <nl> + int rowCount = getRowCount ( ) ; <nl> + for ( int i = 0 ; i < rowCount ; i + + ) <nl> + max = std : : max ( getCellContent ( i , col ) . length ( ) , max ) ; <nl> + return max ; <nl> + } ) ; <nl> + } <nl> + <nl> void StdTable : : copyEntrySlot ( ) <nl> { <nl> QAction * action = qobject_cast < QAction * > ( sender ( ) ) ; <nl> void StdTable : : setupCopyMenu ( QMenu * copyMenu ) <nl> if ( ! getColumnCount ( ) ) <nl> return ; <nl> / / Copy - > Whole Line <nl> - QAction * mCopyLine = new QAction ( tr ( " Whole & Line " ) , this ) ; <nl> + QAction * mCopyLine = new QAction ( tr ( " & Line " ) , copyMenu ) ; <nl> connect ( mCopyLine , SIGNAL ( triggered ( ) ) , this , SLOT ( copyLineSlot ( ) ) ) ; <nl> copyMenu - > addAction ( mCopyLine ) ; <nl> - / / Copy - > Whole Table <nl> - QAction * mCopyTable = new QAction ( tr ( " Whole & Table " ) , this ) ; <nl> + / / Copy - > Cropped Table <nl> + QAction * mCopyTable = new QAction ( tr ( " Cropped & Table " ) , copyMenu ) ; <nl> connect ( mCopyTable , SIGNAL ( triggered ( ) ) , this , SLOT ( copyTableSlot ( ) ) ) ; <nl> copyMenu - > addAction ( mCopyTable ) ; <nl> + / / Copy - > Full Table <nl> + QAction * mCopyTableResize = new QAction ( tr ( " & Full Table " ) , copyMenu ) ; <nl> + connect ( mCopyTableResize , SIGNAL ( triggered ( ) ) , this , SLOT ( copyTableResizeSlot ( ) ) ) ; <nl> + copyMenu - > addAction ( mCopyTableResize ) ; <nl> / / Copy - > Separator <nl> copyMenu - > addSeparator ( ) ; <nl> / / Copy - > ColName <nl> void StdTable : : setupCopyMenu ( QMenu * copyMenu ) <nl> QString title = mCopyTitles . at ( i ) ; <nl> if ( ! title . length ( ) ) / / skip empty copy titles <nl> continue ; <nl> - QAction * mCopyAction = new QAction ( title , this ) ; <nl> + QAction * mCopyAction = new QAction ( title , copyMenu ) ; <nl> mCopyAction - > setObjectName ( QString : : number ( i ) ) ; <nl> connect ( mCopyAction , SIGNAL ( triggered ( ) ) , this , SLOT ( copyEntrySlot ( ) ) ) ; <nl> copyMenu - > addAction ( mCopyAction ) ; <nl> mmm a / src / gui / Src / BasicView / StdTable . h <nl> ppp b / src / gui / Src / BasicView / StdTable . h <nl> class StdTable : public AbstractTableView <nl> public slots : <nl> void copyLineSlot ( ) ; <nl> void copyTableSlot ( ) ; <nl> + void copyTableResizeSlot ( ) ; <nl> void copyEntrySlot ( ) ; <nl> void contextMenuRequestedSlot ( const QPoint & pos ) ; <nl> void headerButtonPressedSlot ( int col ) ; <nl> <nl> private : <nl> + void copyTable ( std : : function < int ( int ) > getMaxColSize ) ; <nl> + <nl> class ColumnCompare <nl> { <nl> public : <nl> mmm a / src / gui / Src / Gui / CPUInfoBox . cpp <nl> ppp b / src / gui / Src / Gui / CPUInfoBox . cpp <nl> void CPUInfoBox : : addFollowMenuItem ( QMenu * menu , QString name , dsint value ) <nl> foreach ( QAction * action , menu - > actions ( ) ) / / check for duplicate action <nl> if ( action - > text ( ) = = name ) <nl> return ; <nl> - QAction * newAction = new QAction ( name , this ) ; <nl> + QAction * newAction = new QAction ( name , menu ) ; <nl> newAction - > setFont ( QFont ( " Courier New " , 8 ) ) ; <nl> menu - > addAction ( newAction ) ; <nl> newAction - > setObjectName ( QString ( " DUMP | " ) + QString ( " % 1 " ) . arg ( value , sizeof ( dsint ) * 2 , 16 , QChar ( ' 0 ' ) ) . toUpper ( ) ) ; <nl>
|
GUI : resolved issue ( additional option to copy a resized table )
|
x64dbg/x64dbg
|
fd8f2d2239645e71f94026dae7c21ef45665785e
|
2016-05-31T04:56:24Z
|
mmm a / tests / runner . py <nl> ppp b / tests / runner . py <nl> def clear ( ) : <nl> assert os . path . exists ( target ) , ' Expected % s to exist since args are % s : % s ' % ( target , str ( args ) , output ) <nl> self . assertContained ( ' hello , world ! ' , self . run_llvm_interpreter ( [ target ] ) ) <nl> <nl> - # emcc src . cpp - o something . js [ - Ox ] . - O0 is the same as not specifying any optimization setting <nl> - for opt_params , opt_level in [ ( [ ] , 0 ) , ( [ ' - O0 ' ] , 0 ) , ( [ ' - O1 ' ] , 1 ) , ( [ ' - O2 ' ] , 2 ) , ( [ ' - O3 ' ] , 3 ) ] : <nl> + # Optimization : emcc src . cpp - o something . js [ - Ox ] . - O0 is the same as not specifying any optimization setting <nl> + for params , opt_level , bc_params in [ # bc params are used after compiling to bitcode <nl> + ( [ ' - o ' , ' something . js ' ] , 0 , None ) , <nl> + ( [ ' - o ' , ' something . js ' , ' - O0 ' ] , 0 , None ) , <nl> + ( [ ' - o ' , ' something . js ' , ' - O1 ' ] , 1 , None ) , <nl> + ( [ ' - o ' , ' something . js ' , ' - O2 ' ] , 2 , None ) , <nl> + ( [ ' - o ' , ' something . js ' , ' - O3 ' ] , 3 , None ) , <nl> + ] : <nl> clear ( ) <nl> - output = Popen ( [ compiler , path_from_root ( ' tests ' , ' hello_world_loop . cpp ' ) , ' - o ' , ' something . js ' ] + opt_params , <nl> + output = Popen ( [ compiler , path_from_root ( ' tests ' , ' hello_world_loop . cpp ' ) ] + params , <nl> stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> assert len ( output [ 0 ] ) = = 0 , output [ 0 ] <nl> + if bc_params : <nl> + output = Popen ( [ compiler , ' something . bc ' ] + bc_params , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> assert os . path . exists ( ' something . js ' ) , ' \ n ' . join ( output ) <nl> assert ( ' Warning : The relooper optimization can be very slow . ' in output [ 1 ] ) = = ( opt_level > = 2 ) , ' relooper warning should appear in opt > = 2 ' <nl> assert ( ' Warning : Applying some potentially unsafe optimizations ! ' in output [ 1 ] ) = = ( opt_level > = 3 ) , ' unsafe warning should appear in opt > = 3 ' <nl> def clear ( ) : <nl> assert os . path . exists ( target ) , ' \ n ' . join ( output ) <nl> self . assertContained ( ' side got : hello from main , over ' , run_js ( target ) ) <nl> <nl> - <nl> - # linking - TODO . in particular , test normal project linking , static and dynamic : get_library should not need to be told what to link ! <nl> - # emcc a . cpp b . cpp = > one . js <nl> - # emcc a . cpp b . cpp - c = > two . o files <nl> - # annotate each . bc with emscripten info , like " compiled with - O2 : do the O2 opts when going to final . js " <nl> - # warn if linking files with different annotations etc . <nl> - # use llvm metadata , example : ! 0 = metadata ! { i32 720913 , i32 0 , i32 4 , metadata ! " / dev / shm / tmp / src . cpp " , metadata ! " / dev / shm / tmp " , metadata ! " clang version 3 . 0 ( tags / RELEASE_30 / rc3 ) " , i1 true , i1 false , metadata ! " EMSCRIPTEN : O3 " , i32 0 , metadata ! 1 , metadata ! 1 , metadata ! 3 , metadata ! 1 } ; [ DW_TAG_compile_unit ] <nl> + # TODO : test normal project linking , static and dynamic : get_library should not need to be told what to link ! <nl> # TODO : when ready , switch tools / shared building to use emcc over emmaken <nl> # TODO : when this is done , more test runner to test these ( i . e . , test all - Ox thoroughly ) <nl> # TODO : wiki docs for using emcc to optimize code <nl>
|
refactor emcc optimization testing
|
emscripten-core/emscripten
|
aa06e063ffbbd62f5a1a6e617fbb52110bd4590e
|
2011-12-14T19:59:09Z
|
new file mode 100644 <nl> index 0000000000 . . 8d2f40e6dd <nl> mmm / dev / null <nl> ppp b / NOTICE <nl> <nl> + Apache Weex <nl> + Copyright 2017 The Apache Software Foundation <nl> + <nl> + This product includes software developed at <nl> + The Apache Software Foundation ( http : / / www . apache . org / ) . <nl> \ No newline at end of file <nl>
|
* [ all ] add NOTICE for apache
|
apache/incubator-weex
|
7a8eac8271e2516b029f706e3140b742cf6b5a48
|
2017-04-28T03:28:44Z
|
mmm a / src / mips / stub - cache - mips . cc <nl> ppp b / src / mips / stub - cache - mips . cc <nl> Handle < Code > LoadStubCompiler : : CompileLoadGlobal ( <nl> <nl> <nl> Handle < Code > BaseLoadStoreStubCompiler : : CompilePolymorphicIC ( <nl> - MapHandleList * receiver_maps , <nl> + TypeHandleList * types , <nl> CodeHandleList * handlers , <nl> Handle < Name > name , <nl> Code : : StubType type , <nl> Handle < Code > BaseLoadStoreStubCompiler : : CompilePolymorphicIC ( <nl> } <nl> <nl> Label number_case ; <nl> - Label * smi_target = HasHeapNumberMap ( receiver_maps ) ? & number_case : & miss ; <nl> + Label * smi_target = IncludesNumberType ( types ) ? & number_case : & miss ; <nl> __ JumpIfSmi ( receiver ( ) , smi_target ) ; <nl> <nl> Register map_reg = scratch1 ( ) ; <nl> <nl> - int receiver_count = receiver_maps - > length ( ) ; <nl> + int receiver_count = types - > length ( ) ; <nl> int number_of_handled_maps = 0 ; <nl> __ lw ( map_reg , FieldMemOperand ( receiver ( ) , HeapObject : : kMapOffset ) ) ; <nl> - Handle < Map > heap_number_map = isolate ( ) - > factory ( ) - > heap_number_map ( ) ; <nl> for ( int current = 0 ; current < receiver_count ; + + current ) { <nl> - Handle < Map > map = receiver_maps - > at ( current ) ; <nl> + Handle < Type > type = types - > at ( current ) ; <nl> + Handle < Map > map = IC : : TypeToMap ( * type , isolate ( ) ) ; <nl> if ( ! map - > is_deprecated ( ) ) { <nl> number_of_handled_maps + + ; <nl> - if ( map . is_identical_to ( heap_number_map ) ) { <nl> + if ( type - > Is ( Type : : Number ( ) ) ) { <nl> ASSERT ( ! number_case . is_unused ( ) ) ; <nl> __ bind ( & number_case ) ; <nl> } <nl> __ Jump ( handlers - > at ( current ) , RelocInfo : : CODE_TARGET , <nl> - eq , map_reg , Operand ( receiver_maps - > at ( current ) ) ) ; <nl> + eq , map_reg , Operand ( map ) ) ; <nl> } <nl> } <nl> ASSERT ( number_of_handled_maps ! = 0 ) ; <nl>
|
MIPS : Convert PatchCache ( and related methods ) to use types rather than objects / maps .
|
v8/v8
|
ca5265d9c7f68d7655c7896cb83a7fdd152cfc5f
|
2013-11-19T02:26:42Z
|
mmm a / CHANGES . txt <nl> ppp b / CHANGES . txt <nl> <nl> 2016 - 07 - 15 version 3 . 0 . 0 - beta - 4 ( C + + / Java / Python / Ruby / Objective - C / C # / JavaScript ) <nl> General <nl> - * Added a deterministic serialization API for C + + and Java . The deterministic <nl> + * Added a deterministic serialization API for C + + . The deterministic <nl> serialization guarantees that given a binary , equal messages will be <nl> serialized to the same bytes . This allows applications like MapReduce to <nl> group equal messages based on the serialized bytes . The deterministic <nl> <nl> * Various performance optimizations . <nl> <nl> Java ( beta ) <nl> - * Introduced a deterministic serialization API in <nl> - CodedOutputStream # useDeterministicSerialization ( ) . See the notes about <nl> - deterministic serialization in the General section . <nl> * File option " java_generate_equals_and_hash " is now deprecated . equals ( ) and <nl> hashCode ( ) methods are generated by default . <nl> * Added a new JSON printer option " omittingInsignificantWhitespace " to produce <nl> mmm a / java / core / src / main / java / com / google / protobuf / CodedOutputStream . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / CodedOutputStream . java <nl> public static CodedOutputStream newInstance ( ByteBuffer byteBuffer ) { <nl> * maps are sorted on the lexicographical order of the UTF8 encoded keys . <nl> * < / ul > <nl> * / <nl> - public final void useDeterministicSerialization ( ) { <nl> + void useDeterministicSerialization ( ) { <nl> serializationDeterministic = true ; <nl> } <nl> <nl>
|
Remove Java deterministic API .
|
protocolbuffers/protobuf
|
82b43d1f41d6c374ebdd942dd86602736c2218e8
|
2016-07-18T17:36:04Z
|
mmm a / examples / python / cancellation / README . md <nl> ppp b / examples / python / cancellation / README . md <nl> context . add_callback ( on_rpc_done ) <nl> secret = _find_secret ( stop_event ) <nl> ` ` ` <nl> <nl> - # # # # # Initiating a Cancellation from a Servicer <nl> + # # # # # Initiating a Cancellation on the Server Side <nl> <nl> Initiating a cancellation from the server side is simpler . Just call <nl> ` ServicerContext . cancel ( ) ` . <nl> mmm a / examples / python / cancellation / server . py <nl> ppp b / examples / python / cancellation / server . py <nl> def _get_hash ( secret ) : <nl> return base64 . b64encode ( hasher . digest ( ) ) <nl> <nl> <nl> - def _find_secret_of_length ( target , ideal_distance , length , stop_event , interesting_hamming_distance = None ) : <nl> + class ResourceLimitExceededError ( Exception ) : <nl> + " " " Signifies the request has exceeded configured limits . " " " <nl> + <nl> + # TODO ( rbellevi ) : Docstring all the things . <nl> + # TODO ( rbellevi ) : File issue about indefinite blocking for server - side <nl> + # streaming . <nl> + <nl> + <nl> + def _find_secret_of_length ( target , ideal_distance , length , stop_event , maximum_hashes , interesting_hamming_distance = None ) : <nl> digits = [ 0 ] * length <nl> + hashes_computed = 0 <nl> while True : <nl> if stop_event . is_set ( ) : <nl> # Yield a sentinel and stop the generator if the RPC has been <nl> # cancelled . <nl> - yield None <nl> + yield None , hashes_computed <nl> raise StopIteration ( ) <nl> secret = b ' ' . join ( struct . pack ( ' B ' , i ) for i in digits ) <nl> hash = _get_hash ( secret ) <nl> def _find_secret_of_length ( target , ideal_distance , length , stop_event , interesti <nl> # Surface interesting candidates , but don ' t stop . <nl> yield hash_name_pb2 . HashNameResponse ( secret = base64 . b64encode ( secret ) , <nl> hashed_name = hash , <nl> - hamming_distance = distance ) <nl> + hamming_distance = distance ) , hashes_computed <nl> elif distance < = ideal_distance : <nl> # Yield the ideal candidate followed by a sentinel to signal the end <nl> # of the stream . <nl> yield hash_name_pb2 . HashNameResponse ( secret = base64 . b64encode ( secret ) , <nl> hashed_name = hash , <nl> - hamming_distance = distance ) <nl> - yield None <nl> + hamming_distance = distance ) , hashes_computed <nl> + yield None , hashes_computed <nl> raise StopIteration ( ) <nl> digits [ - 1 ] + = 1 <nl> i = length - 1 <nl> def _find_secret_of_length ( target , ideal_distance , length , stop_event , interesti <nl> raise StopIteration ( ) <nl> else : <nl> digits [ i ] + = 1 <nl> + hashes_computed + = 1 <nl> + if hashes_computed = = maximum_hashes : <nl> + raise ResourceLimitExceededError ( ) <nl> <nl> <nl> - def _find_secret ( target , maximum_distance , stop_event , interesting_hamming_distance = None ) : <nl> + def _find_secret ( target , maximum_distance , stop_event , maximum_hashes , interesting_hamming_distance = None ) : <nl> length = 1 <nl> + total_hashes = 0 <nl> while True : <nl> print ( " Checking strings of length { } . " . format ( length ) ) <nl> - for candidate in _find_secret_of_length ( target , maximum_distance , length , stop_event , interesting_hamming_distance = interesting_hamming_distance ) : <nl> + last_hashes_computed = 0 <nl> + for candidate , hashes_computed in _find_secret_of_length ( target , maximum_distance , length , stop_event , maximum_hashes - total_hashes , interesting_hamming_distance = interesting_hamming_distance ) : <nl> + last_hashes_computed = hashes_computed <nl> if candidate is not None : <nl> yield candidate <nl> else : <nl> def _find_secret ( target , maximum_distance , stop_event , interesting_hamming_dista <nl> if stop_event . is_set ( ) : <nl> # Terminate the generator if the RPC has been cancelled . <nl> raise StopIteration ( ) <nl> + total_hashes + = last_hashes_computed <nl> print ( " Incrementing length " ) <nl> length + = 1 <nl> <nl> <nl> class HashFinder ( hash_name_pb2_grpc . HashFinderServicer ) : <nl> <nl> + def __init__ ( self , maximum_hashes ) : <nl> + super ( HashFinder , self ) . __init__ ( ) <nl> + self . _maximum_hashes = maximum_hashes <nl> + <nl> def Find ( self , request , context ) : <nl> stop_event = threading . Event ( ) <nl> def on_rpc_done ( ) : <nl> print ( " Attempting to regain servicer thread . " ) <nl> stop_event . set ( ) <nl> context . add_callback ( on_rpc_done ) <nl> - candidates = list ( _find_secret ( request . desired_name , request . ideal_hamming_distance , stop_event ) ) <nl> + try : <nl> + candidates = list ( _find_secret ( request . desired_name , request . ideal_hamming_distance , stop_event , self . _maximum_hashes ) ) <nl> + except ResourceLimitExceededError : <nl> + print ( " Cancelling RPC due to exhausted resources . " ) <nl> + context . cancel ( ) <nl> print ( " Servicer thread returning . " ) <nl> if not candidates : <nl> return hash_name_pb2 . HashNameResponse ( ) <nl> def on_rpc_done ( ) : <nl> secret_generator = _find_secret ( request . desired_name , <nl> request . ideal_hamming_distance , <nl> stop_event , <nl> + self . _maximum_hashes , <nl> interesting_hamming_distance = request . interesting_hamming_distance ) <nl> - for candidate in secret_generator : <nl> - yield candidate <nl> + try : <nl> + for candidate in secret_generator : <nl> + yield candidate <nl> + except ResourceLimitExceededError : <nl> + print ( " Cancelling RPC due to exhausted resources . " ) <nl> + context . cancel <nl> print ( " Regained servicer thread . " ) <nl> <nl> <nl> - def _run_server ( port ) : <nl> + def _run_server ( port , maximum_hashes ) : <nl> server = grpc . server ( futures . ThreadPoolExecutor ( max_workers = 1 ) , <nl> maximum_concurrent_rpcs = 1 ) <nl> hash_name_pb2_grpc . add_HashFinderServicer_to_server ( <nl> - HashFinder ( ) , server ) <nl> + HashFinder ( maximum_hashes ) , server ) <nl> address = ' { } : { } ' . format ( _SERVER_HOST , port ) <nl> server . add_insecure_port ( address ) <nl> server . start ( ) <nl> def main ( ) : <nl> default = 50051 , <nl> nargs = ' ? ' , <nl> help = ' The port on which the server will listen . ' ) <nl> + parser . add_argument ( <nl> + ' - - maximum - hashes ' , <nl> + type = int , <nl> + default = 10000 , <nl> + nargs = ' ? ' , <nl> + help = ' The maximum number of hashes to search before cancelling . ' ) <nl> args = parser . parse_args ( ) <nl> - _run_server ( args . port ) <nl> + _run_server ( args . port , args . maximum_hashes ) <nl> <nl> <nl> if __name__ = = " __main__ " : <nl>
|
Cancel RPCs after a hash limit has been reached
|
grpc/grpc
|
4c852bf25f30b618e412c0a1e9dfb2f33cc75478
|
2019-06-25T19:50:10Z
|
new file mode 100755 <nl> index 00000000000 . . 71b25950466 <nl> mmm / dev / null <nl> ppp b / hphp / tools / import_zend_test . py <nl> <nl> + # ! / usr / bin / env python <nl> + <nl> + import os <nl> + import re <nl> + import sys <nl> + <nl> + if len ( sys . argv ) = = 1 : <nl> + print " Usage : \ n \ n % s / tmp / php - 5 . 4 . 11 / Zend / tests / zend_test . phpt . . . " % sys . argv [ 0 ] <nl> + sys . exit ( 0 ) <nl> + <nl> + test_files = [ ] <nl> + <nl> + def split ( pattern , str ) : <nl> + return re . split ( r ' \ n \ s * - - ' + pattern + ' - - \ s * \ n ' , str , 1 ) <nl> + <nl> + for filename in sys . argv [ 1 : ] : <nl> + print " Importing % s " % filename <nl> + zend = file ( filename ) . read ( ) <nl> + boom = split ( ' FILE ' , zend ) <nl> + if len ( boom ) ! = 2 : <nl> + print " Malformed test , no - - FILE - - : " , filename <nl> + continue <nl> + <nl> + name , therest = boom <nl> + <nl> + boom = split ( ' EXPECT ' , therest ) <nl> + if len ( boom ) = = 2 : <nl> + test , exp = boom <nl> + else : <nl> + boom = split ( ' EXPECTF ' , therest ) <nl> + if len ( boom ) = = 2 : <nl> + test , exp = boom <nl> + else : <nl> + print " Malformed test , no - - EXPECT - - or - - EXPECTF - - : " , filename <nl> + continue <nl> + <nl> + dest_filename = ' zend_ ' + os . path . basename ( filename ) . replace ( ' . phpt ' , ' . php ' ) <nl> + cur_dir = os . path . dirname ( __file__ ) <nl> + dest_dir = os . path . join ( cur_dir , ' . . / test / vm ' ) <nl> + full_dest_filename = os . path . join ( dest_dir , dest_filename ) <nl> + <nl> + test_files . append ( full_dest_filename ) <nl> + <nl> + if ' in % s on ' in exp : <nl> + exp = exp . replace ( ' in % s on ' , ' in hphp / test / vm / % s on ' % dest_filename ) <nl> + filter_file = full_dest_filename + ' . filter ' <nl> + if os . path . exists ( filter_file ) : <nl> + os . unlink ( filter_file ) <nl> + os . symlink ( ' filepath . filter ' , filter_file ) <nl> + exp = exp . replace ( ' Fatal error : ' , ' HipHop Fatal error : ' ) <nl> + exp = exp . replace ( ' Warning : ' , ' HipHop Warning : ' ) <nl> + exp = exp . replace ( ' Notice : ' , ' HipHop Notice : ' ) <nl> + # you ' ll have to fix up the line % d yourself <nl> + <nl> + file ( full_dest_filename , ' w ' ) . write ( test ) <nl> + file ( full_dest_filename + ' . exp ' , ' w ' ) . write ( exp ) <nl> + <nl> + print " \ nYou probably have to run \ n \ n make verify_quick \ n \ nthen " + \ <nl> + " inspect the . out files and copy them over : \ n " <nl> + <nl> + for file in test_files : <nl> + print " cp % s % s " % ( file + " . out " , file + " . exp " ) <nl>
|
script to import zend tests
|
facebook/hhvm
|
a395e9e3dddb59fca233ab1964fc47e44767a5b5
|
2013-03-06T06:07:50Z
|
mmm a / lib / IRGen / Cleanup . h <nl> ppp b / lib / IRGen / Cleanup . h <nl> <nl> <nl> namespace swift { <nl> namespace irgen { <nl> - class IRGenFunction ; <nl> <nl> / / These classes are private to GenCleanup . cpp . <nl> class CleanupControl ; <nl> mmm a / lib / IRGen / Explosion . h <nl> ppp b / lib / IRGen / Explosion . h <nl> namespace irgen { <nl> / / / cleanup . <nl> class ManagedValue { <nl> llvm : : Value * Value ; <nl> - IRGenFunction : : CleanupsDepth Cleanup ; <nl> + CleanupsDepth Cleanup ; <nl> <nl> public : <nl> ManagedValue ( ) = default ; <nl> explicit ManagedValue ( llvm : : Value * value ) <nl> - : Value ( value ) , Cleanup ( IRGenFunction : : CleanupsDepth : : invalid ( ) ) { } <nl> - ManagedValue ( llvm : : Value * value , IRGenFunction : : CleanupsDepth cleanup ) <nl> + : Value ( value ) , Cleanup ( CleanupsDepth : : invalid ( ) ) { } <nl> + ManagedValue ( llvm : : Value * value , CleanupsDepth cleanup ) <nl> : Value ( value ) , Cleanup ( cleanup ) { } <nl> <nl> llvm : : Value * getUnmanagedValue ( ) const { <nl> class ManagedValue { <nl> llvm : : Value * getValue ( ) const { return Value ; } <nl> <nl> bool hasCleanup ( ) const { return Cleanup . isValid ( ) ; } <nl> - IRGenFunction : : CleanupsDepth getCleanup ( ) const { return Cleanup ; } <nl> + CleanupsDepth getCleanup ( ) const { return Cleanup ; } <nl> <nl> / / / Forward this value , deactivating the cleanup and returning the <nl> / / / underlying value . <nl> class ManagedValue { <nl> } <nl> <nl> / / / Split this value into its underlying value and , if present , its cleanup . <nl> - llvm : : Value * split ( llvm : : SmallVectorImpl < IRGenFunction : : CleanupsDepth > <nl> - & cleanups ) { <nl> + llvm : : Value * split ( llvm : : SmallVectorImpl < CleanupsDepth > & cleanups ) { <nl> if ( hasCleanup ( ) ) cleanups . push_back ( getCleanup ( ) ) ; <nl> return getValue ( ) ; <nl> } <nl> mmm a / lib / IRGen / GenControl . cpp <nl> ppp b / lib / IRGen / GenControl . cpp <nl> static void popAndEmitTopCleanup ( IRGenFunction & IGF , <nl> / / / Remove all the dead cleanups on the top of the cleanup stack . <nl> static void popAndEmitTopDeadCleanups ( IRGenFunction & IGF , <nl> DiverseStackImpl < Cleanup > & stack , <nl> - IRGenFunction : : CleanupsDepth end ) { <nl> + CleanupsDepth end ) { <nl> stack . checkIterator ( end ) ; <nl> <nl> while ( stack . stable_begin ( ) ! = end & & stack . begin ( ) - > isDead ( ) ) { <nl> mmm a / lib / IRGen / GenFunc . cpp <nl> ppp b / lib / IRGen / GenFunc . cpp <nl> namespace { <nl> <nl> unsigned LastArgWritten ; <nl> SmallVector < llvm : : Value * , 16 > Args ; <nl> - SmallVector < IRGenFunction : : CleanupsDepth , 16 > ArgCleanups ; <nl> + SmallVector < CleanupsDepth , 16 > ArgCleanups ; <nl> <nl> protected : <nl> CallEmitter ( IRGenFunction & IGF , const Callee & callee , <nl> mmm a / lib / IRGen / GenHeap . cpp <nl> ppp b / lib / IRGen / GenHeap . cpp <nl> namespace { <nl> / / / Enter a cleanup to call swift_dealloc on the given pointer . <nl> / / / This cleanup will usually be deactivated as soon as the <nl> / / / initializer completes . <nl> - IRGenFunction : : CleanupsDepth <nl> + CleanupsDepth <nl> IRGenFunction : : pushDeallocCleanup ( llvm : : Value * allocation , <nl> llvm : : Value * size ) { <nl> pushFullExprCleanup < CallDealloc > ( allocation , size ) ; <nl> mmm a / lib / IRGen / GenInit . cpp <nl> ppp b / lib / IRGen / GenInit . cpp <nl> static OnHeap_t isOnHeap ( VarDecl * var ) { <nl> void Initialization : : registerObject ( IRGenFunction & IGF , Object object , <nl> OnHeap_t onHeap , const TypeInfo & objectTI ) { <nl> / / Create the appropriate destroy cleanup . <nl> - IRGenFunction : : CleanupsDepth destroy ; <nl> + CleanupsDepth destroy ; <nl> <nl> / / We need a destroy cleanup if the object is on the heap or non - POD . <nl> if ( onHeap | | ! objectTI . isPOD ( ResilienceScope : : Local ) ) { <nl> void Initialization : : registerObject ( IRGenFunction & IGF , Object object , <nl> objectTI ) ; <nl> destroy = IGF . getCleanupsDepth ( ) ; <nl> } else { <nl> - destroy = IRGenFunction : : CleanupsDepth : : invalid ( ) ; <nl> + destroy = CleanupsDepth : : invalid ( ) ; <nl> } <nl> <nl> registerObject ( object , destroy ) ; <nl> } <nl> <nl> void Initialization : : registerObjectWithoutDestroy ( Object object ) { <nl> - registerObject ( object , IRGenFunction : : CleanupsDepth : : invalid ( ) ) ; <nl> + registerObject ( object , CleanupsDepth : : invalid ( ) ) ; <nl> } <nl> <nl> / / / Register an object with the initialization process . <nl> void Initialization : : registerObject ( Object object , <nl> - IRGenFunction : : CleanupsDepth destroy ) { <nl> + CleanupsDepth destroy ) { <nl> / / The invariant is that the cleanup has to be an <nl> / / UnboundDestroy if it ' s valid . <nl> <nl> ValueRecord record = { <nl> - IRGenFunction : : CleanupsDepth : : invalid ( ) , destroy <nl> + CleanupsDepth : : invalid ( ) , destroy <nl> } ; <nl> Records . insert ( std : : make_pair ( object . Opaque , record ) ) ; <nl> } <nl> void Initialization : : registerObject ( Object object , <nl> / / / Mark that an object has been allocated . <nl> void Initialization : : markAllocated ( IRGenFunction & IGF , Object object , <nl> OwnedAddress address , <nl> - IRGenFunction : : CleanupsDepth dealloc ) { <nl> + CleanupsDepth dealloc ) { <nl> ValueRecord & record = Records . find ( object . Opaque ) - > second ; <nl> record . DeallocCleanup = dealloc ; <nl> <nl> Initialization : : emitLocalAllocation ( IRGenFunction & IGF , Object object , <nl> / / If the type is known to be empty , don ' t actually allocate anything . <nl> if ( type . isEmpty ( ResilienceScope : : Local ) ) { <nl> OwnedAddress addr = createEmptyAlloca ( IGF . IGM , type ) ; <nl> - markAllocated ( IGF , object , addr , IRGenFunction : : CleanupsDepth : : invalid ( ) ) ; <nl> + markAllocated ( IGF , object , addr , CleanupsDepth : : invalid ( ) ) ; <nl> return addr ; <nl> } <nl> <nl> Initialization : : emitLocalAllocation ( IRGenFunction & IGF , Object object , <nl> / / TODO : lifetime intrinsics ? <nl> <nl> OwnedAddress addr ( rawAddr , IGF . IGM . RefCountedNull ) ; <nl> - markAllocated ( IGF , object , addr , IRGenFunction : : CleanupsDepth : : invalid ( ) ) ; <nl> + markAllocated ( IGF , object , addr , CleanupsDepth : : invalid ( ) ) ; <nl> return addr ; <nl> } <nl> <nl> Initialization : : emitLocalAllocation ( IRGenFunction & IGF , Object object , <nl> <nl> / / Push a cleanup to dealloc the allocation . <nl> / / FIXME : don ' t emit the size twice ! <nl> - IRGenFunction : : CleanupsDepth deallocCleanup <nl> + CleanupsDepth deallocCleanup <nl> = IGF . pushDeallocCleanup ( allocation , layout . emitSize ( IGF ) ) ; <nl> <nl> OwnedAddress addr ( rawAddr , allocation ) ; <nl> Initialization : : emitLocalAllocation ( IRGenFunction & IGF , Object object , <nl> } <nl> <nl> static void maybeSetCleanupState ( IRGenFunction & IGF , <nl> - IRGenFunction : : CleanupsDepth maybeCleanup , <nl> + CleanupsDepth maybeCleanup , <nl> CleanupState newState ) { <nl> if ( maybeCleanup . isValid ( ) ) <nl> IGF . setCleanupState ( maybeCleanup , newState ) ; <nl> mmm a / lib / IRGen / GenInit . h <nl> ppp b / lib / IRGen / GenInit . h <nl> namespace irgen { <nl> / / / variable initialization . <nl> class Initialization { <nl> struct ValueRecord { <nl> - IRGenFunction : : CleanupsDepth DeallocCleanup ; <nl> - IRGenFunction : : CleanupsDepth DestroyCleanup ; <nl> + CleanupsDepth DeallocCleanup ; <nl> + CleanupsDepth DestroyCleanup ; <nl> } ; <nl> <nl> llvm : : DenseMap < void * , ValueRecord > Records ; <nl> class Initialization { <nl> / / / trivial and there isn ' t a dealloc cleanup . <nl> void markAllocated ( IRGenFunction & IGF , Object object , <nl> OwnedAddress address , <nl> - IRGenFunction : : CleanupsDepth dealloc ) ; <nl> + CleanupsDepth dealloc ) ; <nl> <nl> / / / Mark that the value has reached its instant of initialization . <nl> void markInitialized ( IRGenFunction & IGF , Object object ) ; <nl> <nl> private : <nl> / / / Add an object that is going to be initialized . <nl> - void registerObject ( Object object , IRGenFunction : : CleanupsDepth destroy ) ; <nl> + void registerObject ( Object object , CleanupsDepth destroy ) ; <nl> } ; <nl> <nl> } / / end namespace irgen <nl> mmm a / lib / IRGen / GenProto . cpp <nl> ppp b / lib / IRGen / GenProto . cpp <nl> namespace { <nl> <nl> / / Pull off the outer result . <nl> FixedPacking innerResultPacking ; <nl> - IRGenFunction : : CleanupsDepth outerResultCleanup <nl> - = IRGenFunction : : CleanupsDepth : : invalid ( ) ; <nl> + CleanupsDepth outerResultCleanup = CleanupsDepth : : invalid ( ) ; <nl> if ( HasAbstractedResult ) { <nl> outerResult = Address ( outerArgs . claimUnmanagedNext ( ) , <nl> getFixedBufferAlignment ( IGM ) ) ; <nl> void irgen : : emitErasureAsInit ( IRGenFunction & IGF , ErasureExpr * E , <nl> Address object = emitAllocateBuffer ( IGF , buffer , packing , concreteTI ) ; <nl> <nl> / / Push a cleanup to destroy that . <nl> - IRGenFunction : : CleanupsDepth deallocCleanup ; <nl> + CleanupsDepth deallocCleanup ; <nl> bool needsDeallocCleanup = ! isNeverAllocated ( packing ) ; <nl> if ( needsDeallocCleanup ) { <nl> IGF . pushFullExprCleanup < DeallocateBuffer > ( buffer , packing , concreteTI ) ; <nl> mmm a / lib / IRGen / GenStmt . cpp <nl> ppp b / lib / IRGen / GenStmt . cpp <nl> void IRGenFunction : : emitStmt ( Stmt * S ) { <nl> return emitForEachStmt ( cast < ForEachStmt > ( S ) ) ; <nl> <nl> case StmtKind : : Break : <nl> - unimplemented ( cast < BreakStmt > ( S ) - > getLoc ( ) , " break statement " ) ; <nl> - return ; <nl> + return emitBreakStmt ( cast < BreakStmt > ( S ) ) ; <nl> <nl> case StmtKind : : Continue : <nl> - unimplemented ( cast < ContinueStmt > ( S ) - > getLoc ( ) , " continue statement " ) ; <nl> - return ; <nl> + return emitContinueStmt ( cast < ContinueStmt > ( S ) ) ; <nl> } <nl> llvm_unreachable ( " bad statement kind ! " ) ; <nl> } <nl> void IRGenFunction : : emitReturnStmt ( ReturnStmt * S ) { <nl> Builder . ClearInsertionPoint ( ) ; <nl> } <nl> <nl> + static void emitOrDeleteBlock ( IRGenFunction & IGF , llvm : : BasicBlock * BB ) { <nl> + if ( BB - > use_empty ( ) ) { <nl> + / / If the block is unused , we don ' t need it ; just delete it . <nl> + delete BB ; <nl> + } else { <nl> + / / Otherwise , continue emitting code in BB . <nl> + if ( IGF . Builder . hasValidIP ( ) ) <nl> + IGF . Builder . CreateBr ( BB ) ; <nl> + IGF . Builder . emitBlockAnywhere ( BB ) ; <nl> + } <nl> + } <nl> + <nl> void IRGenFunction : : emitWhileStmt ( WhileStmt * S ) { <nl> / / Create a new basic block and jump into it . <nl> llvm : : BasicBlock * loopBB = createBasicBlock ( " while " ) ; <nl> Builder . CreateBr ( loopBB ) ; <nl> Builder . emitBlock ( loopBB ) ; <nl> <nl> + / / Set the destinations for ' break ' and ' continue ' <nl> + llvm : : BasicBlock * endBB = createBasicBlock ( " while . end " ) ; <nl> + BreakDestStack . emplace_back ( endBB , getCleanupsDepth ( ) ) ; <nl> + ContinueDestStack . emplace_back ( loopBB , getCleanupsDepth ( ) ) ; <nl> + <nl> / / Evaluate the condition with the false edge leading directly <nl> / / to the continuation block . <nl> Condition cond = emitCondition ( S - > getCond ( ) , / * hasFalseCode * / false ) ; <nl> void IRGenFunction : : emitWhileStmt ( WhileStmt * S ) { <nl> <nl> / / Complete the conditional execution . <nl> cond . complete ( * this ) ; <nl> + <nl> + emitOrDeleteBlock ( * this , endBB ) ; <nl> + BreakDestStack . pop_back ( ) ; <nl> + ContinueDestStack . pop_back ( ) ; <nl> } <nl> <nl> void IRGenFunction : : emitForStmt ( ForStmt * S ) { <nl> void IRGenFunction : : emitForStmt ( ForStmt * S ) { <nl> llvm : : BasicBlock * loopBB = createBasicBlock ( " for . condition " ) ; <nl> Builder . CreateBr ( loopBB ) ; <nl> Builder . emitBlock ( loopBB ) ; <nl> - <nl> + <nl> + / / Set the destinations for ' break ' and ' continue ' <nl> + llvm : : BasicBlock * incBB = createBasicBlock ( " for . inc " ) ; <nl> + llvm : : BasicBlock * endBB = createBasicBlock ( " for . end " ) ; <nl> + BreakDestStack . emplace_back ( endBB , getCleanupsDepth ( ) ) ; <nl> + ContinueDestStack . emplace_back ( incBB , getCleanupsDepth ( ) ) ; <nl> + <nl> / / Evaluate the condition with the false edge leading directly <nl> / / to the continuation block . <nl> Condition cond = S - > getCond ( ) . isNonNull ( ) ? <nl> void IRGenFunction : : emitForStmt ( ForStmt * S ) { <nl> if ( cond . hasTrue ( ) ) { <nl> cond . enterTrue ( * this ) ; <nl> emitStmt ( S - > getBody ( ) ) ; <nl> - <nl> + <nl> + emitOrDeleteBlock ( * this , incBB ) ; <nl> + <nl> if ( Builder . hasValidIP ( ) & & ! S - > getIncrement ( ) . isNull ( ) ) { <nl> if ( Expr * E = S - > getIncrement ( ) . dyn_cast < Expr * > ( ) ) { <nl> FullExpr scope ( * this ) ; <nl> void IRGenFunction : : emitForStmt ( ForStmt * S ) { <nl> / / Complete the conditional execution . <nl> cond . complete ( * this ) ; <nl> <nl> + emitOrDeleteBlock ( * this , endBB ) ; <nl> + BreakDestStack . pop_back ( ) ; <nl> + ContinueDestStack . pop_back ( ) ; <nl> } <nl> <nl> void IRGenFunction : : emitForEachStmt ( ForEachStmt * S ) { <nl> void IRGenFunction : : emitForEachStmt ( ForEachStmt * S ) { <nl> if ( ! Builder . hasValidIP ( ) ) return ; <nl> <nl> / / Create a new basic block and jump into it . <nl> - llvm : : BasicBlock * LoopBB = createBasicBlock ( " foreach . cond " ) ; <nl> - Builder . CreateBr ( LoopBB ) ; <nl> - Builder . emitBlock ( LoopBB ) ; <nl> + llvm : : BasicBlock * loopBB = createBasicBlock ( " foreach . cond " ) ; <nl> + Builder . CreateBr ( loopBB ) ; <nl> + Builder . emitBlock ( loopBB ) ; <nl> + <nl> + / / Set the destinations for ' break ' and ' continue ' <nl> + llvm : : BasicBlock * endBB = createBasicBlock ( " foreach . end " ) ; <nl> + BreakDestStack . emplace_back ( endBB , getCleanupsDepth ( ) ) ; <nl> + ContinueDestStack . emplace_back ( loopBB , getCleanupsDepth ( ) ) ; <nl> <nl> Condition Cond = emitCondition ( S - > getRangeEmpty ( ) , / * hasFalseCode = * / false , <nl> / * invertValue = * / true ) ; <nl> void IRGenFunction : : emitForEachStmt ( ForEachStmt * S ) { <nl> <nl> / / Loop back to the header . <nl> if ( Builder . hasValidIP ( ) ) { <nl> - Builder . CreateBr ( LoopBB ) ; <nl> + Builder . CreateBr ( loopBB ) ; <nl> Builder . ClearInsertionPoint ( ) ; <nl> } <nl> Cond . exitTrue ( * this ) ; <nl> } <nl> <nl> / / Complete the conditional execution . <nl> - Cond . complete ( * this ) ; <nl> + Cond . complete ( * this ) ; <nl> + <nl> + emitOrDeleteBlock ( * this , endBB ) ; <nl> + BreakDestStack . pop_back ( ) ; <nl> + ContinueDestStack . pop_back ( ) ; <nl> + } <nl> + <nl> + void IRGenFunction : : emitBreakStmt ( BreakStmt * S ) { <nl> + emitBranch ( BreakDestStack . back ( ) ) ; <nl> + Builder . ClearInsertionPoint ( ) ; <nl> } <nl> <nl> + void IRGenFunction : : emitContinueStmt ( ContinueStmt * S ) { <nl> + emitBranch ( ContinueDestStack . back ( ) ) ; <nl> + Builder . ClearInsertionPoint ( ) ; <nl> + } <nl> mmm a / lib / IRGen / IRGenFunction . h <nl> ppp b / lib / IRGen / IRGenFunction . h <nl> <nl> # include " llvm / ADT / DenseMap . h " <nl> # include " DiverseStack . h " <nl> # include " IRBuilder . h " <nl> + # include " JumpDest . h " <nl> <nl> namespace llvm { <nl> class AllocaInst ; <nl> namespace llvm { <nl> namespace swift { <nl> class AssignStmt ; <nl> class BraceStmt ; <nl> + class BreakStmt ; <nl> class ClassType ; <nl> + class ContinueStmt ; <nl> class Decl ; <nl> class Expr ; <nl> class ExtensionDecl ; <nl> namespace swift { <nl> class WhileStmt ; <nl> <nl> namespace irgen { <nl> - class Cleanup ; <nl> class Condition ; <nl> class Explosion ; <nl> enum class ExplosionKind : unsigned ; <nl> class HeapLayout ; <nl> class IRGenModule ; <nl> - class JumpDest ; <nl> class LinkEntity ; <nl> class LValue ; <nl> class ManagedValue ; <nl> class IRGenFunction { <nl> return pushCleanupInState < T , A . . . > ( state , : : std : : forward < A > ( args ) . . . ) ; <nl> } <nl> <nl> - typedef DiverseStackImpl < Cleanup > : : stable_iterator CleanupsDepth ; <nl> - <nl> / / / Retun a stable reference to the current cleanup . <nl> CleanupsDepth getCleanupsDepth ( ) const { <nl> return Cleanups . stable_begin ( ) ; <nl> class IRGenFunction { <nl> llvm : : BasicBlock * UnreachableBB ; <nl> llvm : : Instruction * JumpDestSlot ; <nl> CleanupsDepth InnermostScope ; <nl> + std : : vector < JumpDest > BreakDestStack ; <nl> + std : : vector < JumpDest > ContinueDestStack ; <nl> <nl> friend class Scope ; <nl> Cleanup & initCleanup ( Cleanup & cleanup , size_t allocSize , CleanupState state ) ; <nl> class IRGenFunction { <nl> void emitWhileStmt ( WhileStmt * S ) ; <nl> void emitForStmt ( ForStmt * S ) ; <nl> void emitForEachStmt ( ForEachStmt * S ) ; <nl> + void emitBreakStmt ( BreakStmt * S ) ; <nl> + void emitContinueStmt ( ContinueStmt * S ) ; <nl> <nl> / / mmm Expression emission mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> public : <nl> mmm a / lib / IRGen / JumpDest . h <nl> ppp b / lib / IRGen / JumpDest . h <nl> <nl> # ifndef SWIFT_IRGEN_JUMPDEST_H <nl> # define SWIFT_IRGEN_JUMPDEST_H <nl> <nl> - # include " IRGenFunction . h " <nl> + # include " DiverseStack . h " <nl> <nl> namespace llvm { <nl> class BasicBlock ; <nl> namespace llvm { <nl> namespace swift { <nl> namespace irgen { <nl> <nl> + class Cleanup ; <nl> + typedef DiverseStackImpl < Cleanup > : : stable_iterator CleanupsDepth ; <nl> + <nl> / / / The destination of a direct jump . Swift currently does not <nl> / / / support indirect branches or goto , so the jump mechanism only <nl> / / / needs to worry about branches into scopes , not out of them . <nl> class JumpDest { <nl> llvm : : BasicBlock * Block ; <nl> - IRGenFunction : : CleanupsDepth Depth ; <nl> + CleanupsDepth Depth ; <nl> public : <nl> - JumpDest ( llvm : : BasicBlock * block , IRGenFunction : : CleanupsDepth depth ) <nl> + JumpDest ( llvm : : BasicBlock * block , CleanupsDepth depth ) <nl> : Block ( block ) , Depth ( depth ) { } <nl> <nl> llvm : : BasicBlock * getBlock ( ) const { return Block ; } <nl> - IRGenFunction : : CleanupsDepth getDepth ( ) const { return Depth ; } <nl> + CleanupsDepth getDepth ( ) const { return Depth ; } <nl> } ; <nl> <nl> } / / end namespace irgen <nl> mmm a / lib / IRGen / Scope . h <nl> ppp b / lib / IRGen / Scope . h <nl> namespace irgen { <nl> / / / statement ) has been entered . <nl> class Scope { <nl> IRGenFunction & IGF ; <nl> - IRGenFunction : : CleanupsDepth Depth ; <nl> - IRGenFunction : : CleanupsDepth SavedInnermostScope ; <nl> + CleanupsDepth Depth ; <nl> + CleanupsDepth SavedInnermostScope ; <nl> <nl> void popImpl ( ) { <nl> IGF . Cleanups . checkIterator ( Depth ) ; <nl> class Scope { <nl> void pop ( ) { <nl> assert ( Depth . isValid ( ) & & " popping a scope twice ! " ) ; <nl> popImpl ( ) ; <nl> - Depth = IRGenFunction : : CleanupsDepth : : invalid ( ) ; <nl> + Depth = CleanupsDepth : : invalid ( ) ; <nl> } <nl> <nl> ~ Scope ( ) { <nl> new file mode 100644 <nl> index 000000000000 . . b1f64cce9bb0 <nl> mmm / dev / null <nl> ppp b / test / Interpreter / break_continue . swift <nl> <nl> + / / RUN : % swift - i % s | FileCheck % s <nl> + <nl> + func test1 ( ) { <nl> + println ( " test1 " ) <nl> + var i : Int <nl> + for i = 0 ; ; + + i { <nl> + if i > 2 { <nl> + break <nl> + } <nl> + println ( i ) <nl> + continue <nl> + } <nl> + } <nl> + func test2 ( ) { <nl> + println ( " test2 " ) <nl> + var i : Int <nl> + for i = 0 ; i < 10 ; + + i { <nl> + if i > 2 { <nl> + continue <nl> + } <nl> + println ( i ) <nl> + } <nl> + } <nl> + func test3 ( ) { <nl> + println ( " test3 " ) <nl> + var i : Int <nl> + for i = 0 ; i < 10 ; + + i { <nl> + if i > 2 { <nl> + break <nl> + } <nl> + println ( i ) <nl> + } <nl> + } <nl> + func test4 ( ) { <nl> + println ( " test4 " ) <nl> + for i in 0 . . 10 { <nl> + if i > 2 { <nl> + break <nl> + } <nl> + println ( i ) <nl> + } <nl> + } <nl> + func test5 ( ) { <nl> + println ( " test5 " ) <nl> + for i in 0 . . 10 { <nl> + if i < 2 { <nl> + println ( i ) <nl> + continue <nl> + } <nl> + return <nl> + } <nl> + } <nl> + func test6 ( ) { <nl> + println ( " test6 " ) <nl> + var i = 0 <nl> + while ( i < 10 ) { <nl> + if i < 2 { <nl> + println ( i ) <nl> + + + i <nl> + continue <nl> + } <nl> + return <nl> + } <nl> + } <nl> + func test7 ( ) { <nl> + println ( " test7 " ) <nl> + var i = 0 <nl> + while ( i < 10 ) { <nl> + if i < 2 { <nl> + println ( i ) <nl> + break <nl> + } <nl> + return <nl> + } <nl> + println ( " foo " ) <nl> + } <nl> + func test8 ( ) { <nl> + println ( " test8 " ) <nl> + var i : Int <nl> + for i = 0 ; ; + + i { <nl> + for j in 0 . . 10 { <nl> + if j > 1 { <nl> + break <nl> + } <nl> + println ( j ) <nl> + } <nl> + if i > 2 { <nl> + break <nl> + } <nl> + println ( i ) <nl> + continue <nl> + } <nl> + } <nl> + println ( " start " ) <nl> + test1 ( ) <nl> + / / CHECK : test1 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + test2 ( ) <nl> + / / CHECK : test2 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + test3 ( ) <nl> + / / CHECK : test3 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + test4 ( ) <nl> + / / CHECK : test4 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + test5 ( ) <nl> + / / CHECK : test5 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + test6 ( ) <nl> + / / CHECK : test6 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + test7 ( ) <nl> + / / CHECK : test7 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : foo <nl> + test8 ( ) <nl> + / / CHECK : test8 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 0 <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 1 <nl>
|
IRGen for break / continue .
|
apple/swift
|
26bebcfd6120b3f6114e17d6a9dba5effdaef43c
|
2012-05-31T02:45:18Z
|
mmm a / src / mongo / db / repl / oplog . cpp <nl> ppp b / src / mongo / db / repl / oplog . cpp <nl> MONGO_FAIL_POINT_DEFINE ( hangBeforeLogOpAdvancesLastApplied ) ; <nl> / * * <nl> * This structure contains per - service - context state related to the oplog . <nl> * / <nl> - struct LocalOplogInfo { <nl> + class LocalOplogInfo { <nl> + public : <nl> + static LocalOplogInfo * get ( ServiceContext & service ) ; <nl> + static LocalOplogInfo * get ( ServiceContext * service ) ; <nl> + static LocalOplogInfo * get ( OperationContext * opCtx ) ; <nl> + <nl> LocalOplogInfo ( const LocalOplogInfo & ) = delete ; <nl> LocalOplogInfo & operator = ( const LocalOplogInfo & ) = delete ; <nl> LocalOplogInfo ( ) = default ; <nl> <nl> + / * * <nl> + * Returns namespace of the local oplog collection . <nl> + * / <nl> + const NamespaceString & getOplogCollectionName ( ) const ; <nl> + <nl> + / * * <nl> + * Detects the current replication mode and sets the " _oplogName " accordingly . <nl> + * / <nl> + void setOplogCollectionName ( ServiceContext * service ) ; <nl> + <nl> + Collection * getCollection ( ) const ; <nl> + void setCollection ( Collection * oplog ) ; <nl> + void resetCollection ( ) ; <nl> + <nl> + / * * <nl> + * Sets the global Timestamp to be ' newTime ' . <nl> + * / <nl> + void setNewTimestamp ( ServiceContext * opCtx , const Timestamp & newTime ) ; <nl> + <nl> + / * * <nl> + * Allocates optimes for new entries in the oplog . Stores results in ' slotsOut ' , which <nl> + * contain the new optimes along with their terms and newly calculated hash fields . <nl> + * / <nl> + std : : vector < OplogSlot > getNextOpTimes ( OperationContext * opCtx , std : : size_t count ) ; <nl> + <nl> + private : <nl> / / Name of the oplog collection . <nl> - NamespaceString oplogName ; <nl> + NamespaceString _oplogName ; <nl> <nl> / / The " oplog " pointer is always valid ( or null ) because an operation must take the global <nl> / / exclusive lock to set the pointer to null when the Collection instance is destroyed . See <nl> / / " oplogCheckCloseDatabase " . <nl> - Collection * oplog = nullptr ; <nl> + Collection * _oplog = nullptr ; <nl> <nl> / / Synchronizes the section where a new Timestamp is generated and when it is registered in the <nl> / / storage engine . <nl> - stdx : : mutex newOpMutex ; <nl> + mutable stdx : : mutex _newOpMutex ; <nl> } ; <nl> <nl> const auto localOplogInfo = ServiceContext : : declareDecoration < LocalOplogInfo > ( ) ; <nl> <nl> + / / static <nl> + LocalOplogInfo * LocalOplogInfo : : get ( ServiceContext & service ) { <nl> + return get ( & service ) ; <nl> + } <nl> + <nl> + / / static <nl> + LocalOplogInfo * LocalOplogInfo : : get ( ServiceContext * service ) { <nl> + return & localOplogInfo ( service ) ; <nl> + } <nl> + <nl> + / / static <nl> + LocalOplogInfo * LocalOplogInfo : : get ( OperationContext * opCtx ) { <nl> + return get ( opCtx - > getServiceContext ( ) ) ; <nl> + } <nl> + <nl> + const NamespaceString & LocalOplogInfo : : getOplogCollectionName ( ) const { <nl> + return _oplogName ; <nl> + } <nl> + <nl> + Collection * LocalOplogInfo : : getCollection ( ) const { <nl> + return _oplog ; <nl> + } <nl> + <nl> + void LocalOplogInfo : : setCollection ( Collection * oplog ) { <nl> + _oplog = oplog ; <nl> + } <nl> + <nl> + void LocalOplogInfo : : resetCollection ( ) { <nl> + _oplog = nullptr ; <nl> + } <nl> + <nl> / / so we can fail the same way <nl> void checkOplogInsert ( Status result ) { <nl> massert ( 17322 , str : : stream ( ) < < " write to oplog failed : " < < result . toString ( ) , result . isOK ( ) ) ; <nl> } <nl> <nl> - void _getNextOpTimes ( OperationContext * opCtx , <nl> - Collection * oplog , <nl> - std : : size_t count , <nl> - OplogSlot * slotsOut , <nl> - bool persist = true ) { <nl> - auto & oplogInfo = localOplogInfo ( opCtx - > getServiceContext ( ) ) ; <nl> + std : : vector < OplogSlot > LocalOplogInfo : : getNextOpTimes ( OperationContext * opCtx , std : : size_t count ) { <nl> auto replCoord = ReplicationCoordinator : : get ( opCtx ) ; <nl> long long term = OpTime : : kUninitializedTerm ; <nl> <nl> void _getNextOpTimes ( OperationContext * opCtx , <nl> <nl> / / Allow the storage engine to start the transaction outside the critical section . <nl> opCtx - > recoveryUnit ( ) - > preallocateSnapshot ( ) ; <nl> - stdx : : lock_guard < stdx : : mutex > lk ( oplogInfo . newOpMutex ) ; <nl> + stdx : : lock_guard < stdx : : mutex > lk ( _newOpMutex ) ; <nl> <nl> ts = LogicalClock : : get ( opCtx ) - > reserveTicks ( count ) . asTimestamp ( ) ; <nl> const bool orderedCommit = false ; <nl> <nl> - if ( persist ) { <nl> - fassert ( 28560 , oplog - > getRecordStore ( ) - > oplogDiskLocRegister ( opCtx , ts , orderedCommit ) ) ; <nl> - } <nl> + / / The local oplog collection pointer must already be established by this point . <nl> + / / We can ' t establish it here because that would require locking the local database , which would <nl> + / / be a lock order violation . <nl> + invariant ( _oplog ) ; <nl> + fassert ( 28560 , _oplog - > getRecordStore ( ) - > oplogDiskLocRegister ( opCtx , ts , orderedCommit ) ) ; <nl> <nl> + std : : vector < OplogSlot > oplogSlots ( count ) ; <nl> for ( std : : size_t i = 0 ; i < count ; i + + ) { <nl> - slotsOut [ i ] = { Timestamp ( ts . asULL ( ) + i ) , term } ; <nl> + oplogSlots [ i ] = { Timestamp ( ts . asULL ( ) + i ) , term } ; <nl> } <nl> + return oplogSlots ; <nl> } <nl> <nl> / * * <nl> bool shouldBuildInForeground ( OperationContext * opCtx , <nl> <nl> } / / namespace <nl> <nl> - void setOplogCollectionName ( ServiceContext * service ) { <nl> + void LocalOplogInfo : : setOplogCollectionName ( ServiceContext * service ) { <nl> switch ( ReplicationCoordinator : : get ( service ) - > getReplicationMode ( ) ) { <nl> case ReplicationCoordinator : : modeReplSet : <nl> - localOplogInfo ( service ) . oplogName = NamespaceString : : kRsOplogNamespace ; <nl> + _oplogName = NamespaceString : : kRsOplogNamespace ; <nl> break ; <nl> case ReplicationCoordinator : : modeNone : <nl> / / leave empty . <nl> void setOplogCollectionName ( ServiceContext * service ) { <nl> } <nl> } <nl> <nl> + void setOplogCollectionName ( ServiceContext * service ) { <nl> + LocalOplogInfo : : get ( service ) - > setOplogCollectionName ( service ) ; <nl> + } <nl> + <nl> / * * <nl> * Parse the given BSON array of BSON into a vector of BSON . <nl> * / <nl> OpTime logOp ( OperationContext * opCtx , <nl> return { } ; <nl> } <nl> <nl> - const auto & oplogInfo = localOplogInfo ( opCtx - > getServiceContext ( ) ) ; <nl> + auto oplogInfo = LocalOplogInfo : : get ( opCtx ) ; <nl> <nl> / / Obtain Collection exclusive intent write lock for non - document - locking storage engines . <nl> boost : : optional < Lock : : DBLock > dbWriteLock ; <nl> boost : : optional < Lock : : CollectionLock > collWriteLock ; <nl> if ( ! opCtx - > getServiceContext ( ) - > getStorageEngine ( ) - > supportsDocLocking ( ) ) { <nl> dbWriteLock . emplace ( opCtx , NamespaceString : : kLocalDb , MODE_IX ) ; <nl> - collWriteLock . emplace ( opCtx , oplogInfo . oplogName , MODE_IX ) ; <nl> + collWriteLock . emplace ( opCtx , oplogInfo - > getOplogCollectionName ( ) , MODE_IX ) ; <nl> } <nl> <nl> - auto const oplog = oplogInfo . oplog ; <nl> OplogSlot slot ; <nl> WriteUnitOfWork wuow ( opCtx ) ; <nl> if ( oplogSlot . isNull ( ) ) { <nl> - _getNextOpTimes ( opCtx , oplog , 1 , & slot ) ; <nl> + slot = oplogInfo - > getNextOpTimes ( opCtx , 1U ) [ 0 ] ; <nl> } else { <nl> slot = oplogSlot ; <nl> } <nl> <nl> + auto oplog = oplogInfo - > getCollection ( ) ; <nl> auto writer = _logOpWriter ( opCtx , <nl> opstr , <nl> nss , <nl> std : : vector < OpTime > logInsertOps ( OperationContext * opCtx , <nl> const size_t count = end - begin ; <nl> std : : vector < OplogDocWriter > writers ; <nl> writers . reserve ( count ) ; <nl> - const auto & oplogInfo = localOplogInfo ( opCtx - > getServiceContext ( ) ) ; <nl> + auto oplogInfo = LocalOplogInfo : : get ( opCtx ) ; <nl> <nl> / / Obtain Collection exclusive intent write lock for non - document - locking storage engines . <nl> boost : : optional < Lock : : DBLock > dbWriteLock ; <nl> boost : : optional < Lock : : CollectionLock > collWriteLock ; <nl> if ( ! opCtx - > getServiceContext ( ) - > getStorageEngine ( ) - > supportsDocLocking ( ) ) { <nl> dbWriteLock . emplace ( opCtx , NamespaceString : : kLocalDb , MODE_IX ) ; <nl> - collWriteLock . emplace ( opCtx , oplogInfo . oplogName , MODE_IX ) ; <nl> + collWriteLock . emplace ( opCtx , oplogInfo - > getOplogCollectionName ( ) , MODE_IX ) ; <nl> } <nl> <nl> - auto oplog = oplogInfo . oplog ; <nl> WriteUnitOfWork wuow ( opCtx ) ; <nl> <nl> OperationSessionInfo sessionInfo ; <nl> std : : vector < OpTime > logInsertOps ( OperationContext * opCtx , <nl> auto insertStatementOplogSlot = begin [ i ] . oplogSlot ; <nl> / / Fetch optime now , if not already fetched . <nl> if ( insertStatementOplogSlot . isNull ( ) ) { <nl> - _getNextOpTimes ( opCtx , oplog , 1 , & insertStatementOplogSlot ) ; <nl> + insertStatementOplogSlot = oplogInfo - > getNextOpTimes ( opCtx , 1U ) [ 0 ] ; <nl> } <nl> / / Only ' applyOps ' oplog entries can be prepared . <nl> constexpr bool prepare = false ; <nl> std : : vector < OpTime > logInsertOps ( OperationContext * opCtx , <nl> invariant ( ! opTimes . empty ( ) ) ; <nl> auto lastOpTime = opTimes . back ( ) ; <nl> invariant ( ! lastOpTime . isNull ( ) ) ; <nl> + auto oplog = oplogInfo - > getCollection ( ) ; <nl> _logOpsInner ( <nl> opCtx , nss , basePtrs . get ( ) , timestamps . get ( ) , count , oplog , lastOpTime , wallClockTime ) ; <nl> wuow . commit ( ) ; <nl> void createOplog ( OperationContext * opCtx , const std : : string & oplogCollectionName <nl> void createOplog ( OperationContext * opCtx ) { <nl> const auto isReplSet = ReplicationCoordinator : : get ( opCtx ) - > getReplicationMode ( ) = = <nl> ReplicationCoordinator : : modeReplSet ; <nl> - createOplog ( opCtx , localOplogInfo ( opCtx - > getServiceContext ( ) ) . oplogName . ns ( ) , isReplSet ) ; <nl> + createOplog ( opCtx , LocalOplogInfo : : get ( opCtx ) - > getOplogCollectionName ( ) . ns ( ) , isReplSet ) ; <nl> } <nl> <nl> MONGO_REGISTER_SHIM ( GetNextOpTimeClass : : getNextOpTimes ) <nl> ( OperationContext * opCtx , std : : size_t count ) - > std : : vector < OplogSlot > { <nl> - / / The local oplog collection pointer must already be established by this point . <nl> - / / We can ' t establish it here because that would require locking the local database , which would <nl> - / / be a lock order violation . <nl> - auto oplog = localOplogInfo ( opCtx - > getServiceContext ( ) ) . oplog ; <nl> - invariant ( oplog ) ; <nl> - std : : vector < OplogSlot > oplogSlots ( count ) ; <nl> - auto oplogSlot = oplogSlots . begin ( ) ; <nl> - _getNextOpTimes ( opCtx , oplog , count , & ( * oplogSlot ) ) ; <nl> - return oplogSlots ; <nl> + return LocalOplogInfo : : get ( opCtx ) - > getNextOpTimes ( opCtx , count ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> Status applyCommand_inlock ( OperationContext * opCtx , <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - void setNewTimestamp ( ServiceContext * service , const Timestamp & newTime ) { <nl> - stdx : : lock_guard < stdx : : mutex > lk ( localOplogInfo ( service ) . newOpMutex ) ; <nl> + void LocalOplogInfo : : setNewTimestamp ( ServiceContext * service , const Timestamp & newTime ) { <nl> + stdx : : lock_guard < stdx : : mutex > lk ( _newOpMutex ) ; <nl> LogicalClock : : get ( service ) - > setClusterTimeFromTrustedSource ( LogicalTime ( newTime ) ) ; <nl> } <nl> <nl> + void setNewTimestamp ( ServiceContext * service , const Timestamp & newTime ) { <nl> + LocalOplogInfo : : get ( service ) - > setNewTimestamp ( service , newTime ) ; <nl> + } <nl> + <nl> void initTimestampFromOplog ( OperationContext * opCtx , const std : : string & oplogNS ) { <nl> DBDirectClient c ( opCtx ) ; <nl> static const BSONObj reverseNaturalObj = BSON ( " $ natural " < < - 1 ) ; <nl> void initTimestampFromOplog ( OperationContext * opCtx , const std : : string & oplogNS ) <nl> void oplogCheckCloseDatabase ( OperationContext * opCtx , const Database * db ) { <nl> invariant ( opCtx - > lockState ( ) - > isW ( ) ) ; <nl> if ( db - > name ( ) = = " local " ) { <nl> - localOplogInfo ( opCtx - > getServiceContext ( ) ) . oplog = nullptr ; <nl> + LocalOplogInfo : : get ( opCtx ) - > resetCollection ( ) ; <nl> } <nl> } <nl> <nl> void clearLocalOplogPtr ( ) { <nl> - localOplogInfo ( getGlobalServiceContext ( ) ) . oplog = nullptr ; <nl> + LocalOplogInfo : : get ( getGlobalServiceContext ( ) ) - > resetCollection ( ) ; <nl> } <nl> <nl> void acquireOplogCollectionForLogging ( OperationContext * opCtx ) { <nl> - auto & oplogInfo = localOplogInfo ( opCtx - > getServiceContext ( ) ) ; <nl> - if ( ! oplogInfo . oplogName . isEmpty ( ) ) { <nl> - AutoGetCollection autoColl ( opCtx , oplogInfo . oplogName , MODE_IX ) ; <nl> - oplogInfo . oplog = autoColl . getCollection ( ) ; <nl> + auto oplogInfo = LocalOplogInfo : : get ( opCtx ) ; <nl> + const auto & nss = oplogInfo - > getOplogCollectionName ( ) ; <nl> + if ( ! nss . isEmpty ( ) ) { <nl> + AutoGetCollection autoColl ( opCtx , nss , MODE_IX ) ; <nl> + LocalOplogInfo : : get ( opCtx ) - > setCollection ( autoColl . getCollection ( ) ) ; <nl> } <nl> } <nl> <nl> void establishOplogCollectionForLogging ( OperationContext * opCtx , Collection * oplog ) { <nl> invariant ( opCtx - > lockState ( ) - > isW ( ) ) ; <nl> invariant ( oplog ) ; <nl> - localOplogInfo ( opCtx - > getServiceContext ( ) ) . oplog = oplog ; <nl> + LocalOplogInfo : : get ( opCtx ) - > setCollection ( oplog ) ; <nl> } <nl> <nl> void signalOplogWaiters ( ) { <nl> - auto oplog = localOplogInfo ( getGlobalServiceContext ( ) ) . oplog ; <nl> + auto oplog = LocalOplogInfo : : get ( getGlobalServiceContext ( ) ) - > getCollection ( ) ; <nl> if ( oplog ) { <nl> oplog - > getCappedCallback ( ) - > notifyCappedWaitersIfNeeded ( ) ; <nl> } <nl>
|
SERVER - 40809 clean up LocalOplogInfo in oplog . cpp
|
mongodb/mongo
|
b9c656f6e2d0b0b7676927538ed7ac3278c23322
|
2019-04-25T01:02:27Z
|
mmm a / hphp / hack / src / parsing / namespaces . ml <nl> ppp b / hphp / hack / src / parsing / namespaces . ml <nl> let autoimport_classes = [ <nl> " ConditionWaitHandle " ; <nl> " RescheduleWaitHandle " ; <nl> " SleepWaitHandle " ; <nl> - " ExternalThreadEventWaitHandle " <nl> + " ExternalThreadEventWaitHandle " ; <nl> ] <nl> let autoimport_funcs = [ <nl> " invariant " ; <nl> " invariant_violation " <nl> ] <nl> + let autoimport_types = [ <nl> + " classname " <nl> + ] <nl> <nl> let autoimport_set = <nl> - let autoimport_list = autoimport_classes @ autoimport_funcs in <nl> + let autoimport_list <nl> + = autoimport_classes @ autoimport_funcs @ autoimport_types in <nl> List . fold_left autoimport_list ~ init : SSet . empty ~ f : ( fun s e - > SSet . add e s ) <nl> ( * NOTE that the runtime is able to distinguish between class and <nl> function names when auto - importing * ) <nl> new file mode 100644 <nl> index 00000000000 . . 4ff98da5cfb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / namespaced_classname . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + namespace foo \ bar ; <nl> + <nl> + < < __ConsistentConstruct > > <nl> + class Herp { } <nl> + <nl> + class Derp extends Herp { } <nl> + <nl> + function foo < T as Herp > ( classname < T > $ class ) : T { <nl> + return new $ class ( ) ; <nl> + } <nl> + <nl> + function bar ( Vector < string > $ foo ) : void { } <nl> + <nl> + function main ( ) : void { <nl> + foo ( Derp : : class ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4269126fceb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / namespaced_classname . php . exp <nl> @ @ - 0 , 0 + 1 @ @ <nl> + No errors <nl> new file mode 100644 <nl> index 00000000000 . . 16333b75cb8 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / variable_class_name / hack_classname_t . php <nl> <nl> + < ? hh <nl> + <nl> + < < __ConsistentConstruct > > <nl> + class Herp { <nl> + } <nl> + <nl> + class Derp extends Herp { } <nl> + <nl> + function foo < T as Herp > ( classname < T > $ class ) : T { return new $ class ( ) ; } <nl> + <nl> + function bar ( Vector < string > $ foo ) : void { } <nl> + <nl> + function main ( ) : void { <nl> + var_dump ( foo ( Derp : : class ) ) ; <nl> + } <nl> + <nl> + main ( ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 174be374b1f <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / variable_class_name / hack_classname_t . php . expect <nl> <nl> + object ( Derp ) # 1 ( 0 ) { <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c742dd372a6 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / variable_class_name / hack_classname_t_ns . php <nl> <nl> + < ? hh <nl> + <nl> + namespace foo \ bar ; <nl> + <nl> + < < __ConsistentConstruct > > <nl> + class Herp { <nl> + } <nl> + <nl> + class Derp extends Herp { } <nl> + <nl> + function foo < T as Herp > ( classname < T > $ class ) : T { return new $ class ( ) ; } <nl> + <nl> + function bar ( Vector < string > $ foo ) : void { } <nl> + <nl> + function main ( ) : void { <nl> + var_dump ( foo ( Derp : : class ) ) ; <nl> + } <nl> + <nl> + main ( ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 39e7926e96a <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / variable_class_name / hack_classname_t_ns . php . expect <nl> <nl> + object ( foo \ bar \ Derp ) # 1 ( 0 ) { <nl> + } <nl>
|
Auto - import classname < T > into namespaces
|
facebook/hhvm
|
9a1e446c32e54e95cbbd577c40242cc7d60dd8ad
|
2015-08-06T00:32:33Z
|
mmm a / src / objective - c / tests / GRPCClientTests . m <nl> ppp b / src / objective - c / tests / GRPCClientTests . m <nl> - ( int ) findFreePort { <nl> - ( void ) testErrorCode { <nl> int port = [ self findFreePort ] ; <nl> NSString * const kDummyAddress = [ NSString stringWithFormat : @ " localhost : % d " , port ] ; <nl> - __weak XCTestExpectation * completion = [ self expectationWithDescription : @ " Empty RPC completed . " ] ; <nl> + __weak XCTestExpectation * completion = <nl> + [ self expectationWithDescription : @ " Received correct error code . " ] ; <nl> <nl> GRPCCall * call = [ [ GRPCCall alloc ] initWithHost : kDummyAddress <nl> path : kEmptyCallMethod . HTTPPath <nl>
|
nit - Update test description
|
grpc/grpc
|
e5a3949c515f7f999fa2bd6ce835fc1ae38db19f
|
2018-06-11T22:56:22Z
|
mmm a / src / core / ext / transport / chttp2 / transport / writing . c <nl> ppp b / src / core / ext / transport / chttp2 / transport / writing . c <nl> static void update_list ( grpc_exec_ctx * exec_ctx , grpc_chttp2_transport * t , <nl> GRPC_ERROR_UNREF ( error ) ; <nl> } <nl> <nl> + static bool stream_ref_if_not_destroyed ( gpr_refcount * r ) { <nl> + gpr_atm count ; <nl> + do { <nl> + count = gpr_atm_acq_load ( & r - > count ) ; <nl> + if ( count = = 0 ) return false ; <nl> + } while ( ! gpr_atm_rel_cas ( & r - > count , count , count + 1 ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> bool grpc_chttp2_begin_write ( grpc_exec_ctx * exec_ctx , <nl> grpc_chttp2_transport * t ) { <nl> grpc_chttp2_stream * s ; <nl> bool grpc_chttp2_begin_write ( grpc_exec_ctx * exec_ctx , <nl> <nl> if ( t - > outgoing_window > 0 ) { <nl> while ( grpc_chttp2_list_pop_stalled_by_transport ( t , & s ) ) { <nl> - grpc_chttp2_become_writable ( exec_ctx , t , s , false , <nl> - " transport . read_flow_control " ) ; <nl> + if ( ! t - > closed & & grpc_chttp2_list_add_writable_stream ( t , s ) & & <nl> + stream_ref_if_not_destroyed ( & s - > refcount - > refs ) ) { <nl> + grpc_chttp2_initiate_write ( exec_ctx , t , false , <nl> + " transport . read_flow_control " ) ; <nl> + } <nl> } <nl> } <nl> <nl>
|
Merge pull request from dgquintas / stalled_stream_ref_fix
|
grpc/grpc
|
0292bf617697119b84b68f8ea52ded8a0954ad17
|
2017-01-26T04:32:52Z
|
new file mode 100644 <nl> index 00000000000 . . 605733eac56 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / integration / data / global_inference / www / namespace . out <nl> <nl> + < ? hh / / partial <nl> + <nl> + namespace Foo \ Bar ; <nl> + <nl> + class MyClass { <nl> + } <nl> + <nl> + function buildermyclass ( ) : < < __Soft > > \ Foo \ Bar \ MyClass { <nl> + return new MyClass ( ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 1c61a51a5b6 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / integration / data / global_inference / www / one . out <nl> <nl> + < ? hh / / partial <nl> + <nl> + class One { <nl> + public function foo ( ) : < < __Soft > > int { <nl> + return 1 ; <nl> + } <nl> + <nl> + public function bar ( ) : < < __Soft > > ? int { <nl> + return null ; <nl> + } <nl> + <nl> + public function noparameter ( < < __Soft > > int $ x ) : < < __Soft > > int { <nl> + return $ x ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 74e4b8a78a9 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / integration / data / global_inference / www / three . out <nl> <nl> + < ? hh / / partial <nl> + <nl> + class Three extends Two { <nl> + public function foo ( ) : < < __Soft > > int { <nl> + return 3 ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . e320c75c1f0 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / integration / data / global_inference / www / two . out <nl> <nl> + < ? hh / / partial <nl> + <nl> + class Two extends One { <nl> + public function foo ( ) : < < __Soft > > int { <nl> + return 2 ; <nl> + } <nl> + <nl> + public function bar ( ) : < < __Soft > > int { <nl> + return 1 ; <nl> + } <nl> + <nl> + public function usenum ( ) : < < __Soft > > void { <nl> + $ x = new One ( ) ; <nl> + <nl> + $ x - > noparameter ( 1 ) ; <nl> + } <nl> + } <nl> + <nl> + function throwException ( ) { <nl> + throw new \ Exception ( " " ) ; <nl> + } <nl> + <nl> + function throwExceptionIndirect ( ) : < < __Soft > > void { <nl> + throwException ( ) ; <nl> + } <nl>
|
Back out " removing . out files "
|
facebook/hhvm
|
1a4a9f14738d7b44245d43a1b35d8109a0fa5400
|
2020-10-13T07:33:18Z
|
mmm a / src / library_syscall . js <nl> ppp b / src / library_syscall . js <nl> mergeInto ( LibraryManager . library , { <nl> path = SYSCALLS . calculateAt ( dirfd , path ) ; <nl> return SYSCALLS . doReadlink ( path , buf , bufsize ) ; <nl> } <nl> + case 306 : { / / fchmodat <nl> + # if SYSCALL_DEBUG <nl> + Module . printErr ( ' warning : untested syscall ' ) ; <nl> + # endif <nl> + var dirfd = get ( ) , path = getStr ( ) , mode = get ( ) , flags = get ( ) ; <nl> + assert ( flags = = = 0 ) ; <nl> + path = SYSCALLS . calculateAt ( dirfd , path ) ; <nl> + FS . chmod ( path , mode ) ; <nl> + return 0 ; <nl> + } <nl> case 324 : { / / fallocate <nl> var stream = getStreamFromFD ( ) , mode = get ( ) , offset = get64 ( ) , len = get64 ( ) ; <nl> assert ( mode = = = 0 ) ; <nl>
|
fchmodat syscall
|
emscripten-core/emscripten
|
ec948e301e6a26c8f64de5afc77b32bc26e7ab1e
|
2015-06-01T20:29:00Z
|
mmm a / js / binary / proto_test . js <nl> ppp b / js / binary / proto_test . js <nl> function fillAllFields ( msg ) { <nl> submsg . setC ( 16 ) ; <nl> msg . setOptionalForeignMessage ( submsg ) ; <nl> msg . setOptionalForeignEnum ( proto . jspb . test . ForeignEnum . FOREIGN_FOO ) ; <nl> - msg . setOptionalInt32String ( ' - 12345 ' ) ; <nl> - msg . setOptionalUint32String ( ' 12345 ' ) ; <nl> - msg . setOptionalInt64String ( ' - 123456789012345 ' ) ; <nl> - msg . setOptionalUint64String ( ' 987654321098765 ' ) ; <nl> msg . setOneofString ( ' oneof ' ) ; <nl> <nl> msg . setRepeatedInt32List ( [ - 42 ] ) ; <nl> function fillAllFields ( msg ) { <nl> msg . setPackedRepeatedFloatList ( [ 1 . 5 ] ) ; <nl> msg . setPackedRepeatedDoubleList ( [ - 1 . 5 ] ) ; <nl> msg . setPackedRepeatedBoolList ( [ true ] ) ; <nl> - <nl> - msg . setRepeatedInt32StringList ( [ ' - 12345 ' ] ) ; <nl> - msg . setRepeatedUint32StringList ( [ ' 12345 ' ] ) ; <nl> - msg . setRepeatedInt64StringList ( [ ' - 123456789012345 ' ] ) ; <nl> - msg . setRepeatedUint64StringList ( [ ' 987654321098765 ' ] ) ; <nl> - msg . setPackedRepeatedInt32StringList ( [ ' - 12345 ' ] ) ; <nl> - msg . setPackedRepeatedUint32StringList ( [ ' 12345 ' ] ) ; <nl> - msg . setPackedRepeatedInt64StringList ( [ ' - 123456789012345 ' ] ) ; <nl> - msg . setPackedRepeatedUint64StringList ( [ ' 987654321098765 ' ] ) ; <nl> } <nl> <nl> <nl> function checkAllFields ( msg ) { <nl> assertEquals ( msg . getOptionalForeignMessage ( ) . getC ( ) , 16 ) ; <nl> assertEquals ( msg . getOptionalForeignEnum ( ) , <nl> proto . jspb . test . ForeignEnum . FOREIGN_FOO ) ; <nl> - assertEquals ( msg . getOptionalInt32String ( ) , ' - 12345 ' ) ; <nl> - assertEquals ( msg . getOptionalUint32String ( ) , ' 12345 ' ) ; <nl> - assertEquals ( msg . getOptionalInt64String ( ) , ' - 123456789012345 ' ) ; <nl> - assertEquals ( msg . getOptionalUint64String ( ) , ' 987654321098765 ' ) ; <nl> assertEquals ( msg . getOneofString ( ) , ' oneof ' ) ; <nl> assertEquals ( msg . getOneofFieldCase ( ) , <nl> proto . jspb . test . TestAllTypes . OneofFieldCase . ONEOF_STRING ) ; <nl> function checkAllFields ( msg ) { <nl> assertElementsEquals ( msg . getPackedRepeatedFloatList ( ) , [ 1 . 5 ] ) ; <nl> assertElementsEquals ( msg . getPackedRepeatedDoubleList ( ) , [ - 1 . 5 ] ) ; <nl> assertElementsEquals ( msg . getPackedRepeatedBoolList ( ) , [ true ] ) ; <nl> - <nl> - assertEquals ( msg . getRepeatedInt32StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getRepeatedInt32StringList ( ) , [ ' - 12345 ' ] ) ; <nl> - assertEquals ( msg . getRepeatedUint32StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getRepeatedUint32StringList ( ) , [ ' 12345 ' ] ) ; <nl> - assertEquals ( msg . getRepeatedInt64StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getRepeatedInt64StringList ( ) , [ ' - 123456789012345 ' ] ) ; <nl> - assertEquals ( msg . getRepeatedUint64StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getRepeatedUint64StringList ( ) , [ ' 987654321098765 ' ] ) ; <nl> - <nl> - assertEquals ( msg . getPackedRepeatedInt32StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getPackedRepeatedInt32StringList ( ) , [ ' - 12345 ' ] ) ; <nl> - assertEquals ( msg . getPackedRepeatedUint32StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getPackedRepeatedUint32StringList ( ) , [ ' 12345 ' ] ) ; <nl> - assertEquals ( msg . getPackedRepeatedInt64StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getPackedRepeatedInt64StringList ( ) , <nl> - [ ' - 123456789012345 ' ] ) ; <nl> - assertEquals ( msg . getPackedRepeatedUint64StringList ( ) . length , 1 ) ; <nl> - assertElementsEquals ( msg . getPackedRepeatedUint64StringList ( ) , <nl> - [ ' 987654321098765 ' ] ) ; <nl> } <nl> <nl> <nl> function checkExtensions ( msg ) { <nl> proto . jspb . test . ExtendsWithMessage . optionalExtension ) . getFoo ( ) ) ; <nl> assertEquals ( proto . jspb . test . ForeignEnum . FOREIGN_FOO , <nl> msg . getExtension ( proto . jspb . test . extendOptionalForeignEnum ) ) ; <nl> - assertEquals ( ' - 12345 ' , <nl> - msg . getExtension ( proto . jspb . test . extendOptionalInt32String ) ) ; <nl> - assertEquals ( ' 12345 ' , <nl> - msg . getExtension ( proto . jspb . test . extendOptionalUint32String ) ) ; <nl> - assertEquals ( ' - 123456789012345 ' , <nl> - msg . getExtension ( proto . jspb . test . extendOptionalInt64String ) ) ; <nl> - assertEquals ( ' 987654321098765 ' , <nl> - msg . getExtension ( proto . jspb . test . extendOptionalUint64String ) ) ; <nl> <nl> assertElementsEquals ( <nl> msg . getExtension ( proto . jspb . test . extendRepeatedInt32List ) , <nl> function checkExtensions ( msg ) { <nl> msg . getExtension ( proto . jspb . test . extendRepeatedForeignEnumList ) , <nl> [ proto . jspb . test . ForeignEnum . FOREIGN_FOO ] ) ; <nl> <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendRepeatedInt32StringList ) , <nl> - [ ' - 12345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendRepeatedUint32StringList ) , <nl> - [ ' 12345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendRepeatedInt64StringList ) , <nl> - [ ' - 123456789012345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendRepeatedUint64StringList ) , <nl> - [ ' 987654321098765 ' ] ) ; <nl> - <nl> assertElementsEquals ( <nl> msg . getExtension ( proto . jspb . test . extendPackedRepeatedInt32List ) , <nl> [ - 42 ] ) ; <nl> function checkExtensions ( msg ) { <nl> assertElementsEquals ( <nl> msg . getExtension ( proto . jspb . test . extendPackedRepeatedForeignEnumList ) , <nl> [ proto . jspb . test . ForeignEnum . FOREIGN_FOO ] ) ; <nl> - <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendPackedRepeatedInt32StringList ) , <nl> - [ ' - 12345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendPackedRepeatedUint32StringList ) , <nl> - [ ' 12345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendPackedRepeatedInt64StringList ) , <nl> - [ ' - 123456789012345 ' ] ) ; <nl> - assertElementsEquals ( <nl> - msg . getExtension ( proto . jspb . test . extendPackedRepeatedUint64StringList ) , <nl> - [ ' 987654321098765 ' ] ) ; <nl> } <nl> <nl> <nl> describe ( ' protoBinaryTest ' , function ( ) { <nl> msg . setExtension ( <nl> proto . jspb . test . extendOptionalForeignEnum , <nl> proto . jspb . test . ForeignEnum . FOREIGN_FOO ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendOptionalInt32String , ' - 12345 ' ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendOptionalUint32String , ' 12345 ' ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendOptionalInt64String , ' - 123456789012345 ' ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendOptionalUint64String , ' 987654321098765 ' ) ; <nl> <nl> msg . setExtension ( <nl> proto . jspb . test . extendRepeatedInt32List , [ - 42 ] ) ; <nl> describe ( ' protoBinaryTest ' , function ( ) { <nl> msg . setExtension ( proto . jspb . test . extendRepeatedForeignEnumList , <nl> [ proto . jspb . test . ForeignEnum . FOREIGN_FOO ] ) ; <nl> <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendRepeatedInt32StringList , [ ' - 12345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendRepeatedUint32StringList , [ ' 12345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendRepeatedInt64StringList , [ ' - 123456789012345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendRepeatedUint64StringList , [ ' 987654321098765 ' ] ) ; <nl> - <nl> msg . setExtension ( <nl> proto . jspb . test . extendPackedRepeatedInt32List , [ - 42 ] ) ; <nl> msg . setExtension ( <nl> describe ( ' protoBinaryTest ' , function ( ) { <nl> proto . jspb . test . extendPackedRepeatedBoolList , [ true ] ) ; <nl> msg . setExtension ( proto . jspb . test . extendPackedRepeatedForeignEnumList , <nl> [ proto . jspb . test . ForeignEnum . FOREIGN_FOO ] ) ; <nl> - <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendPackedRepeatedInt32StringList , <nl> - [ ' - 12345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendPackedRepeatedUint32StringList , <nl> - [ ' 12345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendPackedRepeatedInt64StringList , <nl> - [ ' - 123456789012345 ' ] ) ; <nl> - msg . setExtension ( <nl> - proto . jspb . test . extendPackedRepeatedUint64StringList , <nl> - [ ' 987654321098765 ' ] ) ; <nl> } <nl> <nl> <nl> mmm a / js / jasmine . json <nl> ppp b / js / jasmine . json <nl> <nl> { <nl> " spec_dir " : " " , <nl> " spec_files " : [ <nl> - " * _test . js " <nl> + " * _test . js " , <nl> + " binary / * _test . js " <nl> ] , <nl> " helpers " : [ <nl> " node_modules / google - closure - library / closure / goog / bootstrap / nodejs . js " , <nl> mmm a / js / package . json <nl> ppp b / js / package . json <nl> <nl> " description " : " Protocol Buffers for JavaScript " , <nl> " main " : " debug . js " , <nl> " dependencies " : { <nl> - " google - closure - library " : " ~ 20151015 . 0 . 0 " , <nl> + " google - closure - library " : " ~ 20160125 . 0 . 0 " , <nl> " gulp " : " ~ 3 . 9 . 0 " , <nl> " jasmine " : " ~ 2 . 4 . 1 " <nl> } , <nl>
|
Merge pull request from haberman / fixjstests
|
protocolbuffers/protobuf
|
0906f5d18a2548024b511eadcbb4cfc0ca56cd67
|
2016-02-05T22:56:14Z
|
mmm a / Makefile <nl> ppp b / Makefile <nl> pubsub_client : $ ( BINDIR ) / $ ( CONFIG ) / pubsub_client <nl> pubsub_publisher_test : $ ( BINDIR ) / $ ( CONFIG ) / pubsub_publisher_test <nl> pubsub_subscriber_test : $ ( BINDIR ) / $ ( CONFIG ) / pubsub_subscriber_test <nl> qps_driver : $ ( BINDIR ) / $ ( CONFIG ) / qps_driver <nl> - qps_interarrival_test : $ ( BINDIR ) / $ ( CONFIG ) / qps_interarrival_test <nl> qps_test : $ ( BINDIR ) / $ ( CONFIG ) / qps_test <nl> - qps_test_openloop : $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop <nl> qps_worker : $ ( BINDIR ) / $ ( CONFIG ) / qps_worker <nl> server_crash_test : $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test <nl> server_crash_test_client : $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test_client <nl> buildtests : buildtests_c buildtests_cxx <nl> <nl> buildtests_c : privatelibs_c $ ( BINDIR ) / $ ( CONFIG ) / alarm_heap_test $ ( BINDIR ) / $ ( CONFIG ) / alarm_list_test $ ( BINDIR ) / $ ( CONFIG ) / alarm_test $ ( BINDIR ) / $ ( CONFIG ) / alpn_test $ ( BINDIR ) / $ ( CONFIG ) / bin_encoder_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_status_conversion_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_stream_encoder_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_stream_map_test $ ( BINDIR ) / $ ( CONFIG ) / dualstack_socket_test $ ( BINDIR ) / $ ( CONFIG ) / fd_posix_test $ ( BINDIR ) / $ ( CONFIG ) / fling_client $ ( BINDIR ) / $ ( CONFIG ) / fling_server $ ( BINDIR ) / $ ( CONFIG ) / fling_stream_test $ ( BINDIR ) / $ ( CONFIG ) / fling_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_cancellable_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_cmdline_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_env_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_file_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_histogram_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_host_port_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_log_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_slice_buffer_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_slice_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_string_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_sync_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_thd_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_time_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_tls_test $ ( BINDIR ) / $ ( CONFIG ) / gpr_useful_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_auth_context_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_base64_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_byte_buffer_reader_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_channel_stack_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_completion_queue_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_credentials_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_json_token_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_stream_op_test $ ( BINDIR ) / $ ( CONFIG ) / hpack_parser_test $ ( BINDIR ) / $ ( CONFIG ) / hpack_table_test $ ( BINDIR ) / $ ( CONFIG ) / httpcli_format_request_test $ ( BINDIR ) / $ ( CONFIG ) / httpcli_parser_test $ ( BINDIR ) / $ ( CONFIG ) / httpcli_test $ ( BINDIR ) / $ ( CONFIG ) / json_rewrite $ ( BINDIR ) / $ ( CONFIG ) / json_rewrite_test $ ( BINDIR ) / $ ( CONFIG ) / json_test $ ( BINDIR ) / $ ( CONFIG ) / lame_client_test $ ( BINDIR ) / $ ( CONFIG ) / message_compress_test $ ( BINDIR ) / $ ( CONFIG ) / multi_init_test $ ( BINDIR ) / $ ( CONFIG ) / murmur_hash_test $ ( BINDIR ) / $ ( CONFIG ) / no_server_test $ ( BINDIR ) / $ ( CONFIG ) / poll_kick_posix_test $ ( BINDIR ) / $ ( CONFIG ) / resolve_address_test $ ( BINDIR ) / $ ( CONFIG ) / secure_endpoint_test $ ( BINDIR ) / $ ( CONFIG ) / sockaddr_utils_test $ ( BINDIR ) / $ ( CONFIG ) / tcp_client_posix_test $ ( BINDIR ) / $ ( CONFIG ) / tcp_posix_test $ ( BINDIR ) / $ ( CONFIG ) / tcp_server_posix_test $ ( BINDIR ) / $ ( CONFIG ) / time_averaged_stats_test $ ( BINDIR ) / $ ( CONFIG ) / time_test $ ( BINDIR ) / $ ( CONFIG ) / timeout_encoding_test $ ( BINDIR ) / $ ( CONFIG ) / timers_test $ ( BINDIR ) / $ ( CONFIG ) / transport_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / transport_security_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fake_security_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_simple_ssl_with_oauth2_fullstack_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_bad_hostname_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_accept_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_census_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_disappearing_server_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_empty_batch_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_invoke_large_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_max_message_length_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_no_op_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_registered_call_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_payload_and_call_creds_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_with_payload_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_server_finishes_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_delayed_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_request_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_bad_hostname_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_accept_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_census_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_disappearing_server_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_empty_batch_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_invoke_large_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_max_message_length_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_no_op_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_registered_call_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_request_with_payload_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_server_finishes_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_delayed_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_request_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_unsecure_test $ ( BINDIR ) / $ ( CONFIG ) / connection_prefix_bad_client_test $ ( BINDIR ) / $ ( CONFIG ) / initial_settings_frame_bad_client_test <nl> <nl> - buildtests_cxx : privatelibs_cxx $ ( BINDIR ) / $ ( CONFIG ) / async_end2end_test $ ( BINDIR ) / $ ( CONFIG ) / async_streaming_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / async_unary_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / channel_arguments_test $ ( BINDIR ) / $ ( CONFIG ) / cli_call_test $ ( BINDIR ) / $ ( CONFIG ) / client_crash_test $ ( BINDIR ) / $ ( CONFIG ) / client_crash_test_server $ ( BINDIR ) / $ ( CONFIG ) / credentials_test $ ( BINDIR ) / $ ( CONFIG ) / cxx_time_test $ ( BINDIR ) / $ ( CONFIG ) / end2end_test $ ( BINDIR ) / $ ( CONFIG ) / generic_end2end_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_cli $ ( BINDIR ) / $ ( CONFIG ) / interop_client $ ( BINDIR ) / $ ( CONFIG ) / interop_server $ ( BINDIR ) / $ ( CONFIG ) / interop_test $ ( BINDIR ) / $ ( CONFIG ) / mock_test $ ( BINDIR ) / $ ( CONFIG ) / qps_interarrival_test $ ( BINDIR ) / $ ( CONFIG ) / qps_test $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test_client $ ( BINDIR ) / $ ( CONFIG ) / status_test $ ( BINDIR ) / $ ( CONFIG ) / sync_streaming_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / sync_unary_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / thread_pool_test $ ( BINDIR ) / $ ( CONFIG ) / thread_stress_test <nl> + buildtests_cxx : privatelibs_cxx $ ( BINDIR ) / $ ( CONFIG ) / async_end2end_test $ ( BINDIR ) / $ ( CONFIG ) / async_streaming_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / async_unary_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / channel_arguments_test $ ( BINDIR ) / $ ( CONFIG ) / cli_call_test $ ( BINDIR ) / $ ( CONFIG ) / client_crash_test $ ( BINDIR ) / $ ( CONFIG ) / client_crash_test_server $ ( BINDIR ) / $ ( CONFIG ) / credentials_test $ ( BINDIR ) / $ ( CONFIG ) / cxx_time_test $ ( BINDIR ) / $ ( CONFIG ) / end2end_test $ ( BINDIR ) / $ ( CONFIG ) / generic_end2end_test $ ( BINDIR ) / $ ( CONFIG ) / grpc_cli $ ( BINDIR ) / $ ( CONFIG ) / interop_client $ ( BINDIR ) / $ ( CONFIG ) / interop_server $ ( BINDIR ) / $ ( CONFIG ) / interop_test $ ( BINDIR ) / $ ( CONFIG ) / mock_test $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test_client $ ( BINDIR ) / $ ( CONFIG ) / status_test $ ( BINDIR ) / $ ( CONFIG ) / sync_streaming_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / sync_unary_ping_pong_test $ ( BINDIR ) / $ ( CONFIG ) / thread_pool_test $ ( BINDIR ) / $ ( CONFIG ) / thread_stress_test <nl> <nl> test : test_c test_cxx <nl> <nl> test_cxx : buildtests_cxx <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / interop_test | | ( echo test interop_test failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing mock_test " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / mock_test | | ( echo test mock_test failed ; exit 1 ) <nl> - $ ( E ) " [ RUN ] Testing qps_test " <nl> - $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / qps_test | | ( echo test qps_test failed ; exit 1 ) <nl> - $ ( E ) " [ RUN ] Testing qps_test_openloop " <nl> - $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop | | ( echo test qps_test_openloop failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing server_crash_test " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / server_crash_test | | ( echo test server_crash_test failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing status_test " <nl> test_python : static_c <nl> <nl> tools : privatelibs $ ( BINDIR ) / $ ( CONFIG ) / gen_hpack_tables $ ( BINDIR ) / $ ( CONFIG ) / grpc_create_jwt $ ( BINDIR ) / $ ( CONFIG ) / grpc_fetch_oauth2 $ ( BINDIR ) / $ ( CONFIG ) / grpc_print_google_default_creds_token <nl> <nl> - buildbenchmarks : privatelibs $ ( BINDIR ) / $ ( CONFIG ) / low_level_ping_pong_benchmark $ ( BINDIR ) / $ ( CONFIG ) / qps_driver $ ( BINDIR ) / $ ( CONFIG ) / qps_worker <nl> + buildbenchmarks : privatelibs $ ( BINDIR ) / $ ( CONFIG ) / low_level_ping_pong_benchmark $ ( BINDIR ) / $ ( CONFIG ) / qps_driver $ ( BINDIR ) / $ ( CONFIG ) / qps_test $ ( BINDIR ) / $ ( CONFIG ) / qps_worker <nl> <nl> benchmarks : buildbenchmarks <nl> <nl> endif <nl> endif <nl> <nl> <nl> - QPS_INTERARRIVAL_TEST_SRC = \ <nl> - test / cpp / qps / qps_interarrival_test . cc \ <nl> - <nl> - QPS_INTERARRIVAL_TEST_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( QPS_INTERARRIVAL_TEST_SRC ) ) ) ) <nl> - ifeq ( $ ( NO_SECURE ) , true ) <nl> - <nl> - # You can ' t build secure targets if you don ' t have OpenSSL with ALPN . <nl> - <nl> - $ ( BINDIR ) / $ ( CONFIG ) / qps_interarrival_test : openssl_dep_error <nl> - <nl> - else <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 ) / qps_interarrival_test : protobuf_dep_error <nl> - <nl> - else <nl> - <nl> - $ ( BINDIR ) / $ ( CONFIG ) / qps_interarrival_test : $ ( PROTOBUF_DEP ) $ ( QPS_INTERARRIVAL_TEST_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libqps . 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 ) $ ( QPS_INTERARRIVAL_TEST_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libqps . 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 ) / qps_interarrival_test <nl> - <nl> - endif <nl> - <nl> - endif <nl> - <nl> - $ ( OBJDIR ) / $ ( CONFIG ) / test / cpp / qps / qps_interarrival_test . o : $ ( LIBDIR ) / $ ( CONFIG ) / libqps . 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> - deps_qps_interarrival_test : $ ( QPS_INTERARRIVAL_TEST_OBJS : . o = . dep ) <nl> - <nl> - ifneq ( $ ( NO_SECURE ) , true ) <nl> - ifneq ( $ ( NO_DEPS ) , true ) <nl> - - include $ ( QPS_INTERARRIVAL_TEST_OBJS : . o = . dep ) <nl> - endif <nl> - endif <nl> - <nl> - <nl> QPS_TEST_SRC = \ <nl> test / cpp / qps / qps_test . cc \ <nl> <nl> endif <nl> endif <nl> <nl> <nl> - QPS_TEST_OPENLOOP_SRC = \ <nl> - test / cpp / qps / qps_test_openloop . cc \ <nl> - <nl> - QPS_TEST_OPENLOOP_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( QPS_TEST_OPENLOOP_SRC ) ) ) ) <nl> - ifeq ( $ ( NO_SECURE ) , true ) <nl> - <nl> - # You can ' t build secure targets if you don ' t have OpenSSL with ALPN . <nl> - <nl> - $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop : openssl_dep_error <nl> - <nl> - else <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 ) / qps_test_openloop : protobuf_dep_error <nl> - <nl> - else <nl> - <nl> - $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop : $ ( PROTOBUF_DEP ) $ ( QPS_TEST_OPENLOOP_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libqps . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _benchmark_config . 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 $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a <nl> - $ ( E ) " [ LD ] Linking $ @ " <nl> - $ ( Q ) mkdir - p ` dirname $ @ ` <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) $ ( QPS_TEST_OPENLOOP_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libqps . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _benchmark_config . 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 $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) $ ( LDLIBS_SECURE ) $ ( GTEST_LIB ) - o $ ( BINDIR ) / $ ( CONFIG ) / qps_test_openloop <nl> - <nl> - endif <nl> - <nl> - endif <nl> - <nl> - $ ( OBJDIR ) / $ ( CONFIG ) / test / cpp / qps / qps_test_openloop . o : $ ( LIBDIR ) / $ ( CONFIG ) / libqps . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _benchmark_config . 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 $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a <nl> - deps_qps_test_openloop : $ ( QPS_TEST_OPENLOOP_OBJS : . o = . dep ) <nl> - <nl> - ifneq ( $ ( NO_SECURE ) , true ) <nl> - ifneq ( $ ( NO_DEPS ) , true ) <nl> - - include $ ( QPS_TEST_OPENLOOP_OBJS : . o = . dep ) <nl> - endif <nl> - endif <nl> - <nl> - <nl> QPS_WORKER_SRC = \ <nl> test / cpp / qps / worker . cc \ <nl> <nl> mmm a / build . json <nl> ppp b / build . json <nl> <nl> " language " : " c + + " , <nl> " headers " : [ <nl> " test / cpp / qps / driver . h " , <nl> - " test / cpp / qps / interarrival . h " , <nl> " test / cpp / qps / qps_worker . h " , <nl> " test / cpp / qps / report . h " , <nl> " test / cpp / qps / timer . h " <nl> <nl> " grpc + + _benchmark_config " <nl> ] <nl> } , <nl> - { <nl> - " name " : " qps_interarrival_test " , <nl> - " build " : " test " , <nl> - " run " : false , <nl> - " language " : " c + + " , <nl> - " src " : [ <nl> - " test / cpp / qps / qps_interarrival_test . cc " <nl> - ] , <nl> - " deps " : [ <nl> - " qps " , <nl> - " grpc + + _test_util " , <nl> - " grpc_test_util " , <nl> - " grpc + + " , <nl> - " grpc " , <nl> - " gpr_test_util " , <nl> - " gpr " <nl> - ] <nl> - } , <nl> { <nl> " name " : " qps_test " , <nl> - " build " : " test " , <nl> + " build " : " benchmark " , <nl> " language " : " c + + " , <nl> " src " : [ <nl> " test / cpp / qps / qps_test . cc " <nl> <nl> " grpc + + _test_config " <nl> ] <nl> } , <nl> - { <nl> - " name " : " qps_test_openloop " , <nl> - " build " : " test " , <nl> - " language " : " c + + " , <nl> - " src " : [ <nl> - " test / cpp / qps / qps_test_openloop . cc " <nl> - ] , <nl> - " deps " : [ <nl> - " qps " , <nl> - " grpc + + _test_util " , <nl> - " grpc + + _benchmark_config " , <nl> - " grpc_test_util " , <nl> - " grpc + + " , <nl> - " grpc " , <nl> - " gpr_test_util " , <nl> - " gpr " , <nl> - " grpc + + _test_config " <nl> - ] <nl> - } , <nl> { <nl> " name " : " qps_worker " , <nl> " build " : " benchmark " , <nl> mmm a / include / grpc + + / config . h <nl> ppp b / include / grpc + + / config . h <nl> <nl> # define GRPC_CXX0X_NO_OVERRIDE 1 <nl> # define GRPC_CXX0X_NO_CHRONO 1 <nl> # define GRPC_CXX0X_NO_THREAD 1 <nl> - # endif <nl> + # endif <nl> # endif / / Visual Studio <nl> <nl> # ifndef __clang__ <nl> <nl> : : google : : protobuf : : io : : ZeroCopyOutputStream <nl> # define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ <nl> : : google : : protobuf : : io : : ZeroCopyInputStream <nl> - # define GRPC_CUSTOM_CODEDINPUTSTREAM : : google : : protobuf : : io : : CodedInputStream <nl> + # define GRPC_CUSTOM_CODEDINPUTSTREAM \ <nl> + : : google : : protobuf : : io : : CodedInputStream <nl> # endif <nl> <nl> + <nl> # ifdef GRPC_CXX0X_NO_NULLPTR <nl> # include < memory > <nl> const class { <nl> - public : <nl> - template < class T > <nl> - operator T * ( ) const { <nl> - return static_cast < T * > ( 0 ) ; <nl> - } <nl> - template < class T > <nl> - operator std : : unique_ptr < T > ( ) const { <nl> + public : <nl> + template < class T > operator T * ( ) const { return static_cast < T * > ( 0 ) ; } <nl> + template < class T > operator std : : unique_ptr < T > ( ) const { <nl> return std : : unique_ptr < T > ( static_cast < T * > ( 0 ) ) ; <nl> } <nl> - template < class T > <nl> - operator std : : shared_ptr < T > ( ) const { <nl> + template < class T > operator std : : shared_ptr < T > ( ) const { <nl> return std : : shared_ptr < T > ( static_cast < T * > ( 0 ) ) ; <nl> } <nl> - operator bool ( ) const { return false ; } <nl> - <nl> - private : <nl> + operator bool ( ) const { return false ; } <nl> + private : <nl> void operator & ( ) const = delete ; <nl> } nullptr = { } ; <nl> # endif <nl> mmm a / include / grpc + + / time . h <nl> ppp b / include / grpc + + / time . h <nl> namespace grpc { <nl> template < typename T > <nl> class TimePoint { <nl> public : <nl> - TimePoint ( const T & time ) { you_need_a_specialization_of_TimePoint ( ) ; } <nl> + TimePoint ( const T & time ) { <nl> + you_need_a_specialization_of_TimePoint ( ) ; <nl> + } <nl> gpr_timespec raw_time ( ) { <nl> gpr_timespec t ; <nl> return t ; <nl> } <nl> - <nl> private : <nl> void you_need_a_specialization_of_TimePoint ( ) ; <nl> } ; <nl> <nl> - template < > <nl> + template < > <nl> class TimePoint < gpr_timespec > { <nl> public : <nl> - TimePoint ( const gpr_timespec & time ) : time_ ( time ) { } <nl> + TimePoint ( const gpr_timespec & time ) : time_ ( time ) { } <nl> gpr_timespec raw_time ( ) { return time_ ; } <nl> - <nl> private : <nl> gpr_timespec time_ ; <nl> } ; <nl> namespace grpc { <nl> / / from and to should be absolute time . <nl> void Timepoint2Timespec ( const std : : chrono : : system_clock : : time_point & from , <nl> gpr_timespec * to ) ; <nl> - void TimepointHR2Timespec ( <nl> - const std : : chrono : : high_resolution_clock : : time_point & from , <nl> - gpr_timespec * to ) ; <nl> <nl> std : : chrono : : system_clock : : time_point Timespec2Timepoint ( gpr_timespec t ) ; <nl> <nl> template < > <nl> class TimePoint < std : : chrono : : system_clock : : time_point > { <nl> public : <nl> TimePoint ( const std : : chrono : : system_clock : : time_point & time ) { <nl> - Timepoint2Timespec ( time , & time_ ) ; <nl> + Timepoint2Timespec ( time , & time_ ) ; <nl> } <nl> gpr_timespec raw_time ( ) const { return time_ ; } <nl> - <nl> private : <nl> gpr_timespec time_ ; <nl> } ; <nl> mmm a / src / cpp / util / time . cc <nl> ppp b / src / cpp / util / time . cc <nl> using std : : chrono : : duration_cast ; <nl> using std : : chrono : : nanoseconds ; <nl> using std : : chrono : : seconds ; <nl> using std : : chrono : : system_clock ; <nl> - using std : : chrono : : high_resolution_clock ; <nl> <nl> namespace grpc { <nl> <nl> void Timepoint2Timespec ( const system_clock : : time_point & from , <nl> to - > tv_nsec = nsecs . count ( ) ; <nl> } <nl> <nl> - void TimepointHR2Timespec ( const high_resolution_clock : : time_point & from , <nl> - gpr_timespec * to ) { <nl> - high_resolution_clock : : duration deadline = from . time_since_epoch ( ) ; <nl> - seconds secs = duration_cast < seconds > ( deadline ) ; <nl> - if ( from = = high_resolution_clock : : time_point : : max ( ) | | <nl> - secs . count ( ) > = gpr_inf_future . tv_sec | | secs . count ( ) < 0 ) { <nl> - * to = gpr_inf_future ; <nl> - return ; <nl> - } <nl> - nanoseconds nsecs = duration_cast < nanoseconds > ( deadline - secs ) ; <nl> - to - > tv_sec = secs . count ( ) ; <nl> - to - > tv_nsec = nsecs . count ( ) ; <nl> - } <nl> - <nl> system_clock : : time_point Timespec2Timepoint ( gpr_timespec t ) { <nl> if ( gpr_time_cmp ( t , gpr_inf_future ) = = 0 ) { <nl> return system_clock : : time_point : : max ( ) ; <nl> mmm a / test / cpp / qps / client . h <nl> ppp b / test / cpp / qps / client . h <nl> <nl> # define TEST_QPS_CLIENT_H <nl> <nl> # include " test / cpp / qps / histogram . h " <nl> - # include " test / cpp / qps / interarrival . h " <nl> # include " test / cpp / qps / timer . h " <nl> # include " test / cpp / qps / qpstest . grpc . pb . h " <nl> <nl> <nl> # include < mutex > <nl> <nl> namespace grpc { <nl> - <nl> - # if defined ( __APPLE__ ) <nl> - / / Specialize Timepoint for high res clock as we need that <nl> - template < > <nl> - class TimePoint < std : : chrono : : high_resolution_clock : : time_point > { <nl> - public : <nl> - TimePoint ( const std : : chrono : : high_resolution_clock : : time_point & time ) { <nl> - TimepointHR2Timespec ( time , & time_ ) ; <nl> - } <nl> - gpr_timespec raw_time ( ) const { return time_ ; } <nl> - <nl> - private : <nl> - gpr_timespec time_ ; <nl> - } ; <nl> - # endif <nl> - <nl> namespace testing { <nl> <nl> - typedef std : : chrono : : high_resolution_clock grpc_time_source ; <nl> - typedef std : : chrono : : time_point < grpc_time_source > grpc_time ; <nl> - <nl> class Client { <nl> public : <nl> - explicit Client ( const ClientConfig & config ) <nl> - : timer_ ( new Timer ) , interarrival_timer_ ( ) { <nl> + explicit Client ( const ClientConfig & config ) : timer_ ( new Timer ) { <nl> for ( int i = 0 ; i < config . client_channels ( ) ; i + + ) { <nl> channels_ . push_back ( ClientChannelInfo ( <nl> config . server_targets ( i % config . server_targets_size ( ) ) , config ) ) ; <nl> class Client { <nl> <nl> protected : <nl> SimpleRequest request_ ; <nl> - bool closed_loop_ ; <nl> <nl> class ClientChannelInfo { <nl> public : <nl> class Client { <nl> <nl> virtual bool ThreadFunc ( Histogram * histogram , size_t thread_idx ) = 0 ; <nl> <nl> - void SetupLoadTest ( const ClientConfig & config , size_t num_threads ) { <nl> - / / Set up the load distribution based on the number of threads <nl> - if ( config . load_type ( ) = = CLOSED_LOOP ) { <nl> - closed_loop_ = true ; <nl> - } else { <nl> - closed_loop_ = false ; <nl> - <nl> - std : : unique_ptr < RandomDist > random_dist ; <nl> - const auto & load = config . load_params ( ) ; <nl> - switch ( config . load_type ( ) ) { <nl> - case POISSON : <nl> - random_dist . reset ( <nl> - new ExpDist ( load . poisson ( ) . offered_load ( ) / num_threads ) ) ; <nl> - break ; <nl> - case UNIFORM : <nl> - random_dist . reset ( <nl> - new UniformDist ( load . uniform ( ) . interarrival_lo ( ) * num_threads , <nl> - load . uniform ( ) . interarrival_hi ( ) * num_threads ) ) ; <nl> - break ; <nl> - case DETERMINISTIC : <nl> - random_dist . reset ( <nl> - new DetDist ( num_threads / load . determ ( ) . offered_load ( ) ) ) ; <nl> - break ; <nl> - case PARETO : <nl> - random_dist . reset ( <nl> - new ParetoDist ( load . pareto ( ) . interarrival_base ( ) * num_threads , <nl> - load . pareto ( ) . alpha ( ) ) ) ; <nl> - break ; <nl> - default : <nl> - GPR_ASSERT ( false ) ; <nl> - break ; <nl> - } <nl> - <nl> - interarrival_timer_ . init ( * random_dist , num_threads ) ; <nl> - for ( size_t i = 0 ; i < num_threads ; i + + ) { <nl> - next_time_ . push_back ( <nl> - grpc_time_source : : now ( ) + <nl> - std : : chrono : : duration_cast < grpc_time_source : : duration > ( <nl> - interarrival_timer_ ( i ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - bool NextIssueTime ( int thread_idx , grpc_time * time_delay ) { <nl> - if ( closed_loop_ ) { <nl> - return false ; <nl> - } else { <nl> - * time_delay = next_time_ [ thread_idx ] ; <nl> - next_time_ [ thread_idx ] + = <nl> - std : : chrono : : duration_cast < grpc_time_source : : duration > ( <nl> - interarrival_timer_ ( thread_idx ) ) ; <nl> - return true ; <nl> - } <nl> - } <nl> - <nl> private : <nl> class Thread { <nl> public : <nl> class Client { <nl> <nl> std : : vector < std : : unique_ptr < Thread > > threads_ ; <nl> std : : unique_ptr < Timer > timer_ ; <nl> - <nl> - InterarrivalTimer interarrival_timer_ ; <nl> - std : : vector < grpc_time > next_time_ ; <nl> } ; <nl> <nl> std : : unique_ptr < Client > CreateSynchronousUnaryClient ( const ClientConfig & args ) ; <nl> mmm a / test / cpp / qps / client_async . cc <nl> ppp b / test / cpp / qps / client_async . cc <nl> <nl> * / <nl> <nl> # include < cassert > <nl> - # include < forward_list > <nl> # include < functional > <nl> - # include < list > <nl> # include < memory > <nl> - # include < mutex > <nl> # include < string > <nl> # include < thread > <nl> # include < vector > <nl> <nl> namespace grpc { <nl> namespace testing { <nl> <nl> - typedef std : : list < grpc_time > deadline_list ; <nl> - <nl> class ClientRpcContext { <nl> public : <nl> - ClientRpcContext ( int ch ) : channel_id_ ( ch ) { } <nl> + ClientRpcContext ( ) { } <nl> virtual ~ ClientRpcContext ( ) { } <nl> / / next state , return false if done . Collect stats when appropriate <nl> virtual bool RunNextState ( bool , Histogram * hist ) = 0 ; <nl> - virtual ClientRpcContext * StartNewClone ( ) = 0 ; <nl> + virtual void StartNewClone ( ) = 0 ; <nl> static void * tag ( ClientRpcContext * c ) { return reinterpret_cast < void * > ( c ) ; } <nl> static ClientRpcContext * detag ( void * t ) { <nl> return reinterpret_cast < ClientRpcContext * > ( t ) ; <nl> } <nl> - <nl> - deadline_list : : iterator deadline_posn ( ) const { return deadline_posn_ ; } <nl> - void set_deadline_posn ( const deadline_list : : iterator & it ) { <nl> - deadline_posn_ = it ; <nl> - } <nl> - virtual void Start ( CompletionQueue * cq ) = 0 ; <nl> - int channel_id ( ) const { return channel_id_ ; } <nl> - <nl> - protected : <nl> - int channel_id_ ; <nl> - <nl> - private : <nl> - deadline_list : : iterator deadline_posn_ ; <nl> } ; <nl> <nl> template < class RequestType , class ResponseType > <nl> class ClientRpcContextUnaryImpl : public ClientRpcContext { <nl> public : <nl> ClientRpcContextUnaryImpl ( <nl> - int channel_id , TestService : : Stub * stub , const RequestType & req , <nl> + TestService : : Stub * stub , const RequestType & req , <nl> std : : function < <nl> std : : unique_ptr < grpc : : ClientAsyncResponseReader < ResponseType > > ( <nl> - TestService : : Stub * , grpc : : ClientContext * , const RequestType & , <nl> - CompletionQueue * ) > start_req , <nl> + TestService : : Stub * , grpc : : ClientContext * , const RequestType & ) > <nl> + start_req , <nl> std : : function < void ( grpc : : Status , ResponseType * ) > on_done ) <nl> - : ClientRpcContext ( channel_id ) , <nl> - context_ ( ) , <nl> + : context_ ( ) , <nl> stub_ ( stub ) , <nl> req_ ( req ) , <nl> response_ ( ) , <nl> next_state_ ( & ClientRpcContextUnaryImpl : : RespDone ) , <nl> callback_ ( on_done ) , <nl> - start_req_ ( start_req ) { } <nl> - void Start ( CompletionQueue * cq ) GRPC_OVERRIDE { <nl> - start_ = Timer : : Now ( ) ; <nl> - response_reader_ = start_req_ ( stub_ , & context_ , req_ , cq ) ; <nl> + start_req_ ( start_req ) , <nl> + start_ ( Timer : : Now ( ) ) , <nl> + response_reader_ ( start_req ( stub_ , & context_ , req_ ) ) { <nl> response_reader_ - > Finish ( & response_ , & status_ , ClientRpcContext : : tag ( this ) ) ; <nl> } <nl> ~ ClientRpcContextUnaryImpl ( ) GRPC_OVERRIDE { } <nl> class ClientRpcContextUnaryImpl : public ClientRpcContext { <nl> return ret ; <nl> } <nl> <nl> - ClientRpcContext * StartNewClone ( ) GRPC_OVERRIDE { <nl> - return new ClientRpcContextUnaryImpl ( channel_id_ , stub_ , req_ , start_req_ , <nl> - callback_ ) ; <nl> + void StartNewClone ( ) GRPC_OVERRIDE { <nl> + new ClientRpcContextUnaryImpl ( stub_ , req_ , start_req_ , callback_ ) ; <nl> } <nl> <nl> private : <nl> class ClientRpcContextUnaryImpl : public ClientRpcContext { <nl> } <nl> bool DoCallBack ( bool ) { <nl> callback_ ( status_ , & response_ ) ; <nl> - return true ; / / we ' re done , this ' ll be ignored <nl> + return false ; <nl> } <nl> grpc : : ClientContext context_ ; <nl> TestService : : Stub * stub_ ; <nl> class ClientRpcContextUnaryImpl : public ClientRpcContext { <nl> bool ( ClientRpcContextUnaryImpl : : * next_state_ ) ( bool ) ; <nl> std : : function < void ( grpc : : Status , ResponseType * ) > callback_ ; <nl> std : : function < std : : unique_ptr < grpc : : ClientAsyncResponseReader < ResponseType > > ( <nl> - TestService : : Stub * , grpc : : ClientContext * , const RequestType & , <nl> - CompletionQueue * ) > start_req_ ; <nl> + TestService : : Stub * , grpc : : ClientContext * , const RequestType & ) > start_req_ ; <nl> grpc : : Status status_ ; <nl> double start_ ; <nl> std : : unique_ptr < grpc : : ClientAsyncResponseReader < ResponseType > > <nl> response_reader_ ; <nl> } ; <nl> <nl> - typedef std : : forward_list < ClientRpcContext * > context_list ; <nl> - <nl> class AsyncClient : public Client { <nl> public : <nl> - explicit AsyncClient ( <nl> - const ClientConfig & config , <nl> - std : : function < ClientRpcContext * ( int , TestService : : Stub * , <nl> - const SimpleRequest & ) > setup_ctx ) <nl> - : Client ( config ) , <nl> - channel_lock_ ( config . client_channels ( ) ) , <nl> - contexts_ ( config . client_channels ( ) ) , <nl> - max_outstanding_per_channel_ ( config . outstanding_rpcs_per_channel ( ) ) , <nl> - channel_count_ ( config . client_channels ( ) ) , <nl> - pref_channel_inc_ ( config . async_client_threads ( ) ) { <nl> - SetupLoadTest ( config , config . async_client_threads ( ) ) ; <nl> - <nl> + explicit AsyncClient ( const ClientConfig & config , <nl> + std : : function < void ( CompletionQueue * , TestService : : Stub * , <nl> + const SimpleRequest & ) > setup_ctx ) <nl> + : Client ( config ) { <nl> for ( int i = 0 ; i < config . async_client_threads ( ) ; i + + ) { <nl> cli_cqs_ . emplace_back ( new CompletionQueue ) ; <nl> - if ( ! closed_loop_ ) { <nl> - rpc_deadlines_ . emplace_back ( ) ; <nl> - next_channel_ . push_back ( i % channel_count_ ) ; <nl> - issue_allowed_ . push_back ( true ) ; <nl> - <nl> - grpc_time next_issue ; <nl> - NextIssueTime ( i , & next_issue ) ; <nl> - next_issue_ . push_back ( next_issue ) ; <nl> - } <nl> } <nl> - <nl> int t = 0 ; <nl> for ( int i = 0 ; i < config . outstanding_rpcs_per_channel ( ) ; i + + ) { <nl> - for ( int ch = 0 ; ch < channel_count_ ; ch + + ) { <nl> + for ( auto channel = channels_ . begin ( ) ; channel ! = channels_ . end ( ) ; <nl> + channel + + ) { <nl> auto * cq = cli_cqs_ [ t ] . get ( ) ; <nl> t = ( t + 1 ) % cli_cqs_ . size ( ) ; <nl> - auto ctx = setup_ctx ( ch , channels_ [ ch ] . get_stub ( ) , request_ ) ; <nl> - if ( closed_loop_ ) { <nl> - ctx - > Start ( cq ) ; <nl> - } else { <nl> - contexts_ [ ch ] . push_front ( ctx ) ; <nl> - } <nl> + setup_ctx ( cq , channel - > get_stub ( ) , request_ ) ; <nl> } <nl> } <nl> } <nl> class AsyncClient : public Client { <nl> size_t thread_idx ) GRPC_OVERRIDE GRPC_FINAL { <nl> void * got_tag ; <nl> bool ok ; <nl> - grpc_time deadline , short_deadline ; <nl> - if ( closed_loop_ ) { <nl> - deadline = grpc_time_source : : now ( ) + std : : chrono : : seconds ( 1 ) ; <nl> - short_deadline = deadline ; <nl> - } else { <nl> - if ( rpc_deadlines_ [ thread_idx ] . empty ( ) ) { <nl> - deadline = grpc_time_source : : now ( ) + std : : chrono : : seconds ( 1 ) ; <nl> - } else { <nl> - deadline = * ( rpc_deadlines_ [ thread_idx ] . begin ( ) ) ; <nl> - } <nl> - short_deadline = <nl> - issue_allowed_ [ thread_idx ] ? next_issue_ [ thread_idx ] : deadline ; <nl> - } <nl> - <nl> - bool got_event ; <nl> - <nl> - switch ( cli_cqs_ [ thread_idx ] - > AsyncNext ( & got_tag , & ok , short_deadline ) ) { <nl> + switch ( cli_cqs_ [ thread_idx ] - > AsyncNext ( <nl> + & got_tag , & ok , <nl> + std : : chrono : : system_clock : : now ( ) + std : : chrono : : seconds ( 1 ) ) ) { <nl> case CompletionQueue : : SHUTDOWN : <nl> return false ; <nl> case CompletionQueue : : TIMEOUT : <nl> - got_event = false ; <nl> - break ; <nl> + return true ; <nl> case CompletionQueue : : GOT_EVENT : <nl> - got_event = true ; <nl> - break ; <nl> - default : <nl> - GPR_ASSERT ( false ) ; <nl> break ; <nl> } <nl> - if ( ( closed_loop_ | | ! rpc_deadlines_ [ thread_idx ] . empty ( ) ) & & <nl> - grpc_time_source : : now ( ) > deadline ) { <nl> - / / we have missed some 1 - second deadline , which is too much <nl> - gpr_log ( GPR_INFO , " Missed an RPC deadline , giving up " ) ; <nl> - return false ; <nl> - } <nl> - if ( got_event ) { <nl> - ClientRpcContext * ctx = ClientRpcContext : : detag ( got_tag ) ; <nl> - if ( ctx - > RunNextState ( ok , histogram ) = = false ) { <nl> - / / call the callback and then clone the ctx <nl> - ctx - > RunNextState ( ok , histogram ) ; <nl> - ClientRpcContext * clone_ctx = ctx - > StartNewClone ( ) ; <nl> - if ( closed_loop_ ) { <nl> - clone_ctx - > Start ( cli_cqs_ [ thread_idx ] . get ( ) ) ; <nl> - } else { <nl> - / / Remove the entry from the rpc deadlines list <nl> - rpc_deadlines_ [ thread_idx ] . erase ( ctx - > deadline_posn ( ) ) ; <nl> - / / Put the clone_ctx in the list of idle contexts for this channel <nl> - / / Under lock <nl> - int ch = clone_ctx - > channel_id ( ) ; <nl> - std : : lock_guard < std : : mutex > g ( channel_lock_ [ ch ] ) ; <nl> - contexts_ [ ch ] . push_front ( clone_ctx ) ; <nl> - } <nl> - / / delete the old version <nl> - delete ctx ; <nl> - } <nl> - if ( ! closed_loop_ ) <nl> - issue_allowed_ [ thread_idx ] = <nl> - true ; / / may be ok now even if it hadn ' t been <nl> - } <nl> - if ( ! closed_loop_ & & issue_allowed_ [ thread_idx ] & & <nl> - grpc_time_source : : now ( ) > = next_issue_ [ thread_idx ] ) { <nl> - / / Attempt to issue <nl> - bool issued = false ; <nl> - for ( int num_attempts = 0 , channel_attempt = next_channel_ [ thread_idx ] ; <nl> - num_attempts < channel_count_ & & ! issued ; num_attempts + + ) { <nl> - bool can_issue = false ; <nl> - ClientRpcContext * ctx = nullptr ; <nl> - { <nl> - std : : lock_guard < std : : mutex > g ( channel_lock_ [ channel_attempt ] ) ; <nl> - if ( ! contexts_ [ channel_attempt ] . empty ( ) ) { <nl> - / / Get an idle context from the front of the list <nl> - ctx = * ( contexts_ [ channel_attempt ] . begin ( ) ) ; <nl> - contexts_ [ channel_attempt ] . pop_front ( ) ; <nl> - can_issue = true ; <nl> - } <nl> - } <nl> - if ( can_issue ) { <nl> - / / do the work to issue <nl> - rpc_deadlines_ [ thread_idx ] . emplace_back ( grpc_time_source : : now ( ) + <nl> - std : : chrono : : seconds ( 1 ) ) ; <nl> - auto it = rpc_deadlines_ [ thread_idx ] . end ( ) ; <nl> - - - it ; <nl> - ctx - > set_deadline_posn ( it ) ; <nl> - ctx - > Start ( cli_cqs_ [ thread_idx ] . get ( ) ) ; <nl> - issued = true ; <nl> - / / If we did issue , then next time , try our thread ' s next <nl> - / / preferred channel <nl> - next_channel_ [ thread_idx ] + = pref_channel_inc_ ; <nl> - if ( next_channel_ [ thread_idx ] > = channel_count_ ) <nl> - next_channel_ [ thread_idx ] = ( thread_idx % channel_count_ ) ; <nl> - } else { <nl> - / / Do a modular increment of channel attempt if we couldn ' t issue <nl> - channel_attempt = ( channel_attempt + 1 ) % channel_count_ ; <nl> - } <nl> - } <nl> - if ( issued ) { <nl> - / / We issued one ; see when we can issue the next <nl> - grpc_time next_issue ; <nl> - NextIssueTime ( thread_idx , & next_issue ) ; <nl> - next_issue_ [ thread_idx ] = next_issue ; <nl> - } else { <nl> - issue_allowed_ [ thread_idx ] = false ; <nl> - } <nl> + <nl> + ClientRpcContext * ctx = ClientRpcContext : : detag ( got_tag ) ; <nl> + if ( ctx - > RunNextState ( ok , histogram ) = = false ) { <nl> + / / call the callback and then delete it <nl> + ctx - > RunNextState ( ok , histogram ) ; <nl> + ctx - > StartNewClone ( ) ; <nl> + delete ctx ; <nl> } <nl> + <nl> return true ; <nl> } <nl> <nl> private : <nl> std : : vector < std : : unique_ptr < CompletionQueue > > cli_cqs_ ; <nl> - <nl> - std : : vector < deadline_list > rpc_deadlines_ ; / / per thread deadlines <nl> - std : : vector < int > next_channel_ ; / / per thread round - robin channel ctr <nl> - std : : vector < bool > issue_allowed_ ; / / may this thread attempt to issue <nl> - std : : vector < grpc_time > next_issue_ ; / / when should it issue ? <nl> - <nl> - std : : vector < std : : mutex > channel_lock_ ; <nl> - std : : vector < context_list > contexts_ ; / / per - channel list of idle contexts <nl> - int max_outstanding_per_channel_ ; <nl> - int channel_count_ ; <nl> - int pref_channel_inc_ ; <nl> } ; <nl> <nl> class AsyncUnaryClient GRPC_FINAL : public AsyncClient { <nl> class AsyncUnaryClient GRPC_FINAL : public AsyncClient { <nl> ~ AsyncUnaryClient ( ) GRPC_OVERRIDE { EndThreads ( ) ; } <nl> <nl> private : <nl> - static ClientRpcContext * SetupCtx ( int channel_id , TestService : : Stub * stub , <nl> - const SimpleRequest & req ) { <nl> + static void SetupCtx ( CompletionQueue * cq , TestService : : Stub * stub , <nl> + const SimpleRequest & req ) { <nl> auto check_done = [ ] ( grpc : : Status s , SimpleResponse * response ) { } ; <nl> - auto start_req = [ ] ( TestService : : Stub * stub , grpc : : ClientContext * ctx , <nl> - const SimpleRequest & request , CompletionQueue * cq ) { <nl> + auto start_req = [ cq ] ( TestService : : Stub * stub , grpc : : ClientContext * ctx , <nl> + const SimpleRequest & request ) { <nl> return stub - > AsyncUnaryCall ( ctx , request , cq ) ; <nl> } ; <nl> - return new ClientRpcContextUnaryImpl < SimpleRequest , SimpleResponse > ( <nl> - channel_id , stub , req , start_req , check_done ) ; <nl> + new ClientRpcContextUnaryImpl < SimpleRequest , SimpleResponse > ( <nl> + stub , req , start_req , check_done ) ; <nl> } <nl> } ; <nl> <nl> template < class RequestType , class ResponseType > <nl> class ClientRpcContextStreamingImpl : public ClientRpcContext { <nl> public : <nl> ClientRpcContextStreamingImpl ( <nl> - int channel_id , TestService : : Stub * stub , const RequestType & req , <nl> - std : : function < std : : unique_ptr < grpc : : ClientAsyncReaderWriter < <nl> - RequestType , ResponseType > > ( TestService : : Stub * , grpc : : ClientContext * , <nl> - CompletionQueue * , void * ) > start_req , <nl> + TestService : : Stub * stub , const RequestType & req , <nl> + std : : function < std : : unique_ptr < <nl> + grpc : : ClientAsyncReaderWriter < RequestType , ResponseType > > ( <nl> + TestService : : Stub * , grpc : : ClientContext * , void * ) > start_req , <nl> std : : function < void ( grpc : : Status , ResponseType * ) > on_done ) <nl> - : ClientRpcContext ( channel_id ) , <nl> - context_ ( ) , <nl> + : context_ ( ) , <nl> stub_ ( stub ) , <nl> req_ ( req ) , <nl> response_ ( ) , <nl> next_state_ ( & ClientRpcContextStreamingImpl : : ReqSent ) , <nl> callback_ ( on_done ) , <nl> start_req_ ( start_req ) , <nl> - start_ ( Timer : : Now ( ) ) { } <nl> + start_ ( Timer : : Now ( ) ) , <nl> + stream_ ( start_req_ ( stub_ , & context_ , ClientRpcContext : : tag ( this ) ) ) { } <nl> ~ ClientRpcContextStreamingImpl ( ) GRPC_OVERRIDE { } <nl> bool RunNextState ( bool ok , Histogram * hist ) GRPC_OVERRIDE { <nl> return ( this - > * next_state_ ) ( ok , hist ) ; <nl> } <nl> - ClientRpcContext * StartNewClone ( ) GRPC_OVERRIDE { <nl> - return new ClientRpcContextStreamingImpl ( channel_id_ , stub_ , req_ , <nl> - start_req_ , callback_ ) ; <nl> - } <nl> - void Start ( CompletionQueue * cq ) GRPC_OVERRIDE { <nl> - stream_ = start_req_ ( stub_ , & context_ , cq , ClientRpcContext : : tag ( this ) ) ; <nl> + void StartNewClone ( ) GRPC_OVERRIDE { <nl> + new ClientRpcContextStreamingImpl ( stub_ , req_ , start_req_ , callback_ ) ; <nl> } <nl> <nl> private : <nl> class ClientRpcContextStreamingImpl : public ClientRpcContext { <nl> std : : function < void ( grpc : : Status , ResponseType * ) > callback_ ; <nl> std : : function < <nl> std : : unique_ptr < grpc : : ClientAsyncReaderWriter < RequestType , ResponseType > > ( <nl> - TestService : : Stub * , grpc : : ClientContext * , CompletionQueue * , void * ) > <nl> - start_req_ ; <nl> + TestService : : Stub * , grpc : : ClientContext * , void * ) > start_req_ ; <nl> grpc : : Status status_ ; <nl> double start_ ; <nl> std : : unique_ptr < grpc : : ClientAsyncReaderWriter < RequestType , ResponseType > > <nl> class AsyncStreamingClient GRPC_FINAL : public AsyncClient { <nl> public : <nl> explicit AsyncStreamingClient ( const ClientConfig & config ) <nl> : AsyncClient ( config , SetupCtx ) { <nl> - / / async streaming currently only supported closed loop <nl> - GPR_ASSERT ( config . load_type ( ) = = CLOSED_LOOP ) ; <nl> - <nl> StartThreads ( config . async_client_threads ( ) ) ; <nl> } <nl> <nl> ~ AsyncStreamingClient ( ) GRPC_OVERRIDE { EndThreads ( ) ; } <nl> <nl> private : <nl> - static ClientRpcContext * SetupCtx ( int channel_id , TestService : : Stub * stub , <nl> - const SimpleRequest & req ) { <nl> + static void SetupCtx ( CompletionQueue * cq , TestService : : Stub * stub , <nl> + const SimpleRequest & req ) { <nl> auto check_done = [ ] ( grpc : : Status s , SimpleResponse * response ) { } ; <nl> - auto start_req = [ ] ( TestService : : Stub * stub , grpc : : ClientContext * ctx , <nl> - CompletionQueue * cq , void * tag ) { <nl> + auto start_req = [ cq ] ( TestService : : Stub * stub , grpc : : ClientContext * ctx , <nl> + void * tag ) { <nl> auto stream = stub - > AsyncStreamingCall ( ctx , cq , tag ) ; <nl> return stream ; <nl> } ; <nl> - return new ClientRpcContextStreamingImpl < SimpleRequest , SimpleResponse > ( <nl> - channel_id , stub , req , start_req , check_done ) ; <nl> + new ClientRpcContextStreamingImpl < SimpleRequest , SimpleResponse > ( <nl> + stub , req , start_req , check_done ) ; <nl> } <nl> } ; <nl> <nl> mmm a / test / cpp / qps / client_sync . cc <nl> ppp b / test / cpp / qps / client_sync . cc <nl> <nl> * / <nl> <nl> # include < cassert > <nl> - # include < chrono > <nl> # include < memory > <nl> # include < mutex > <nl> # include < string > <nl> <nl> # include " test / cpp / qps / client . h " <nl> # include " test / cpp / qps / qpstest . grpc . pb . h " <nl> # include " test / cpp / qps / histogram . h " <nl> - # include " test / cpp / qps / interarrival . h " <nl> # include " test / cpp / qps / timer . h " <nl> <nl> namespace grpc { <nl> class SynchronousClient : public Client { <nl> num_threads_ = <nl> config . outstanding_rpcs_per_channel ( ) * config . client_channels ( ) ; <nl> responses_ . resize ( num_threads_ ) ; <nl> - SetupLoadTest ( config , num_threads_ ) ; <nl> } <nl> <nl> virtual ~ SynchronousClient ( ) { } ; <nl> <nl> protected : <nl> - void WaitToIssue ( int thread_idx ) { <nl> - grpc_time next_time ; <nl> - if ( NextIssueTime ( thread_idx , & next_time ) ) { <nl> - std : : this_thread : : sleep_until ( next_time ) ; <nl> - } <nl> - } <nl> - <nl> size_t num_threads_ ; <nl> std : : vector < SimpleResponse > responses_ ; <nl> } ; <nl> class SynchronousUnaryClient GRPC_FINAL : public SynchronousClient { <nl> ~ SynchronousUnaryClient ( ) { EndThreads ( ) ; } <nl> <nl> bool ThreadFunc ( Histogram * histogram , size_t thread_idx ) GRPC_OVERRIDE { <nl> - WaitToIssue ( thread_idx ) ; <nl> auto * stub = channels_ [ thread_idx % channels_ . size ( ) ] . get_stub ( ) ; <nl> double start = Timer : : Now ( ) ; <nl> grpc : : ClientContext context ; <nl> class SynchronousStreamingClient GRPC_FINAL : public SynchronousClient { <nl> } <nl> <nl> bool ThreadFunc ( Histogram * histogram , size_t thread_idx ) GRPC_OVERRIDE { <nl> - WaitToIssue ( thread_idx ) ; <nl> double start = Timer : : Now ( ) ; <nl> if ( stream_ [ thread_idx ] - > Write ( request_ ) & & <nl> stream_ [ thread_idx ] - > Read ( & responses_ [ thread_idx ] ) ) { <nl> deleted file mode 100644 <nl> index f90a17a8945 . . 00000000000 <nl> mmm a / test / cpp / qps / interarrival . h <nl> ppp / dev / null <nl> <nl> - / * <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> - * / <nl> - <nl> - # ifndef TEST_QPS_INTERARRIVAL_H <nl> - # define TEST_QPS_INTERARRIVAL_H <nl> - <nl> - # include < chrono > <nl> - # include < cmath > <nl> - # include < random > <nl> - <nl> - # include < grpc + + / config . h > <nl> - <nl> - namespace grpc { <nl> - namespace testing { <nl> - <nl> - / / First create classes that define a random distribution <nl> - / / Note that this code does not include C + + - specific random distribution <nl> - / / features supported in std : : random . Although this would make this code easier , <nl> - / / this code is required to serve as the template code for other language <nl> - / / stacks . Thus , this code only uses a uniform distribution of doubles [ 0 , 1 ) <nl> - / / and then provides the distribution functions itself . <nl> - <nl> - class RandomDist { <nl> - public : <nl> - RandomDist ( ) { } <nl> - virtual ~ RandomDist ( ) = 0 ; <nl> - / / Argument to operator ( ) is a uniform double in the range [ 0 , 1 ) <nl> - virtual double operator ( ) ( double uni ) const = 0 ; <nl> - } ; <nl> - <nl> - inline RandomDist : : ~ RandomDist ( ) { } <nl> - <nl> - / / ExpDist implements an exponential distribution , which is the <nl> - / / interarrival distribution for a Poisson process . The parameter <nl> - / / lambda is the mean rate of arrivals . This is the <nl> - / / most useful distribution since it is actually additive and <nl> - / / memoryless . It is a good representation of activity coming in from <nl> - / / independent identical stationary sources . For more information , <nl> - / / see http : / / en . wikipedia . org / wiki / Exponential_distribution <nl> - <nl> - class ExpDist GRPC_FINAL : public RandomDist { <nl> - public : <nl> - explicit ExpDist ( double lambda ) : lambda_recip_ ( 1 . 0 / lambda ) { } <nl> - ~ ExpDist ( ) GRPC_OVERRIDE { } <nl> - double operator ( ) ( double uni ) const GRPC_OVERRIDE { <nl> - / / Note : Use 1 . 0 - uni above to avoid NaN if uni is 0 <nl> - return lambda_recip_ * ( - log ( 1 . 0 - uni ) ) ; <nl> - } <nl> - <nl> - private : <nl> - double lambda_recip_ ; <nl> - } ; <nl> - <nl> - / / UniformDist implements a random distribution that has <nl> - / / interarrival time uniformly spread between [ lo , hi ) . The <nl> - / / mean interarrival time is ( lo + hi ) / 2 . For more information , <nl> - / / see http : / / en . wikipedia . org / wiki / Uniform_distribution_ % 28continuous % 29 <nl> - <nl> - class UniformDist GRPC_FINAL : public RandomDist { <nl> - public : <nl> - UniformDist ( double lo , double hi ) : lo_ ( lo ) , range_ ( hi - lo ) { } <nl> - ~ UniformDist ( ) GRPC_OVERRIDE { } <nl> - double operator ( ) ( double uni ) const GRPC_OVERRIDE { <nl> - return uni * range_ + lo_ ; <nl> - } <nl> - <nl> - private : <nl> - double lo_ ; <nl> - double range_ ; <nl> - } ; <nl> - <nl> - / / DetDist provides a random distribution with interarrival time <nl> - / / of val . Note that this is not additive , so using this on multiple <nl> - / / flows of control ( threads within the same client or separate <nl> - / / clients ) will not preserve any deterministic interarrival gap across <nl> - / / requests . <nl> - <nl> - class DetDist GRPC_FINAL : public RandomDist { <nl> - public : <nl> - explicit DetDist ( double val ) : val_ ( val ) { } <nl> - ~ DetDist ( ) GRPC_OVERRIDE { } <nl> - double operator ( ) ( double uni ) const GRPC_OVERRIDE { return val_ ; } <nl> - <nl> - private : <nl> - double val_ ; <nl> - } ; <nl> - <nl> - / / ParetoDist provides a random distribution with interarrival time <nl> - / / spread according to a Pareto ( heavy - tailed ) distribution . In this <nl> - / / model , many interarrival times are close to the base , but a sufficient <nl> - / / number will be high ( up to infinity ) as to disturb the mean . It is a <nl> - / / good representation of the response times of data center jobs . See <nl> - / / http : / / en . wikipedia . org / wiki / Pareto_distribution <nl> - <nl> - class ParetoDist GRPC_FINAL : public RandomDist { <nl> - public : <nl> - ParetoDist ( double base , double alpha ) <nl> - : base_ ( base ) , alpha_recip_ ( 1 . 0 / alpha ) { } <nl> - ~ ParetoDist ( ) GRPC_OVERRIDE { } <nl> - double operator ( ) ( double uni ) const GRPC_OVERRIDE { <nl> - / / Note : Use 1 . 0 - uni above to avoid div by zero if uni is 0 <nl> - return base_ / pow ( 1 . 0 - uni , alpha_recip_ ) ; <nl> - } <nl> - <nl> - private : <nl> - double base_ ; <nl> - double alpha_recip_ ; <nl> - } ; <nl> - <nl> - / / A class library for generating pseudo - random interarrival times <nl> - / / in an efficient re - entrant way . The random table is built at construction <nl> - / / time , and each call must include the thread id of the invoker <nl> - <nl> - typedef std : : default_random_engine qps_random_engine ; <nl> - <nl> - class InterarrivalTimer { <nl> - public : <nl> - InterarrivalTimer ( ) { } <nl> - void init ( const RandomDist & r , int threads , int entries = 1000000 ) { <nl> - qps_random_engine gen ; <nl> - std : : uniform_real_distribution < double > uniform ( 0 . 0 , 1 . 0 ) ; <nl> - for ( int i = 0 ; i < entries ; i + + ) { <nl> - random_table_ . push_back ( std : : chrono : : nanoseconds ( <nl> - static_cast < int64_t > ( 1e9 * r ( uniform ( gen ) ) ) ) ) ; <nl> - } <nl> - / / Now set up the thread positions <nl> - for ( int i = 0 ; i < threads ; i + + ) { <nl> - thread_posns_ . push_back ( random_table_ . begin ( ) + ( entries * i ) / threads ) ; <nl> - } <nl> - } <nl> - virtual ~ InterarrivalTimer ( ) { } ; <nl> - <nl> - std : : chrono : : nanoseconds operator ( ) ( int thread_num ) { <nl> - auto ret = * ( thread_posns_ [ thread_num ] + + ) ; <nl> - if ( thread_posns_ [ thread_num ] = = random_table_ . end ( ) ) <nl> - thread_posns_ [ thread_num ] = random_table_ . begin ( ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - private : <nl> - typedef std : : vector < std : : chrono : : nanoseconds > time_table ; <nl> - std : : vector < time_table : : const_iterator > thread_posns_ ; <nl> - time_table random_table_ ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - # endif <nl> mmm a / test / cpp / qps / qps_driver . cc <nl> ppp b / test / cpp / qps / qps_driver . cc <nl> DEFINE_int32 ( client_channels , 1 , " Number of client channels " ) ; <nl> DEFINE_int32 ( payload_size , 1 , " Payload size " ) ; <nl> DEFINE_string ( client_type , " SYNCHRONOUS_CLIENT " , " Client type " ) ; <nl> DEFINE_int32 ( async_client_threads , 1 , " Async client threads " ) ; <nl> - DEFINE_string ( load_type , " CLOSED_LOOP " , " Load type " ) ; <nl> - DEFINE_double ( load_param_1 , 0 . 0 , " Load parameter 1 " ) ; <nl> - DEFINE_double ( load_param_2 , 0 . 0 , " Load parameter 2 " ) ; <nl> <nl> using grpc : : testing : : ClientConfig ; <nl> using grpc : : testing : : ServerConfig ; <nl> using grpc : : testing : : ClientType ; <nl> using grpc : : testing : : ServerType ; <nl> - using grpc : : testing : : LoadType ; <nl> using grpc : : testing : : RpcType ; <nl> using grpc : : testing : : ResourceUsage ; <nl> <nl> static void QpsDriver ( ) { <nl> <nl> ClientType client_type ; <nl> ServerType server_type ; <nl> - LoadType load_type ; <nl> GPR_ASSERT ( ClientType_Parse ( FLAGS_client_type , & client_type ) ) ; <nl> GPR_ASSERT ( ServerType_Parse ( FLAGS_server_type , & server_type ) ) ; <nl> - GPR_ASSERT ( LoadType_Parse ( FLAGS_load_type , & load_type ) ) ; <nl> <nl> ClientConfig client_config ; <nl> client_config . set_client_type ( client_type ) ; <nl> - client_config . set_load_type ( load_type ) ; <nl> client_config . set_enable_ssl ( FLAGS_enable_ssl ) ; <nl> client_config . set_outstanding_rpcs_per_channel ( <nl> FLAGS_outstanding_rpcs_per_channel ) ; <nl> static void QpsDriver ( ) { <nl> client_config . set_async_client_threads ( FLAGS_async_client_threads ) ; <nl> client_config . set_rpc_type ( rpc_type ) ; <nl> <nl> - / / set up the load parameters <nl> - switch ( load_type ) { <nl> - case grpc : : testing : : CLOSED_LOOP : <nl> - break ; <nl> - case grpc : : testing : : POISSON : { <nl> - auto poisson = client_config . mutable_load_params ( ) - > mutable_poisson ( ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_1 ! = 0 . 0 ) ; <nl> - poisson - > set_offered_load ( FLAGS_load_param_1 ) ; <nl> - break ; <nl> - } <nl> - case grpc : : testing : : UNIFORM : { <nl> - auto uniform = client_config . mutable_load_params ( ) - > mutable_uniform ( ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_1 ! = 0 . 0 ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_2 ! = 0 . 0 ) ; <nl> - uniform - > set_interarrival_lo ( FLAGS_load_param_1 / 1e6 ) ; <nl> - uniform - > set_interarrival_hi ( FLAGS_load_param_2 / 1e6 ) ; <nl> - break ; <nl> - } <nl> - case grpc : : testing : : DETERMINISTIC : { <nl> - auto determ = client_config . mutable_load_params ( ) - > mutable_determ ( ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_1 ! = 0 . 0 ) ; <nl> - determ - > set_offered_load ( FLAGS_load_param_1 ) ; <nl> - break ; <nl> - } <nl> - case grpc : : testing : : PARETO : { <nl> - auto pareto = client_config . mutable_load_params ( ) - > mutable_pareto ( ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_1 ! = 0 . 0 ) ; <nl> - GPR_ASSERT ( FLAGS_load_param_2 ! = 0 . 0 ) ; <nl> - pareto - > set_interarrival_base ( FLAGS_load_param_1 / 1e6 ) ; <nl> - pareto - > set_alpha ( FLAGS_load_param_2 ) ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> ServerConfig server_config ; <nl> server_config . set_server_type ( server_type ) ; <nl> server_config . set_threads ( FLAGS_server_threads ) ; <nl> deleted file mode 100644 <nl> index cecd1be03f6 . . 00000000000 <nl> mmm a / test / cpp / qps / qps_interarrival_test . cc <nl> ppp / dev / null <nl> <nl> - / * <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> - * / <nl> - <nl> - # include " test / cpp / qps / interarrival . h " <nl> - # include < chrono > <nl> - # include < iostream > <nl> - <nl> - / / Use the C histogram rather than C + + to avoid depending on proto <nl> - # include < grpc / support / histogram . h > <nl> - # include < grpc + + / config . h > <nl> - <nl> - using grpc : : testing : : RandomDist ; <nl> - using grpc : : testing : : InterarrivalTimer ; <nl> - <nl> - void RunTest ( RandomDist & & r , int threads , std : : string title ) { <nl> - InterarrivalTimer timer ; <nl> - timer . init ( r , threads ) ; <nl> - gpr_histogram * h ( gpr_histogram_create ( 0 . 01 , 60e9 ) ) ; <nl> - <nl> - for ( int i = 0 ; i < 10000000 ; i + + ) { <nl> - for ( int j = 0 ; j < threads ; j + + ) { <nl> - gpr_histogram_add ( h , timer ( j ) . count ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - std : : cout < < title < < " Distribution " < < std : : endl ; <nl> - std : : cout < < " Value , Percentile " < < std : : endl ; <nl> - for ( double pct = 0 . 0 ; pct < 100 . 0 ; pct + = 1 . 0 ) { <nl> - std : : cout < < gpr_histogram_percentile ( h , pct ) < < " , " < < pct < < std : : endl ; <nl> - } <nl> - <nl> - gpr_histogram_destroy ( h ) ; <nl> - } <nl> - <nl> - using grpc : : testing : : ExpDist ; <nl> - using grpc : : testing : : DetDist ; <nl> - using grpc : : testing : : UniformDist ; <nl> - using grpc : : testing : : ParetoDist ; <nl> - <nl> - int main ( int argc , char * * argv ) { <nl> - RunTest ( ExpDist ( 10 . 0 ) , 5 , std : : string ( " Exponential ( 10 ) " ) ) ; <nl> - RunTest ( DetDist ( 5 . 0 ) , 5 , std : : string ( " Det ( 5 ) " ) ) ; <nl> - RunTest ( UniformDist ( 0 . 0 , 10 . 0 ) , 5 , std : : string ( " Uniform ( 1 , 10 ) " ) ) ; <nl> - RunTest ( ParetoDist ( 1 . 0 , 1 . 0 ) , 5 , std : : string ( " Pareto ( 1 , 1 ) " ) ) ; <nl> - return 0 ; <nl> - } <nl> deleted file mode 100644 <nl> index 0f6d8e8530e . . 00000000000 <nl> mmm a / test / cpp / qps / qps_test_openloop . cc <nl> ppp / dev / null <nl> <nl> - / * <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> - * / <nl> - <nl> - # include < set > <nl> - <nl> - # include < grpc / support / log . h > <nl> - <nl> - # include < signal . h > <nl> - <nl> - # include " test / cpp / qps / driver . h " <nl> - # include " test / cpp / qps / report . h " <nl> - # include " test / cpp / util / benchmark_config . h " <nl> - <nl> - namespace grpc { <nl> - namespace testing { <nl> - <nl> - static const int WARMUP = 5 ; <nl> - static const int BENCHMARK = 10 ; <nl> - <nl> - static void RunQPS ( ) { <nl> - gpr_log ( GPR_INFO , " Running QPS test , open - loop " ) ; <nl> - <nl> - ClientConfig client_config ; <nl> - client_config . set_client_type ( ASYNC_CLIENT ) ; <nl> - client_config . set_enable_ssl ( false ) ; <nl> - client_config . set_outstanding_rpcs_per_channel ( 1000 ) ; <nl> - client_config . set_client_channels ( 8 ) ; <nl> - client_config . set_payload_size ( 1 ) ; <nl> - client_config . set_async_client_threads ( 8 ) ; <nl> - client_config . set_rpc_type ( UNARY ) ; <nl> - client_config . set_load_type ( POISSON ) ; <nl> - client_config . mutable_load_params ( ) - > <nl> - mutable_poisson ( ) - > set_offered_load ( 10000 . 0 ) ; <nl> - <nl> - ServerConfig server_config ; <nl> - server_config . set_server_type ( ASYNC_SERVER ) ; <nl> - server_config . set_enable_ssl ( false ) ; <nl> - server_config . set_threads ( 4 ) ; <nl> - <nl> - const auto result = <nl> - RunScenario ( client_config , 1 , server_config , 1 , WARMUP , BENCHMARK , - 2 ) ; <nl> - <nl> - GetReporter ( ) - > ReportQPSPerCore ( * result , server_config ) ; <nl> - GetReporter ( ) - > ReportLatency ( * result ) ; <nl> - } <nl> - <nl> - } / / namespace testing <nl> - } / / namespace grpc <nl> - <nl> - int main ( int argc , char * * argv ) { <nl> - grpc : : testing : : InitBenchmark ( & argc , & argv , true ) ; <nl> - <nl> - signal ( SIGPIPE , SIG_IGN ) ; <nl> - grpc : : testing : : RunQPS ( ) ; <nl> - <nl> - return 0 ; <nl> - } <nl> mmm a / test / cpp / qps / qpstest . proto <nl> ppp b / test / cpp / qps / qpstest . proto <nl> package grpc . testing ; <nl> <nl> enum PayloadType { <nl> / / Compressable text format . <nl> - COMPRESSABLE = 1 ; <nl> + COMPRESSABLE = 1 ; <nl> <nl> / / Uncompressable binary format . <nl> UNCOMPRESSABLE = 2 ; <nl> enum RpcType { <nl> STREAMING = 2 ; <nl> } <nl> <nl> - enum LoadType { <nl> - CLOSED_LOOP = 1 ; <nl> - POISSON = 2 ; <nl> - UNIFORM = 3 ; <nl> - DETERMINISTIC = 4 ; <nl> - PARETO = 5 ; <nl> - } <nl> - <nl> - message PoissonParams { <nl> - optional double offered_load = 1 ; <nl> - } <nl> - <nl> - message UniformParams { <nl> - optional double interarrival_lo = 1 ; <nl> - optional double interarrival_hi = 2 ; <nl> - } <nl> - <nl> - message DeterministicParams { <nl> - optional double offered_load = 1 ; <nl> - } <nl> - <nl> - message ParetoParams { <nl> - optional double interarrival_base = 1 ; <nl> - optional double alpha = 2 ; <nl> - } <nl> - <nl> - message LoadParams { <nl> - oneof load { <nl> - PoissonParams poisson = 1 ; <nl> - UniformParams uniform = 2 ; <nl> - DeterministicParams determ = 3 ; <nl> - ParetoParams pareto = 4 ; <nl> - } ; <nl> - } <nl> - <nl> message ClientConfig { <nl> repeated string server_targets = 1 ; <nl> required ClientType client_type = 2 ; <nl> - optional bool enable_ssl = 3 [ default = false ] ; <nl> + optional bool enable_ssl = 3 [ default = false ] ; <nl> required int32 outstanding_rpcs_per_channel = 4 ; <nl> required int32 client_channels = 5 ; <nl> required int32 payload_size = 6 ; <nl> / / only for async client : <nl> optional int32 async_client_threads = 7 ; <nl> - optional RpcType rpc_type = 8 [ default = UNARY ] ; <nl> + optional RpcType rpc_type = 8 [ default = UNARY ] ; <nl> optional string host = 9 ; <nl> - optional LoadType load_type = 10 [ default = CLOSED_LOOP ] ; <nl> - optional LoadParams load_params = 11 ; <nl> } <nl> <nl> / / Request current stats <nl> - message Mark { <nl> - } <nl> + message Mark { } <nl> <nl> message ClientArgs { <nl> oneof argtype { <nl> message ClientStatus { <nl> <nl> message ServerConfig { <nl> required ServerType server_type = 1 ; <nl> - optional int32 threads = 2 [ default = 1 ] ; <nl> - optional bool enable_ssl = 3 [ default = false ] ; <nl> + optional int32 threads = 2 [ default = 1 ] ; <nl> + optional bool enable_ssl = 3 [ default = false ] ; <nl> optional string host = 4 ; <nl> } <nl> <nl> message ServerStatus { <nl> message SimpleRequest { <nl> / / Desired payload type in the response from the server . <nl> / / If response_type is RANDOM , server randomly chooses one from other formats . <nl> - optional PayloadType response_type = 1 [ default = COMPRESSABLE ] ; <nl> + optional PayloadType response_type = 1 [ default = COMPRESSABLE ] ; <nl> <nl> / / Desired payload size in the response from the server . <nl> / / If response_type is COMPRESSABLE , this denotes the size before compression . <nl> - optional int32 response_size = 2 [ default = 0 ] ; <nl> + optional int32 response_size = 2 [ default = 0 ] ; <nl> <nl> / / Optional input payload sent along with the request . <nl> optional Payload payload = 3 ; <nl> mmm a / tools / run_tests / tests . json <nl> ppp b / tools / run_tests / tests . json <nl> <nl> " posix " <nl> ] <nl> } , <nl> - { <nl> - " flaky " : false , <nl> - " language " : " c + + " , <nl> - " name " : " qps_test " , <nl> - " platforms " : [ <nl> - " windows " , <nl> - " posix " <nl> - ] <nl> - } , <nl> - { <nl> - " flaky " : false , <nl> - " language " : " c + + " , <nl> - " name " : " qps_test_openloop " , <nl> - " platforms " : [ <nl> - " windows " , <nl> - " posix " <nl> - ] <nl> - } , <nl> { <nl> " flaky " : false , <nl> " language " : " c + + " , <nl>
|
Merge pull request from grpc / revert - 1948 - poisson
|
grpc/grpc
|
b32c082906b9b52b89387761c3f7cb01638bcadc
|
2015-06-08T17:24:25Z
|
mmm a / tensorflow / lite / micro / kernels / BUILD <nl> ppp b / tensorflow / lite / micro / kernels / BUILD <nl> config_setting ( <nl> define_values = { " tflm_build " : " xtensa_hifimini " } , <nl> ) <nl> <nl> - config_setting ( <nl> - name = " xtensa_hifimini_staging " , <nl> - define_values = { " tflm_build " : " xtensa_hifimini_staging " } , <nl> - ) <nl> - <nl> package_group ( <nl> name = " micro " , <nl> packages = [ " / / tensorflow / lite / micro / . . . " ] , <nl> cc_library ( <nl> " / / conditions : default " : [ <nl> ] , <nl> " : xtensa_hifimini " : [ <nl> - " xtensa_hifimini / fixedpoint_utils . h " , <nl> - ] , <nl> - " : xtensa_hifimini_staging " : [ <nl> - " xtensa_hifimini / fixedpoint_utils . h " , <nl> + " xtensa / fixedpoint_utils . h " , <nl> ] , <nl> } ) , <nl> copts = micro_copts ( ) , <nl> cc_library ( <nl> " fully_connected . cc " , <nl> ] , <nl> " : xtensa_hifimini " : [ <nl> - " xtensa_hifimini / fully_connected . cc " , <nl> - ] , <nl> - " : xtensa_hifimini_staging " : [ <nl> - " xtensa_hifimini_staging / fully_connected . cc " , <nl> + " xtensa / fully_connected . cc " , <nl> ] , <nl> } ) , <nl> hdrs = [ " fully_connected . h " ] , <nl> cc_library ( <nl> " : micro " , <nl> ] , <nl> deps = [ <nl> - " : activation_utils " , <nl> " : fixedpoint_utils " , <nl> " : kernel_util " , <nl> - " : micro_utils " , <nl> " / / tensorflow / lite / c : common " , <nl> " / / tensorflow / lite / kernels : kernel_util " , <nl> - " / / tensorflow / lite / kernels : op_macros " , <nl> - " / / tensorflow / lite / kernels : padding " , <nl> " / / tensorflow / lite / kernels / internal : common " , <nl> - " / / tensorflow / lite / kernels / internal : compatibility " , <nl> " / / tensorflow / lite / kernels / internal : quantization_util " , <nl> " / / tensorflow / lite / kernels / internal : reference_base " , <nl> " / / tensorflow / lite / kernels / internal : tensor " , <nl> - " / / tensorflow / lite / kernels / internal : types " , <nl> - " / / tensorflow / lite / micro : memory_helpers " , <nl> - " / / tensorflow / lite / micro : micro_utils " , <nl> ] + select ( { <nl> " / / conditions : default " : [ ] , <nl> " : xtensa_hifimini " : [ <nl> cc_library ( <nl> " svdf . cc " , <nl> ] , <nl> " : xtensa_hifimini " : [ <nl> - " xtensa_hifimini / conv . cc " , <nl> - " xtensa_hifimini / depthwise_conv . cc " , <nl> - " xtensa_hifimini / quantize . cc " , <nl> - " xtensa_hifimini / softmax . cc " , <nl> - " xtensa_hifimini / svdf . cc " , <nl> - ] , <nl> - " : xtensa_hifimini_staging " : [ <nl> - # TODO ( b / 144176795 ) : finer granularity would help reduce the <nl> - # duplication of srcs in the BUILD rules ( in this case conv . cc and <nl> - # depthwise_conv . cc ) . We are falling back to reference kernels in <nl> - # case the optimized kernels are not implemented to match the <nl> - # behavior that we get with the Makefiles . <nl> - " conv . cc " , <nl> - " depthwise_conv . cc " , <nl> - " xtensa_hifimini_staging / quantize . cc " , <nl> - " xtensa_hifimini_staging / softmax . cc " , <nl> - " xtensa_hifimini_staging / svdf . cc " , <nl> + " xtensa / conv . cc " , <nl> + " xtensa / depthwise_conv . cc " , <nl> + " xtensa / quantize . cc " , <nl> + " xtensa / softmax . cc " , <nl> + " xtensa / svdf . cc " , <nl> ] , <nl> } ) , <nl> hdrs = [ " micro_ops . h " ] , <nl> mmm a / tensorflow / lite / micro / kernels / xtensa / conv . cc <nl> ppp b / tensorflow / lite / micro / kernels / xtensa / conv . cc <nl> limitations under the License . <nl> # include " tensorflow / lite / kernels / kernel_util . h " <nl> # include " tensorflow / lite / kernels / padding . h " <nl> # include " tensorflow / lite / micro / kernels / kernel_util . h " <nl> - # include " tensorflow / lite / micro / kernels / xtensa_hifimini / fixedpoint_utils . h " <nl> + # include " tensorflow / lite / micro / kernels / xtensa / fixedpoint_utils . h " <nl> <nl> namespace tflite { <nl> namespace { <nl> mmm a / tensorflow / lite / micro / kernels / xtensa / depthwise_conv . cc <nl> ppp b / tensorflow / lite / micro / kernels / xtensa / depthwise_conv . cc <nl> limitations under the License . <nl> # include " tensorflow / lite / kernels / kernel_util . h " <nl> # include " tensorflow / lite / kernels / padding . h " <nl> # include " tensorflow / lite / micro / kernels / kernel_util . h " <nl> - # include " tensorflow / lite / micro / kernels / xtensa_hifimini / fixedpoint_utils . h " <nl> + # include " tensorflow / lite / micro / kernels / xtensa / fixedpoint_utils . h " <nl> <nl> namespace tflite { <nl> namespace { <nl> mmm a / tensorflow / lite / micro / kernels / xtensa / fully_connected . cc <nl> ppp b / tensorflow / lite / micro / kernels / xtensa / fully_connected . cc <nl> limitations under the License . <nl> # include " tensorflow / lite / kernels / internal / tensor_ctypes . h " <nl> # include " tensorflow / lite / kernels / kernel_util . h " <nl> # include " tensorflow / lite / micro / kernels / kernel_util . h " <nl> - # include " tensorflow / lite / micro / kernels / xtensa_hifimini / fixedpoint_utils . h " <nl> + # include " tensorflow / lite / micro / kernels / xtensa / fixedpoint_utils . h " <nl> <nl> namespace tflite { <nl> namespace { <nl> mmm a / tensorflow / lite / micro / kernels / xtensa / quantize . cc <nl> ppp b / tensorflow / lite / micro / kernels / xtensa / quantize . cc <nl> limitations under the License . <nl> # include " tensorflow / lite / kernels / internal / tensor_ctypes . h " <nl> # include " tensorflow / lite / kernels / kernel_util . h " <nl> # include " tensorflow / lite / micro / kernels / kernel_util . h " <nl> - # include " tensorflow / lite / micro / kernels / xtensa_hifimini / fixedpoint_utils . h " <nl> + # include " tensorflow / lite / micro / kernels / xtensa / fixedpoint_utils . h " <nl> <nl> namespace tflite { <nl> namespace { <nl> mmm a / tensorflow / lite / micro / kernels / xtensa / svdf . cc <nl> ppp b / tensorflow / lite / micro / kernels / xtensa / svdf . cc <nl> limitations under the License . <nl> # include " tensorflow / lite / kernels / op_macros . h " <nl> # include " tensorflow / lite / micro / kernels / activation_utils . h " <nl> # include " tensorflow / lite / micro / kernels / kernel_util . h " <nl> - # include " tensorflow / lite / micro / kernels / xtensa_hifimini / fixedpoint_utils . h " <nl> + # include " tensorflow / lite / micro / kernels / xtensa / fixedpoint_utils . h " <nl> <nl> namespace tflite { <nl> namespace { <nl>
|
Steps towards deleting micro / kernels / xtensa_hifimini in favor of micro / kernels / xtensa
|
tensorflow/tensorflow
|
70beb7d170341dd07d66feeb5f48ae52c114708f
|
2020-11-19T18:37:39Z
|
mmm a / ReactWindows / ReactNative / Modules / Storage / AsyncStorageModule . cs <nl> ppp b / ReactWindows / ReactNative / Modules / Storage / AsyncStorageModule . cs <nl> <nl> using ReactNative . Bridge ; <nl> using System ; <nl> using System . Text ; <nl> + using System . Threading ; <nl> using System . Threading . Tasks ; <nl> using Windows . Storage ; <nl> <nl> class AsyncStorageModule : NativeModuleBase <nl> private const string DirectoryName = " AsyncStorage \ \ " ; <nl> private const string FileExtension = " . data " ; <nl> <nl> - private readonly object _gate = new object ( ) ; <nl> + private readonly SemaphoreSlim _mutex = new SemaphoreSlim ( 1 , 1 ) ; <nl> <nl> public override string Name <nl> { <nl> public async void multiGet ( string [ ] keys , ICallback callback ) <nl> var error = default ( JObject ) ; <nl> var data = new JArray ( ) ; <nl> <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + foreach ( var key in keys ) <nl> { <nl> - foreach ( var key in keys ) <nl> + if ( key = = null ) <nl> { <nl> - if ( key = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> - break ; <nl> - } <nl> - <nl> - var value = Get ( key ) ; <nl> - data . Add ( new JArray ( key , value ) ) ; <nl> + error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> + break ; <nl> } <nl> + <nl> + var value = await GetAsync ( key ) . ConfigureAwait ( false ) ; <nl> + data . Add ( new JArray ( key , value ) ) ; <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> if ( error ! = null ) <nl> { <nl> public async void multiSet ( string [ ] [ ] keyValueArray , ICallback callback ) <nl> <nl> var error = default ( JObject ) ; <nl> <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + foreach ( var pair in keyValueArray ) <nl> { <nl> - foreach ( var pair in keyValueArray ) <nl> + if ( pair . Length ! = 2 ) <nl> { <nl> - if ( pair . Length ! = 2 ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidValueError ( null ) ; <nl> - break ; <nl> - } <nl> + error = AsyncStorageErrorHelpers . GetInvalidValueError ( null ) ; <nl> + break ; <nl> + } <nl> <nl> - if ( pair [ 0 ] = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> - break ; <nl> - } <nl> + if ( pair [ 0 ] = = null ) <nl> + { <nl> + error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> + break ; <nl> + } <nl> <nl> - if ( pair [ 1 ] = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidValueError ( pair [ 0 ] ) ; <nl> - break ; <nl> - } <nl> + if ( pair [ 1 ] = = null ) <nl> + { <nl> + error = AsyncStorageErrorHelpers . GetInvalidValueError ( pair [ 0 ] ) ; <nl> + break ; <nl> + } <nl> <nl> - error = Set ( pair [ 0 ] , pair [ 1 ] ) ; <nl> - if ( error ! = null ) <nl> - { <nl> - break ; <nl> - } <nl> + error = await SetAsync ( pair [ 0 ] , pair [ 1 ] ) . ConfigureAwait ( false ) ; <nl> + if ( error ! = null ) <nl> + { <nl> + break ; <nl> } <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> if ( error ! = null ) <nl> { <nl> public async void multiRemove ( string [ ] keys , ICallback callback ) <nl> <nl> var error = default ( JObject ) ; <nl> <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + foreach ( var key in keys ) <nl> { <nl> - foreach ( var key in keys ) <nl> + if ( key = = null ) <nl> { <nl> - if ( key = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> - break ; <nl> - } <nl> + error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> + break ; <nl> + } <nl> <nl> - error = Remove ( key ) ; <nl> - if ( error ! = null ) <nl> - { <nl> - break ; <nl> - } <nl> + error = await RemoveAsync ( key ) . ConfigureAwait ( false ) ; <nl> + if ( error ! = null ) <nl> + { <nl> + break ; <nl> } <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> if ( error ! = null ) <nl> { <nl> public async void multiMerge ( string [ ] [ ] keyValueArray , ICallback callback ) <nl> <nl> var error = default ( JObject ) ; <nl> <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + foreach ( var pair in keyValueArray ) <nl> { <nl> - foreach ( var pair in keyValueArray ) <nl> + if ( pair . Length ! = 2 ) <nl> { <nl> - if ( pair . Length ! = 2 ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidValueError ( null ) ; <nl> - break ; <nl> - } <nl> + error = AsyncStorageErrorHelpers . GetInvalidValueError ( null ) ; <nl> + break ; <nl> + } <nl> <nl> - if ( pair [ 0 ] = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> - break ; <nl> - } <nl> + if ( pair [ 0 ] = = null ) <nl> + { <nl> + error = AsyncStorageErrorHelpers . GetInvalidKeyError ( null ) ; <nl> + break ; <nl> + } <nl> <nl> - if ( pair [ 1 ] = = null ) <nl> - { <nl> - error = AsyncStorageErrorHelpers . GetInvalidValueError ( pair [ 0 ] ) ; <nl> - break ; <nl> - } <nl> + if ( pair [ 1 ] = = null ) <nl> + { <nl> + error = AsyncStorageErrorHelpers . GetInvalidValueError ( pair [ 0 ] ) ; <nl> + break ; <nl> + } <nl> <nl> - error = Merge ( pair [ 0 ] , pair [ 1 ] ) ; <nl> - if ( error ! = null ) <nl> - { <nl> - break ; <nl> - } <nl> + error = await MergeAsync ( pair [ 0 ] , pair [ 1 ] ) . ConfigureAwait ( false ) ; <nl> + if ( error ! = null ) <nl> + { <nl> + break ; <nl> } <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> if ( error ! = null ) <nl> { <nl> public async void multiMerge ( string [ ] [ ] keyValueArray , ICallback callback ) <nl> [ ReactMethod ] <nl> public async void clear ( ICallback callback ) <nl> { <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + var localFolder = ApplicationData . Current . LocalFolder ; <nl> + var storageItem = await localFolder . TryGetItemAsync ( DirectoryName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + if ( storageItem ! = null ) <nl> { <nl> - var localFolder = ApplicationData . Current . LocalFolder ; <nl> - var storageItem = localFolder . TryGetItemAsync ( DirectoryName ) . AsTask ( ) . Result ; <nl> - if ( storageItem ! = null ) <nl> - { <nl> - storageItem . DeleteAsync ( ) . AsTask ( ) . Wait ( ) ; <nl> - } <nl> + await storageItem . DeleteAsync ( ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> callback . Invoke ( ) ; <nl> } <nl> public async void getAllKeys ( ICallback callback ) <nl> { <nl> var keys = new JArray ( ) ; <nl> <nl> - await Task . Run ( ( ) = > <nl> + await _mutex . WaitAsync ( ) . ConfigureAwait ( false ) ; <nl> + try <nl> { <nl> - lock ( _gate ) <nl> + var localFolder = ApplicationData . Current . LocalFolder ; <nl> + var storageItem = await localFolder . TryGetItemAsync ( DirectoryName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + if ( storageItem ! = null ) <nl> { <nl> - var localFolder = ApplicationData . Current . LocalFolder ; <nl> - var storageItem = localFolder . TryGetItemAsync ( DirectoryName ) . AsTask ( ) . Result ; <nl> - if ( storageItem ! = null ) <nl> + var directory = await localFolder . GetFolderAsync ( DirectoryName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + var items = await directory . GetItemsAsync ( ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + foreach ( var item in items ) <nl> { <nl> - var directory = localFolder . GetFolderAsync ( DirectoryName ) . AsTask ( ) . Result ; <nl> - var items = directory . GetItemsAsync ( ) . AsTask ( ) . Result ; <nl> - foreach ( var item in items ) <nl> + var itemName = item . Name ; <nl> + var itemLength = itemName . Length ; <nl> + var extLength = FileExtension . Length ; <nl> + if ( itemName . EndsWith ( FileExtension ) & & itemLength > extLength ) <nl> { <nl> - var itemName = item . Name ; <nl> - var itemLength = itemName . Length ; <nl> - var extLength = FileExtension . Length ; <nl> - if ( itemName . EndsWith ( FileExtension ) & & itemLength > extLength ) <nl> - { <nl> - keys . Add ( item . Name . Substring ( 0 , itemLength - extLength ) ) ; <nl> - } <nl> + keys . Add ( item . Name . Substring ( 0 , itemLength - extLength ) ) ; <nl> } <nl> } <nl> } <nl> - } ) ; <nl> + } <nl> + finally <nl> + { <nl> + _mutex . Release ( ) ; <nl> + } <nl> <nl> callback . Invoke ( null , keys ) ; <nl> } <nl> <nl> - private string Get ( string key ) <nl> + private async Task < string > GetAsync ( string key ) <nl> { <nl> var localFolder = ApplicationData . Current . LocalFolder ; <nl> var fileName = GetFileName ( key ) ; <nl> <nl> - var storageItem = localFolder . TryGetItemAsync ( fileName ) . AsTask ( ) . Result ; <nl> + var storageItem = await localFolder . TryGetItemAsync ( fileName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> if ( storageItem ! = null ) <nl> { <nl> - var file = localFolder . GetFileAsync ( fileName ) . AsTask ( ) . Result ; <nl> - return FileIO . ReadTextAsync ( file ) . AsTask ( ) . Result ; <nl> + var file = await localFolder . GetFileAsync ( fileName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + return await FileIO . ReadTextAsync ( file ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> } <nl> <nl> return null ; <nl> } <nl> <nl> - private JObject Merge ( string key , string value ) <nl> + private async Task < JObject > MergeAsync ( string key , string value ) <nl> { <nl> - var oldValue = Get ( key ) ; <nl> + var oldValue = await GetAsync ( key ) . ConfigureAwait ( false ) ; <nl> <nl> var newValue = default ( string ) ; <nl> if ( oldValue = = null ) <nl> private JObject Merge ( string key , string value ) <nl> newValue = oldJson . ToString ( Formatting . None ) ; <nl> } <nl> <nl> - return Set ( key , newValue ) ; <nl> + return await SetAsync ( key , newValue ) . ConfigureAwait ( false ) ; <nl> } <nl> <nl> - private JObject Remove ( string key ) <nl> + private async Task < JObject > RemoveAsync ( string key ) <nl> { <nl> var localFolder = ApplicationData . Current . LocalFolder ; <nl> var fileName = GetFileName ( key ) ; <nl> - var storageItem = localFolder . TryGetItemAsync ( fileName ) . AsTask ( ) . Result ; <nl> + var storageItem = await localFolder . TryGetItemAsync ( fileName ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> if ( storageItem ! = null ) <nl> { <nl> - storageItem . DeleteAsync ( ) . AsTask ( ) . Wait ( ) ; <nl> + await storageItem . DeleteAsync ( ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> } <nl> <nl> return null ; <nl> } <nl> <nl> - private JObject Set ( string key , string value ) <nl> + private async Task < JObject > SetAsync ( string key , string value ) <nl> { <nl> var localFolder = ApplicationData . Current . LocalFolder ; <nl> - var file = localFolder . CreateFileAsync ( GetFileName ( key ) , CreationCollisionOption . ReplaceExisting ) . AsTask ( ) . Result ; <nl> - FileIO . WriteTextAsync ( file , value ) . AsTask ( ) . Wait ( ) ; <nl> + var file = await localFolder . CreateFileAsync ( GetFileName ( key ) , CreationCollisionOption . ReplaceExisting ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> + await FileIO . WriteTextAsync ( file , value ) . AsTask ( ) . ConfigureAwait ( false ) ; <nl> return default ( JObject ) ; <nl> } <nl> <nl>
|
perf ( AsyncStorage ) : replace blocking filesystem calls with async ( )
|
microsoft/react-native-windows
|
a91b25dbefda1d0d50349c4f975b20c5f929c894
|
2016-08-18T16:40:11Z
|
mmm a / tensorflow / g3doc / api_docs / python / array_ops . md <nl> ppp b / tensorflow / g3doc / api_docs / python / array_ops . md <nl> For example : <nl> <nl> ` ` ` prettyprint <nl> # ' t ' is [ [ 1 , 1 ] , [ 2 , 2 ] ] <nl> - # ' paddings ' is [ [ 1 , 1 ] ] , [ 2 , 2 ] ] <nl> + # ' paddings ' is [ [ 1 , 1 ] , [ 2 , 2 ] ] <nl> # rank of ' t ' is 2 <nl> - pad ( t , paddings ) = = > [ [ 0 , 0 , 0 , 0 , 0 ] <nl> - [ 0 , 0 , 0 , 0 , 0 ] <nl> - [ 0 , 1 , 1 , 0 , 0 ] <nl> - [ [ 0 , 2 , 2 , 0 , 0 ] <nl> - [ 0 , 0 , 0 , 0 , 0 ] ] <nl> + pad ( t , paddings ) = = > [ [ 0 , 0 , 0 , 0 , 0 , 0 ] <nl> + [ 0 , 0 , 1 , 1 , 0 , 0 ] <nl> + [ 0 , 0 , 2 , 2 , 0 , 0 ] <nl> + [ 0 , 0 , 0 , 0 , 0 , 0 ] ] <nl> ` ` ` <nl> <nl> # # # # # Args : <nl> mmm a / tensorflow / g3doc / api_docs / python / image . md <nl> ppp b / tensorflow / g3doc / api_docs / python / image . md <nl> corresponds to pure red , hue 1 / 3 is pure green , and 2 / 3 is pure blue . <nl> <nl> - - - <nl> <nl> - # # # ` tf . image . convert_image_dtype ( image , dtype , name = None ) ` { # convert_image_dtype } <nl> + # # # ` tf . image . convert_image_dtype ( image , dtype , saturate = False , name = None ) ` { # convert_image_dtype } <nl> <nl> Convert ` image ` to ` dtype ` , scaling its values if needed . <nl> <nl> positive representable number for the data type . <nl> This op converts between data types , scaling the values appropriately before <nl> casting . <nl> <nl> - Note that for floating point inputs , this op expects values to lie in [ 0 , 1 ) . <nl> - Conversion of an image containing values outside that range may lead to <nl> - overflow errors when converted to integer ` Dtype ` s . <nl> + Note that converting from floating point inputs to integer types may lead to <nl> + over / underflow problems . Set saturate to ` True ` to avoid such problem in <nl> + problematic conversions . Saturation will clip the output into the allowed <nl> + range before performing a potentially dangerous cast ( i . e . when casting from <nl> + a floating point to an integer type , or when casting from an signed to an <nl> + unsigned type ) . <nl> <nl> # # # # # Args : <nl> <nl> <nl> * < b > ` image ` < / b > : An image . <nl> * < b > ` dtype ` < / b > : A ` DType ` to convert ` image ` to . <nl> + * < b > ` saturate ` < / b > : If ` True ` , clip the input before casting ( if necessary ) . <nl> * < b > ` name ` < / b > : A name for this operation ( optional ) . <nl> <nl> # # # # # Returns : <nl> type and representation ( RGB or HSV ) . <nl> <nl> - - - <nl> <nl> - # # # ` tf . image . adjust_brightness ( image , delta , min_value = None , max_value = None ) ` { # adjust_brightness } <nl> + # # # ` tf . image . adjust_brightness ( image , delta ) ` { # adjust_brightness } <nl> <nl> Adjust the brightness of RGB or Grayscale images . <nl> <nl> - The value ` delta ` is added to all components of the tensor ` image ` . ` image ` <nl> - and ` delta ` are cast to ` float ` before adding , and the resulting values are <nl> - clamped to ` [ min_value , max_value ] ` . Finally , the result is cast back to <nl> - ` images . dtype ` . <nl> + This is a convenience method that converts an RGB image to float <nl> + representation , adjusts its brightness , and then converts it back to the <nl> + original data type . If several adjustments are chained it is advisable to <nl> + minimize the number of redundant conversions . <nl> <nl> - If ` min_value ` or ` max_value ` are not given , they are set to the minimum and <nl> - maximum allowed values for ` image . dtype ` respectively . <nl> + The value ` delta ` is added to all components of the tensor ` image ` . Both <nl> + ` image ` and ` delta ` are converted to ` float ` before adding ( and ` image ` is <nl> + scaled appropriately if it is in fixed - point representation ) . For regular <nl> + images , ` delta ` should be in the range ` [ 0 , 1 ) ` , as it is added to the image in <nl> + floating point representation , where pixel values are in the ` [ 0 , 1 ) ` range . <nl> <nl> # # # # # Args : <nl> <nl> <nl> * < b > ` image ` < / b > : A tensor . <nl> * < b > ` delta ` < / b > : A scalar . Amount to add to the pixel values . <nl> - * < b > ` min_value ` < / b > : Minimum value for output . <nl> - * < b > ` max_value ` < / b > : Maximum value for output . <nl> <nl> # # # # # Returns : <nl> <nl> - A tensor of the same shape and type as ` image ` . <nl> + A brightness - adjusted tensor of the same shape and type as ` image ` . <nl> <nl> <nl> - - - <nl> Adjust the brightness of images by a random factor . <nl> Equivalent to ` adjust_brightness ( ) ` using a ` delta ` randomly picked in the <nl> interval ` [ - max_delta , max_delta ) ` . <nl> <nl> - Note that ` delta ` is picked as a float . Because for integer type images , <nl> - the brightness adjusted result is rounded before casting , integer images may <nl> - have modifications in the range ` [ - max_delta , max_delta ] ` . <nl> - <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` image ` < / b > : 3 - D tensor of shape ` [ height , width , channels ] ` . <nl> + * < b > ` image ` < / b > : An image . <nl> * < b > ` max_delta ` < / b > : float , must be non - negative . <nl> * < b > ` seed ` < / b > : A Python integer . Used to create a random seed . See <nl> [ ` set_random_seed ` ] ( . . / . . / api_docs / python / constant_op . md # set_random_seed ) <nl> have modifications in the range ` [ - max_delta , max_delta ] ` . <nl> <nl> # # # # # Returns : <nl> <nl> - 3 - D tensor of images of shape ` [ height , width , channels ] ` <nl> + The brightness - adjusted image . <nl> <nl> # # # # # Raises : <nl> <nl> have modifications in the range ` [ - max_delta , max_delta ] ` . <nl> <nl> - - - <nl> <nl> - # # # ` tf . image . adjust_contrast ( images , contrast_factor , min_value = None , max_value = None ) ` { # adjust_contrast } <nl> + # # # ` tf . image . adjust_contrast ( images , contrast_factor ) ` { # adjust_contrast } <nl> <nl> Adjust contrast of RGB or grayscale images . <nl> <nl> + This is a convenience method that converts an RGB image to float <nl> + representation , adjusts its contrast , and then converts it back to the <nl> + original data type . If several adjustments are chained it is advisable to <nl> + minimize the number of redundant conversions . <nl> + <nl> ` images ` is a tensor of at least 3 dimensions . The last 3 dimensions are <nl> interpreted as ` [ height , width , channels ] ` . The other dimensions only <nl> represent a collection of images , such as ` [ batch , height , width , channels ] . ` <nl> <nl> Contrast is adjusted independently for each channel of each image . <nl> <nl> - For each channel , this Op first computes the mean of the image pixels in the <nl> + For each channel , this Op computes the mean of the image pixels in the <nl> channel and then adjusts each component ` x ` of each pixel to <nl> ` ( x - mean ) * contrast_factor + mean ` . <nl> <nl> - The adjusted values are then clipped to fit in the ` [ min_value , max_value ] ` <nl> - interval . If ` min_value ` or ` max_value ` is not given , it is replaced with the <nl> - minimum and maximum values for the data type of ` images ` respectively . <nl> - <nl> - The contrast - adjusted image is always computed as ` float ` , and it is <nl> - cast back to its original type after clipping . <nl> - <nl> # # # # # Args : <nl> <nl> <nl> * < b > ` images ` < / b > : Images to adjust . At least 3 - D . <nl> * < b > ` contrast_factor ` < / b > : A float multiplier for adjusting contrast . <nl> - * < b > ` min_value ` < / b > : Minimum value for clipping the adjusted pixels . <nl> - * < b > ` max_value ` < / b > : Maximum value for clipping the adjusted pixels . <nl> <nl> # # # # # Returns : <nl> <nl> The constrast - adjusted image or images . <nl> <nl> - # # # # # Raises : <nl> - <nl> - <nl> - * < b > ` ValueError ` < / b > : if the arguments are invalid . <nl> - <nl> <nl> - - - <nl> <nl> picked in the interval ` [ lower , upper ] ` . <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` image ` < / b > : 3 - D tensor of shape ` [ height , width , channels ] ` . <nl> + * < b > ` image ` < / b > : An image tensor with 3 or more dimensions . <nl> * < b > ` lower ` < / b > : float . Lower bound for the random contrast factor . <nl> * < b > ` upper ` < / b > : float . Upper bound for the random contrast factor . <nl> * < b > ` seed ` < / b > : A Python integer . Used to create a random seed . See <nl> picked in the interval ` [ lower , upper ] ` . <nl> <nl> # # # # # Returns : <nl> <nl> - 3 - D tensor of shape ` [ height , width , channels ] ` . <nl> + The contrast - adjusted tensor . <nl> <nl> # # # # # Raises : <nl> <nl> Note that this implementation is limited : <nl> * < b > ` ValueError ` < / b > : if the shape of ' image ' is incompatible with this function . <nl> <nl> <nl> + <nl> + # # Other Functions and Classes <nl> + - - - <nl> + <nl> + # # # ` tf . image . saturate_cast ( image , dtype ) ` { # saturate_cast } <nl> + <nl> + Performs a safe cast of image data to ` dtype ` . <nl> + <nl> + This function casts the data in image to ` dtype ` , without applying any <nl> + scaling . If there is a danger that image data would over or underflow in the <nl> + cast , this op applies the appropriate clamping before the cast . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` image ` < / b > : An image to cast to a different data type . <nl> + * < b > ` dtype ` < / b > : A ` DType ` to cast ` image ` to . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + ` image ` , safely cast to ` dtype ` . <nl> + <nl> + <nl> mmm a / tensorflow / g3doc / api_docs / python / index . md <nl> ppp b / tensorflow / g3doc / api_docs / python / index . md <nl> <nl> * [ ` resize_nearest_neighbor ` ] ( . . / . . / api_docs / python / image . md # resize_nearest_neighbor ) <nl> * [ ` rgb_to_grayscale ` ] ( . . / . . / api_docs / python / image . md # rgb_to_grayscale ) <nl> * [ ` rgb_to_hsv ` ] ( . . / . . / api_docs / python / image . md # rgb_to_hsv ) <nl> + * [ ` saturate_cast ` ] ( . . / . . / api_docs / python / image . md # saturate_cast ) <nl> * [ ` transpose_image ` ] ( . . / . . / api_docs / python / image . md # transpose_image ) <nl> <nl> * * * [ Sparse Tensors ] ( . . / . . / api_docs / python / sparse_ops . md ) * * : <nl> mmm a / tensorflow / g3doc / api_docs / python / train . md <nl> ppp b / tensorflow / g3doc / api_docs / python / train . md <nl> depending on whether or not a ` Coordinator ` was passed to <nl> was captured . ( No exceptions are captured when using a Coordinator . ) <nl> <nl> <nl> + - - - <nl> + <nl> + # # # # ` tf . train . QueueRunner . name ` { # QueueRunner . name } <nl> + <nl> + The string name of the underlying Queue . <nl> + <nl> + <nl> <nl> - - - <nl> <nl>
|
Update generated Op docs .
|
tensorflow/tensorflow
|
b0e20ead254abb47285f27e0cd35195a612fbc0d
|
2015-12-15T22:47:28Z
|
mmm a / examples / BUILD <nl> ppp b / examples / BUILD <nl> licenses ( [ " notice " ] ) # 3 - clause BSD <nl> <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> + load ( " @ grpc_python_dependencies / / : requirements . bzl " , " requirement " ) <nl> load ( " / / bazel : grpc_build_system . bzl " , " grpc_proto_library " ) <nl> + load ( " @ org_pubref_rules_protobuf / / python : rules . bzl " , " py_proto_library " ) <nl> <nl> grpc_proto_library ( <nl> name = " auth_sample " , <nl> grpc_proto_library ( <nl> srcs = [ " protos / keyvaluestore . proto " ] , <nl> ) <nl> <nl> + py_proto_library ( <nl> + name = " py_helloworld " , <nl> + protos = [ " protos / helloworld . proto " ] , <nl> + with_grpc = True , <nl> + deps = [ requirement ( ' protobuf ' ) , ] , <nl> + ) <nl> + <nl> cc_binary ( <nl> name = " greeter_client " , <nl> srcs = [ " cpp / helloworld / greeter_client . cc " ] , <nl> new file mode 100644 <nl> index 00000000000 . . b07dd12ebd3 <nl> mmm / dev / null <nl> ppp b / examples / python / errors / BUILD . bazel <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + load ( " @ grpc_python_dependencies / / : requirements . bzl " , " requirement " ) <nl> + <nl> + py_library ( <nl> + name = " client " , <nl> + testonly = 1 , <nl> + srcs = [ " client . py " ] , <nl> + deps = [ <nl> + " / / src / python / grpcio / grpc : grpcio " , <nl> + " / / src / python / grpcio_status / grpc_status : grpc_status " , <nl> + " / / examples : py_helloworld " , <nl> + requirement ( ' googleapis - common - protos ' ) , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " server " , <nl> + testonly = 1 , <nl> + srcs = [ " server . py " ] , <nl> + deps = [ <nl> + " / / src / python / grpcio / grpc : grpcio " , <nl> + " / / src / python / grpcio_status / grpc_status : grpc_status " , <nl> + " / / examples : py_helloworld " , <nl> + ] + select ( { <nl> + " / / conditions : default " : [ requirement ( " futures " ) ] , <nl> + " / / : python3 " : [ ] , <nl> + } ) , <nl> + ) <nl> + <nl> + py_test ( <nl> + name = " test / _error_handling_example_test " , <nl> + srcs = [ " test / _error_handling_example_test . py " ] , <nl> + deps = [ <nl> + " : client " , <nl> + " : server " , <nl> + " / / src / python / grpcio_tests / tests : bazel_namespace_package_hack " , <nl> + ] , <nl> + size = " small " , <nl> + imports = [ <nl> + " . . / . . / . . / src / python / grpcio_status " , <nl> + " . . / . . / . . / src / python / grpcio_tests " , <nl> + ] , <nl> + ) <nl> new file mode 100644 <nl> index 00000000000 . . 2cfc26a93b0 <nl> mmm / dev / null <nl> ppp b / examples / python / errors / README . md <nl> <nl> + # gRPC Python Error Handling Example <nl> + <nl> + The goal of this example is sending error status from server that is more complicated than a code and detail string . <nl> + <nl> + The definition for an RPC method in proto files contains request message and response message . There are many error states that can be shared across RPC methods ( e . g . stack trace , insufficient quota ) . Using a different path to handle error will make the code more maintainable . <nl> + <nl> + Ideally , the final status of an RPC should be described in the trailing headers of HTTP2 , and gRPC Python provides helper functions in ` grpcio - status ` package to assist the packing and unpacking of error status . <nl> + <nl> + <nl> + # # # Requirement <nl> + ` ` ` <nl> + grpcio > = 1 . 18 . 0 <nl> + grpcio - status > = 1 . 18 . 0 <nl> + googleapis - common - protos > = 1 . 5 . 5 <nl> + ` ` ` <nl> + <nl> + <nl> + # # # Error Detail Proto <nl> + <nl> + You may provide any custom proto message as error detail in your implementation . Here are protos are defined by Google Cloud Library Team : <nl> + <nl> + * [ code . proto ] ( [ https : / / github . com / googleapis / api - common - protos / blob / master / google / rpc / code . proto ] ( https : / / github . com / googleapis / api - common - protos / blob / 87185dfffad4afa5a33a8c153f0e1ea53b4f85dc / google / rpc / code . proto ) ) contains definition of RPC error codes . <nl> + * [ error_details . proto ] ( [ https : / / github . com / googleapis / api - common - protos / blob / master / google / rpc / error_details . proto ] ( https : / / github . com / googleapis / api - common - protos / blob / 87185dfffad4afa5a33a8c153f0e1ea53b4f85dc / google / rpc / error_details . proto ) ) contains definitions of common error details . <nl> + <nl> + <nl> + # # # Definition of Status Proto <nl> + <nl> + Here is the definition of Status proto . For full text , please see [ status . proto ] ( https : / / github . com / googleapis / api - common - protos / blob / 87185dfffad4afa5a33a8c153f0e1ea53b4f85dc / google / rpc / status . proto ) . <nl> + <nl> + ` ` ` proto <nl> + / / The ` Status ` type defines a logical error model that is suitable for different <nl> + / / programming environments , including REST APIs and RPC APIs . It is used by <nl> + / / [ gRPC ] ( https : / / github . com / grpc ) . The error model is designed to be : <nl> + / / <nl> + / / - Simple to use and understand for most users <nl> + / / - Flexible enough to meet unexpected needs <nl> + / / <nl> + / / # Overview <nl> + / / <nl> + / / The ` Status ` message contains three pieces of data : error code , error message , <nl> + / / and error details . The error code should be an enum value of <nl> + / / [ google . rpc . Code ] [ google . rpc . Code ] , but it may accept additional error codes if needed . The <nl> + / / error message should be a developer - facing English message that helps <nl> + / / developers * understand * and * resolve * the error . If a localized user - facing <nl> + / / error message is needed , put the localized message in the error details or <nl> + / / localize it in the client . The optional error details may contain arbitrary <nl> + / / information about the error . There is a predefined set of error detail types <nl> + / / in the package ` google . rpc ` that can be used for common error conditions . <nl> + / / <nl> + / / # Language mapping <nl> + / / <nl> + / / The ` Status ` message is the logical representation of the error model , but it <nl> + / / is not necessarily the actual wire format . When the ` Status ` message is <nl> + / / exposed in different client libraries and different wire protocols , it can be <nl> + / / mapped differently . For example , it will likely be mapped to some exceptions <nl> + / / in Java , but more likely mapped to some error codes in C . <nl> + / / <nl> + / / # Other uses <nl> + / / <nl> + / / The error model and the ` Status ` message can be used in a variety of <nl> + / / environments , either with or without APIs , to provide a <nl> + / / consistent developer experience across different environments . <nl> + / / <nl> + / / Example uses of this error model include : <nl> + / / <nl> + / / - Partial errors . If a service needs to return partial errors to the client , <nl> + / / it may embed the ` Status ` in the normal response to indicate the partial <nl> + / / errors . <nl> + / / <nl> + / / - Workflow errors . A typical workflow has multiple steps . Each step may <nl> + / / have a ` Status ` message for error reporting . <nl> + / / <nl> + / / - Batch operations . If a client uses batch request and batch response , the <nl> + / / ` Status ` message should be used directly inside batch response , one for <nl> + / / each error sub - response . <nl> + / / <nl> + / / - Asynchronous operations . If an API call embeds asynchronous operation <nl> + / / results in its response , the status of those operations should be <nl> + / / represented directly using the ` Status ` message . <nl> + / / <nl> + / / - Logging . If some API errors are stored in logs , the message ` Status ` could <nl> + / / be used directly after any stripping needed for security / privacy reasons . <nl> + message Status { <nl> + / / The status code , which should be an enum value of [ google . rpc . Code ] [ google . rpc . Code ] . <nl> + int32 code = 1 ; <nl> + <nl> + / / A developer - facing error message , which should be in English . Any <nl> + / / user - facing error message should be localized and sent in the <nl> + / / [ google . rpc . Status . details ] [ google . rpc . Status . details ] field , or localized by the client . <nl> + string message = 2 ; <nl> + <nl> + / / A list of messages that carry the error details . There is a common set of <nl> + / / message types for APIs to use . <nl> + repeated google . protobuf . Any details = 3 ; <nl> + } <nl> + ` ` ` <nl> + <nl> + <nl> + # # # Usage of Well - Known - Proto ` Any ` <nl> + <nl> + Please check [ ProtoBuf Document : Any ] ( https : / / developers . google . com / protocol - buffers / docs / reference / python - generated # any ) <nl> + <nl> + ` ` ` Python <nl> + any_message . Pack ( message ) <nl> + any_message . Unpack ( message ) <nl> + assert any_message . Is ( message . DESCRIPTOR ) <nl> + ` ` ` <nl> new file mode 100644 <nl> index 00000000000 . . a79b8fce1bd <nl> mmm / dev / null <nl> ppp b / examples / python / errors / client . py <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + " " " This example handles rich error status in client - side . " " " <nl> + <nl> + from __future__ import print_function <nl> + import logging <nl> + <nl> + import grpc <nl> + from grpc_status import rpc_status <nl> + from google . rpc import error_details_pb2 <nl> + <nl> + from examples . protos import helloworld_pb2 <nl> + from examples . protos import helloworld_pb2_grpc <nl> + <nl> + _LOGGER = logging . getLogger ( __name__ ) <nl> + <nl> + <nl> + def process ( stub ) : <nl> + try : <nl> + response = stub . SayHello ( helloworld_pb2 . HelloRequest ( name = ' Alice ' ) ) <nl> + _LOGGER . info ( ' Call success : % s ' , response . message ) <nl> + except grpc . RpcError as rpc_error : <nl> + _LOGGER . error ( ' Call failure : % s ' , rpc_error ) <nl> + status = rpc_status . from_call ( rpc_error ) <nl> + for detail in status . details : <nl> + if detail . Is ( error_details_pb2 . QuotaFailure . DESCRIPTOR ) : <nl> + info = error_details_pb2 . QuotaFailure ( ) <nl> + detail . Unpack ( info ) <nl> + _LOGGER . error ( ' Quota failure : % s ' , info ) <nl> + else : <nl> + raise RuntimeError ( ' Unexpected failure : % s ' % detail ) <nl> + <nl> + <nl> + def main ( ) : <nl> + # NOTE ( gRPC Python Team ) : . close ( ) is possible on a channel and should be <nl> + # used in circumstances in which the with statement does not fit the needs <nl> + # of the code . <nl> + with grpc . insecure_channel ( ' localhost : 50051 ' ) as channel : <nl> + stub = helloworld_pb2_grpc . GreeterStub ( channel ) <nl> + process ( stub ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + logging . basicConfig ( ) <nl> + main ( ) <nl> new file mode 100644 <nl> index 00000000000 . . f49586b848a <nl> mmm / dev / null <nl> ppp b / examples / python / errors / server . py <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + " " " This example sends out rich error status from server - side . " " " <nl> + <nl> + from concurrent import futures <nl> + import time <nl> + import logging <nl> + import threading <nl> + <nl> + import grpc <nl> + from grpc_status import rpc_status <nl> + <nl> + from google . protobuf import any_pb2 <nl> + from google . rpc import code_pb2 , status_pb2 , error_details_pb2 <nl> + <nl> + from examples . protos import helloworld_pb2 <nl> + from examples . protos import helloworld_pb2_grpc <nl> + <nl> + _ONE_DAY_IN_SECONDS = 60 * 60 * 24 <nl> + <nl> + <nl> + def create_greet_limit_exceed_error_status ( name ) : <nl> + detail = any_pb2 . Any ( ) <nl> + detail . Pack ( <nl> + error_details_pb2 . QuotaFailure ( <nl> + violations = [ <nl> + error_details_pb2 . QuotaFailure . Violation ( <nl> + subject = " name : % s " % name , <nl> + description = " Limit one greeting per person " , <nl> + ) <nl> + ] , ) ) <nl> + return status_pb2 . Status ( <nl> + code = code_pb2 . RESOURCE_EXHAUSTED , <nl> + message = ' Request limit exceeded . ' , <nl> + details = [ detail ] , <nl> + ) <nl> + <nl> + <nl> + class LimitedGreeter ( helloworld_pb2_grpc . GreeterServicer ) : <nl> + <nl> + def __init__ ( self ) : <nl> + self . _lock = threading . RLock ( ) <nl> + self . _greeted = set ( ) <nl> + <nl> + def SayHello ( self , request , context ) : <nl> + with self . _lock : <nl> + if request . name in self . _greeted : <nl> + rich_status = create_greet_limit_exceed_error_status ( <nl> + request . name ) <nl> + context . abort_with_status ( rpc_status . to_status ( rich_status ) ) <nl> + else : <nl> + self . _greeted . add ( request . name ) <nl> + return helloworld_pb2 . HelloReply ( message = ' Hello , % s ! ' % request . name ) <nl> + <nl> + <nl> + def create_server ( server_address ) : <nl> + server = grpc . server ( futures . ThreadPoolExecutor ( ) ) <nl> + helloworld_pb2_grpc . add_GreeterServicer_to_server ( LimitedGreeter ( ) , server ) <nl> + port = server . add_insecure_port ( server_address ) <nl> + return server , port <nl> + <nl> + <nl> + def serve ( server ) : <nl> + server . start ( ) <nl> + try : <nl> + while True : <nl> + time . sleep ( _ONE_DAY_IN_SECONDS ) <nl> + except KeyboardInterrupt : <nl> + server . stop ( None ) <nl> + <nl> + <nl> + def main ( ) : <nl> + server , unused_port = create_server ( ' [ : : ] : 50051 ' ) <nl> + serve ( server ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + logging . basicConfig ( ) <nl> + main ( ) <nl> new file mode 100644 <nl> index 00000000000 . . a79ca45e2a1 <nl> mmm / dev / null <nl> ppp b / examples / python / errors / test / _error_handling_example_test . py <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + " " " Tests of the error handling example . " " " <nl> + <nl> + # NOTE ( lidiz ) This module only exists in Bazel BUILD file , for more details <nl> + # please refer to comments in the " bazel_namespace_package_hack " module . <nl> + try : <nl> + from tests import bazel_namespace_package_hack <nl> + bazel_namespace_package_hack . sys_path_to_site_dir_hack ( ) <nl> + except ImportError : <nl> + pass <nl> + <nl> + import unittest <nl> + import logging <nl> + <nl> + import grpc <nl> + <nl> + from examples . protos import helloworld_pb2_grpc <nl> + from examples . python . errors import client as error_handling_client <nl> + from examples . python . errors import server as error_handling_server <nl> + <nl> + <nl> + class ErrorHandlingExampleTest ( unittest . TestCase ) : <nl> + <nl> + def setUp ( self ) : <nl> + self . _server , port = error_handling_server . create_server ( ' [ : : ] : 0 ' ) <nl> + self . _server . start ( ) <nl> + self . _channel = grpc . insecure_channel ( ' localhost : % d ' % port ) <nl> + <nl> + def tearDown ( self ) : <nl> + self . _channel . close ( ) <nl> + self . _server . stop ( None ) <nl> + <nl> + def test_error_handling_example ( self ) : <nl> + stub = helloworld_pb2_grpc . GreeterStub ( self . _channel ) <nl> + error_handling_client . process ( stub ) <nl> + error_handling_client . process ( stub ) <nl> + # No unhandled exception raised , test passed ! <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + logging . basicConfig ( ) <nl> + unittest . main ( verbosity = 2 ) <nl> mmm a / src / python / grpcio_tests / tests / BUILD . bazel <nl> ppp b / src / python / grpcio_tests / tests / BUILD . bazel <nl> py_library ( <nl> visibility = [ <nl> " / / src / python / grpcio_tests / tests / status : __subpackages__ " , <nl> " / / src / python / grpcio_tests / tests / interop : __subpackages__ " , <nl> + " / / examples / python / errors : __subpackages__ " , <nl> ] , <nl> ) <nl>
|
Merge pull request from lidizheng / example - errors
|
grpc/grpc
|
56605cd55df7280b3766d6ed1b8e8af86e6ff7ff
|
2019-03-28T21:47:30Z
|
mmm a / doc / manual - src / en / index . rst <nl> ppp b / doc / manual - src / en / index . rst <nl> Aria2 Manual <nl> Contents : <nl> <nl> . . toctree : : <nl> - : maxdepth : 3 <nl> + : maxdepth : 2 <nl> <nl> - README <nl> aria2c <nl> + README <nl>
|
Exchanged README and aria2c page in toctree .
|
aria2/aria2
|
9ce6a831c3f9393e5888d28299dfff59d4622865
|
2012-07-06T15:46:03Z
|
mmm a / src / hashmap . cc <nl> ppp b / src / hashmap . cc <nl> HashMap : : ~ HashMap ( ) { <nl> HashMap : : Entry * HashMap : : Lookup ( void * key , uint32_t hash , bool insert ) { <nl> / / Find a matching entry . <nl> Entry * p = Probe ( key , hash ) ; <nl> - if ( p - > key ! = NULL ) { <nl> + if ( p - > key ! = NULL ) { <nl> return p ; <nl> } <nl> <nl> HashMap : : Entry * HashMap : : Lookup ( void * key , uint32_t hash , bool insert ) { <nl> } <nl> <nl> <nl> + void HashMap : : Remove ( void * key , uint32_t hash ) { <nl> + / / Lookup the entry for the key to remove . <nl> + Entry * p = Probe ( key , hash ) ; <nl> + if ( p - > key = = NULL ) { <nl> + / / Key not found nothing to remove . <nl> + return ; <nl> + } <nl> + <nl> + / / To remove the entry we need to ensure that it does not create an empty <nl> + / / entry that will cause search for an entry to stop to soon . If all the <nl> + / / entries between the entry to remove and the next empty slot have their <nl> + / / initial position inside this interval clearing the entry to remove will not <nl> + / / break the search . If while searching for the next empty entry an entry is <nl> + / / encountered which does not have its initial position between the entry to <nl> + / / remove and the position looked at this entry can be moved to the place of <nl> + / / the entry to remove without breaking the search for it and the new entry to <nl> + / / remove will be its previous position . <nl> + / / Algorithm from http : / / en . wikipedia . org / wiki / Open_addressing . <nl> + <nl> + / / This guarantees loop termination as there is at least one empty entry so <nl> + / / eventually the removed entyr will have an empty entry after it . <nl> + ASSERT ( occupancy_ < capacity_ ) ; <nl> + <nl> + / / p is the candidate entry to clear . q is used to scan forwards . <nl> + Entry * q = p ; / / Start at the entry to remove . <nl> + while ( true ) { <nl> + / / Move q to the next entry . <nl> + q = q + 1 ; <nl> + if ( q = = map_end ( ) ) { <nl> + q = map_ ; <nl> + } <nl> + <nl> + / / All entries between p and q have their initial position between p and q <nl> + / / and the entry p can be cleared without breaking the search for these <nl> + / / entries . <nl> + if ( q - > key = = NULL ) { <nl> + break ; <nl> + } <nl> + <nl> + / / Find the initial position for the entry at position q . <nl> + Entry * r = map_ + ( q - > hash & ( capacity_ - 1 ) ) ; <nl> + <nl> + / / If the entry at position q has its initial position outside the range <nl> + / / between p and q it can be moved forward to position p and will still be <nl> + / / found . There is now a new candidate entry for clearing . <nl> + if ( q > p & & ( r < = p | | r > q ) | | <nl> + q < p & & ( r < = p & & r > q ) ) { <nl> + * p = * q ; <nl> + p = q ; <nl> + } <nl> + } <nl> + <nl> + / / Clear the entry which is allowed to en emptied . <nl> + p - > key = NULL ; <nl> + occupancy_ - - ; <nl> + } <nl> + <nl> + <nl> void HashMap : : Clear ( ) { <nl> / / Mark all entries as empty . <nl> const Entry * end = map_end ( ) ; <nl> HashMap : : Entry * HashMap : : Probe ( void * key , uint32_t hash ) { <nl> const Entry * end = map_end ( ) ; <nl> ASSERT ( map_ < = p & & p < end ) ; <nl> <nl> - ASSERT ( occupancy_ < capacity_ ) ; / / guarantees loop termination <nl> + ASSERT ( occupancy_ < capacity_ ) ; / / Guarantees loop termination . <nl> while ( p - > key ! = NULL & & ( hash ! = p - > hash | | ! match_ ( key , p - > key ) ) ) { <nl> p + + ; <nl> if ( p > = end ) { <nl> mmm a / src / hashmap . h <nl> ppp b / src / hashmap . h <nl> class HashMap { <nl> / / Otherwise , NULL is returned . <nl> Entry * Lookup ( void * key , uint32_t hash , bool insert ) ; <nl> <nl> + / / Removes the entry with matching key . <nl> + void Remove ( void * key , uint32_t hash ) ; <nl> + <nl> / / Empties the hash map ( occupancy ( ) = = 0 ) . <nl> void Clear ( ) ; <nl> <nl> mmm a / test / cctest / test - hashmap . cc <nl> ppp b / test / cctest / test - hashmap . cc <nl> static bool DefaultMatchFun ( void * a , void * b ) { <nl> } <nl> <nl> <nl> + typedef uint32_t ( * IntKeyHash ) ( uint32_t key ) ; <nl> + <nl> + <nl> class IntSet { <nl> public : <nl> - IntSet ( ) : map_ ( DefaultMatchFun ) { } <nl> + IntSet ( IntKeyHash hash ) : hash_ ( hash ) , map_ ( DefaultMatchFun ) { } <nl> <nl> void Insert ( int x ) { <nl> CHECK_NE ( 0 , x ) ; / / 0 corresponds to ( void * ) NULL - illegal key value <nl> - HashMap : : Entry * p = map_ . Lookup ( reinterpret_cast < void * > ( x ) , Hash ( x ) , true ) ; <nl> + HashMap : : Entry * p = map_ . Lookup ( reinterpret_cast < void * > ( x ) , hash_ ( x ) , true ) ; <nl> CHECK ( p ! = NULL ) ; / / insert is set ! <nl> CHECK_EQ ( reinterpret_cast < void * > ( x ) , p - > key ) ; <nl> / / we don ' t care about p - > value <nl> } <nl> <nl> + void Remove ( int x ) { <nl> + CHECK_NE ( 0 , x ) ; / / 0 corresponds to ( void * ) NULL - illegal key value <nl> + map_ . Remove ( reinterpret_cast < void * > ( x ) , hash_ ( x ) ) ; <nl> + } <nl> + <nl> bool Present ( int x ) { <nl> - HashMap : : Entry * p = map_ . Lookup ( reinterpret_cast < void * > ( x ) , Hash ( x ) , false ) ; <nl> + HashMap : : Entry * p = map_ . Lookup ( reinterpret_cast < void * > ( x ) , hash_ ( x ) , false ) ; <nl> if ( p ! = NULL ) { <nl> CHECK_EQ ( reinterpret_cast < void * > ( x ) , p - > key ) ; <nl> } <nl> class IntSet { <nl> <nl> private : <nl> HashMap map_ ; <nl> - static uint32_t Hash ( uint32_t key ) { return key * 23 ; } <nl> + IntKeyHash hash_ ; <nl> } ; <nl> <nl> <nl> - TEST ( Set ) { <nl> - IntSet set ; <nl> + static uint32_t Hash ( uint32_t key ) { return 23 ; } <nl> + static uint32_t CollisionHash ( uint32_t key ) { return key & 0x3 ; } <nl> + <nl> + <nl> + void TestSet ( IntKeyHash hash , int size ) { <nl> + IntSet set ( hash ) ; <nl> CHECK_EQ ( 0 , set . occupancy ( ) ) ; <nl> <nl> set . Insert ( 1 ) ; <nl> TEST ( Set ) { <nl> CHECK ( ! set . Present ( 4 ) ) ; <nl> CHECK_EQ ( 3 , set . occupancy ( ) ) ; <nl> <nl> + set . Remove ( 1 ) ; <nl> + CHECK ( ! set . Present ( 1 ) ) ; <nl> + CHECK ( set . Present ( 2 ) ) ; <nl> + CHECK ( set . Present ( 3 ) ) ; <nl> + CHECK_EQ ( 2 , set . occupancy ( ) ) ; <nl> + <nl> + set . Remove ( 3 ) ; <nl> + CHECK ( ! set . Present ( 1 ) ) ; <nl> + CHECK ( set . Present ( 2 ) ) ; <nl> + CHECK ( ! set . Present ( 3 ) ) ; <nl> + CHECK_EQ ( 1 , set . occupancy ( ) ) ; <nl> + <nl> set . Clear ( ) ; <nl> CHECK_EQ ( 0 , set . occupancy ( ) ) ; <nl> <nl> TEST ( Set ) { <nl> const int start = 453 ; <nl> const int factor = 13 ; <nl> const int offset = 7 ; <nl> - const uint32_t n = 1000 ; <nl> + const uint32_t n = size ; <nl> <nl> int x = start ; <nl> for ( uint32_t i = 0 ; i < n ; i + + ) { <nl> CHECK_EQ ( i , static_cast < double > ( set . occupancy ( ) ) ) ; <nl> set . Insert ( x ) ; <nl> - x = x * factor + offset ; <nl> + x = x * factor + offset ; <nl> } <nl> + CHECK_EQ ( n , static_cast < double > ( set . occupancy ( ) ) ) ; <nl> <nl> / / Verify the same sequence of values . <nl> x = start ; <nl> for ( uint32_t i = 0 ; i < n ; i + + ) { <nl> CHECK ( set . Present ( x ) ) ; <nl> - x = x * factor + offset ; <nl> + x = x * factor + offset ; <nl> } <nl> - <nl> CHECK_EQ ( n , static_cast < double > ( set . occupancy ( ) ) ) ; <nl> + <nl> + / / Remove all these values . <nl> + x = start ; <nl> + for ( uint32_t i = 0 ; i < n ; i + + ) { <nl> + CHECK_EQ ( n - i , static_cast < double > ( set . occupancy ( ) ) ) ; <nl> + CHECK ( set . Present ( x ) ) ; <nl> + set . Remove ( x ) ; <nl> + CHECK ( ! set . Present ( x ) ) ; <nl> + x = x * factor + offset ; <nl> + <nl> + / / Verify the the expected values are still there . <nl> + int y = start ; <nl> + for ( uint32_t j = 0 ; j < n ; j + + ) { <nl> + if ( j < = i ) { <nl> + CHECK ( ! set . Present ( y ) ) ; <nl> + } else { <nl> + CHECK ( set . Present ( y ) ) ; <nl> + } <nl> + y = y * factor + offset ; <nl> + } <nl> + <nl> + } <nl> + CHECK_EQ ( 0 , set . occupancy ( ) ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( Set ) { <nl> + TestSet ( Hash , 1000 ) ; <nl> + TestSet ( CollisionHash , 100 ) ; <nl> } <nl>
|
Add a remove method to the hash map .
|
v8/v8
|
77b9c60169ba92ff0941959ebf5ea513d13ccb67
|
2009-05-15T07:09:17Z
|
mmm a / lib / Sema / TypeCheckConstraintsDiag . cpp <nl> ppp b / lib / Sema / TypeCheckConstraintsDiag . cpp <nl> static ConstraintLocator * simplifyLocator ( ConstraintSystem & cs , <nl> return cs . getConstraintLocator ( anchor , path ) ; <nl> } <nl> <nl> + / / / \ brief Emit a diagnostic for the given failure . <nl> + / / / <nl> + / / / \ param cs The constraint system in which the diagnostic was generated . <nl> + / / / \ param failure The failure to emit . <nl> + / / / <nl> + / / / \ returns true if the diagnostic was emitted successfully . <nl> + static bool diagnoseFailure ( ConstraintSystem & cs , Failure & failure ) { <nl> + / / If there ' s no anchor , we have no location information to use when emitting <nl> + / / the diagnostic . <nl> + if ( ! failure . getLocator ( ) | | ! failure . getLocator ( ) - > getAnchor ( ) ) <nl> + return false ; <nl> + <nl> + SourceRange range1 , range2 ; <nl> + <nl> + auto locator = simplifyLocator ( cs , failure . getLocator ( ) , range1 , range2 ) ; <nl> + auto & tc = cs . getTypeChecker ( ) ; <nl> + <nl> + auto anchor = locator - > getAnchor ( ) ; <nl> + auto loc = anchor - > getLoc ( ) ; <nl> + switch ( failure . getKind ( ) ) { <nl> + case Failure : : TupleSizeMismatch : { <nl> + auto tuple1 = failure . getFirstType ( ) - > castTo < TupleType > ( ) ; <nl> + auto tuple2 = failure . getSecondType ( ) - > castTo < TupleType > ( ) ; <nl> + tc . diagnose ( loc , diag : : invalid_tuple_size , tuple1 , tuple2 , <nl> + tuple1 - > getFields ( ) . size ( ) , <nl> + tuple2 - > getFields ( ) . size ( ) ) <nl> + . highlight ( range1 ) . highlight ( range2 ) ; <nl> + break ; <nl> + } <nl> + <nl> + case Failure : : TupleUnused : <nl> + tc . diagnose ( loc , diag : : invalid_tuple_element_unused , <nl> + failure . getFirstType ( ) , <nl> + failure . getSecondType ( ) ) <nl> + . highlight ( range1 ) . highlight ( range2 ) ; <nl> + break ; <nl> + <nl> + case Failure : : TypesNotEqual : <nl> + case Failure : : TypesNotTrivialSubtypes : <nl> + case Failure : : TypesNotSubtypes : <nl> + case Failure : : TypesNotConvertible : <nl> + case Failure : : TypesNotConstructible : <nl> + tc . diagnose ( loc , diag : : invalid_relation , <nl> + failure . getKind ( ) - Failure : : TypesNotEqual , <nl> + failure . getFirstType ( ) , <nl> + failure . getSecondType ( ) ) <nl> + . highlight ( range1 ) . highlight ( range2 ) ; <nl> + break ; <nl> + <nl> + case Failure : : DoesNotHaveMember : <nl> + tc . diagnose ( loc , diag : : does_not_have_member , <nl> + failure . getFirstType ( ) , <nl> + failure . getName ( ) ) <nl> + . highlight ( range1 ) . highlight ( range2 ) ; <nl> + break ; <nl> + <nl> + case Failure : : DoesNotConformToProtocol : <nl> + tc . diagnose ( loc , diag : : type_does_not_conform , <nl> + failure . getFirstType ( ) , <nl> + failure . getSecondType ( ) ) <nl> + . highlight ( range1 ) . highlight ( range2 ) ; <nl> + break ; <nl> + <nl> + default : <nl> + / / FIXME : Handle all failure kinds <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> bool ConstraintSystem : : diagnose ( ) { <nl> - / / If there were no unavoidable failures , attempt to solve again , capturing <nl> + / / If there were any unavoidable failures , emit the first one we can . <nl> + if ( ! unavoidableFailures . empty ( ) ) { <nl> + for ( auto failure : unavoidableFailures ) { <nl> + if ( diagnoseFailure ( * this , * failure ) ) <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / There were no unavoidable failures , so attempt to solve again , capturing <nl> / / any failures that come from our attempts to select overloads or bind <nl> / / type variables . <nl> - if ( unavoidableFailures . empty ( ) ) { <nl> + { <nl> SmallVector < Solution , 4 > solutions ; <nl> <nl> / / Set up solver state . <nl> bool ConstraintSystem : : diagnose ( ) { <nl> / / Fall through to produce diagnostics . <nl> } <nl> <nl> - if ( unavoidableFailures . size ( ) + failures . size ( ) = = 1 ) { <nl> + if ( failures . size ( ) = = 1 ) { <nl> auto & failure = unavoidableFailures . empty ( ) ? * failures . begin ( ) <nl> : * * unavoidableFailures . begin ( ) ; <nl> - if ( failure . getLocator ( ) & & failure . getLocator ( ) - > getAnchor ( ) ) { <nl> - SourceRange range1 , range2 ; <nl> - <nl> - auto locator = simplifyLocator ( * this , failure . getLocator ( ) , range1 , <nl> - range2 ) ; <nl> - auto & tc = getTypeChecker ( ) ; <nl> - <nl> - auto anchor = locator - > getAnchor ( ) ; <nl> - auto loc = anchor - > getLoc ( ) ; <nl> - switch ( failure . getKind ( ) ) { <nl> - case Failure : : TupleSizeMismatch : { <nl> - auto tuple1 = failure . getFirstType ( ) - > castTo < TupleType > ( ) ; <nl> - auto tuple2 = failure . getSecondType ( ) - > castTo < TupleType > ( ) ; <nl> - tc . diagnose ( loc , diag : : invalid_tuple_size , tuple1 , tuple2 , <nl> - tuple1 - > getFields ( ) . size ( ) , <nl> - tuple2 - > getFields ( ) . size ( ) ) <nl> - . highlight ( range1 ) . highlight ( range2 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case Failure : : TupleUnused : <nl> - tc . diagnose ( loc , diag : : invalid_tuple_element_unused , <nl> - failure . getFirstType ( ) , <nl> - failure . getSecondType ( ) ) <nl> - . highlight ( range1 ) . highlight ( range2 ) ; <nl> - break ; <nl> - <nl> - case Failure : : TypesNotEqual : <nl> - case Failure : : TypesNotTrivialSubtypes : <nl> - case Failure : : TypesNotSubtypes : <nl> - case Failure : : TypesNotConvertible : <nl> - case Failure : : TypesNotConstructible : <nl> - tc . diagnose ( loc , diag : : invalid_relation , <nl> - failure . getKind ( ) - Failure : : TypesNotEqual , <nl> - failure . getFirstType ( ) , <nl> - failure . getSecondType ( ) ) <nl> - . highlight ( range1 ) . highlight ( range2 ) ; <nl> - break ; <nl> - <nl> - case Failure : : DoesNotHaveMember : <nl> - tc . diagnose ( loc , diag : : does_not_have_member , <nl> - failure . getFirstType ( ) , <nl> - failure . getName ( ) ) <nl> - . highlight ( range1 ) . highlight ( range2 ) ; <nl> - break ; <nl> - <nl> - case Failure : : DoesNotConformToProtocol : <nl> - tc . diagnose ( loc , diag : : type_does_not_conform , <nl> - failure . getFirstType ( ) , <nl> - failure . getSecondType ( ) ) <nl> - . highlight ( range1 ) . highlight ( range2 ) ; <nl> - break ; <nl> - <nl> - default : <nl> - / / FIXME : Handle all failure kinds <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> + return diagnoseFailure ( * this , failure ) ; <nl> } <nl> <nl> return false ; <nl>
|
If we have any " unavoidable " failures , diagnose them immediately .
|
apple/swift
|
dda2647559316497375ec34cea0bf926c160db16
|
2013-06-06T17:33:10Z
|
mmm a / jstests / core / collation_shell_helpers . js <nl> ppp b / jstests / core / collation_shell_helpers . js <nl> <nl> - / / Ensure that shell helpers correctly deliver the collation to the server . <nl> - / / <nl> - / / TODO SERVER - 23791 : Once we have an end - to - end working on mongod , we should be able to strengthen <nl> - / / the assertions in this file in order to ensure that the server is correctly respecting the <nl> - / / assertion . Currently we exercise the code paths in the shell that are supposed to propagate the <nl> - / / collation to the server , but we don ' t require that the result of executing the command respects <nl> - / / the collation . <nl> + / / Integration tests for the collation feature . <nl> ( function ( ) { <nl> ' use strict ' ; <nl> <nl> + load ( " jstests / libs / analyze_plan . js " ) ; <nl> + <nl> var coll = db . collation_shell_helpers ; <nl> coll . drop ( ) ; <nl> <nl> + var explainRes ; <nl> + var planStage ; <nl> + <nl> var assertIndexHasCollation = function ( keyPattern , collation ) { <nl> var foundIndex = false ; <nl> var indexSpecs = coll . getIndexes ( ) ; <nl> <nl> assert . commandWorked ( coll . createIndexes ( [ { e : 1 } ] , { collation : { locale : " simple " } } ) ) ; <nl> assertIndexHasCollation ( { e : 1 } , { locale : " simple " } ) ; <nl> <nl> - / / TODO SERVER - 23791 : Test that queries with matching collations can use these indices , and that <nl> - / / the indices contain collator - generated comparison keys rather than the verbatim indexed <nl> - / / strings . <nl> + / / Test that an index with a non - simple collation contains collator - generated comparison keys <nl> + / / rather than the verbatim indexed strings . <nl> + if ( db . getMongo ( ) . useReadCommands ( ) ) { <nl> + coll . drop ( ) ; <nl> + assert . commandWorked ( coll . createIndex ( { a : 1 } , { collation : { locale : " fr_CA " } } ) ) ; <nl> + assert . commandWorked ( coll . createIndex ( { b : 1 } ) ) ; <nl> + assert . writeOK ( coll . insert ( { a : " foo " , b : " foo " } ) ) ; <nl> + assert . eq ( <nl> + 1 , coll . find ( { } , { _id : 0 , a : 1 } ) . collation ( { locale : " fr_CA " } ) . hint ( { a : 1 } ) . itcount ( ) ) ; <nl> + assert . neq ( <nl> + " foo " , <nl> + coll . find ( { } , { _id : 0 , a : 1 } ) . collation ( { locale : " fr_CA " } ) . hint ( { a : 1 } ) . next ( ) . a ) ; <nl> + assert . eq ( <nl> + 1 , coll . find ( { } , { _id : 0 , b : 1 } ) . collation ( { locale : " fr_CA " } ) . hint ( { b : 1 } ) . itcount ( ) ) ; <nl> + assert . eq ( " foo " , <nl> + coll . find ( { } , { _id : 0 , b : 1 } ) . collation ( { locale : " fr_CA " } ) . hint ( { b : 1 } ) . next ( ) . b ) ; <nl> + } <nl> + <nl> + / / Test that a query with a string comparison can use an index with a non - simple collation if it <nl> + / / has a matching collation . <nl> + if ( db . getMongo ( ) . useReadCommands ( ) ) { <nl> + coll . drop ( ) ; <nl> + assert . commandWorked ( coll . createIndex ( { a : 1 } , { collation : { locale : " fr_CA " } } ) ) ; <nl> + <nl> + / / Query has simple collation , but index has fr_CA collation . <nl> + explainRes = coll . find ( { a : " foo " } ) . explain ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + assert ( planHasStage ( explainRes . queryPlanner . winningPlan , " COLLSCAN " ) ) ; <nl> + <nl> + / / Query has en_US collation , but index has fr_CA collation . <nl> + explainRes = coll . find ( { a : " foo " } ) . collation ( { locale : " en_US " } ) . explain ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + assert ( planHasStage ( explainRes . queryPlanner . winningPlan , " COLLSCAN " ) ) ; <nl> + <nl> + / / Matching collations . <nl> + explainRes = coll . find ( { a : " foo " } ) . collation ( { locale : " fr_CA " } ) . explain ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + assert ( planHasStage ( explainRes . queryPlanner . winningPlan , " IXSCAN " ) ) ; <nl> + } <nl> <nl> / / <nl> / / Test helpers for operations that accept a collation . <nl> <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " bar " } ) ) ; <nl> <nl> / / Aggregation . <nl> - assert . eq ( 2 , coll . aggregate ( [ ] , { collation : { locale : " fr " } } ) . itcount ( ) ) ; <nl> + assert . eq ( 0 , coll . aggregate ( [ { $ match : { str : " FOO " } } ] ) . itcount ( ) ) ; <nl> + assert . eq ( 1 , <nl> + coll . aggregate ( [ { $ match : { str : " FOO " } } ] , { collation : { locale : " en_US " , strength : 2 } } ) <nl> + . itcount ( ) ) ; <nl> assert . commandWorked ( coll . explain ( ) . aggregate ( [ ] , { collation : { locale : " fr " } } ) ) ; <nl> <nl> / / Count command . <nl> <nl> assert . eq ( 0 , coll . count ( { str : " FOO " } ) ) ; <nl> assert . eq ( 0 , coll . count ( { str : " FOO " } , { collation : { locale : " en_US " } } ) ) ; <nl> assert . eq ( 1 , coll . count ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ) ; <nl> - assert . commandWorked ( coll . explain ( ) . find ( ) . collation ( { locale : " fr " } ) . count ( ) ) ; <nl> + <nl> + explainRes = <nl> + coll . explain ( " executionStats " ) . find ( { str : " FOO " } ) . collation ( { locale : " en_US " } ) . count ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " COLLSCAN " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 0 , planStage . advanced ) ; <nl> + <nl> + explainRes = coll . explain ( " executionStats " ) <nl> + . find ( { str : " FOO " } ) <nl> + . collation ( { locale : " en_US " , strength : 2 } ) <nl> + . count ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " COLLSCAN " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 1 , planStage . advanced ) ; <nl> <nl> / / Distinct . <nl> assert . eq ( [ " foo " , " bar " ] , coll . distinct ( " str " , { } , { collation : { locale : " fr " } } ) ) ; <nl> <nl> . itcount ( ) ) ; <nl> assert . commandWorked ( coll . dropIndexes ( ) ) ; <nl> <nl> - / / With a partial index . <nl> - / / { _id : 1 , str : " foo " } will be indexed even though " foo " > " FOO " , since the collation is <nl> - / / case - insensitive . <nl> + / / With a partial index . { _id : 1 , str : " foo " } will be indexed even though " foo " > " FOO " , <nl> + / / since the collation is case - insensitive . <nl> assert . commandWorked ( coll . ensureIndex ( { str : 1 } , { <nl> partialFilterExpression : { str : { $ lte : " FOO " } } , <nl> collation : { locale : " en_US " , strength : 2 } <nl> <nl> coll . find ( ) . collation ( { locale : " fr " } ) . itcount ( ) ; <nl> } ) ; <nl> } <nl> - / / Explain of find always uses the find command , so this will succeed regardless of readMode . <nl> - assert . commandWorked ( coll . explain ( ) . find ( ) . collation ( { locale : " fr " } ) . finish ( ) ) ; <nl> - assert . commandWorked ( coll . find ( ) . collation ( { locale : " fr " } ) . explain ( ) ) ; <nl> <nl> - / / findAndModify . <nl> - assert . eq ( { _id : 2 , str : " baz " } , coll . findAndModify ( { <nl> - query : { str : " bar " } , <nl> + / / Explain of find always uses the find command , so this will succeed regardless of readMode . <nl> + explainRes = <nl> + coll . explain ( " executionStats " ) . find ( { str : " FOO " } ) . collation ( { locale : " en_US " } ) . finish ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + assert . eq ( 0 , explainRes . executionStats . nReturned ) ; <nl> + explainRes = coll . explain ( " executionStats " ) <nl> + . find ( { str : " FOO " } ) <nl> + . collation ( { locale : " en_US " , strength : 2 } ) <nl> + . finish ( ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + assert . eq ( 1 , explainRes . executionStats . nReturned ) ; <nl> + <nl> + / / Update via findAndModify . <nl> + coll . drop ( ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 2 , str : " bar " } ) ) ; <nl> + assert . eq ( { _id : 1 , str : " baz " } , coll . findAndModify ( { <nl> + query : { str : " FOO " } , <nl> update : { $ set : { str : " baz " } } , <nl> new : true , <nl> - collation : { locale : " fr " } <nl> + collation : { locale : " en_US " , strength : 2 } <nl> } ) ) ; <nl> - assert . commandWorked ( coll . explain ( ) . findAndModify ( <nl> - { query : { str : " bar " } , update : { $ set : { str : " baz " } } , new : true , collation : { locale : " fr " } } ) ) ; <nl> + explainRes = coll . explain ( " executionStats " ) . findAndModify ( { <nl> + query : { str : " BAR " } , <nl> + update : { $ set : { str : " baz " } } , <nl> + new : true , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " UPDATE " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 1 , planStage . nWouldModify ) ; <nl> + <nl> + / / Delete via findAndModify . <nl> + coll . drop ( ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 2 , str : " bar " } ) ) ; <nl> + assert . eq ( { _id : 1 , str : " foo " } , <nl> + coll . findAndModify ( <nl> + { query : { str : " FOO " } , remove : true , collation : { locale : " en_US " , strength : 2 } } ) ) ; <nl> + explainRes = coll . explain ( " executionStats " ) . findAndModify ( { <nl> + query : { str : " BAR " } , <nl> + remove : true , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " DELETE " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 1 , planStage . nWouldDelete ) ; <nl> <nl> / / Group . <nl> - assert . eq ( [ { str : " foo " , count : 1 } , { str : " baz " , count : 1 } ] , coll . group ( { <nl> + coll . drop ( ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 2 , str : " bar " } ) ) ; <nl> + assert . eq ( [ { str : " foo " , count : 1 } ] , coll . group ( { <nl> + cond : { str : " FOO " } , <nl> key : { str : 1 } , <nl> initial : { count : 0 } , <nl> reduce : function ( curr , result ) { <nl> result . count + = 1 ; <nl> } , <nl> - collation : { locale : " fr " } <nl> + collation : { locale : " en_US " , strength : 2 } <nl> } ) ) ; <nl> - assert . commandWorked ( coll . explain ( ) . group ( { <nl> + explainRes = coll . explain ( " executionStats " ) . group ( { <nl> + cond : { str : " FOO " } , <nl> key : { str : 1 } , <nl> initial : { count : 0 } , <nl> reduce : function ( curr , result ) { <nl> result . count + = 1 ; <nl> } , <nl> - collation : { locale : " fr " } <nl> - } ) ) ; <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " GROUP " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( planStage . nGroups , 1 ) ; <nl> <nl> / / mapReduce . <nl> var mapReduceOut = coll . mapReduce ( <nl> <nl> function ( key , values ) { <nl> return Array . sum ( values ) ; <nl> } , <nl> - { out : { inline : 1 } , collation : { locale : " fr " } } ) ; <nl> + { out : { inline : 1 } , query : { str : " FOO " } , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . commandWorked ( mapReduceOut ) ; <nl> - assert . eq ( mapReduceOut . results . length , 2 ) ; <nl> + assert . eq ( mapReduceOut . results . length , 1 ) ; <nl> <nl> / / Remove . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - assert . commandWorked ( <nl> - coll . explain ( ) . remove ( { str : " foo " } , { justOne : true , collation : { locale : " fr " } } ) ) ; <nl> - assert . writeOK ( coll . remove ( { str : " foo " } , { justOne : true , collation : { locale : " fr " } } ) ) ; <nl> + explainRes = coll . explain ( " executionStats " ) . remove ( { str : " FOO " } , { <nl> + justOne : true , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " DELETE " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 1 , planStage . nWouldDelete ) ; <nl> + <nl> + var writeRes = <nl> + coll . remove ( { str : " FOO " } , { justOne : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 1 , writeRes . nRemoved ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . remove ( { str : " foo " } , { justOne : true , collation : { locale : " fr " } } ) ; <nl> + coll . remove ( { str : " FOO " } , { justOne : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> assert . throws ( function ( ) { <nl> - coll . explain ( ) . remove ( { str : " foo " } , { justOne : true , collation : { locale : " fr " } } ) ; <nl> + coll . explain ( ) . remove ( { str : " FOO " } , <nl> + { justOne : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - assert . commandWorked ( coll . explain ( ) . update ( <nl> - { str : " foo " } , { $ set : { other : 99 } } , { multi : true , collation : { locale : " fr " } } ) ) ; <nl> - assert . writeOK ( coll . update ( <nl> - { str : " foo " } , { $ set : { other : 99 } } , { multi : true , collation : { locale : " fr " } } ) ) ; <nl> + explainRes = coll . explain ( " executionStats " ) . update ( { str : " FOO " } , { $ set : { other : 99 } } , { <nl> + multi : true , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } ) ; <nl> + assert . commandWorked ( explainRes ) ; <nl> + planStage = getPlanStage ( explainRes . executionStats . executionStages , " UPDATE " ) ; <nl> + assert . neq ( null , planStage ) ; <nl> + assert . eq ( 2 , planStage . nWouldModify ) ; <nl> + <nl> + var writeRes = coll . update ( { str : " FOO " } , <nl> + { $ set : { other : 99 } } , <nl> + { multi : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> + assert . eq ( 2 , writeRes . nModified ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . update ( <nl> - { str : " foo " } , { $ set : { other : 99 } } , { multi : true , collation : { locale : " fr " } } ) ; <nl> + coll . update ( { str : " FOO " } , <nl> + { $ set : { other : 99 } } , <nl> + { multi : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> assert . throws ( function ( ) { <nl> - coll . explain ( ) . update ( <nl> - { str : " foo " } , { $ set : { other : 99 } } , { multi : true , collation : { locale : " fr " } } ) ; <nl> + coll . explain ( ) . update ( { str : " FOO " } , <nl> + { $ set : { other : 99 } } , <nl> + { multi : true , collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> var bulk ; <nl> <nl> if ( db . getMongo ( ) . writeMode ( ) ! = = " commands " ) { <nl> + coll . drop ( ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> + <nl> / / Can ' t use the bulk API to set a collation when using legacy write ops . <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> assert . throws ( function ( ) { <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) ; <nl> } ) ; <nl> <nl> bulk = coll . initializeOrderedBulkOp ( ) ; <nl> assert . throws ( function ( ) { <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " en_US " } ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) ; <nl> } ) ; <nl> } else { <nl> + var writeRes ; <nl> + <nl> / / update ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . update ( { $ set : { other : 99 } } ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . update ( { <nl> + $ set : { other : 99 } <nl> + } ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 2 , writeRes . nModified ) ; <nl> <nl> / / updateOne ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . updateOne ( { $ set : { other : 99 } } ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . updateOne ( { <nl> + $ set : { other : 99 } <nl> + } ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 1 , writeRes . nModified ) ; <nl> <nl> / / replaceOne ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . replaceOne ( { str : " oof " } ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . replaceOne ( { str : " oof " } ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 1 , writeRes . nModified ) ; <nl> <nl> / / replaceOne ( ) with upsert ( ) . <nl> coll . drop ( ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> + assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . upsert ( ) . replaceOne ( { str : " foo " } ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " } ) . upsert ( ) . replaceOne ( { str : " foo " } ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 1 , writeRes . nUpserted ) ; <nl> + assert . eq ( 0 , writeRes . nModified ) ; <nl> + <nl> + bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . upsert ( ) . replaceOne ( { <nl> + str : " foo " <nl> + } ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 0 , writeRes . nUpserted ) ; <nl> + assert . eq ( 1 , writeRes . nModified ) ; <nl> <nl> / / removeOne ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . removeOne ( ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . removeOne ( ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 1 , writeRes . nRemoved ) ; <nl> <nl> / / remove ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> bulk = coll . initializeUnorderedBulkOp ( ) ; <nl> - bulk . find ( { str : " foo " } ) . collation ( { locale : " fr " } ) . remove ( ) ; <nl> - assert . writeOK ( bulk . execute ( ) ) ; <nl> + bulk . find ( { str : " FOO " } ) . collation ( { locale : " en_US " , strength : 2 } ) . remove ( ) ; <nl> + writeRes = bulk . execute ( ) ; <nl> + assert . writeOK ( writeRes ) ; <nl> + assert . eq ( 2 , writeRes . nRemoved ) ; <nl> } <nl> <nl> / / <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . deleteOne ( { str : " foo " } , { collation : { locale : " fr " } } ) ; <nl> + var res = coll . deleteOne ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . eq ( 1 , res . deletedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . deleteOne ( { str : " foo " } , { collation : { locale : " fr " } } ) ; <nl> + coll . deleteOne ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . deleteMany ( { str : " foo " } , { collation : { locale : " fr " } } ) ; <nl> + var res = coll . deleteMany ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . eq ( 2 , res . deletedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . deleteMany ( { str : " foo " } , { collation : { locale : " fr " } } ) ; <nl> + coll . deleteMany ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . eq ( { _id : 1 , str : " foo " } , <nl> - coll . findOneAndDelete ( { str : " foo " } , { collation : { locale : " fr " } } ) ) ; <nl> + coll . findOneAndDelete ( { str : " FOO " } , { collation : { locale : " en_US " , strength : 2 } } ) ) ; <nl> assert . eq ( null , coll . findOne ( { _id : 1 } ) ) ; <nl> <nl> / / findOneAndReplace ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . eq ( { _id : 1 , str : " foo " } , <nl> - coll . findOneAndReplace ( { str : " foo " } , { str : " bar " } , { collation : { locale : " fr " } } ) ) ; <nl> + coll . findOneAndReplace ( <nl> + { str : " FOO " } , { str : " bar " } , { collation : { locale : " en_US " , strength : 2 } } ) ) ; <nl> assert . neq ( null , coll . findOne ( { str : " bar " } ) ) ; <nl> <nl> / / findOneAndUpdate ( ) . <nl> coll . drop ( ) ; <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> - assert . eq ( <nl> - { _id : 1 , str : " foo " } , <nl> - coll . findOneAndUpdate ( { str : " foo " } , { $ set : { other : 99 } } , { collation : { locale : " fr " } } ) ) ; <nl> + assert . eq ( { _id : 1 , str : " foo " } , <nl> + coll . findOneAndUpdate ( <nl> + { str : " FOO " } , { $ set : { other : 99 } } , { collation : { locale : " en_US " , strength : 2 } } ) ) ; <nl> assert . neq ( null , coll . findOne ( { other : 99 } ) ) ; <nl> <nl> / / replaceOne ( ) . <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . replaceOne ( { str : " foo " } , { str : " bar " } , { collation : { locale : " fr " } } ) ; <nl> + var res = coll . replaceOne ( <nl> + { str : " FOO " } , { str : " bar " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . eq ( 1 , res . modifiedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . replaceOne ( { str : " foo " } , { str : " bar " } , { collation : { locale : " fr " } } ) ; <nl> + coll . replaceOne ( <nl> + { str : " FOO " } , { str : " bar " } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . updateOne ( { str : " foo " } , { $ set : { other : 99 } } , { collation : { locale : " fr " } } ) ; <nl> + var res = coll . updateOne ( <nl> + { str : " FOO " } , { $ set : { other : 99 } } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . eq ( 1 , res . modifiedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . updateOne ( { str : " foo " } , { $ set : { other : 99 } } , { collation : { locale : " fr " } } ) ; <nl> + coll . updateOne ( <nl> + { str : " FOO " } , { $ set : { other : 99 } } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . updateMany ( { str : " foo " } , { $ set : { other : 99 } } , { collation : { locale : " fr " } } ) ; <nl> + var res = coll . updateMany ( <nl> + { str : " FOO " } , { $ set : { other : 99 } } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> assert . eq ( 2 , res . modifiedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . updateMany ( { str : " foo " } , { $ set : { other : 99 } } , { collation : { locale : " fr " } } ) ; <nl> + coll . updateMany ( <nl> + { str : " FOO " } , { $ set : { other : 99 } } , { collation : { locale : " en_US " , strength : 2 } } ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> var res = coll . bulkWrite ( [ { <nl> - updateOne : <nl> - { filter : { str : " foo " } , update : { $ set : { other : 99 } } , collation : { locale : " fr " } } <nl> + updateOne : { <nl> + filter : { str : " FOO " } , <nl> + update : { $ set : { other : 99 } } , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } <nl> } ] ) ; <nl> assert . eq ( 1 , res . matchedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> coll . bulkWrite ( [ { <nl> updateOne : { <nl> - filter : { str : " foo " } , <nl> + filter : { str : " FOO " } , <nl> update : { $ set : { other : 99 } } , <nl> - collation : { locale : " fr " } <nl> + collation : { locale : " en_US " , strength : 2 } <nl> } <nl> } ] ) ; <nl> } ) ; <nl> <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> var res = coll . bulkWrite ( [ { <nl> - updateMany : <nl> - { filter : { str : " foo " } , update : { $ set : { other : 99 } } , collation : { locale : " fr " } } <nl> + updateMany : { <nl> + filter : { str : " FOO " } , <nl> + update : { $ set : { other : 99 } } , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } <nl> } ] ) ; <nl> assert . eq ( 2 , res . matchedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> coll . bulkWrite ( [ { <nl> updateMany : { <nl> - filter : { str : " foo " } , <nl> + filter : { str : " FOO " } , <nl> update : { $ set : { other : 99 } } , <nl> - collation : { locale : " fr " } <nl> + collation : { locale : " en_US " , strength : 2 } <nl> } <nl> } ] ) ; <nl> } ) ; <nl> <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> var res = coll . bulkWrite ( [ { <nl> - replaceOne : <nl> - { filter : { str : " foo " } , replacement : { str : " bar " } , collation : { locale : " fr " } } <nl> + replaceOne : { <nl> + filter : { str : " FOO " } , <nl> + replacement : { str : " bar " } , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } <nl> } ] ) ; <nl> assert . eq ( 1 , res . matchedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> coll . bulkWrite ( [ { <nl> - replaceOne : <nl> - { filter : { str : " foo " } , replacement : { str : " bar " } , collation : { locale : " fr " } } <nl> + replaceOne : { <nl> + filter : { str : " FOO " } , <nl> + replacement : { str : " bar " } , <nl> + collation : { locale : " en_US " , strength : 2 } <nl> + } <nl> } ] ) ; <nl> } ) ; <nl> } <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . bulkWrite ( [ { deleteOne : { filter : { str : " foo " } , collation : { locale : " fr " } } } ] ) ; <nl> + var res = coll . bulkWrite ( <nl> + [ { deleteOne : { filter : { str : " FOO " } , collation : { locale : " en_US " , strength : 2 } } } ] ) ; <nl> assert . eq ( 1 , res . deletedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . bulkWrite ( [ { deleteOne : { filter : { str : " foo " } , collation : { locale : " fr " } } } ] ) ; <nl> + coll . bulkWrite ( <nl> + [ { deleteOne : { filter : { str : " FOO " } , collation : { locale : " en_US " , strength : 2 } } } ] ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 1 , str : " foo " } ) ) ; <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " foo " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> - var res = coll . bulkWrite ( [ { deleteMany : { filter : { str : " foo " } , collation : { locale : " fr " } } } ] ) ; <nl> + var res = coll . bulkWrite ( <nl> + [ { deleteMany : { filter : { str : " FOO " } , collation : { locale : " en_US " , strength : 2 } } } ] ) ; <nl> assert . eq ( 2 , res . deletedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> - coll . bulkWrite ( [ { deleteMany : { filter : { str : " foo " } , collation : { locale : " fr " } } } ] ) ; <nl> + coll . bulkWrite ( <nl> + [ { deleteMany : { filter : { str : " FOO " } , collation : { locale : " en_US " , strength : 2 } } } ] ) ; <nl> } ) ; <nl> } <nl> <nl> <nl> assert . writeOK ( coll . insert ( { _id : 2 , str : " bar " } ) ) ; <nl> if ( db . getMongo ( ) . writeMode ( ) = = = " commands " ) { <nl> var res = coll . bulkWrite ( [ <nl> - { deleteOne : { filter : { str : " foo " } , collation : { locale : " fr " } } } , <nl> - { deleteOne : { filter : { str : " bar " } , collation : { locale : " en_US " } } } <nl> + { deleteOne : { filter : { str : " FOO " } , collation : { locale : " fr " , strength : 2 } } } , <nl> + { deleteOne : { filter : { str : " BAR " } , collation : { locale : " en_US " , strength : 2 } } } <nl> ] ) ; <nl> assert . eq ( 2 , res . deletedCount ) ; <nl> } else { <nl> assert . throws ( function ( ) { <nl> coll . bulkWrite ( [ <nl> - { deleteOne : { filter : { str : " foo " } , collation : { locale : " fr " } } } , <nl> - { deleteOne : { filter : { str : " bar " } , collation : { locale : " en_US " } } } <nl> + { deleteOne : { filter : { str : " FOO " } , collation : { locale : " fr " , strength : 2 } } } , <nl> + { deleteOne : { filter : { str : " BAR " } , collation : { locale : " en_US " , strength : 2 } } } <nl> ] ) ; <nl> } ) ; <nl> } <nl> mmm a / src / mongo / db / commands / find_and_modify . cpp <nl> ppp b / src / mongo / db / commands / find_and_modify . cpp <nl> void makeUpdateRequest ( const FindAndModifyRequest & args , <nl> requestOut - > setProj ( args . getFields ( ) ) ; <nl> requestOut - > setUpdates ( args . getUpdateObj ( ) ) ; <nl> requestOut - > setSort ( args . getSort ( ) ) ; <nl> + requestOut - > setCollation ( args . getCollation ( ) ) ; <nl> requestOut - > setUpsert ( args . isUpsert ( ) ) ; <nl> requestOut - > setReturnDocs ( args . shouldReturnNew ( ) ? UpdateRequest : : RETURN_NEW <nl> : UpdateRequest : : RETURN_OLD ) ; <nl> void makeDeleteRequest ( const FindAndModifyRequest & args , bool explain , DeleteReq <nl> requestOut - > setQuery ( args . getQuery ( ) ) ; <nl> requestOut - > setProj ( args . getFields ( ) ) ; <nl> requestOut - > setSort ( args . getSort ( ) ) ; <nl> + requestOut - > setCollation ( args . getCollation ( ) ) ; <nl> requestOut - > setMulti ( false ) ; <nl> requestOut - > setYieldPolicy ( PlanExecutor : : YIELD_AUTO ) ; <nl> requestOut - > setReturnDeleted ( true ) ; / / Always return the old value . <nl> mmm a / src / mongo / db / commands / mr . cpp <nl> ppp b / src / mongo / db / commands / mr . cpp <nl> class MapReduceCommand : public Command { <nl> auto qr = stdx : : make_unique < QueryRequest > ( nss ) ; <nl> qr - > setFilter ( config . filter ) ; <nl> qr - > setSort ( config . sort ) ; <nl> + qr - > setCollation ( config . collation ) ; <nl> <nl> const ExtensionsCallbackReal extensionsCallback ( txn , & nss ) ; <nl> <nl> mmm a / src / mongo / db / query / get_executor . cpp <nl> ppp b / src / mongo / db / query / get_executor . cpp <nl> StatusWith < unique_ptr < PlanExecutor > > getExecutorGroup ( OperationContext * txn , <nl> const NamespaceString nss ( request . ns ) ; <nl> auto qr = stdx : : make_unique < QueryRequest > ( nss ) ; <nl> qr - > setFilter ( request . query ) ; <nl> + qr - > setCollation ( request . collation ) ; <nl> qr - > setExplain ( request . explain ) ; <nl> <nl> const ExtensionsCallbackReal extensionsCallback ( txn , & nss ) ; <nl>
|
SERVER - 23791 harden integration testing for commands that accept a collation
|
mongodb/mongo
|
bd5ef88fd884a2cc95eab6d4b66ce09d5efacb81
|
2016-06-03T22:54:51Z
|
mmm a / dbms / src / Columns / ColumnUnique . h <nl> ppp b / dbms / src / Columns / ColumnUnique . h <nl> ColumnUnique < ColumnType , IndexType > : : ColumnUnique ( const DataTypePtr & type ) : is <nl> auto & column_nullable = static_cast < ColumnNullable & > ( nullable_column - > assumeMutableRef ( ) ) ; <nl> column_holder = column_nullable . getNestedColumnPtr ( ) ; <nl> nullable_column_map = & column_nullable . getNullMapData ( ) ; <nl> - ( * nullable_column_map ) [ 1 ] = 0 ; <nl> + ( * nullable_column_map ) [ getDefaultValueIndex ( ) ] = 0 ; <nl> } <nl> else <nl> column_holder = type - > createColumn ( ) - > cloneResized ( numSpecialValues ( ) ) ; <nl> void ColumnUnique < ColumnType , IndexType > : : buildIndex ( ) <nl> auto column = getRawColumnPtr ( ) ; <nl> index = std : : make_unique < IndexMapType > ( ) ; <nl> <nl> - ( * index ) [ StringRefWrapper < ColumnType > ( column , getDefaultValueIndex ( ) ) ] = getDefaultValueIndex ( ) ; <nl> - <nl> for ( auto row : ext : : range ( numSpecialValues ( ) , column - > size ( ) ) ) <nl> { <nl> ( * index ) [ StringRefWrapper < ColumnType > ( column , row ) ] = row ; <nl> mmm a / dbms / src / Columns / ColumnVector . cpp <nl> ppp b / dbms / src / Columns / ColumnVector . cpp <nl> MutableColumnPtr ColumnVector < T > : : cloneResized ( size_t size ) const <nl> memcpy ( & new_col . data [ 0 ] , & data [ 0 ] , count * sizeof ( data [ 0 ] ) ) ; <nl> <nl> if ( size > count ) <nl> - memset ( & new_col . data [ count ] , static_cast < int > ( value_type ( ) ) , size - count ) ; <nl> + memset ( & new_col . data [ count ] , static_cast < int > ( value_type ( ) ) , ( size - count ) * sizeof ( value_type ( ) ) ) ; <nl> } <nl> <nl> return std : : move ( res ) ; <nl>
|
Moved DataTypeWithDictionary implementation to DataTypeWithDictionary . cpp
|
ClickHouse/ClickHouse
|
7788d30dcaadb72a2313a86ab43ca5e2fda2864e
|
2018-05-03T17:23:18Z
|
mmm a / src / core / security / security_connector . c <nl> ppp b / src / core / security / security_connector . c <nl> static const char * ssl_cipher_suites ( void ) { <nl> / * - - Common methods . - - * / <nl> <nl> / * Returns the first property with that name . * / <nl> - static const tsi_peer_property * tsi_peer_get_property_by_name ( <nl> + const tsi_peer_property * tsi_peer_get_property_by_name ( <nl> const tsi_peer * peer , const char * name ) { <nl> size_t i ; <nl> if ( peer = = NULL ) return NULL ; <nl> mmm a / src / core / security / security_connector . h <nl> ppp b / src / core / security / security_connector . h <nl> typedef struct { <nl> grpc_security_status grpc_ssl_server_security_connector_create ( <nl> const grpc_ssl_server_config * config , grpc_security_connector * * sc ) ; <nl> <nl> + / * Util . * / <nl> + const tsi_peer_property * tsi_peer_get_property_by_name ( <nl> + const tsi_peer * peer , const char * name ) ; <nl> + <nl> # endif / * GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONNECTOR_H * / <nl>
|
Merge pull request from jboeuf / tsi_util_refactoring
|
grpc/grpc
|
5a8b87c5b7bad27241e6f5d6c73329e41396689b
|
2015-05-18T23:36:38Z
|
new file mode 100644 <nl> index 00000000000 . . 248ea02f5c1 <nl> mmm / dev / null <nl> ppp b / docs / tutorials / gluon / datasets . md <nl> <nl> + <nl> + # Gluon ` Dataset ` s and ` DataLoader ` <nl> + <nl> + One of the most critical steps for model training and inference is loading the data : without data you can ' t do Machine Learning ! In this tutorial we use the Gluon API to define a [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) and use a [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) to iterate through the dataset in mini - batches . <nl> + <nl> + # # Introduction to ` Dataset ` s <nl> + <nl> + [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) objects are used to represent collections of data , and include methods to load and parse the data ( that is often stored on disk ) . Gluon has a number of different [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) classes for working with image data straight out - of - the - box , but we ' ll use the [ ` ArrayDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = arraydataset # mxnet . gluon . data . ArrayDataset ) to introduce the idea of a [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) . <nl> + <nl> + We first start by generating random data ` X ` ( with 3 variables ) and corresponding random labels ` y ` to simulate a typical supervised learning task . We generate 10 samples and we pass them all to the [ ` ArrayDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = arraydataset # mxnet . gluon . data . ArrayDataset ) . <nl> + <nl> + <nl> + ` ` ` python <nl> + import mxnet as mx <nl> + <nl> + X = mx . random . uniform ( shape = ( 10 , 3 ) ) <nl> + y = mx . random . uniform ( shape = ( 10 , 1 ) ) <nl> + dataset = mx . gluon . data . dataset . ArrayDataset ( X , y ) <nl> + ` ` ` <nl> + <nl> + A key feature of a [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) is the __ * ability to retrieve a single sample given an index * __ . Our random data and labels were generated in memory , so this [ ` ArrayDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = arraydataset # mxnet . gluon . data . ArrayDataset ) doesn ' t have to load anything from disk , but the interface is the same for all [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) s . <nl> + <nl> + <nl> + ` ` ` python <nl> + sample_idx = 4 <nl> + sample = dataset [ sample_idx ] <nl> + <nl> + assert len ( sample ) = = 2 <nl> + assert sample [ 0 ] . shape = = ( 3 , ) <nl> + assert sample [ 1 ] . shape = = ( 1 , ) <nl> + print ( sample ) <nl> + ` ` ` <nl> + <nl> + ( <nl> + [ 0 . 4375872 0 . 29753461 0 . 89177299 ] <nl> + < NDArray 3 @ cpu ( 0 ) > , <nl> + [ 0 . 83261985 ] <nl> + < NDArray 1 @ cpu ( 0 ) > ) <nl> + <nl> + <nl> + We get a tuple of a data sample and its corresponding label , which makes sense because we passed the data ` X ` and the labels ` y ` in that order when we instantiated the [ ` ArrayDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = arraydataset # mxnet . gluon . data . ArrayDataset ) . We don ' t usually retrieve individual samples from [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) objects though ( unless we ' re quality checking the output samples ) . Instead we use a [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) . <nl> + <nl> + # # Introduction to ` DataLoader ` <nl> + <nl> + A [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) is used to create mini - batches of samples from a [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) , and provides a convenient iterator interface for looping these batches . It ' s typically much more efficient to pass a mini - batch of data through a neural network than a single sample at a time , because the computation can be performed in parallel . A required parameter of [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) is the size of the mini - batches you want to create , called ` batch_size ` . <nl> + <nl> + Another benefit of using [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) is the ability to easily load data in parallel using [ ` multiprocessing ` ] ( https : / / docs . python . org / 3 . 6 / library / multiprocessing . html ) . Just set the ` num_workers ` parameter to the number of CPUs avaliable on your machine for maximum performance . <nl> + <nl> + <nl> + ` ` ` python <nl> + from multiprocessing import cpu_count <nl> + <nl> + data_loader = mx . gluon . data . DataLoader ( dataset , batch_size = 5 , num_workers = cpu_count ( ) ) <nl> + <nl> + for X_batch , y_batch in data_loader : <nl> + print ( " X_batch has shape { } , and y_batch has shape { } " . format ( X_batch . shape , y_batch . shape ) ) <nl> + ` ` ` <nl> + <nl> + X_batch has shape ( 5 , 3 ) , and y_batch has shape ( 5 , 1 ) <nl> + X_batch has shape ( 5 , 3 ) , and y_batch has shape ( 5 , 1 ) <nl> + <nl> + <nl> + We can see 2 mini - batches of data ( and labels ) , each with 5 samples , which makes sense given we started with a dataset of 10 samples . When comparing the shape of the batches to the samples returned by the [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) , we ' ve gained an extra dimension at the start which is sometimes called the batch axis . <nl> + <nl> + Our ` data_loader ` loop will stop when every sample of ` dataset ` has been returned as part of a batch . Sometimes the dataset length isn ' t divisible by the mini - batch size , leaving a final batch with a smaller number of samples . [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) ' s default behavior is to return this smaller mini - batch , but this can be changed by setting the ` last_batch ` parameter to ` discard ` ( which ignores the last batch ) or ` rollover ` ( which starts the next epoch with the remaining samples ) . <nl> + <nl> + # # Machine learning with ` Dataset ` s and ` DataLoader ` s <nl> + <nl> + You will often use a few different [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) objects in your Machine Learning project . It ' s essential to separate your training dataset from testing dataset , and it ' s also good practice to have validation dataset ( a . k . a . development dataset ) that can be used for optimising hyperparameters . <nl> + <nl> + Using Gluon [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) objects , we define the data to be included in each of these separate datasets . Common use cases for loading data are covered already ( e . g . [ ` mxnet . gluon . data . vision . datasets . ImageFolderDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = imagefolderdataset # mxnet . gluon . data . vision . datasets . ImageFolderDataset ) ) , but it ' s simple to create your own custom [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) classes for other types of data . You can even use included [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) objects for common datasets if you want to experiment quickly ; they download and parse the data for you ! In this example we use the [ Fashion MNIST ] ( https : / / github . com / zalandoresearch / fashion - mnist ) dataset from Zalando Research . <nl> + <nl> + Many of the image [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) s accept a function ( via the optional ` transform ` parameter ) which is applied to each sample returned by the [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) . It ' s useful for performing data augmentation , but can also be used for more simple data type conversion and pixel value scaling as seen below . <nl> + <nl> + <nl> + ` ` ` python <nl> + def transform ( data , label ) : <nl> + data = data . astype ( ' float32 ' ) / 255 <nl> + return data , label <nl> + <nl> + train_dataset = mx . gluon . data . vision . datasets . FashionMNIST ( train = True , transform = transform ) <nl> + valid_dataset = mx . gluon . data . vision . datasets . FashionMNIST ( train = False , transform = transform ) <nl> + ` ` ` <nl> + <nl> + <nl> + ` ` ` python <nl> + % matplotlib inline <nl> + from matplotlib . pylab import imshow <nl> + <nl> + sample_idx = 234 <nl> + sample = train_dataset [ sample_idx ] <nl> + data = sample [ 0 ] <nl> + label = sample [ 1 ] <nl> + label_desc = { 0 : ' T - shirt / top ' , 1 : ' Trouser ' , 2 : ' Pullover ' , 3 : ' Dress ' , 4 : ' Coat ' , 5 : ' Sandal ' , 6 : ' Shirt ' , 7 : ' Sneaker ' , 8 : ' Bag ' , 9 : ' Ankle boot ' } <nl> + <nl> + imshow ( data [ : , : , 0 ] . asnumpy ( ) , cmap = ' gray ' ) <nl> + print ( " Data type : { } " . format ( data . dtype ) ) <nl> + print ( " Label : { } " . format ( label ) ) <nl> + print ( " Label description : { } " . format ( label_desc [ label ] ) ) <nl> + ` ` ` <nl> + <nl> + Data type : < class ' numpy . float32 ' > <nl> + Label : 8 <nl> + Label description : Bag <nl> + <nl> + <nl> + <nl> + ! [ png ] ( https : / / raw . githubusercontent . com / dmlc / web - data / master / mxnet / doc / tutorials / gluon / datasets / fashion_mnist_bag . png ) <nl> + <nl> + <nl> + When training machine learning models it is important to shuffle the training samples every time you pass through the dataset ( i . e . each epoch ) . Sometimes the order of your samples will have a spurious relationship with the target variable , and shuffling the samples helps remove this . With [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) it ' s as simple as adding ` shuffle = True ` . You don ' t need to shuffle the validation and testing data though . <nl> + <nl> + If you have more complex shuffling requirements ( e . g . when handling sequential data ) , take a look at [ ` mxnet . gluon . data . BatchSampler ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = batchsampler # mxnet . gluon . data . BatchSampler ) and pass this to your [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) instead . <nl> + <nl> + <nl> + ` ` ` python <nl> + batch_size = 32 <nl> + train_data_loader = mx . gluon . data . DataLoader ( train_dataset , batch_size , shuffle = True , num_workers = cpu_count ( ) ) <nl> + valid_data_loader = mx . gluon . data . DataLoader ( valid_dataset , batch_size , num_workers = cpu_count ( ) ) <nl> + ` ` ` <nl> + <nl> + With both ` DataLoader ` s defined , we can now train a model to classify each image and evaluate the validation loss at each epoch . Our Fashion MNIST dataset has 10 classes including shirt , dress , sneakers , etc . We define a simple fully connected network with a softmax output and use cross entropy as our loss . <nl> + <nl> + <nl> + ` ` ` python <nl> + from mxnet import gluon , autograd , ndarray <nl> + <nl> + def construct_net ( ) : <nl> + net = gluon . nn . HybridSequential ( ) <nl> + with net . name_scope ( ) : <nl> + net . add ( gluon . nn . Dense ( 128 , activation = " relu " ) ) <nl> + net . add ( gluon . nn . Dense ( 64 , activation = " relu " ) ) <nl> + net . add ( gluon . nn . Dense ( 10 ) ) <nl> + return net <nl> + <nl> + # construct and initialize network . <nl> + ctx = mx . cpu ( ) <nl> + net = construct_net ( ) <nl> + net . hybridize ( ) <nl> + net . collect_params ( ) . initialize ( mx . init . Xavier ( ) ) <nl> + # define loss and trainer . <nl> + criterion = gluon . loss . SoftmaxCrossEntropyLoss ( ) <nl> + trainer = gluon . Trainer ( net . collect_params ( ) , ' sgd ' , { ' learning_rate ' : 0 . 1 } ) <nl> + <nl> + epochs = 5 <nl> + for epoch in range ( epochs ) : <nl> + <nl> + # training loop ( with autograd and trainer steps , etc . ) <nl> + cumulative_train_loss = mx . nd . array ( [ 0 ] ) <nl> + training_samples = 0 <nl> + for batch_idx , ( data , label ) in enumerate ( train_data_loader ) : <nl> + data = data . as_in_context ( ctx ) . reshape ( ( - 1 , 784 ) ) # 28 * 28 = 784 <nl> + label = label . as_in_context ( ctx ) <nl> + with autograd . record ( ) : <nl> + output = net ( data ) <nl> + loss = criterion ( output , label ) <nl> + loss . backward ( ) <nl> + trainer . step ( data . shape [ 0 ] ) <nl> + cumulative_train_loss + = loss . sum ( ) <nl> + training_samples + = data . shape [ 0 ] <nl> + train_loss = cumulative_train_loss . asscalar ( ) / training_samples <nl> + <nl> + # validation loop <nl> + cumulative_valid_loss = mx . nd . array ( [ 0 ] ) <nl> + valid_samples = 0 <nl> + for batch_idx , ( data , label ) in enumerate ( valid_data_loader ) : <nl> + data = data . as_in_context ( ctx ) . reshape ( ( - 1 , 784 ) ) # 28 * 28 = 784 <nl> + label = label . as_in_context ( ctx ) <nl> + output = net ( data ) <nl> + loss = criterion ( output , label ) <nl> + cumulative_valid_loss + = loss . sum ( ) <nl> + valid_samples + = data . shape [ 0 ] <nl> + valid_loss = cumulative_valid_loss . asscalar ( ) / valid_samples <nl> + <nl> + print ( " Epoch { } , training loss : { : . 2f } , validation loss : { : . 2f } " . format ( epoch , train_loss , valid_loss ) ) <nl> + ` ` ` <nl> + <nl> + Epoch 0 , training loss : 0 . 54 , validation loss : 0 . 45 <nl> + Epoch 1 , training loss : 0 . 40 , validation loss : 0 . 39 <nl> + Epoch 2 , training loss : 0 . 36 , validation loss : 0 . 39 <nl> + Epoch 3 , training loss : 0 . 33 , validation loss : 0 . 34 <nl> + Epoch 4 , training loss : 0 . 32 , validation loss : 0 . 33 <nl> + <nl> + <nl> + # Using own data with included ` Dataset ` s <nl> + <nl> + Gluon has a number of different [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) classes for working with your own image data straight out - of - the - box . You can get started quickly using the [ ` mxnet . gluon . data . vision . datasets . ImageFolderDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = imagefolderdataset # mxnet . gluon . data . vision . datasets . ImageFolderDataset ) which loads images directly from a user - defined folder , and infers the label ( i . e . class ) from the folders . <nl> + <nl> + We will run through an example for image classification , but a similar process applies for other vision tasks . If you already have your own collection of images to work with you should partition your data into training and test sets , and place all objects of the same class into seperate folders . Similar to : <nl> + <nl> + . / images / train / car / abc . jpg <nl> + . / images / train / car / efg . jpg <nl> + . / images / train / bus / hij . jpg <nl> + . / images / train / bus / klm . jpg <nl> + . / images / test / car / xyz . jpg <nl> + . / images / test / bus / uvw . jpg <nl> + <nl> + You can download the Caltech 101 dataset if you don ' t already have images to work with for this example , but please note the download is 126MB . <nl> + <nl> + ` ` ` python <nl> + ! wget http : / / www . vision . caltech . edu / Image_Datasets / Caltech101 / 101_ObjectCategories . tar . gz <nl> + ! tar - xzf 101_ObjectCategories . tar . gz <nl> + ` ` ` <nl> + <nl> + After downloading and extracting the data archive , we seperate the data into training and test sets ( 50 : 50 split ) , and place images of the same class into the same folders , as required for using [ ` ImageFolderDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = imagefolderdataset # mxnet . gluon . data . vision . datasets . ImageFolderDataset ) . <nl> + <nl> + ` ` ` python <nl> + import shutil <nl> + import os <nl> + <nl> + def split_train_test ( source_dir = ' . / 101_ObjectCategories ' , train_dir = ' . / images / train ' , test_dir = ' . / images / test ' ) : <nl> + " " " <nl> + Walks through source_dir and alternates between places files in the train_dir and the test_dir . <nl> + " " " <nl> + train_set = True <nl> + for root , dirs , files in os . walk ( source_dir ) : <nl> + for name in files : <nl> + current_filepath = os . path . join ( root , name ) <nl> + dataset_dir = train_dir if train_set else test_dir <nl> + new_filepath = current_filepath . replace ( source_dir , dataset_dir ) <nl> + try : <nl> + os . makedirs ( os . path . dirname ( new_filepath ) ) <nl> + except FileExistsError : <nl> + pass <nl> + shutil . move ( current_filepath , new_filepath ) <nl> + train_set = not train_set <nl> + shutil . rmtree ( source_dir ) <nl> + <nl> + split_train_test ( ) <nl> + ` ` ` <nl> + <nl> + We instantiate the [ ` ImageFolderDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = imagefolderdataset # mxnet . gluon . data . vision . datasets . ImageFolderDataset ) s by providing the path to the data , and the folder structure will be traversed to determine which image classes are available and which images correspond to each class . You must take care to ensure the same classes are both the training and testing datasets , otherwise the label encodings can get muddled . <nl> + <nl> + Optionally , you can pass a ` transform ` parameter to these [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) s as we ' ve seen before . <nl> + <nl> + <nl> + ` ` ` python <nl> + train_dataset = mx . gluon . data . vision . datasets . ImageFolderDataset ( ' . / images / train ' ) <nl> + test_dataset = mx . gluon . data . vision . datasets . ImageFolderDataset ( ' . / images / test ' ) <nl> + ` ` ` <nl> + <nl> + Samples from these datasets are tuples of data and label . Images are loaded from disk , decoded and optionally transformed when the ` __getitem__ ( i ) ` method is called ( equivalent to ` train_dataset [ i ] ` ) . <nl> + <nl> + As with the Fashion MNIST dataset the labels will be integer encoded . You can use the ` synsets ` property of the [ ` ImageFolderDataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = imagefolderdataset # mxnet . gluon . data . vision . datasets . ImageFolderDataset ) s to retrieve the original descriptions ( e . g . ` train_dataset . synsets [ i ] ` ) . <nl> + <nl> + <nl> + ` ` ` python <nl> + sample_idx = 888 <nl> + sample = train_dataset [ sample_idx ] <nl> + data = sample [ 0 ] <nl> + label = sample [ 1 ] <nl> + <nl> + imshow ( data . asnumpy ( ) , cmap = ' gray ' ) <nl> + print ( " Data type : { } " . format ( data . dtype ) ) <nl> + print ( " Label : { } " . format ( label ) ) <nl> + print ( " Label description : { } " . format ( train_dataset . synsets [ label ] ) ) <nl> + assert label = = 1 <nl> + ` ` ` <nl> + <nl> + Data type : < class ' numpy . uint8 ' > <nl> + Label : 2 <nl> + Label description : Faces_easy <nl> + <nl> + <nl> + ! [ png ] ( https : / / raw . githubusercontent . com / dmlc / web - data / master / mxnet / doc / tutorials / gluon / datasets / caltech101_face . png <nl> + ) <nl> + <nl> + # Using own data with custom ` Dataset ` s <nl> + <nl> + Sometimes you have data that doesn ' t quite fit the format expected by the included [ ` Dataset ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataset # mxnet . gluon . data . Dataset ) s . You might be able to preprocess your data to fit the expected format , but it is easy to create your own dataset to do this . <nl> + <nl> + All you need to do is create a class that implements a ` __getitem__ ` method , that returns a sample ( i . e . a tuple of [ ` mx . nd . NDArray ` ] ( https : / / mxnet . incubator . apache . org / api / python / ndarray / ndarray . html # mxnet . ndarray . NDArray ) s ) . <nl> + <nl> + See the [ Data Augmentation with Masks ] ( http : / / mxnet . incubator . apache . org / tutorials / python / data_augmentation_with_masks . html ) tutorial for an example of this . <nl> + <nl> + # Appendix : Upgrading from Module ` DataIter ` to Gluon ` DataLoader ` <nl> + <nl> + Before Gluon ' s [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) , MXNet used [ ` DataIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = dataiter # mxnet . io . DataIter ) objects for loading data for training and testing . [ ` DataIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = dataiter # mxnet . io . DataIter ) has a similar interface for iterating through data , but it isn ' t directly compatible with typical Gluon [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) loops . Unlike Gluon [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) which often returns a tuple of ` ( data , label ) ` , a [ ` DataIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = dataiter # mxnet . io . DataIter ) returns a [ ` DataBatch ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = databatch # mxnet . io . DataBatch ) object that has ` data ` and ` label ` properties . Switching to [ ` DataLoader ` ] ( https : / / mxnet . incubator . apache . org / api / python / gluon / data . html ? highlight = dataloader # mxnet . gluon . data . DataLoader ) s is highly recommended when using Gluon , but you ' ll need to take care of pre - processing steps such as augmentations in a ` transform ` function . <nl> + <nl> + So you can get up and running with Gluon quicker if you have already imlemented complex pre - processing steps using [ ` DataIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = dataiter # mxnet . io . DataIter ) , we have provided a simple class to wrap existing [ ` DataIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = dataiter # mxnet . io . DataIter ) objects so they can be used in a typical Gluon training loop . You can use this class for ` DataIter ` s such as [ ` mxnet . image . ImageIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / image / image . html ? highlight = imageiter # mxnet . image . ImageIter ) and [ ` mxnet . io . ImageRecordIter ` ] ( https : / / mxnet . incubator . apache . org / api / python / io / io . html ? highlight = imagere # mxnet . io . ImageRecordIter ) that have single data and label arrays . <nl> + <nl> + <nl> + ` ` ` python <nl> + class DataIterLoader ( ) : <nl> + def __init__ ( self , data_iter ) : <nl> + self . data_iter = data_iter <nl> + <nl> + def __iter__ ( self ) : <nl> + self . data_iter . reset ( ) <nl> + return self <nl> + <nl> + def __next__ ( self ) : <nl> + batch = self . data_iter . __next__ ( ) <nl> + assert len ( batch . data ) = = len ( batch . label ) = = 1 <nl> + data = batch . data [ 0 ] <nl> + label = batch . label [ 0 ] <nl> + return data , label <nl> + <nl> + def next ( self ) : <nl> + return self . __next__ ( ) # for Python 2 <nl> + ` ` ` <nl> + <nl> + <nl> + ` ` ` python <nl> + data_iter = mx . io . NDArrayIter ( data = X , label = y , batch_size = 5 ) <nl> + data_iter_loader = DataIterLoader ( data_iter ) <nl> + for X_batch , y_batch in data_iter_loader : <nl> + assert X_batch . shape = = ( 5 , 3 ) <nl> + assert y_batch . shape = = ( 5 , 1 ) <nl> + ` ` ` <nl> \ No newline at end of file <nl> mmm a / docs / tutorials / index . md <nl> ppp b / docs / tutorials / index . md <nl> The Gluon and Module tutorials are in Python , but you can also find a variety of <nl> <nl> - [ Serialization - saving , loading and checkpointing ] ( http : / / gluon . mxnet . io / chapter03_deep - neural - networks / serialization . html ) <nl> <nl> + - [ Gluon Datasets and DataLoaders ] ( http : / / mxnet . incubator . apache . org / tutorials / gluon / datasets . html ) <nl> + <nl> < / div > <nl> <nl> <nl>
|
[ MXNET - 141 ] Add tutorial Gluon Datasets and DataLoaders ( )
|
apache/incubator-mxnet
|
9a0d0028695cbc3553ffadf3537b1003bb0006c4
|
2018-04-02T16:53:43Z
|
mmm a / src / properties / peerlistsortmodel . h <nl> ppp b / src / properties / peerlistsortmodel . h <nl> class PeerListSortModel : public QSortFilterProxyModel { <nl> <nl> protected : <nl> bool lessThan ( const QModelIndex & left , const QModelIndex & right ) const { <nl> - if ( sortColumn ( ) = = PeerListDelegate : : IP ) { <nl> - const QStringList ipLeft = sourceModel ( ) - > data ( left ) . toString ( ) . split ( ' . ' ) ; <nl> - const QStringList ipRight = sourceModel ( ) - > data ( right ) . toString ( ) . split ( ' . ' ) ; <nl> - if ( ( ipRight . size ( ) & ipLeft . size ( ) ) ! = 4 ) / / One row in model <nl> - return false ; <nl> - Q_ASSERT ( ipLeft . size ( ) = = 4 ) ; <nl> - Q_ASSERT ( ipRight . size ( ) = = 4 ) ; <nl> + if ( sortColumn ( ) = = PeerListDelegate : : IP | | sortColumn ( ) = = PeerListDelegate : : CLIENT ) { <nl> + QVariant vL = sourceModel ( ) - > data ( left ) ; <nl> + QVariant vR = sourceModel ( ) - > data ( right ) ; <nl> + if ( ! ( vL . isValid ( ) & & vR . isValid ( ) ) ) <nl> + return QSortFilterProxyModel : : lessThan ( left , right ) ; <nl> + Q_ASSERT ( vL . isValid ( ) ) ; <nl> + Q_ASSERT ( vR . isValid ( ) ) ; <nl> <nl> - int i = 0 ; <nl> - while ( i < 4 ) { <nl> - int l = ipLeft . at ( i ) . toInt ( ) ; <nl> - int r = ipRight . at ( i ) . toInt ( ) ; <nl> - if ( l < r ) <nl> - return true ; <nl> - else if ( l > r ) <nl> - return false ; <nl> - + + i ; <nl> - } <nl> - return false ; <nl> + bool res = false ; <nl> + if ( misc : : naturalSort ( vL . toString ( ) , vR . toString ( ) , res ) ) <nl> + return res ; <nl> + <nl> + return QSortFilterProxyModel : : lessThan ( left , right ) ; <nl> } <nl> return QSortFilterProxyModel : : lessThan ( left , right ) ; <nl> } <nl>
|
Update naturalSorting in the Peers tab .
|
qbittorrent/qBittorrent
|
6e9ed4ead7af52c5af96be2de0e8b418bb5219a1
|
2013-09-10T15:34:15Z
|
mmm a / modules / ml / include / opencv2 / ml . hpp <nl> ppp b / modules / ml / include / opencv2 / ml . hpp <nl> class CV_EXPORTS_W NormalBayesClassifier : public StatModel <nl> / * * Creates empty model <nl> Use StatModel : : train to train the model after creation . * / <nl> CV_WRAP static Ptr < NormalBayesClassifier > create ( ) ; <nl> + <nl> + / * * @ brief Loads and creates a serialized NormalBayesClassifier from a file <nl> + * <nl> + * Use NormalBayesClassifier : : save to serialize and store an NormalBayesClassifier to disk . <nl> + * Load the NormalBayesClassifier from this file again , by calling this function with the path to the file . <nl> + * Optionally specify the node for the file containing the classifier <nl> + * <nl> + * @ param filepath path to serialized NormalBayesClassifier <nl> + * @ param nodeName name of node containing the classifier <nl> + * / <nl> + CV_WRAP static Ptr < NormalBayesClassifier > load ( const String & filepath , const String & nodeName = String ( ) ) ; <nl> } ; <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> class CV_EXPORTS_W EM : public StatModel <nl> can use one of the EM : : train \ * methods or load it from file using Algorithm : : load \ < EM \ > ( filename ) . <nl> * / <nl> CV_WRAP static Ptr < EM > create ( ) ; <nl> + <nl> + / * * @ brief Loads and creates a serialized EM from a file <nl> + * <nl> + * Use EM : : save to serialize and store an EM to disk . <nl> + * Load the EM from this file again , by calling this function with the path to the file . <nl> + * Optionally specify the node for the file containing the classifier <nl> + * <nl> + * @ param filepath path to serialized EM <nl> + * @ param nodeName name of node containing the classifier <nl> + * / <nl> + CV_WRAP static Ptr < EM > load ( const String & filepath , const String & nodeName = String ( ) ) ; <nl> } ; <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> class CV_EXPORTS_W LogisticRegression : public StatModel <nl> Creates Logistic Regression model with parameters given . <nl> * / <nl> CV_WRAP static Ptr < LogisticRegression > create ( ) ; <nl> + <nl> + / * * @ brief Loads and creates a serialized LogisticRegression from a file <nl> + * <nl> + * Use LogisticRegression : : save to serialize and store an LogisticRegression to disk . <nl> + * Load the LogisticRegression from this file again , by calling this function with the path to the file . <nl> + * Optionally specify the node for the file containing the classifier <nl> + * <nl> + * @ param filepath path to serialized LogisticRegression <nl> + * @ param nodeName name of node containing the classifier <nl> + * / <nl> + CV_WRAP static Ptr < LogisticRegression > load ( const String & filepath , const String & nodeName = String ( ) ) ; <nl> } ; <nl> <nl> <nl> class CV_EXPORTS_W SVMSGD : public cv : : ml : : StatModel <nl> * / <nl> CV_WRAP static Ptr < SVMSGD > create ( ) ; <nl> <nl> + / * * @ brief Loads and creates a serialized SVMSGD from a file <nl> + * <nl> + * Use SVMSGD : : save to serialize and store an SVMSGD to disk . <nl> + * Load the SVMSGD from this file again , by calling this function with the path to the file . <nl> + * Optionally specify the node for the file containing the classifier <nl> + * <nl> + * @ param filepath path to serialized SVMSGD <nl> + * @ param nodeName name of node containing the classifier <nl> + * / <nl> + CV_WRAP static Ptr < SVMSGD > load ( const String & filepath , const String & nodeName = String ( ) ) ; <nl> + <nl> / * * @ brief Function sets optimal parameters values for chosen SVM SGD model . <nl> * @ param svmsgdType is the type of SVMSGD classifier . <nl> * @ param marginType is the type of margin constraint . <nl> mmm a / modules / ml / src / em . cpp <nl> ppp b / modules / ml / src / em . cpp <nl> Ptr < EM > EM : : create ( ) <nl> return makePtr < EMImpl > ( ) ; <nl> } <nl> <nl> + Ptr < EM > EM : : load ( const String & filepath , const String & nodeName ) <nl> + { <nl> + return Algorithm : : load < EM > ( filepath , nodeName ) ; <nl> + } <nl> + <nl> } <nl> } / / namespace cv <nl> <nl> mmm a / modules / ml / src / lr . cpp <nl> ppp b / modules / ml / src / lr . cpp <nl> Ptr < LogisticRegression > LogisticRegression : : create ( ) <nl> return makePtr < LogisticRegressionImpl > ( ) ; <nl> } <nl> <nl> + Ptr < LogisticRegression > LogisticRegression : : load ( const String & filepath , const String & nodeName ) <nl> + { <nl> + return Algorithm : : load < LogisticRegression > ( filepath , nodeName ) ; <nl> + } <nl> + <nl> + <nl> bool LogisticRegressionImpl : : train ( const Ptr < TrainData > & trainData , int ) <nl> { <nl> / / return value <nl> mmm a / modules / ml / src / nbayes . cpp <nl> ppp b / modules / ml / src / nbayes . cpp <nl> Ptr < NormalBayesClassifier > NormalBayesClassifier : : create ( ) <nl> return p ; <nl> } <nl> <nl> + Ptr < NormalBayesClassifier > NormalBayesClassifier : : load ( const String & filepath , const String & nodeName ) <nl> + { <nl> + return Algorithm : : load < NormalBayesClassifier > ( filepath , nodeName ) ; <nl> + } <nl> + <nl> } <nl> } <nl> <nl> mmm a / modules / ml / src / svmsgd . cpp <nl> ppp b / modules / ml / src / svmsgd . cpp <nl> Ptr < SVMSGD > SVMSGD : : create ( ) <nl> return makePtr < SVMSGDImpl > ( ) ; <nl> } <nl> <nl> + Ptr < SVMSGD > SVMSGD : : load ( const String & filepath , const String & nodeName ) <nl> + { <nl> + return Algorithm : : load < SVMSGD > ( filepath , nodeName ) ; <nl> + } <nl> + <nl> + <nl> void SVMSGDImpl : : normalizeSamples ( Mat & samples , Mat & average , float & multiplier ) <nl> { <nl> int featuresCount = samples . cols ; <nl>
|
Wrappers for load methods of EM , LR , SVMSGD and Normal Bayes Classifier
|
opencv/opencv
|
519fbdb8ab934fa0d99e58cd6cacc92cbd830d5e
|
2017-01-29T13:21:55Z
|
mmm a / version <nl> ppp b / version <nl> @ @ - 1 + 1 @ @ <nl> - 12 . 4 . 3 <nl> + 12 . 4 . 4 <nl>
|
version 12 . 4 . 4
|
pqrs-org/Karabiner-Elements
|
40445bf1fcb42f04d6ce481cddde1e74ac924742
|
2019-05-27T02:00:30Z
|
new file mode 100644 <nl> index 00000000000 . . 63c6cfaea74 <nl> mmm / dev / null <nl> ppp b / js / common / modules / org / arangodb / stub_and_mock . js <nl> <nl> + / * jslint indent : 2 , nomen : true , maxlen : 100 , white : true , plusplus : true , eqeq : true * / <nl> + / * global require , exports * / <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Mini Stub and Mock Framework <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <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> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Lucas Dohmen <nl> + / / / @ author Copyright 2011 - 2012 , triAGENS GmbH , Cologne , Germany <nl> + <nl> + var stub , <nl> + allow , <nl> + expect , <nl> + FunctionStub , <nl> + FunctionMock , <nl> + _ = require ( " underscore " ) ; <nl> + <nl> + / / Sorry for Yak Shaving . But I can ' t take it anymore . <nl> + <nl> + / / x = stub ( ) ; <nl> + <nl> + stub = function ( ) { <nl> + return function ( ) { } ; <nl> + } ; <nl> + <nl> + / / allow ( x ) . to ( { <nl> + / / receive : " functionName " , <nl> + / / and_return : { x : 1 } <nl> + / / } ) ; <nl> + <nl> + FunctionStub = function ( obj ) { <nl> + this . obj = obj ; <nl> + } ; <nl> + <nl> + FunctionStub . prototype . to = function ( config ) { <nl> + this . obj [ config . receive ] = function ( ) { <nl> + return config . and_return ; <nl> + } ; <nl> + } ; <nl> + <nl> + allow = function ( obj ) { <nl> + return ( new FunctionStub ( obj ) ) ; <nl> + } ; <nl> + <nl> + / / expect ( x ) . to ( { <nl> + / / receive : " functionName " , <nl> + / / withArguments : [ 5 ] , <nl> + / / and_return { x : 1 } <nl> + / / } ) ; <nl> + / / <nl> + / / . . . <nl> + / / <nl> + / / x . assertIsSatisfied ( ) ; <nl> + <nl> + FunctionMock = function ( obj ) { <nl> + this . obj = obj ; <nl> + this . obj . satisfied = true ; <nl> + <nl> + this . obj . assertIsSatisfied = function ( ) { <nl> + assertTrue ( this . satisfied , " Mock Expectation was not satisfied " ) ; <nl> + } ; <nl> + } ; <nl> + <nl> + FunctionMock . prototype . to = function ( config ) { <nl> + var obj = this . obj ; <nl> + obj . satisfied = false ; <nl> + <nl> + this . obj [ config . receive ] = function ( ) { <nl> + var args = Array . prototype . slice . call ( arguments , 0 ) ; <nl> + <nl> + if ( ( config . withArguments = = = undefined ) | | ( _ . isEqual ( args , config . withArguments ) ) ) { <nl> + obj . satisfied = true ; <nl> + } <nl> + <nl> + return config . and_return ; <nl> + } ; <nl> + } ; <nl> + <nl> + expect = function ( obj ) { <nl> + return ( new FunctionMock ( obj ) ) ; <nl> + } ; <nl> + <nl> + exports . stub = stub ; <nl> + exports . allow = allow ; <nl> + exports . expect = expect ; <nl> mmm a / js / common / tests / shell - foxx - repository . js <nl> ppp b / js / common / tests / shell - foxx - repository . js <nl> require ( " internal " ) . flushModuleCache ( ) ; <nl> var jsunity = require ( " jsunity " ) , <nl> FoxxRepository = require ( " org / arangodb / foxx / repository " ) . Repository , <nl> Model = require ( " org / arangodb / foxx / model " ) . Model , <nl> - _ = require ( " underscore " ) , <nl> - stub , <nl> - allow , <nl> - expect , <nl> - FunctionStub , <nl> - FunctionMock ; <nl> - <nl> - / * Mini Stub and Mock Framework <nl> - * <nl> - * Sorry for Yak Shaving . But I can ' t take it anymore . <nl> - * / <nl> - <nl> - / / x = stub ( ) ; <nl> - <nl> - stub = function ( ) { <nl> - return function ( ) { } ; <nl> - } ; <nl> - <nl> - / / allow ( x ) . to ( { <nl> - / / receive : " functionName " , <nl> - / / and_return : { x : 1 } <nl> - / / } ) ; <nl> - <nl> - FunctionStub = function ( obj ) { <nl> - this . obj = obj ; <nl> - } ; <nl> - <nl> - FunctionStub . prototype . to = function ( config ) { <nl> - this . obj [ config . receive ] = function ( ) { <nl> - return config . and_return ; <nl> - } ; <nl> - } ; <nl> - <nl> - allow = function ( obj ) { <nl> - return ( new FunctionStub ( obj ) ) ; <nl> - } ; <nl> - <nl> - / / expect ( x ) . to ( { <nl> - / / receive : " functionName " , <nl> - / / withArguments : [ 5 ] , <nl> - / / and_return { x : 1 } <nl> - / / } ) ; <nl> - / / <nl> - / / . . . <nl> - / / <nl> - / / x . assertIsSatisfied ( ) ; <nl> - <nl> - FunctionMock = function ( obj ) { <nl> - this . obj = obj ; <nl> - this . obj . satisfied = true ; <nl> - <nl> - this . obj . assertIsSatisfied = function ( ) { <nl> - assertTrue ( this . satisfied , " Mock Expectation was not satisfied " ) ; <nl> - } ; <nl> - } ; <nl> - <nl> - FunctionMock . prototype . to = function ( config ) { <nl> - var obj = this . obj ; <nl> - obj . satisfied = false ; <nl> - <nl> - this . obj [ config . receive ] = function ( ) { <nl> - var args = Array . prototype . slice . call ( arguments , 0 ) ; <nl> - <nl> - if ( ( config . withArguments = = = undefined ) | | ( _ . isEqual ( args , config . withArguments ) ) ) { <nl> - obj . satisfied = true ; <nl> - } <nl> - <nl> - return config . and_return ; <nl> - } ; <nl> - } ; <nl> - <nl> - expect = function ( obj ) { <nl> - return ( new FunctionMock ( obj ) ) ; <nl> - } ; <nl> + stub_and_mock = require ( " org / arangodb / stub_and_mock " ) , <nl> + stub = stub_and_mock . stub , <nl> + allow = stub_and_mock . allow , <nl> + expect = stub_and_mock . expect ; <nl> <nl> function RepositorySpec ( ) { <nl> var TestRepository , instance , prefix , collection , modelPrototype , model , modelData ; <nl>
|
Moved stub_and_mock to its own module
|
arangodb/arangodb
|
c1bf1b1d11d39f353ab5f36acd93881d11322f14
|
2013-09-16T11:28:51Z
|
mmm a / hphp / compiler / analysis / analysis_result . cpp <nl> ppp b / hphp / compiler / analysis / analysis_result . cpp <nl> int AnalysisResult : : getClassCount ( ) const { <nl> return total ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / static analysis functions <nl> - <nl> - static bool by_source ( const BlockScopePtr & b1 , const BlockScopePtr & b2 ) { <nl> - if ( auto d = b1 - > getStmt ( ) - > getRange ( ) . compare ( b2 - > getStmt ( ) - > getRange ( ) ) ) { <nl> - return d < 0 ; <nl> - } <nl> - return b1 - > getContainingFile ( ) - > getName ( ) < <nl> - b2 - > getContainingFile ( ) - > getName ( ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Program <nl> <nl> mmm a / hphp / runtime / base / apc - file - storage . cpp <nl> ppp b / hphp / runtime / base / apc - file - storage . cpp <nl> void APCFileStorage : : adviseOut ( ) { <nl> } <nl> for ( auto i = 0u ; i < m_fds . size ( ) ; i + + ) { <nl> if ( fadvise_dontneed ( m_fds [ i ] , m_chunkSize ) < 0 ) { <nl> - Logger : : Error ( " Failed to fadvise chunk file % d , fd = % d " , i , m_fds [ i ] ) ; <nl> + Logger : : Error ( " Failed to fadvise chunk file % u , fd = % d " , i , m_fds [ i ] ) ; <nl> } <nl> } <nl> } <nl> bool APCFileStorage : : addFile ( ) { <nl> # error " No implementation for posix_fallocate on your platform . " <nl> # endif <nl> if ( ! couldAllocate ) { <nl> - Logger : : Error ( " Failed to posix_fallocate of size % " PRId64 , m_chunkSize ) ; <nl> + Logger : : Error ( " Failed to posix_fallocate of size % zu " , m_chunkSize ) ; <nl> close ( fd ) ; <nl> return false ; <nl> } <nl> bool APCFileStorage : : addFile ( ) { <nl> char * addr = ( char * ) mmap ( nullptr , m_chunkSize , PROT_READ | PROT_WRITE , <nl> MAP_SHARED , fd , 0 ) ; <nl> if ( addr = = ( char * ) - 1 ) { <nl> - Logger : : Error ( " Failed to mmap % s of size % " PRId64 , name , m_chunkSize ) ; <nl> + Logger : : Error ( " Failed to mmap % s of size % zu " , name , m_chunkSize ) ; <nl> close ( fd ) ; <nl> return false ; <nl> } <nl> mmm a / hphp / runtime / base / heap - collect . cpp <nl> ppp b / hphp / runtime / base / heap - collect . cpp <nl> struct Counter { <nl> } <nl> } ; <nl> <nl> - bool hasNativeData ( const HeapObject * h ) { <nl> - return h - > kind ( ) = = HeaderKind : : NativeObject ; <nl> - } <nl> - <nl> constexpr auto MinMark = GCBits ( 1 ) ; <nl> constexpr auto MaxMark = GCBits ( 3 ) ; <nl> <nl> mmm a / hphp / runtime / base / variable - unserializer . cpp <nl> ppp b / hphp / runtime / base / variable - unserializer . cpp <nl> void throwUnterminatedElement ( ) { <nl> <nl> [ [ noreturn ] ] NEVER_INLINE <nl> void throwLargeStringSize ( int64_t size ) { <nl> - throw Exception ( " Size of serialized string ( % ld ) exceeds max " , size ) ; <nl> + throw Exception ( " Size of serialized string ( % " PRId64 " ) exceeds max " , size ) ; <nl> } <nl> <nl> [ [ noreturn ] ] NEVER_INLINE <nl> void throwNegativeStringSize ( int64_t size ) { <nl> - throw Exception ( " Size of serialized string ( % ld ) must not be negative " , size ) ; <nl> + throw Exception ( " Size of serialized string ( % " PRId64 " ) " <nl> + " must not be negative " , size ) ; <nl> } <nl> <nl> [ [ noreturn ] ] NEVER_INLINE <nl> mmm a / hphp / runtime / ext / gd / ext_gd . cpp <nl> ppp b / hphp / runtime / ext / gd / ext_gd . cpp <nl> Variant HHVM_FUNCTION ( imageaffinematrixget , <nl> <nl> default : <nl> raise_warning ( " imageaffinematrixget ( ) : Invalid type for " <nl> - " element % li " , type ) ; <nl> + " element % " PRId64 , type ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / hphp / runtime / ext / shmop / ext_shmop . cpp <nl> ppp b / hphp / runtime / ext / shmop / ext_shmop . cpp <nl> struct ShmopRequestLocal final : RequestEventHandler { <nl> ShmRec * findShm ( const char * functionName , int64_t shmid ) { <nl> auto const it = m_records . find ( shmid ) ; <nl> if ( it = = m_records . end ( ) ) { <nl> - raise_warning ( " % s ( ) : no shared memory segment with an id of [ % ld ] " , <nl> - functionName , shmid ) ; <nl> + raise_warning ( " % s ( ) : no shared memory segment with an id of " <nl> + " [ % " PRId64 " ] " , functionName , shmid ) ; <nl> return nullptr ; <nl> } else { <nl> return it - > second . get ( ) ; <nl> mmm a / hphp / runtime / server / cli - server . cpp <nl> ppp b / hphp / runtime / server / cli - server . cpp <nl> Array init_ini_settings ( const std : : string & settings ) { <nl> FTRACE ( 5 , " init_ini_settings : unable to set PHP_INI_USER setting : { } " <nl> " ( access = { } ) \ n " , name , detail [ s_access ] . toInt64 ( ) ) ; <nl> Logger : : Warning ( " CLI server received an invalid INI setting : % s " <nl> - " ( access = % li ) " , <nl> + " ( access = % " PRId64 " ) " , <nl> name . data ( ) , detail [ s_access ] . toInt64 ( ) ) ; <nl> } else { <nl> count + + ; <nl> void CLIWorker : : doJob ( int client ) { <nl> if ( api_version ! = CLI_SERVER_API_VERSION ) { <nl> cli_write ( client , " version_bad " ) ; <nl> throw Exception ( <nl> - " CLI_SERVER_API_VERSION ( % lu ) does not match client ( % lu ) " , <nl> + " CLI_SERVER_API_VERSION ( % " PRIu64 " ) " <nl> + " does not match client ( % " PRIu64 " ) " , <nl> CLI_SERVER_API_VERSION , api_version <nl> ) ; <nl> } else { <nl> mmm a / hphp / runtime / vm / member - operations . cpp <nl> ppp b / hphp / runtime / vm / member - operations . cpp <nl> void raise_inout_undefined_index ( TypedValue tv ) { <nl> } <nl> <nl> void raise_inout_undefined_index ( int64_t i ) { <nl> - raise_notice ( " Undefined index on inout parameter : % li " , i ) ; <nl> + raise_notice ( " Undefined index on inout parameter : % " PRId64 , i ) ; <nl> } <nl> <nl> void raise_inout_undefined_index ( const StringData * sd ) { <nl>
|
fix some compiler warnings from mac build
|
facebook/hhvm
|
4b981a623d11d927fa32917d1b2e1b10e1569555
|
2018-04-21T18:33:06Z
|
mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> bool CVideoDatabase : : GetPaths ( set < CStdString > & paths ) <nl> return false ; <nl> } <nl> <nl> - bool CVideoDatabase : : GetPathsForTvShow ( int idShow , vector < int > & paths ) <nl> + bool CVideoDatabase : : GetPathsForTvShow ( int idShow , set < int > & paths ) <nl> { <nl> CStdString strSQL ; <nl> try <nl> bool CVideoDatabase : : GetPathsForTvShow ( int idShow , vector < int > & paths ) <nl> m_pDS - > query ( strSQL . c_str ( ) ) ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - paths . push_back ( m_pDS - > fv ( 0 ) . get_asInt ( ) ) ; <nl> + paths . insert ( m_pDS - > fv ( 0 ) . get_asInt ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> void CVideoDatabase : : GetMusicVideoDirectorsByName ( const CStdString & strSearch , C <nl> } <nl> } <nl> <nl> - void CVideoDatabase : : CleanDatabase ( IVideoInfoScannerObserver * pObserver , const vector < int > * paths ) <nl> + void CVideoDatabase : : CleanDatabase ( IVideoInfoScannerObserver * pObserver , const set < int > * paths ) <nl> { <nl> CGUIDialogProgress * progress = NULL ; <nl> try <nl> void CVideoDatabase : : CleanDatabase ( IVideoInfoScannerObserver * pObserver , const v <nl> } <nl> <nl> CStdString strPaths ; <nl> - for ( unsigned int i = 0 ; i < paths - > size ( ) ; + + i ) <nl> - strPaths . Format ( " % s , % i " , strPaths . Mid ( 0 ) . c_str ( ) , paths - > at ( i ) ) ; <nl> + for ( std : : set < int > : : const_iterator i = paths - > begin ( ) ; i ! = paths - > end ( ) ; + + i ) <nl> + strPaths . AppendFormat ( " , % i " , * i ) ; <nl> sql = PrepareSQL ( " select * from files , path where files . idPath = path . idPath and path . idPath in ( % s ) " , strPaths . Mid ( 1 ) . c_str ( ) ) ; <nl> } <nl> else <nl> void CVideoDatabase : : CleanDatabase ( IVideoInfoScannerObserver * pObserver , const v <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> if ( ! CDirectory : : Exists ( m_pDS - > fv ( " path . strPath " ) . get_asString ( ) ) ) <nl> - strIds . Format ( " % s % i , " , strIds . Mid ( 0 ) , m_pDS - > fv ( " path . idPath " ) . get_asInt ( ) ) ; / / mid since we cannot format the same string <nl> + strIds . AppendFormat ( " % i , " , m_pDS - > fv ( " path . idPath " ) . get_asInt ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> if ( ! strIds . IsEmpty ( ) ) <nl> { <nl> - strIds . TrimLeft ( " " ) ; <nl> strIds . TrimRight ( " , " ) ; <nl> sql = PrepareSQL ( " delete from path where idPath in ( % s ) " , strIds . c_str ( ) ) ; <nl> m_pDS - > exec ( sql . c_str ( ) ) ; <nl> mmm a / xbmc / video / VideoDatabase . h <nl> ppp b / xbmc / video / VideoDatabase . h <nl> class CVideoDatabase : public CDatabase <nl> bool SetPathHash ( const CStdString & path , const CStdString & hash ) ; <nl> bool GetPathHash ( const CStdString & path , CStdString & hash ) ; <nl> bool GetPaths ( std : : set < CStdString > & paths ) ; <nl> - bool GetPathsForTvShow ( int idShow , std : : vector < int > & paths ) ; <nl> + bool GetPathsForTvShow ( int idShow , std : : set < int > & paths ) ; <nl> <nl> / * ! \ brief retrieve subpaths of a given path . Assumes a heirarchical folder structure <nl> \ param basepath the root path to retrieve subpaths for <nl> class CVideoDatabase : public CDatabase <nl> bool HasContent ( VIDEODB_CONTENT_TYPE type ) ; <nl> bool HasSets ( ) const ; <nl> <nl> - void CleanDatabase ( VIDEO : : IVideoInfoScannerObserver * pObserver = NULL , const std : : vector < int > * paths = NULL ) ; <nl> + void CleanDatabase ( VIDEO : : IVideoInfoScannerObserver * pObserver = NULL , const std : : set < int > * paths = NULL ) ; <nl> <nl> / * ! \ brief Add a file to the database , if necessary <nl> If the file is already in the database , we simply return its id . <nl> mmm a / xbmc / video / VideoInfoScanner . cpp <nl> ppp b / xbmc / video / VideoInfoScanner . cpp <nl> namespace VIDEO <nl> if ( hash . IsEmpty ( ) & & ! dbHash . IsEmpty ( ) ) <nl> { <nl> CLog : : Log ( LOGDEBUG , " VideoInfoScanner : Skipping dir ' % s ' as it ' s empty or doesn ' t exist - adding to clean list " , strDirectory . c_str ( ) ) ; <nl> - m_pathsToClean . push_back ( m_database . GetPathId ( strDirectory ) ) ; <nl> + m_pathsToClean . insert ( m_database . GetPathId ( strDirectory ) ) ; <nl> } <nl> else <nl> CLog : : Log ( LOGDEBUG , " VideoInfoScanner : Skipping dir ' % s ' due to no change " , strDirectory . c_str ( ) ) ; <nl> namespace VIDEO <nl> if ( ! m_bStop & & ( content = = CONTENT_MOVIES | | content = = CONTENT_MUSICVIDEOS ) ) <nl> { <nl> m_database . SetPathHash ( strDirectory , hash ) ; <nl> - m_pathsToClean . push_back ( m_database . GetPathId ( strDirectory ) ) ; <nl> + m_pathsToClean . insert ( m_database . GetPathId ( strDirectory ) ) ; <nl> CLog : : Log ( LOGDEBUG , " VideoInfoScanner : Finished adding information from dir % s " , strDirectory . c_str ( ) ) ; <nl> } <nl> } <nl> else <nl> { <nl> - m_pathsToClean . push_back ( m_database . GetPathId ( strDirectory ) ) ; <nl> + m_pathsToClean . insert ( m_database . GetPathId ( strDirectory ) ) ; <nl> CLog : : Log ( LOGDEBUG , " VideoInfoScanner : No ( new ) information was found in dir % s " , strDirectory . c_str ( ) ) ; <nl> } <nl> } <nl> namespace VIDEO <nl> for ( vector < int > : : iterator i = libPaths . begin ( ) ; i < libPaths . end ( ) ; + + i ) <nl> { <nl> if ( find ( seenPaths . begin ( ) , seenPaths . end ( ) , * i ) = = seenPaths . end ( ) ) <nl> - m_pathsToClean . push_back ( * i ) ; <nl> + m_pathsToClean . insert ( * i ) ; <nl> } <nl> } <nl> if ( pDlgProgress ) <nl> namespace VIDEO <nl> } <nl> return ; <nl> } <nl> - m_pathsToClean . push_back ( m_database . GetPathId ( item - > GetPath ( ) ) ) ; <nl> + m_pathsToClean . insert ( m_database . GetPathId ( item - > GetPath ( ) ) ) ; <nl> m_database . GetPathsForTvShow ( m_database . GetTvShowId ( item - > GetPath ( ) ) , m_pathsToClean ) ; <nl> item - > SetProperty ( " hash " , hash ) ; <nl> } <nl> mmm a / xbmc / video / VideoInfoScanner . h <nl> ppp b / xbmc / video / VideoInfoScanner . h <nl> namespace VIDEO <nl> CVideoDatabase m_database ; <nl> std : : set < CStdString > m_pathsToScan ; <nl> std : : set < CStdString > m_pathsToCount ; <nl> - std : : vector < int > m_pathsToClean ; <nl> + std : : set < int > m_pathsToClean ; <nl> CNfoFile m_nfoReader ; <nl> } ; <nl> } <nl>
|
Merge pull request from jmarshallnz / video_cleaning_faster
|
xbmc/xbmc
|
c6e0dd0750acfa436db1d02e8272a26dcb27ec44
|
2012-02-15T09:28:40Z
|
mmm a / tensorflow / compiler / xla / tests / reduce_test . cc <nl> ppp b / tensorflow / compiler / xla / tests / reduce_test . cc <nl> class ReduceTest : public ClientLibraryTestBase { <nl> std : : unique_ptr < GlobalData > input_global_data = <nl> client_ - > TransferToServer ( input_literal ) . ConsumeValueOrDie ( ) ; <nl> <nl> - float expected = 0 . 0 ; <nl> - for ( float item : input_data ) { <nl> - expected + = item ; <nl> - } <nl> + float expected = absl : : c_accumulate ( input_data , 0 . 0f ) ; <nl> ComputeAndCompareR0 < float > ( & builder , expected , { input_global_data . get ( ) } , <nl> ErrorSpec ( 0 . 001 ) ) ; <nl> } <nl>
|
Small code simplication
|
tensorflow/tensorflow
|
7456ae8bc579c940427722b234ff3e0ed7baeae3
|
2020-02-20T21:03:30Z
|
mmm a / tests / ci_build / Dockerfile . gpu_build <nl> ppp b / tests / ci_build / Dockerfile . gpu_build <nl> RUN \ <nl> <nl> # NCCL2 ( License : https : / / docs . nvidia . com / deeplearning / sdk / nccl - sla / index . html ) <nl> RUN \ <nl> - export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> + export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> export NCCL_VERSION = 2 . 7 . 5 - 1 & & \ <nl> apt - get update & & \ <nl> apt - get install - y - - allow - downgrades - - allow - change - held - packages libnccl2 = $ { NCCL_VERSION } + cuda $ { CUDA_SHORT } libnccl - dev = $ { NCCL_VERSION } + cuda $ { CUDA_SHORT } <nl> mmm a / tests / ci_build / Dockerfile . gpu_build_centos6 <nl> ppp b / tests / ci_build / Dockerfile . gpu_build_centos6 <nl> RUN \ <nl> <nl> # NCCL2 ( License : https : / / docs . nvidia . com / deeplearning / sdk / nccl - sla / index . html ) <nl> RUN \ <nl> - export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> + export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> export NCCL_VERSION = 2 . 4 . 8 - 1 & & \ <nl> wget https : / / developer . download . nvidia . com / compute / machine - learning / repos / rhel7 / x86_64 / nvidia - machine - learning - repo - rhel7 - 1 . 0 . 0 - 1 . x86_64 . rpm & & \ <nl> rpm - i nvidia - machine - learning - repo - rhel7 - 1 . 0 . 0 - 1 . x86_64 . rpm & & \ <nl> mmm a / tests / ci_build / Dockerfile . jvm_gpu_build <nl> ppp b / tests / ci_build / Dockerfile . jvm_gpu_build <nl> RUN \ <nl> <nl> # NCCL2 ( License : https : / / docs . nvidia . com / deeplearning / sdk / nccl - sla / index . html ) <nl> RUN \ <nl> - export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> + export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> export NCCL_VERSION = 2 . 4 . 8 - 1 & & \ <nl> wget https : / / developer . download . nvidia . com / compute / machine - learning / repos / rhel7 / x86_64 / nvidia - machine - learning - repo - rhel7 - 1 . 0 . 0 - 1 . x86_64 . rpm & & \ <nl> rpm - i nvidia - machine - learning - repo - rhel7 - 1 . 0 . 0 - 1 . x86_64 . rpm & & \ <nl> mmm a / tests / ci_build / Dockerfile . rmm <nl> ppp b / tests / ci_build / Dockerfile . rmm <nl> RUN \ <nl> <nl> # NCCL2 ( License : https : / / docs . nvidia . com / deeplearning / sdk / nccl - sla / index . html ) <nl> RUN \ <nl> - export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> + export CUDA_SHORT = ` echo $ CUDA_VERSION_ARG | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] ' ` & & \ <nl> export NCCL_VERSION = 2 . 7 . 5 - 1 & & \ <nl> apt - get update & & \ <nl> apt - get install - y - - allow - downgrades - - allow - change - held - packages libnccl2 = $ { NCCL_VERSION } + cuda $ { CUDA_SHORT } libnccl - dev = $ { NCCL_VERSION } + cuda $ { CUDA_SHORT } <nl> mmm a / tests / ci_build / ci_build . sh <nl> ppp b / tests / ci_build / ci_build . sh <nl> WORKSPACE = " $ { WORKSPACE : - $ { SCRIPT_DIR } / . . / . . / } " <nl> DOCKER_IMG_NAME = " xgb - ci . $ { CONTAINER_TYPE } " <nl> <nl> # Append cuda version if available <nl> - CUDA_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | egrep - o ' CUDA_VERSION = [ 0 - 9 ] + \ . [ 0 - 9 ] + ' | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] + ' ) <nl> + CUDA_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | grep - o - E ' CUDA_VERSION = [ 0 - 9 ] + \ . [ 0 - 9 ] + ' | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] + ' ) <nl> # Append jdk version if available <nl> - JDK_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | egrep - o ' JDK_VERSION = [ 0 - 9 ] + ' | egrep - o ' [ 0 - 9 ] + ' ) <nl> + JDK_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | grep - o - E ' JDK_VERSION = [ 0 - 9 ] + ' | grep - o - E ' [ 0 - 9 ] + ' ) <nl> # Append cmake version if available <nl> - CMAKE_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | egrep - o ' CMAKE_VERSION = [ 0 - 9 ] + \ . [ 0 - 9 ] + ' | egrep - o ' [ 0 - 9 ] + \ . [ 0 - 9 ] + ' ) <nl> + CMAKE_VERSION = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | grep - o - E ' CMAKE_VERSION = [ 0 - 9 ] + \ . [ 0 - 9 ] + ' | grep - o - E ' [ 0 - 9 ] + \ . [ 0 - 9 ] + ' ) <nl> # Append R version if available <nl> - USE_R35 = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | egrep - o ' USE_R35 = [ 0 - 9 ] + ' | egrep - o ' [ 0 - 9 ] + $ ' ) <nl> + USE_R35 = $ ( echo " $ { CI_DOCKER_BUILD_ARG } " | grep - o - E ' USE_R35 = [ 0 - 9 ] + ' | grep - o - E ' [ 0 - 9 ] + $ ' ) <nl> if [ [ $ { USE_R35 } = = " 1 " ] ] ; then <nl> USE_R35 = " _r35 " <nl> elif [ [ $ { USE_R35 } = = " 0 " ] ] ; then <nl>
|
[ ci ] replace ' egrep ' with ' grep - E ' ( )
|
dmlc/xgboost
|
e1de390e6e3003bd19f1e191103c1b9ff9d53546
|
2020-10-27T19:05:48Z
|
mmm a / dbms / include / DB / Interpreters / InterpreterOptimizeQuery . h <nl> ppp b / dbms / include / DB / Interpreters / InterpreterOptimizeQuery . h <nl> class InterpreterOptimizeQuery <nl> { <nl> public : <nl> InterpreterOptimizeQuery ( ASTPtr query_ptr_ , Context & context_ ) <nl> - : query_ptr ( query_ptr_ ) , context ( context_ ) { } <nl> + : query_ptr ( query_ptr_ ) , context ( context_ ) , <nl> + aio_threshold ( context_ . getSettings ( ) . min_bytes_to_use_direct_io ) { } <nl> <nl> void execute ( ) <nl> { <nl> const ASTOptimizeQuery & ast = typeid_cast < const ASTOptimizeQuery & > ( * query_ptr ) ; <nl> StoragePtr table = context . getTable ( ast . database , ast . table ) ; <nl> auto table_lock = table - > lockStructure ( true ) ; <nl> - table - > optimize ( ) ; <nl> + table - > optimize ( aio_threshold ) ; <nl> } <nl> <nl> private : <nl> ASTPtr query_ptr ; <nl> Context context ; <nl> + size_t aio_threshold ; <nl> } ; <nl> <nl> <nl> mmm a / dbms / include / DB / Storages / IStorage . h <nl> ppp b / dbms / include / DB / Storages / IStorage . h <nl> class IStorage : private boost : : noncopyable , public ITableDeclaration <nl> / * * Выполнить какую - либо фоновую работу . Например , объединение кусков в таблице типа MergeTree . <nl> * Возвращает - была ли выполнена какая - либо работа . <nl> * / <nl> - virtual bool optimize ( ) <nl> + virtual bool optimize ( size_t aio_threshold ) <nl> { <nl> throw Exception ( " Method optimize is not supported by storage " + getName ( ) , ErrorCodes : : NOT_IMPLEMENTED ) ; <nl> } <nl> mmm a / dbms / include / DB / Storages / MergeTree / MergeTreeDataMerger . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / MergeTreeDataMerger . h <nl> class MergeTreeDataMerger <nl> * / <nl> MergeTreeData : : DataPartPtr mergeParts ( <nl> const MergeTreeData : : DataPartsVector & parts , const String & merged_name , MergeList : : Entry & merge_entry , <nl> - MergeTreeData : : Transaction * out_transaction = nullptr , DiskSpaceMonitor : : Reservation * disk_reservation = nullptr ) ; <nl> + size_t aio_threshold , MergeTreeData : : Transaction * out_transaction = nullptr , <nl> + DiskSpaceMonitor : : Reservation * disk_reservation = nullptr ) ; <nl> <nl> / / / Примерное количество места на диске , нужное для мерджа . С запасом . <nl> size_t estimateDiskSpaceForMerge ( const MergeTreeData : : DataPartsVector & parts ) ; <nl> mmm a / dbms / include / DB / Storages / MergeTree / MergedBlockOutputStream . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / MergedBlockOutputStream . h <nl> class IMergedBlockOutputStream : public IBlockOutputStream <nl> MergeTreeData & storage_ , <nl> size_t min_compress_block_size_ , <nl> size_t max_compress_block_size_ , <nl> - CompressionMethod compression_method_ ) <nl> + CompressionMethod compression_method_ , <nl> + size_t aio_threshold_ ) <nl> : storage ( storage_ ) , <nl> min_compress_block_size ( min_compress_block_size_ ) , <nl> max_compress_block_size ( max_compress_block_size_ ) , <nl> - aio_threshold ( storage . context . getSettingsRef ( ) . min_bytes_to_use_direct_io ) , <nl> + aio_threshold ( aio_threshold_ ) , <nl> compression_method ( compression_method_ ) <nl> { <nl> } <nl> class MergedBlockOutputStream : public IMergedBlockOutputStream <nl> MergeTreeData & storage_ , <nl> String part_path_ , <nl> const NamesAndTypesList & columns_list_ , <nl> - CompressionMethod compression_method , <nl> - const std : : map < std : : string , size_t > * merged_column_to_size_ = nullptr ) <nl> + CompressionMethod compression_method ) <nl> : IMergedBlockOutputStream ( <nl> storage_ , storage_ . context . getSettings ( ) . min_compress_block_size , <nl> - storage_ . context . getSettings ( ) . max_compress_block_size , compression_method ) , <nl> + storage_ . context . getSettings ( ) . max_compress_block_size , compression_method , <nl> + storage_ . context . getSettings ( ) . min_bytes_to_use_direct_io ) , <nl> columns_list ( columns_list_ ) , part_path ( part_path_ ) <nl> { <nl> - Poco : : File ( part_path ) . createDirectories ( ) ; <nl> - <nl> - if ( storage . mode ! = MergeTreeData : : Unsorted ) <nl> - { <nl> - index_file_stream = new WriteBufferFromFile ( part_path + " primary . idx " , DBMS_DEFAULT_BUFFER_SIZE , O_TRUNC | O_CREAT | O_WRONLY ) ; <nl> - index_stream = new HashingWriteBuffer ( * index_file_stream ) ; <nl> - } <nl> + init ( ) ; <nl> + for ( const auto & it : columns_list ) <nl> + addStream ( part_path , it . name , * it . type ) ; <nl> + } <nl> <nl> + MergedBlockOutputStream ( <nl> + MergeTreeData & storage_ , <nl> + String part_path_ , <nl> + const NamesAndTypesList & columns_list_ , <nl> + CompressionMethod compression_method , <nl> + const std : : map < std : : string , size_t > & merged_column_to_size_ , <nl> + size_t aio_threshold_ ) <nl> + : IMergedBlockOutputStream ( <nl> + storage_ , storage_ . context . getSettings ( ) . min_compress_block_size , <nl> + storage_ . context . getSettings ( ) . max_compress_block_size , compression_method , <nl> + aio_threshold_ ) , <nl> + columns_list ( columns_list_ ) , part_path ( part_path_ ) <nl> + { <nl> + init ( ) ; <nl> for ( const auto & it : columns_list ) <nl> { <nl> size_t estimated_size = 0 ; <nl> - if ( merged_column_to_size_ ! = nullptr ) <nl> - { <nl> - auto it2 = merged_column_to_size_ - > find ( it . name ) ; <nl> - if ( it2 ! = merged_column_to_size_ - > end ( ) ) <nl> - estimated_size = it2 - > second ; <nl> - } <nl> + auto it2 = merged_column_to_size_ . find ( it . name ) ; <nl> + if ( it2 ! = merged_column_to_size_ . end ( ) ) <nl> + estimated_size = it2 - > second ; <nl> addStream ( part_path , it . name , * it . type , estimated_size ) ; <nl> } <nl> } <nl> class MergedBlockOutputStream : public IMergedBlockOutputStream <nl> return marks_count ; <nl> } <nl> <nl> + private : <nl> + void init ( ) <nl> + { <nl> + Poco : : File ( part_path ) . createDirectories ( ) ; <nl> + <nl> + if ( storage . mode ! = MergeTreeData : : Unsorted ) <nl> + { <nl> + index_file_stream = new WriteBufferFromFile ( part_path + " primary . idx " , DBMS_DEFAULT_BUFFER_SIZE , O_TRUNC | O_CREAT | O_WRONLY ) ; <nl> + index_stream = new HashingWriteBuffer ( * index_file_stream ) ; <nl> + } <nl> + } <nl> + <nl> private : <nl> NamesAndTypesList columns_list ; <nl> String part_path ; <nl> class MergedColumnOnlyOutputStream : public IMergedBlockOutputStream <nl> MergedColumnOnlyOutputStream ( MergeTreeData & storage_ , String part_path_ , bool sync_ , CompressionMethod compression_method ) <nl> : IMergedBlockOutputStream ( <nl> storage_ , storage_ . context . getSettings ( ) . min_compress_block_size , <nl> - storage_ . context . getSettings ( ) . max_compress_block_size , compression_method ) , <nl> + storage_ . context . getSettings ( ) . max_compress_block_size , compression_method , <nl> + storage_ . context . getSettings ( ) . min_bytes_to_use_direct_io ) , <nl> part_path ( part_path_ ) , sync ( sync_ ) <nl> { <nl> } <nl> mmm a / dbms / include / DB / Storages / StorageBuffer . h <nl> ppp b / dbms / include / DB / Storages / StorageBuffer . h <nl> friend class BufferBlockOutputStream ; <nl> <nl> / / / Сбрасывает все буферы в подчинённую таблицу . <nl> void shutdown ( ) override ; <nl> - bool optimize ( ) override ; <nl> + bool optimize ( size_t aio_threshold ) override ; <nl> <nl> void rename ( const String & new_path_to_db , const String & new_database_name , const String & new_table_name ) override { name = new_table_name ; } <nl> <nl> mmm a / dbms / include / DB / Storages / StorageMaterializedView . h <nl> ppp b / dbms / include / DB / Storages / StorageMaterializedView . h <nl> class StorageMaterializedView : public StorageView { <nl> <nl> BlockOutputStreamPtr write ( ASTPtr query ) override ; <nl> void drop ( ) override ; <nl> - bool optimize ( ) override ; <nl> + bool optimize ( size_t aio_threshold ) override ; <nl> <nl> BlockInputStreams read ( <nl> const Names & column_names , <nl> mmm a / dbms / include / DB / Storages / StorageMergeTree . h <nl> ppp b / dbms / include / DB / Storages / StorageMergeTree . h <nl> friend class MergeTreeBlockOutputStream ; <nl> <nl> / * * Выполнить очередной шаг объединения кусков . <nl> * / <nl> - bool optimize ( ) override <nl> + bool optimize ( size_t aio_threshold ) override <nl> { <nl> - return merge ( true ) ; <nl> + return merge ( aio_threshold , true ) ; <nl> } <nl> <nl> void dropPartition ( const Field & partition , bool detach , const Settings & settings ) override ; <nl> friend class MergeTreeBlockOutputStream ; <nl> * Если aggressive - выбрать куски , не обращая внимание на соотношение размеров и их новизну ( для запроса OPTIMIZE ) . <nl> * Возвращает , получилось ли что - нибудь объединить . <nl> * / <nl> - bool merge ( bool aggressive = false , BackgroundProcessingPool : : Context * context = nullptr ) ; <nl> + bool merge ( size_t aio_threshold , bool aggressive = false , BackgroundProcessingPool : : Context * context = nullptr ) ; <nl> <nl> bool mergeTask ( BackgroundProcessingPool : : Context & context ) ; <nl> <nl> mmm a / dbms / include / DB / Storages / StorageReplicatedMergeTree . h <nl> ppp b / dbms / include / DB / Storages / StorageReplicatedMergeTree . h <nl> class StorageReplicatedMergeTree : public IStorage <nl> <nl> BlockOutputStreamPtr write ( ASTPtr query ) override ; <nl> <nl> - bool optimize ( ) override ; <nl> + bool optimize ( size_t aio_threshold ) override ; <nl> <nl> void alter ( const AlterCommands & params , const String & database_name , const String & table_name , Context & context ) override ; <nl> <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeDataMerger . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataMerger . cpp <nl> bool MergeTreeDataMerger : : selectPartsToMerge ( MergeTreeData : : DataPartsVector & pa <nl> / / / parts должны быть отсортированы . <nl> MergeTreeData : : DataPartPtr MergeTreeDataMerger : : mergeParts ( <nl> const MergeTreeData : : DataPartsVector & parts , const String & merged_name , MergeList : : Entry & merge_entry , <nl> - MergeTreeData : : Transaction * out_transaction , DiskSpaceMonitor : : Reservation * disk_reservation ) <nl> + size_t aio_threshold , MergeTreeData : : Transaction * out_transaction , <nl> + DiskSpaceMonitor : : Reservation * disk_reservation ) <nl> { <nl> merge_entry - > num_parts = parts . size ( ) ; <nl> <nl> MergeTreeData : : DataPartPtr MergeTreeDataMerger : : mergeParts ( <nl> data . getFullPath ( ) + parts [ i ] - > name + ' / ' , DEFAULT_MERGE_BLOCK_SIZE , union_column_names , data , <nl> parts [ i ] , ranges , false , nullptr , " " ) ; <nl> <nl> + input - > setAIOThreshold ( aio_threshold ) ; <nl> + <nl> input - > setProgressCallback ( [ & merge_entry , rows_total ] ( const Progress & value ) <nl> { <nl> const auto new_rows_read = __sync_add_and_fetch ( & merge_entry - > rows_read , value . rows ) ; <nl> MergeTreeData : : DataPartPtr MergeTreeDataMerger : : mergeParts ( <nl> <nl> const String new_part_tmp_path = data . getFullPath ( ) + " tmp_ " + merged_name + " / " ; <nl> <nl> - MergedBlockOutputStream to { data , new_part_tmp_path , union_columns , CompressionMethod : : LZ4 , & merged_column_to_size } ; <nl> + MergedBlockOutputStream to { data , new_part_tmp_path , union_columns , CompressionMethod : : LZ4 , merged_column_to_size , aio_threshold } ; <nl> <nl> merged_stream - > readPrefix ( ) ; <nl> to . writePrefix ( ) ; <nl> mmm a / dbms / src / Storages / StorageBuffer . cpp <nl> ppp b / dbms / src / Storages / StorageBuffer . cpp <nl> void StorageBuffer : : shutdown ( ) <nl> if ( flush_thread . joinable ( ) ) <nl> flush_thread . join ( ) ; <nl> <nl> - optimize ( ) ; <nl> + / / / Параметр игнорируется . <nl> + optimize ( 0 ) ; <nl> } <nl> <nl> <nl> - bool StorageBuffer : : optimize ( ) <nl> + bool StorageBuffer : : optimize ( size_t / * aio_threshold * / ) <nl> { <nl> flushAllBuffers ( false ) ; <nl> <nl> void StorageBuffer : : alter ( const AlterCommands & params , const String & database_ <nl> auto lock = lockStructureForAlter ( ) ; <nl> <nl> / / / Чтобы не осталось блоков старой структуры . <nl> - optimize ( ) ; <nl> + / / / Параметр игнорируется . <nl> + optimize ( 0 ) ; <nl> <nl> params . apply ( * columns , materialized_columns , alias_columns , column_defaults ) ; <nl> InterpreterAlterQuery : : updateMetadata ( database_name , table_name , <nl> mmm a / dbms / src / Storages / StorageMaterializedView . cpp <nl> ppp b / dbms / src / Storages / StorageMaterializedView . cpp <nl> void StorageMaterializedView : : drop ( ) <nl> } <nl> } <nl> <nl> - bool StorageMaterializedView : : optimize ( ) { <nl> - return data - > optimize ( ) ; <nl> + bool StorageMaterializedView : : optimize ( size_t aio_threshold ) { <nl> + return data - > optimize ( aio_threshold ) ; <nl> } <nl> <nl> <nl> mmm a / dbms / src / Storages / StorageMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageMergeTree . cpp <nl> void StorageMergeTree : : alter ( const AlterCommands & params , const String & databa <nl> } <nl> } <nl> <nl> - bool StorageMergeTree : : merge ( bool aggressive , BackgroundProcessingPool : : Context * pool_context ) <nl> + bool StorageMergeTree : : merge ( size_t aio_threshold , bool aggressive , BackgroundProcessingPool : : Context * pool_context ) <nl> { <nl> auto structure_lock = lockStructure ( true ) ; <nl> <nl> bool StorageMergeTree : : merge ( bool aggressive , BackgroundProcessingPool : : Context <nl> } <nl> <nl> const auto & merge_entry = context . getMergeList ( ) . insert ( database_name , table_name , merged_name ) ; <nl> - merger . mergeParts ( merging_tagger - > parts , merged_name , * merge_entry , nullptr , & * merging_tagger - > reserved_space ) ; <nl> + merger . mergeParts ( merging_tagger - > parts , merged_name , * merge_entry , aio_threshold , nullptr , & * merging_tagger - > reserved_space ) ; <nl> <nl> return true ; <nl> } <nl> <nl> - bool StorageMergeTree : : mergeTask ( BackgroundProcessingPool : : Context & context ) <nl> + bool StorageMergeTree : : mergeTask ( BackgroundProcessingPool : : Context & background_processing_pool_context ) <nl> { <nl> if ( shutdown_called ) <nl> return false ; <nl> try <nl> { <nl> - return merge ( false , & context ) ; <nl> + size_t aio_threshold = context . getSettings ( ) . min_bytes_to_use_direct_io ; <nl> + return merge ( aio_threshold , false , & background_processing_pool_context ) ; <nl> } <nl> catch ( Exception & e ) <nl> { <nl> mmm a / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> bool StorageReplicatedMergeTree : : executeLogEntry ( const LogEntry & entry , Backgro <nl> <nl> const auto & merge_entry = context . getMergeList ( ) . insert ( database_name , table_name , entry . new_part_name ) ; <nl> MergeTreeData : : Transaction transaction ; <nl> - MergeTreeData : : DataPartPtr part = merger . mergeParts ( parts , entry . new_part_name , * merge_entry , & transaction ) ; <nl> + size_t aio_threshold = context . getSettings ( ) . min_bytes_to_use_direct_io ; <nl> + MergeTreeData : : DataPartPtr part = merger . mergeParts ( parts , entry . new_part_name , * merge_entry , aio_threshold , & transaction ) ; <nl> <nl> zkutil : : Ops ops ; <nl> checkPartAndAddToZooKeeper ( part , ops ) ; <nl> BlockOutputStreamPtr StorageReplicatedMergeTree : : write ( ASTPtr query ) <nl> } <nl> <nl> <nl> - bool StorageReplicatedMergeTree : : optimize ( ) <nl> + bool StorageReplicatedMergeTree : : optimize ( size_t aio_threshold ) <nl> { <nl> / / / Померджим какие - нибудь куски из директории unreplicated . <nl> / / / TODO : Мерджить реплицируемые куски тоже . <nl> bool StorageReplicatedMergeTree : : optimize ( ) <nl> return false ; <nl> <nl> const auto & merge_entry = context . getMergeList ( ) . insert ( database_name , table_name , merged_name ) ; <nl> - unreplicated_merger - > mergeParts ( parts , merged_name , * merge_entry ) ; <nl> + unreplicated_merger - > mergeParts ( parts , merged_name , * merge_entry , aio_threshold ) ; <nl> return true ; <nl> } <nl> <nl>
|
dbms : Server : Added support for the client - side parameter min_bytes_to_use_direct_io in OPTIMIZE . [ # METR - 15090 ]
|
ClickHouse/ClickHouse
|
5cd9ed058256fef5095506f58fcb6c9be3d5f70b
|
2015-04-10T15:31:51Z
|
mmm a / modules / planning / common / speed / st_boundary . cc <nl> ppp b / modules / planning / common / speed / st_boundary . cc <nl> bool STBoundary : : GetUnblockSRange ( const double curr_time , double * s_upper , <nl> } <nl> <nl> const double r = <nl> - ( left = = right <nl> - ? 0 . 0 <nl> - : ( curr_time - upper_points_ [ left ] . t ( ) ) / <nl> - ( upper_points_ [ right ] . t ( ) - upper_points_ [ left ] . t ( ) ) ) ; <nl> + ( left = = right ? 0 . 0 : ( curr_time - upper_points_ [ left ] . t ( ) ) / <nl> + ( upper_points_ [ right ] . t ( ) - <nl> + upper_points_ [ left ] . t ( ) ) ) ; <nl> <nl> double upper_cross_s = <nl> upper_points_ [ left ] . s ( ) + <nl> bool STBoundary : : GetUnblockSRange ( const double curr_time , double * s_upper , <nl> } else if ( boundary_type_ = = BoundaryType : : OVERTAKE ) { <nl> * s_lower = std : : fmax ( * s_lower , upper_cross_s ) ; <nl> } else { <nl> - AERROR < < " boundary_type is not supported . boundary_type : " <nl> + ADEBUG < < " boundary_type is not supported . boundary_type : " <nl> < < static_cast < int > ( boundary_type_ ) ; <nl> - return false ; <nl> } <nl> return true ; <nl> } <nl> bool STBoundary : : GetBoundarySRange ( const double curr_time , double * s_upper , <nl> return false ; <nl> } <nl> const double r = <nl> - ( left = = right <nl> - ? 0 . 0 <nl> - : ( curr_time - upper_points_ [ left ] . t ( ) ) / <nl> - ( upper_points_ [ right ] . t ( ) - upper_points_ [ left ] . t ( ) ) ) ; <nl> + ( left = = right ? 0 . 0 : ( curr_time - upper_points_ [ left ] . t ( ) ) / <nl> + ( upper_points_ [ right ] . t ( ) - <nl> + upper_points_ [ left ] . t ( ) ) ) ; <nl> <nl> * s_upper = upper_points_ [ left ] . s ( ) + <nl> r * ( upper_points_ [ right ] . s ( ) - upper_points_ [ left ] . s ( ) ) ; <nl>
|
Planning : ignore UNKNOWN and KEEPCLEAR obstacle in GetUnblockSRange ( )
|
ApolloAuto/apollo
|
78b109d360682e7ef6845f514f442e73e10f761b
|
2019-12-12T22:05:38Z
|
mmm a / tensorflow / compiler / xla / service / gpu / BUILD <nl> ppp b / tensorflow / compiler / xla / service / gpu / BUILD <nl> cc_library ( <nl> deps = [ <nl> " : backend_configs " , <nl> " : buffer_allocations " , <nl> + " : cudnn_batchnorm_runner " , <nl> " : elemental_ir_emitter " , <nl> " : gpu_constants " , <nl> " : gpu_conv_runner " , <nl> cc_library ( <nl> " : backend_configs " , <nl> " : buffer_allocations " , <nl> " : cusolver_context " , <nl> + " : cudnn_batchnorm_runner " , <nl> " : gpu_conv_runner " , <nl> " : gpu_debug_info_manager " , <nl> " : gpu_types " , <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " cudnn_batchnorm_runner " , <nl> + srcs = [ " cudnn_batchnorm_runner . cc " ] , <nl> + hdrs = [ " cudnn_batchnorm_runner . h " ] , <nl> + deps = [ <nl> + " : backend_configs " , <nl> + " : ir_emission_utils " , <nl> + " : stream_executor_util " , <nl> + " / / tensorflow / compiler / xla : shape_util " , <nl> + " / / tensorflow / compiler / xla : status " , <nl> + " / / tensorflow / compiler / xla : status_macros " , <nl> + " / / tensorflow / compiler / xla : statusor " , <nl> + " / / tensorflow / compiler / xla : types " , <nl> + " / / tensorflow / compiler / xla : util " , <nl> + " / / tensorflow / compiler / xla : xla_data_proto " , <nl> + " / / tensorflow / compiler / xla / service : hlo " , <nl> + " / / tensorflow / core : stream_executor_no_cuda " , <nl> + " @ com_google_absl / / absl / strings " , <nl> + " @ com_google_absl / / absl / types : optional " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " gpu_conv_rewriter " , <nl> srcs = [ " gpu_conv_rewriter . cc " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . 9ce6851ae4a2f <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_runner . cc <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 / xla / service / gpu / cudnn_batchnorm_runner . h " <nl> + <nl> + # include " absl / strings / str_cat . h " <nl> + # include " tensorflow / compiler / xla / layout_util . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / backend_configs . pb . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / stream_executor_util . h " <nl> + # include " tensorflow / compiler / xla / shape_util . h " <nl> + # include " tensorflow / compiler / xla / status_macros . h " <nl> + # include " tensorflow / compiler / xla / util . h " <nl> + <nl> + namespace xla { <nl> + namespace gpu { <nl> + namespace { <nl> + <nl> + struct CudnnBatchNormParamsCommon { <nl> + se : : DeviceMemoryBase operand ; <nl> + se : : dnn : : BatchDescriptor operand_desc ; <nl> + se : : dnn : : BatchDescriptor scale_offset_desc ; <nl> + se : : DeviceMemory < float > scale ; <nl> + float epsilon ; <nl> + } ; <nl> + <nl> + struct CudnnBatchNormForwardInferenceParams { <nl> + CudnnBatchNormParamsCommon common ; <nl> + se : : DeviceMemoryBase output ; <nl> + se : : DeviceMemory < float > offset ; <nl> + se : : DeviceMemory < float > mean ; <nl> + se : : DeviceMemory < float > variance ; <nl> + } ; <nl> + <nl> + struct CudnnBatchNormForwardTrainingParams { <nl> + CudnnBatchNormParamsCommon common ; <nl> + se : : DeviceMemoryBase output_data ; <nl> + se : : DeviceMemory < float > offset ; <nl> + se : : DeviceMemory < float > output_mean ; <nl> + se : : DeviceMemory < float > output_inv_stddev ; <nl> + } ; <nl> + <nl> + struct CudnnBatchNormBackwardParams { <nl> + CudnnBatchNormParamsCommon common ; <nl> + se : : DeviceMemoryBase output_grad_data ; <nl> + se : : DeviceMemoryBase grad_output ; <nl> + se : : DeviceMemory < float > output_grad_scale ; <nl> + se : : DeviceMemory < float > output_grad_offset ; <nl> + se : : DeviceMemory < float > mean ; <nl> + se : : DeviceMemory < float > inv_stddev ; <nl> + } ; <nl> + <nl> + struct DnnBatchDescriptors { <nl> + se : : dnn : : BatchDescriptor input_desc ; <nl> + se : : dnn : : BatchDescriptor scale_offset_desc ; <nl> + } ; <nl> + <nl> + DnnBatchDescriptors MakeBatchNormDescriptors ( const Shape & shape , <nl> + int64 feature_index ) { <nl> + std : : vector < int64 > logical_to_physical = <nl> + LayoutUtil : : MakeLogicalToPhysical ( shape . layout ( ) ) ; <nl> + <nl> + auto physical_dim_size = [ & ] ( int64 physical_dim ) { <nl> + return shape . dimensions ( LayoutUtil : : Major ( shape . layout ( ) , physical_dim ) ) ; <nl> + } ; <nl> + <nl> + / / Batchnorm only cares about the location of the depth ( aka " feature " ) dim . <nl> + / / The other dims are all treated the same . Thus we can use the kBatchDepthYX <nl> + / / cudnn layout for any XLA shape + layout , even XLA shapes that don ' t have <nl> + / / exactly 4 dimensions : We put everything that comes before the feature dim <nl> + / / into " batch " , and everything that comes after the feature dim into " Y " . <nl> + int64 batch_size = 1 ; <nl> + int64 y_size = 1 ; <nl> + int64 physical_dim ; <nl> + for ( physical_dim = 0 ; physical_dim ! = logical_to_physical [ feature_index ] ; <nl> + + + physical_dim ) { <nl> + CHECK_LT ( physical_dim , shape . dimensions_size ( ) ) ; <nl> + batch_size * = physical_dim_size ( physical_dim ) ; <nl> + } <nl> + + + physical_dim ; / / Skip the feature dimension . <nl> + for ( ; physical_dim < shape . dimensions_size ( ) ; + + physical_dim ) { <nl> + y_size * = physical_dim_size ( physical_dim ) ; <nl> + } <nl> + <nl> + DnnBatchDescriptors batch_descs ; <nl> + batch_descs . input_desc . set_layout ( se : : dnn : : DataLayout : : kBatchDepthYX ) <nl> + . set_count ( batch_size ) <nl> + . set_feature_map_count ( shape . dimensions ( feature_index ) ) <nl> + . set_height ( y_size ) <nl> + . set_width ( 1 ) ; <nl> + <nl> + batch_descs . scale_offset_desc . set_layout ( se : : dnn : : DataLayout : : kBatchDepthYX ) <nl> + . set_feature_map_count ( batch_descs . input_desc . feature_map_count ( ) ) <nl> + . set_height ( 1 ) <nl> + . set_width ( 1 ) <nl> + . set_count ( 1 ) ; <nl> + <nl> + return batch_descs ; <nl> + } <nl> + <nl> + void AssignCommonParams ( const HloInstruction * batchnorm , <nl> + CudnnBatchNormParamsCommon * params , <nl> + const se : : DeviceMemoryBase & operand , <nl> + const se : : DeviceMemory < float > & scale , float epsilon , <nl> + int64 feature_index ) { <nl> + / / The BatchNormTraining HLO outputs a tuple of three elements : output data , <nl> + / / batch mean , and batch variance . We want to make our descriptors based on <nl> + / / the shape of the output data . Batchnorm backward call outputs a tuple of <nl> + / / three elements : grad data , grad offset , and grad scale . We want to make <nl> + / / our descriptors based on the shape of the grad data . <nl> + const Shape & shape = batchnorm - > shape ( ) . IsTuple ( ) <nl> + ? batchnorm - > shape ( ) . tuple_shapes ( 0 ) <nl> + : batchnorm - > shape ( ) ; <nl> + DnnBatchDescriptors batch_descs = <nl> + MakeBatchNormDescriptors ( shape , feature_index ) ; <nl> + params - > operand_desc = batch_descs . input_desc ; <nl> + params - > scale_offset_desc = batch_descs . scale_offset_desc ; <nl> + params - > operand = operand ; <nl> + params - > scale = scale ; <nl> + params - > epsilon = epsilon ; <nl> + } <nl> + <nl> + template < typename ElemType > <nl> + void RunCudnnBatchNormForwardInferenceImpl ( <nl> + CudnnBatchNormForwardInferenceParams * params , se : : Stream * stream ) { <nl> + se : : DeviceMemory < float > null_device_ptr ( nullptr ) ; <nl> + auto output_buf = se : : DeviceMemory < ElemType > ( params - > output ) ; <nl> + stream - > ThenBatchNormalizationForward ( <nl> + se : : DeviceMemory < ElemType > ( params - > common . operand ) , <nl> + params - > common . scale , / / <nl> + params - > offset , / / <nl> + params - > mean , / / <nl> + params - > variance , / / <nl> + / * side_input = * / null_device_ptr , params - > common . operand_desc , / / <nl> + params - > common . scale_offset_desc , params - > common . epsilon , / / <nl> + se : : dnn : : ActivationMode : : kNone , / / <nl> + & output_buf , / / <nl> + / * batch_mean = * / nullptr , / / <nl> + / * batch_var = * / nullptr , / / <nl> + / * saved_mean = * / nullptr , / / <nl> + / * saved_inv_var = * / nullptr , / / <nl> + / * is_training = * / false , / / <nl> + / * var_to_inv_var = * / nullptr , / / <nl> + / * inv_var_to_var = * / nullptr , / / <nl> + / * reserve_space_allocator = * / nullptr , / / <nl> + / * workspace_allocator = * / nullptr ) ; <nl> + } <nl> + <nl> + template < typename ElemType > <nl> + void RunCudnnBatchNormForwardTrainingImpl ( <nl> + CudnnBatchNormForwardTrainingParams * params , se : : Stream * stream ) { <nl> + se : : DeviceMemory < float > null_device_ptr ( nullptr ) ; <nl> + auto output_data = se : : DeviceMemory < ElemType > ( params - > output_data ) ; <nl> + stream - > ThenBatchNormalizationForward ( <nl> + se : : DeviceMemory < ElemType > ( params - > common . operand ) , <nl> + params - > common . scale , / / <nl> + params - > offset , / / <nl> + / * estimated_mean = * / null_device_ptr , / / <nl> + / * estimated_variance = * / null_device_ptr , / / <nl> + / * side_input = * / null_device_ptr , / / <nl> + params - > common . operand_desc , / / <nl> + params - > common . scale_offset_desc , / / <nl> + params - > common . epsilon , / / <nl> + se : : dnn : : ActivationMode : : kNone , / / <nl> + & output_data , / / <nl> + / * batch_mean = * / & null_device_ptr , / / <nl> + / * batch_var = * / & null_device_ptr , / / <nl> + / * saved_mean = * / & params - > output_mean , / / <nl> + / * saved_inv_var = * / & params - > output_inv_stddev , / / <nl> + / * is_training = * / true , / / <nl> + / * var_to_inv_var = * / nullptr , / / <nl> + / * inv_var_to_var = * / nullptr , / / <nl> + / * reserve_space_allocator = * / nullptr , / / <nl> + / * workspace_allocator = * / nullptr ) ; <nl> + } <nl> + <nl> + template < typename ElemType > <nl> + void RunCudnnBatchNormBackwardImpl ( CudnnBatchNormBackwardParams * params , <nl> + se : : Stream * stream ) { <nl> + se : : DeviceMemory < float > null_device_ptr ( nullptr ) ; <nl> + auto output_grad_data = se : : DeviceMemory < ElemType > ( params - > output_grad_data ) ; <nl> + stream - > ThenBatchNormalizationBackward ( <nl> + se : : DeviceMemory < ElemType > ( params - > grad_output ) , / / <nl> + se : : DeviceMemory < ElemType > ( params - > common . operand ) , / / <nl> + params - > common . scale , / / <nl> + params - > mean , / / <nl> + params - > inv_stddev , / / <nl> + params - > common . operand_desc , / / <nl> + params - > common . scale_offset_desc , / / <nl> + params - > common . epsilon , / / <nl> + & output_grad_data , / / <nl> + & params - > output_grad_scale , / / <nl> + & params - > output_grad_offset , / / <nl> + / * reserve_space_allocator = * / nullptr , / / <nl> + / * workspace_allocator = * / nullptr ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + Status RunCudnnBatchNormForwardInference ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > offset , se : : DeviceMemory < float > mean , <nl> + se : : DeviceMemory < float > variance , float epsilon , int64 feature_index , <nl> + se : : Stream * stream ) { <nl> + CudnnBatchNormForwardInferenceParams inference_params ; <nl> + AssignCommonParams ( batchnorm , & inference_params . common , operand , scale , <nl> + epsilon , feature_index ) ; <nl> + inference_params . offset = offset ; <nl> + inference_params . mean = mean ; <nl> + inference_params . variance = variance ; <nl> + inference_params . output = output ; <nl> + <nl> + PrimitiveType output_primitive_type = batchnorm - > shape ( ) . element_type ( ) ; <nl> + switch ( output_primitive_type ) { <nl> + case F16 : <nl> + RunCudnnBatchNormForwardInferenceImpl < Eigen : : half > ( & inference_params , <nl> + stream ) ; <nl> + break ; <nl> + case F32 : <nl> + RunCudnnBatchNormForwardInferenceImpl < float > ( & inference_params , stream ) ; <nl> + break ; <nl> + default : <nl> + return Unimplemented ( " Primitive type not implemented for \ " % s \ " " , <nl> + batchnorm - > ToString ( ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RunCudnnBatchNormForwardTraining ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output_data , se : : DeviceMemory < float > output_mean , <nl> + se : : DeviceMemory < float > output_inv_stddev , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > offset , float epsilon , int64 feature_index , <nl> + se : : Stream * stream ) { <nl> + CudnnBatchNormForwardTrainingParams forward_params ; <nl> + AssignCommonParams ( batchnorm , & forward_params . common , operand , scale , epsilon , <nl> + feature_index ) ; <nl> + forward_params . offset = offset ; <nl> + forward_params . output_data = output_data ; <nl> + forward_params . output_mean = output_mean ; <nl> + forward_params . output_inv_stddev = output_inv_stddev ; <nl> + <nl> + PrimitiveType output_primitive_type = <nl> + batchnorm - > shape ( ) . tuple_shapes ( 0 ) . element_type ( ) ; <nl> + switch ( output_primitive_type ) { <nl> + case F16 : <nl> + RunCudnnBatchNormForwardTrainingImpl < Eigen : : half > ( & forward_params , <nl> + stream ) ; <nl> + break ; <nl> + case F32 : <nl> + RunCudnnBatchNormForwardTrainingImpl < float > ( & forward_params , stream ) ; <nl> + break ; <nl> + default : <nl> + return Unimplemented ( " Primitive type not implemented for \ " % s \ " " , <nl> + batchnorm - > ToString ( ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RunCudnnBatchNormBackward ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output_grad_data , se : : DeviceMemoryBase grad_output , <nl> + se : : DeviceMemory < float > output_grad_scale , <nl> + se : : DeviceMemory < float > output_grad_offset , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > mean , se : : DeviceMemory < float > inv_stddev , <nl> + float epsilon , int64 feature_index , se : : Stream * stream ) { <nl> + CudnnBatchNormBackwardParams backward_params ; <nl> + AssignCommonParams ( batchnorm , & backward_params . common , operand , scale , <nl> + epsilon , feature_index ) ; <nl> + backward_params . output_grad_data = output_grad_data ; <nl> + backward_params . grad_output = grad_output ; <nl> + backward_params . output_grad_scale = output_grad_scale ; <nl> + backward_params . output_grad_offset = output_grad_offset ; <nl> + backward_params . mean = mean ; <nl> + backward_params . inv_stddev = inv_stddev ; <nl> + <nl> + PrimitiveType output_primitive_type = <nl> + batchnorm - > shape ( ) . tuple_shapes ( 0 ) . element_type ( ) ; <nl> + switch ( output_primitive_type ) { <nl> + case F16 : <nl> + RunCudnnBatchNormBackwardImpl < Eigen : : half > ( & backward_params , stream ) ; <nl> + break ; <nl> + case F32 : <nl> + RunCudnnBatchNormBackwardImpl < float > ( & backward_params , stream ) ; <nl> + break ; <nl> + default : <nl> + return Unimplemented ( " Primitive type not implemented for \ " % s \ " " , <nl> + batchnorm - > ToString ( ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + } / / namespace gpu <nl> + } / / namespace xla <nl> new file mode 100755 <nl> index 0000000000000 . . 9a630d013f733 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_runner . h <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> + # ifndef TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CUDNN_BATCHNORM_RUNNER_H_ <nl> + # define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CUDNN_BATCHNORM_RUNNER_H_ <nl> + <nl> + # include " absl / types / optional . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / ir_emission_utils . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_instruction . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_instructions . h " <nl> + # include " tensorflow / compiler / xla / status . h " <nl> + # include " tensorflow / compiler / xla / statusor . h " <nl> + # include " tensorflow / compiler / xla / types . h " <nl> + # include " tensorflow / compiler / xla / xla_data . pb . h " <nl> + # include " tensorflow / core / platform / stream_executor_no_cuda . h " <nl> + <nl> + namespace xla { <nl> + namespace gpu { <nl> + <nl> + Status RunCudnnBatchNormForwardInference ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > offset , se : : DeviceMemory < float > mean , <nl> + se : : DeviceMemory < float > variance , float epsilon , int64 feature_index , <nl> + se : : Stream * stream ) ; <nl> + <nl> + Status RunCudnnBatchNormForwardTraining ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output_data , se : : DeviceMemory < float > output_mean , <nl> + se : : DeviceMemory < float > output_inv_stddev , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > offset , float epsilon , int64 feature_index , <nl> + se : : Stream * stream ) ; <nl> + <nl> + Status RunCudnnBatchNormBackward ( <nl> + const HloInstruction * batchnorm , se : : DeviceMemoryBase operand , <nl> + se : : DeviceMemoryBase output_grad_data , se : : DeviceMemoryBase grad_output , <nl> + se : : DeviceMemory < float > output_grad_scale , <nl> + se : : DeviceMemory < float > output_grad_offset , se : : DeviceMemory < float > scale , <nl> + se : : DeviceMemory < float > mean , se : : DeviceMemory < float > inv_stddev , <nl> + float epsilon , int64 feature_index , se : : Stream * stream ) ; <nl> + } / / namespace gpu <nl> + } / / namespace xla <nl> + # endif / / TENSORFLOW_COMPILER_XLA_SERVICE_GPU_CUDNN_BATCHNORM_RUNNER_H_ <nl> mmm a / tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_thunk . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_thunk . cc <nl> limitations under the License . <nl> # include < string > <nl> <nl> # include " absl / strings / str_cat . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_runner . h " <nl> # include " tensorflow / compiler / xla / service / gpu / hlo_execution_profiler . h " <nl> # include " tensorflow / compiler / xla / service / gpu / ir_emission_utils . h " <nl> # include " tensorflow / compiler / xla / types . h " <nl> namespace gpu { <nl> <nl> namespace dnn = se : : dnn ; <nl> <nl> - static std : : pair < dnn : : BatchDescriptor / * input_desc * / , <nl> - dnn : : BatchDescriptor / * scale_offset_desc * / > <nl> - MakeDescriptors ( const Shape & shape , int64 feature_index ) { <nl> - std : : vector < int64 > logical_to_physical = <nl> - LayoutUtil : : MakeLogicalToPhysical ( shape . layout ( ) ) ; <nl> - <nl> - auto physical_dim_size = [ & ] ( int64 physical_dim ) { <nl> - return shape . dimensions ( LayoutUtil : : Major ( shape . layout ( ) , physical_dim ) ) ; <nl> - } ; <nl> - <nl> - / / Batchnorm only cares about the location of the depth ( aka " feature " ) dim . <nl> - / / The other dims are all treated the same . Thus we can use the kBatchDepthYX <nl> - / / cudnn layout for any XLA shape + layout , even XLA shapes that don ' t have <nl> - / / exactly 4 dimensions : We put everything that comes before the feature dim <nl> - / / into " batch " , and everything that comes after the feature dim into " Y " . <nl> - int64 batch_size = 1 ; <nl> - int64 y_size = 1 ; <nl> - int64 physical_dim ; <nl> - for ( physical_dim = 0 ; physical_dim ! = logical_to_physical [ feature_index ] ; <nl> - + + physical_dim ) { <nl> - CHECK_LT ( physical_dim , shape . dimensions_size ( ) ) ; <nl> - batch_size * = physical_dim_size ( physical_dim ) ; <nl> + namespace { <nl> + void CheckInputOutputPrimitivetypeAreValid ( const HloInstruction * hlo ) { <nl> + / / All input and output statistics variables must be F32 . Also , the last <nl> + / / operand for CudnnBatchNormForwardInference , CudnnBatchNormForwardTraining , <nl> + / / and CudnnBatchNormBackward is the feature_index which must be S64 . <nl> + / / The allowed types for non - statistics variables are as follows : <nl> + / / CudnnBatchNormForwardInference : <nl> + / / operand [ 0 ] : { half , float } <nl> + / / out [ 0 ] : { half , float } <nl> + / / CudnnBatchNormForwardTraining : <nl> + / / operand [ 0 ] : { half , float } <nl> + / / out [ 0 ] : { half , float } <nl> + / / CudnnBatchNormBackward : <nl> + / / operand [ 0 ] : { half , float } <nl> + / / operand [ 4 ] : { half , float } <nl> + / / out [ 0 ] : { half , float } <nl> + / / Note non - statistics inputs and outputs mentioned above should be of the <nl> + / / same type . <nl> + <nl> + / / Check Inputs . <nl> + int64 num_operands = hlo - > operand_count ( ) ; <nl> + PrimitiveType operand_primitive_type = <nl> + hlo - > operand ( 0 ) - > shape ( ) . element_type ( ) ; <nl> + CHECK ( operand_primitive_type = = F16 | | operand_primitive_type = = F32 ) <nl> + < < " Not yet implemented " ; <nl> + <nl> + for ( int i = 1 ; i < num_operands - 2 ; i + + ) { <nl> + if ( hlo - > custom_call_target ( ) = = kCudnnBatchNormBackwardCallTarget & & <nl> + i = = 4 ) { <nl> + / / The first operand to batchnorm grad is the input and the 4th operand is <nl> + / / the grad_output , both of which can be Eigen : : half . <nl> + CHECK_EQ ( hlo - > operand ( i ) - > shape ( ) . element_type ( ) , operand_primitive_type ) <nl> + < < " Invalid datatype " ; <nl> + continue ; <nl> + } <nl> + CHECK_EQ ( hlo - > operand ( i ) - > shape ( ) . element_type ( ) , F32 ) <nl> + < < " Not yet implemented " ; <nl> } <nl> - + + physical_dim ; / / Skip the feature dimension . <nl> - for ( ; physical_dim < shape . dimensions_size ( ) ; + + physical_dim ) { <nl> - y_size * = physical_dim_size ( physical_dim ) ; <nl> - } <nl> - <nl> - dnn : : BatchDescriptor input_desc ; <nl> - input_desc . set_layout ( dnn : : DataLayout : : kBatchDepthYX ) <nl> - . set_count ( batch_size ) <nl> - . set_feature_map_count ( shape . dimensions ( feature_index ) ) <nl> - . set_height ( y_size ) <nl> - . set_width ( 1 ) ; <nl> <nl> - dnn : : BatchDescriptor scale_offset_desc ; <nl> - scale_offset_desc . set_layout ( dnn : : DataLayout : : kBatchDepthYX ) <nl> - . set_feature_map_count ( input_desc . feature_map_count ( ) ) <nl> - . set_height ( 1 ) <nl> - . set_width ( 1 ) <nl> - . set_count ( 1 ) ; <nl> - <nl> - return std : : make_pair ( input_desc , scale_offset_desc ) ; <nl> + / / The last operand is the feature index which must be int64 . <nl> + CHECK_EQ ( hlo - > operand ( num_operands - 1 ) - > shape ( ) . element_type ( ) , S64 ) <nl> + < < " Not yet impelemented " ; <nl> + <nl> + / / Check Outputs . <nl> + if ( hlo - > shape ( ) . IsTuple ( ) ) { <nl> + CHECK_EQ ( hlo - > shape ( ) . tuple_shapes ( 0 ) . element_type ( ) , <nl> + operand_primitive_type ) <nl> + < < " Invalid datatype " ; <nl> + <nl> + for ( int j = 1 ; j < hlo - > shape ( ) . tuple_shapes_size ( ) ; j + + ) { <nl> + CHECK_EQ ( hlo - > shape ( ) . tuple_shapes ( j ) . element_type ( ) , F32 ) <nl> + < < " Not yet implemented " ; <nl> + } <nl> + } else { <nl> + CHECK_EQ ( hlo - > shape ( ) . element_type ( ) , operand_primitive_type ) <nl> + < < " Invalid datatype " ; <nl> + } <nl> } <nl> + } / / namespace <nl> <nl> CudnnBatchNormForwardInferenceThunk : : CudnnBatchNormForwardInferenceThunk ( <nl> const BufferAllocation : : Slice & operand , <nl> CudnnBatchNormForwardInferenceThunk : : CudnnBatchNormForwardInferenceThunk ( <nl> kCudnnBatchNormForwardInferenceCallTarget ) ; <nl> CHECK ( <nl> LayoutUtil : : LayoutsInShapesEqual ( hlo - > shape ( ) , hlo - > operand ( 0 ) - > shape ( ) ) ) ; <nl> - CHECK_EQ ( hlo - > shape ( ) . element_type ( ) , F32 ) < < " Not yet implemented " ; <nl> + CheckInputOutputPrimitivetypeAreValid ( hlo ) ; <nl> } <nl> <nl> Status CudnnBatchNormForwardInferenceThunk : : ExecuteOnStream ( <nl> const ExecuteParams & params ) { <nl> - auto & stream = * params . stream ; <nl> auto & buffer_allocations = * params . buffer_allocations ; <nl> - <nl> - dnn : : BatchDescriptor operand_desc ; <nl> - dnn : : BatchDescriptor scale_offset_desc ; <nl> - std : : tie ( operand_desc , scale_offset_desc ) = <nl> - MakeDescriptors ( hlo_instruction ( ) - > shape ( ) , feature_index_ ) ; <nl> - <nl> - se : : DeviceMemory < float > null_device_ptr ( nullptr ) ; <nl> - se : : DeviceMemory < float > output ( buffer_allocations . GetDeviceAddress ( output_ ) ) ; <nl> auto op_profiler = <nl> params . profiler - > MakeScopedInstructionProfiler ( hlo_instruction ( ) ) ; <nl> - stream . ThenBatchNormalizationForward ( <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( operand_ ) ) , <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( scale_ ) ) , <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( offset_ ) ) , <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( mean_ ) ) , <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( variance_ ) ) , <nl> - / * side_input = * / null_device_ptr , <nl> - operand_desc , / / <nl> - scale_offset_desc , / / <nl> - epsilon_ , / / <nl> - se : : dnn : : ActivationMode : : kNone , / / <nl> - & output , / / <nl> - / * batch_mean = * / nullptr , / / <nl> - / * batch_var = * / nullptr , / / <nl> - / * saved_mean = * / nullptr , / / <nl> - / * saved_inv_var = * / nullptr , / / <nl> - / * is_training = * / false , / / <nl> - / * var_to_inv_var = * / nullptr , / / <nl> - / * inv_var_to_var = * / nullptr , / / <nl> - / * reserve_space_allocator = * / nullptr , / / <nl> - / * workspace_allocator = * / nullptr ) ; <nl> + se : : DeviceMemoryBase output_base = <nl> + buffer_allocations . GetDeviceAddress ( output_ ) ; <nl> + se : : DeviceMemoryBase operand = buffer_allocations . GetDeviceAddress ( operand_ ) ; <nl> + se : : DeviceMemory < float > scale ( buffer_allocations . GetDeviceAddress ( scale_ ) ) ; <nl> + se : : DeviceMemory < float > offset ( buffer_allocations . GetDeviceAddress ( offset_ ) ) ; <nl> + se : : DeviceMemory < float > mean ( buffer_allocations . GetDeviceAddress ( mean_ ) ) ; <nl> + se : : DeviceMemory < float > variance ( <nl> + buffer_allocations . GetDeviceAddress ( variance_ ) ) ; <nl> + auto & stream = * params . stream ; <nl> + TF_RETURN_IF_ERROR ( RunCudnnBatchNormForwardInference ( <nl> + hlo_instruction ( ) , operand , output_base , scale , offset , mean , variance , <nl> + epsilon_ , feature_index_ , & stream ) ) ; <nl> <nl> if ( ! stream . ok ( ) ) { <nl> return InternalError ( " BatchNormalizationForward call failed . " ) ; <nl> CudnnBatchNormForwardTrainingThunk : : CudnnBatchNormForwardTrainingThunk ( <nl> CHECK_EQ ( hlo - > shape ( ) . tuple_shapes_size ( ) , 3 ) ; <nl> CHECK ( LayoutUtil : : LayoutsInShapesEqual ( hlo - > shape ( ) . tuple_shapes ( 0 ) , <nl> hlo - > operand ( 0 ) - > shape ( ) ) ) ; <nl> - for ( const auto & tuple_shape : hlo - > shape ( ) . tuple_shapes ( ) ) { <nl> - CHECK_EQ ( tuple_shape . element_type ( ) , F32 ) < < " Not yet implemented " ; <nl> - } <nl> + CheckInputOutputPrimitivetypeAreValid ( hlo ) ; <nl> } <nl> <nl> Status CudnnBatchNormForwardTrainingThunk : : ExecuteOnStream ( <nl> const ExecuteParams & params ) { <nl> - auto & stream = * params . stream ; <nl> auto & buffer_allocations = * params . buffer_allocations ; <nl> + se : : DeviceMemoryBase operand = buffer_allocations . GetDeviceAddress ( operand_ ) ; <nl> + se : : DeviceMemoryBase output_data = <nl> + buffer_allocations . GetDeviceAddress ( output_data_ ) ; <nl> <nl> - dnn : : BatchDescriptor operand_desc ; <nl> - dnn : : BatchDescriptor scale_offset_desc ; <nl> - / / The BatchNormTraining HLO outputs a tuple of three elements : output data , <nl> - / / batch mean , and batch variance . We want to make our descriptors based on <nl> - / / the shape of the output data . <nl> - std : : tie ( operand_desc , scale_offset_desc ) = MakeDescriptors ( <nl> - hlo_instruction ( ) - > shape ( ) . tuple_shapes ( 0 ) , feature_index_ ) ; <nl> - <nl> - se : : DeviceMemory < float > output_data ( <nl> - buffer_allocations . GetDeviceAddress ( output_data_ ) ) ; <nl> se : : DeviceMemory < float > output_mean ( <nl> buffer_allocations . GetDeviceAddress ( output_mean_ ) ) ; <nl> se : : DeviceMemory < float > output_inv_stddev ( <nl> Status CudnnBatchNormForwardTrainingThunk : : ExecuteOnStream ( <nl> se : : DeviceMemory < float > null_device_ptr ( nullptr ) ; <nl> auto op_profiler = <nl> params . profiler - > MakeScopedInstructionProfiler ( hlo_instruction ( ) ) ; <nl> - stream . ThenBatchNormalizationForward ( <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( operand_ ) ) , <nl> + auto & stream = * params . stream ; <nl> + TF_RETURN_IF_ERROR ( RunCudnnBatchNormForwardTraining ( <nl> + hlo_instruction ( ) , operand , output_data , output_mean , output_inv_stddev , <nl> se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( scale_ ) ) , <nl> se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( offset_ ) ) , <nl> - / * estimated_mean = * / null_device_ptr , <nl> - / * estimated_variance = * / null_device_ptr , <nl> - / * side_input = * / null_device_ptr , <nl> - operand_desc , / / <nl> - scale_offset_desc , / / <nl> - epsilon_ , / / <nl> - se : : dnn : : ActivationMode : : kNone , / / <nl> - & output_data , / / <nl> - / * batch_mean = * / & null_device_ptr , / / <nl> - / * batch_var = * / & null_device_ptr , / / <nl> - / * saved_mean = * / & output_mean , / / <nl> - / * saved_inv_var = * / & output_inv_stddev , / / <nl> - / * is_training = * / true , / / <nl> - / * var_to_inv_var = * / nullptr , / / <nl> - / * inv_var_to_var = * / nullptr , / / <nl> - / * reserve_space_allocator = * / nullptr , / / <nl> - / * workspace_allocator = * / nullptr ) ; <nl> + epsilon_ , feature_index_ , & stream ) ) ; <nl> <nl> / / Write the output tuple . <nl> const int kNumOutputs = 3 ; <nl> CudnnBatchNormBackwardThunk : : CudnnBatchNormBackwardThunk ( <nl> hlo - > operand ( 0 ) - > shape ( ) ) ) ; <nl> CHECK ( LayoutUtil : : LayoutsInShapesEqual ( hlo - > shape ( ) . tuple_shapes ( 0 ) , <nl> hlo - > operand ( 4 ) - > shape ( ) ) ) ; <nl> - for ( const auto & tuple_shape : hlo - > shape ( ) . tuple_shapes ( ) ) { <nl> - CHECK_EQ ( tuple_shape . element_type ( ) , F32 ) < < " Not yet implemented " ; <nl> - } <nl> + CheckInputOutputPrimitivetypeAreValid ( hlo ) ; <nl> } <nl> <nl> Status CudnnBatchNormBackwardThunk : : ExecuteOnStream ( <nl> const ExecuteParams & params ) { <nl> - auto & stream = * params . stream ; <nl> auto & buffer_allocations = * params . buffer_allocations ; <nl> - <nl> - dnn : : BatchDescriptor operand_desc ; <nl> - dnn : : BatchDescriptor scale_offset_desc ; <nl> - <nl> - / / This call outputs a tuple of three elements : grad data , grad offset , and <nl> - / / grad scale . We want to make our descriptors based on the shape of the grad <nl> - / / data . <nl> - std : : tie ( operand_desc , scale_offset_desc ) = MakeDescriptors ( <nl> - hlo_instruction ( ) - > shape ( ) . tuple_shapes ( 0 ) , feature_index_ ) ; <nl> - <nl> - se : : DeviceMemory < float > output_grad_data ( <nl> - buffer_allocations . GetDeviceAddress ( output_grad_data_ ) ) ; <nl> + se : : DeviceMemoryBase operand = buffer_allocations . GetDeviceAddress ( operand_ ) ; <nl> + se : : DeviceMemoryBase output_grad_data = <nl> + buffer_allocations . GetDeviceAddress ( output_grad_data_ ) ; <nl> + se : : DeviceMemoryBase grad_output = <nl> + buffer_allocations . GetDeviceAddress ( grad_output_ ) ; <nl> se : : DeviceMemory < float > output_grad_scale ( <nl> buffer_allocations . GetDeviceAddress ( output_grad_scale_ ) ) ; <nl> se : : DeviceMemory < float > output_grad_offset ( <nl> Status CudnnBatchNormBackwardThunk : : ExecuteOnStream ( <nl> <nl> auto op_profiler = <nl> params . profiler - > MakeScopedInstructionProfiler ( hlo_instruction ( ) ) ; <nl> - stream . ThenBatchNormalizationBackward ( <nl> - se : : DeviceMemory < float > ( <nl> - buffer_allocations . GetDeviceAddress ( grad_output_ ) ) , <nl> - se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( operand_ ) ) , <nl> + se : : Stream * stream = params . stream ; <nl> + TF_RETURN_IF_ERROR ( RunCudnnBatchNormBackward ( <nl> + hlo_instruction ( ) , operand , output_grad_data , grad_output , <nl> + output_grad_scale , output_grad_offset , <nl> se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( scale_ ) ) , <nl> se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( mean_ ) ) , <nl> se : : DeviceMemory < float > ( buffer_allocations . GetDeviceAddress ( inv_stddev_ ) ) , <nl> - operand_desc , scale_offset_desc , epsilon_ , & output_grad_data , <nl> - & output_grad_scale , & output_grad_offset , nullptr , nullptr ) ; <nl> + epsilon_ , feature_index_ , stream ) ) ; <nl> <nl> / / Write the output tuple . <nl> const int kNumOutputs = 3 ; <nl> Status CudnnBatchNormBackwardThunk : : ExecuteOnStream ( <nl> ptrs [ 2 ] = output_grad_offset . opaque ( ) ; <nl> se : : DeviceMemory < void * > tuple_addr ( <nl> buffer_allocations . GetDeviceAddress ( output_tuple_ ) ) ; <nl> - SafeH2DMemcpy ( tuple_addr , std : : move ( ptrs ) , kNumOutputs , & stream ) ; <nl> + SafeH2DMemcpy ( tuple_addr , std : : move ( ptrs ) , kNumOutputs , stream ) ; <nl> <nl> - if ( ! stream . ok ( ) ) { <nl> + if ( ! stream - > ok ( ) ) { <nl> return InternalError ( " BatchNormalizationBackward call failed . " ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> old mode 100644 <nl> new mode 100755 <nl>
|
Merge pull request from AyanmoI : amoitra / bn_cudnn
|
tensorflow/tensorflow
|
ed10ca36b82703be769a0604de0dfbd230b420ef
|
2019-10-11T01:12:12Z
|
mmm a / atom / browser / ui / cocoa / atom_touch_bar . mm <nl> ppp b / atom / browser / ui / cocoa / atom_touch_bar . mm <nl> - ( void ) sliderAction : ( id ) sender { <nl> window_ - > NotifyTouchBarItemInteraction ( [ item_id UTF8String ] , details ) ; <nl> } <nl> <nl> - - ( NSString * ) idFromIdentifier : ( NSString * ) identifier withPrefix : ( NSString * ) prefix { <nl> + - ( NSString * ) idFromIdentifier : ( NSString * ) identifier <nl> + withPrefix : ( NSString * ) prefix { <nl> return [ identifier substringFromIndex : [ prefix length ] ] ; <nl> } <nl> <nl>
|
: art :
|
electron/electron
|
506b42b5633e69babffbe5b079ab658378cb741f
|
2017-03-03T22:00:39Z
|
mmm a / hphp / runtime / vm / jit / check . cpp <nl> ppp b / hphp / runtime / vm / jit / check . cpp <nl> <nl> # include " hphp / runtime / vm / jit / phys - reg . h " <nl> # include " hphp / runtime / vm / jit / block . h " <nl> # include " hphp / runtime / vm / jit / cfg . h " <nl> + # include " hphp / runtime / vm / jit / id - set . h " <nl> <nl> namespace HPHP { namespace JIT { <nl> <nl> bool checkTmpsSpanningCalls ( const IRUnit & unit ) { <nl> / / CallBuiltin is ok because it is not a php - level call . ( It will <nl> / / call a C + + helper and we can push / pop around it normally . ) <nl> auto isCall = [ & ] ( Opcode op ) { <nl> - return op = = Call | | op = = CallArray ; <nl> + return op = = Call | | op = = CallArray | | op = = ContEnter ; <nl> } ; <nl> <nl> - typedef StateVector < SSATmp , bool > State ; <nl> + auto ignoreSrc = [ & ] ( IRInstruction & inst , SSATmp * src ) { <nl> + / * <nl> + * ReDefSP , ReDefGeneratorSP , and TakeStack , and FramePtr / StKptr - typed <nl> + * tmps are used only for stack analysis in the simplifier and therefore <nl> + * may live across calls . In particular , ReDef [ Generator ] SP are used to <nl> + * bridge the logical stack of the caller when a callee is inlined so that <nl> + * analysis does not scan into the callee stack when searching for a type <nl> + * of value in the caller . <nl> + * <nl> + * Tmps defined by DefConst are always available and not assigned to <nl> + * registers . However , results of LdConst may not span calls . <nl> + * / <nl> + return ( inst . is ( ReDefSP ) & & src - > isA ( Type : : StkPtr ) ) | | <nl> + ( inst . is ( ReDefGeneratorSP ) & & src - > isA ( Type : : StkPtr ) ) | | <nl> + inst . is ( TakeStack ) | | <nl> + src - > isA ( Type : : StkPtr ) | | <nl> + src - > inst ( ) - > is ( DefConst ) | | <nl> + src - > isA ( Type : : FramePtr ) ; <nl> + } ; <nl> <nl> + StateVector < Block , IdSet < SSATmp > > livein ( unit , IdSet < SSATmp > ( ) ) ; <nl> bool isValid = true ; <nl> - forPreorderDoms ( <nl> - blocks . front ( ) , children , State ( unit , false ) , <nl> - [ & ] ( Block * b , State & state ) { <nl> - for ( auto & inst : * b ) { <nl> - for ( auto & src : inst . srcs ( ) ) { <nl> - / * <nl> - * These SSATmp ' s are used only for stack analysis in the <nl> - * simplifier and therefore may live across calls . In particular <nl> - * these instructions are used to bridge the logical stack of the <nl> - * caller when a callee is inlined so that analysis does not scan <nl> - * into the callee stack when searching for a type of value in the <nl> - * caller . <nl> - * / <nl> - if ( inst . op ( ) = = ReDefSP & & src - > isA ( Type : : StkPtr ) ) continue ; <nl> - if ( inst . op ( ) = = ReDefGeneratorSP & & src - > isA ( Type : : StkPtr ) ) { <nl> - continue ; <nl> - } <nl> - <nl> - if ( src - > isA ( Type : : FramePtr ) ) continue ; <nl> - if ( src - > isConst ( ) ) continue ; <nl> - if ( ! state [ src ] ) { <nl> - auto msg = folly : : format ( " checkTmpsSpanningCalls failed \ n " <nl> - " instruction : { } \ n " <nl> - " src : { } \ n " , <nl> - inst . toString ( ) , <nl> - src - > toString ( ) ) . str ( ) ; <nl> - std : : cerr < < msg ; <nl> - FTRACE ( 1 , " { } " , msg ) ; <nl> - isValid = false ; <nl> - } <nl> - } <nl> - <nl> - / * <nl> - * Php calls kill all live temporaries . We can ' t keep them <nl> - * alive across the call because we currently have no <nl> - * callee - saved registers in our abi , and all translations <nl> - * share the same spill slots . <nl> - * / <nl> - if ( isCall ( inst . op ( ) ) ) state . reset ( ) ; <nl> - <nl> - for ( auto & d : inst . dsts ( ) ) { <nl> - state [ d ] = true ; <nl> - } <nl> + postorderWalk ( unit , [ & ] ( Block * block ) { <nl> + auto & live = livein [ block ] ; <nl> + if ( auto taken = block - > taken ( ) ) live = livein [ taken ] ; <nl> + if ( auto next = block - > next ( ) ) live | = livein [ next ] ; <nl> + for ( auto it = block - > end ( ) ; it ! = block - > begin ( ) ; ) { <nl> + auto & inst = * - - it ; <nl> + for ( auto & dst : inst . dsts ( ) ) { <nl> + live . erase ( dst ) ; <nl> + } <nl> + if ( isCall ( inst . op ( ) ) ) { <nl> + live . forEach ( [ & ] ( uint32_t tmp ) { <nl> + auto msg = folly : : format ( " checkTmpsSpanningCalls failed \ n " <nl> + " instruction : { } \ n " <nl> + " src : t { } \ n " , <nl> + inst . toString ( ) , tmp ) . str ( ) ; <nl> + std : : cerr < < msg ; <nl> + FTRACE ( 1 , " { } " , msg ) ; <nl> + isValid = false ; <nl> + } ) ; <nl> + } <nl> + for ( auto * src : inst . srcs ( ) ) { <nl> + if ( ! ignoreSrc ( inst , src ) ) live . add ( src ) ; <nl> } <nl> } <nl> - ) ; <nl> + } ) ; <nl> <nl> return isValid ; <nl> } <nl>
|
Strengthen checkTmpsSpanningCalls ( )
|
facebook/hhvm
|
d5a96369acc7eadaac737b54bae7f991ae9439f2
|
2014-01-03T04:04:37Z
|
mmm a / modules / planning / common / path / path_data . cc <nl> ppp b / modules / planning / common / path / path_data . cc <nl> namespace planning { <nl> using SLPoint = apollo : : common : : SLPoint ; <nl> using Vec2d = apollo : : common : : math : : Vec2d ; <nl> <nl> - void PathData : : set_discretized_path ( const DiscretizedPath & path ) { <nl> + bool PathData : : set_discretized_path ( const DiscretizedPath & path ) { <nl> + if ( reference_line_ = = nullptr ) { <nl> + AERROR < < " Should NOT set discretized path when reference line is nullptr . " <nl> + " Please set reference line first . " ; <nl> + return false ; <nl> + } <nl> discretized_path_ = path ; <nl> + if ( ! CartesianToFrenet ( discretized_path_ , & frenet_path_ ) ) { <nl> + AERROR < < " Fail to transfer discretized path to frenet path . " ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> } <nl> <nl> bool PathData : : set_frenet_path ( const FrenetFramePath & frenet_path ) { <nl> if ( reference_line_ = = nullptr ) { <nl> - AERROR < < " Should NOT set frenet path with reference line is nullptr . " <nl> + AERROR < < " Should NOT set frenet path when reference line is nullptr . " <nl> " Please set reference line first . " ; <nl> return false ; <nl> } <nl> bool PathData : : set_frenet_path ( const FrenetFramePath & frenet_path ) { <nl> return true ; <nl> } <nl> <nl> - void PathData : : set_discretized_path ( <nl> - const std : : vector < common : : PathPoint > & path_points ) { <nl> - discretized_path_ . set_points ( path_points ) ; <nl> - } <nl> - <nl> const DiscretizedPath & PathData : : discretized_path ( ) const { <nl> return discretized_path_ ; <nl> } <nl> const FrenetFramePath & PathData : : frenet_frame_path ( ) const { <nl> } <nl> <nl> void PathData : : set_reference_line ( const ReferenceLine * reference_line ) { <nl> - / / Clear ( ) ; <nl> + Clear ( ) ; <nl> reference_line_ = reference_line ; <nl> } <nl> <nl> bool PathData : : FrenetToCartesian ( const FrenetFramePath & frenet_path , <nl> return true ; <nl> } <nl> <nl> + bool PathData : : CartesianToFrenet ( const DiscretizedPath & discretized_path , <nl> + FrenetFramePath * const frenet_path ) { <nl> + DCHECK_NOTNULL ( frenet_path ) ; <nl> + std : : vector < common : : FrenetFramePoint > frenet_frame_points ; <nl> + <nl> + for ( const auto & path_point : discretized_path . points ( ) ) { <nl> + SLPoint sl_point ; <nl> + if ( ! reference_line_ - > get_point_in_frenet_frame ( <nl> + Vec2d ( path_point . x ( ) , path_point . y ( ) ) , & sl_point ) ) { <nl> + AERROR < < " Fail to transfer cartesian point to frenet point . " ; <nl> + return false ; <nl> + } <nl> + common : : FrenetFramePoint frenet_point ; <nl> + / / NOTICE : does not set dl and ddl here . Add if needed . <nl> + frenet_point . set_s ( sl_point . s ( ) ) ; <nl> + frenet_point . set_l ( sl_point . l ( ) ) ; <nl> + frenet_frame_points . push_back ( std : : move ( frenet_point ) ) ; <nl> + } <nl> + * frenet_path = FrenetFramePath ( frenet_frame_points ) ; <nl> + return true ; <nl> + } <nl> + <nl> } / / namespace planning <nl> } / / namespace apollo <nl> mmm a / modules / planning / common / path / path_data . h <nl> ppp b / modules / planning / common / path / path_data . h <nl> class PathData { <nl> public : <nl> PathData ( ) = default ; <nl> <nl> - void set_discretized_path ( const DiscretizedPath & path ) ; <nl> - <nl> - void set_discretized_path ( const std : : vector < common : : PathPoint > & path_points ) ; <nl> + bool set_discretized_path ( const DiscretizedPath & path ) ; <nl> <nl> bool set_frenet_path ( const FrenetFramePath & frenet_path ) ; <nl> <nl> mmm a / modules / planning / optimizer / qp_spline_path / qp_spline_path_generator . cc <nl> ppp b / modules / planning / optimizer / qp_spline_path / qp_spline_path_generator . cc <nl> bool QpSplinePathGenerator : : Generate ( <nl> s + = s_resolution ; <nl> } <nl> path_data - > set_reference_line ( & reference_line_ ) ; <nl> - path_data - > set_discretized_path ( path_points ) ; <nl> + path_data - > set_discretized_path ( DiscretizedPath ( path_points ) ) ; <nl> return true ; <nl> } <nl> <nl>
|
Planning : added function to transfer discretized path to frenet path in PathData
|
ApolloAuto/apollo
|
0086662fcbffb03621cadd221bb3dbb71540eca4
|
2017-08-08T13:52:28Z
|
mmm a / PowerEditor / src / localization . cpp <nl> ppp b / PowerEditor / src / localization . cpp <nl> MenuPosition menuPos [ ] = { <nl> { 9 , - 1 , - 1 , " run " } , <nl> <nl> { 0 , 2 , - 1 , " file - openFolder " } , <nl> - { 0 , 12 , - 1 , " file - closeMore " } , <nl> - { 0 , 21 , - 1 , " file - recentFiles " } , <nl> + { 0 , 13 , - 1 , " file - closeMore " } , <nl> + { 0 , 22 , - 1 , " file - recentFiles " } , <nl> <nl> { 1 , 10 , - 1 , " edit - copyToClipboard " } , <nl> { 1 , 11 , - 1 , " edit - indent " } , <nl>
|
Fix a localization regression
|
notepad-plus-plus/notepad-plus-plus
|
2efd5682e8be6426767dc5c1fbd36ac2b601dff1
|
2017-08-22T07:41:12Z
|
mmm a / tensorflow / compiler / tf2tensorrt / convert / convert_nodes . cc <nl> ppp b / tensorflow / compiler / tf2tensorrt / convert / convert_nodes . cc <nl> Status ConvertFusedBatchNorm ( OpConverterParams * params ) { <nl> node_def . name ( ) ) ; <nl> } <nl> nvinfer1 : : ITensor * tensor = inputs . at ( 0 ) . tensor ( ) ; <nl> - <nl> + if ( ! params - > use_implicit_batch & & tensor - > getDimensions ( ) . d [ 1 ] = = - 1 ) { <nl> + / / This check is to make sure that channel dimension is known during <nl> + / / conversion . <nl> + / / <nl> + / / We check this only in explicit batch mode and reject an op with unknown <nl> + / / channel dimension during segmentation . In implicit batch mode we have <nl> + / / known shapes during conversion even though the shapes may not be known <nl> + / / during segmentation ( see the actual argument for input_shapes when <nl> + / / ConvertGraphDefToEngine is called from TRTEngineOp : : BuildEngine ) . <nl> + return errors : : InvalidArgument ( " Channel dimension must be static , at " , <nl> + node_def . name ( ) ) ; <nl> + } <nl> / / Check parameter types <nl> auto parameter_type = inputs . at ( 1 ) . weights ( ) . TrtDType ( ) ; <nl> if ( ( parameter_type ! = nvinfer1 : : DataType : : kFLOAT ) & & <nl> mmm a / tensorflow / compiler / tf2tensorrt / convert / convert_nodes_test . cc <nl> ppp b / tensorflow / compiler / tf2tensorrt / convert / convert_nodes_test . cc <nl> TEST_F ( OpConverterTest , ConvertConst ) { <nl> TestConvertConst < DT_UINT64 , uint64 , int32 > ( this ) ; <nl> } <nl> <nl> + template < typename T > <nl> + NodeDef CreateFusedBatchNormOp ( DataType tf_type , std : : string data_format , <nl> + bool is_training , float epsilon ) { <nl> + Scope s = Scope : : NewRootScope ( ) ; <nl> + auto x = ops : : Placeholder ( s . WithOpName ( " x " ) , tf_type ) ; <nl> + auto scale = ops : : Placeholder ( s . WithOpName ( " scale " ) , tf_type ) ; <nl> + auto offset = ops : : Placeholder ( s . WithOpName ( " offset " ) , tf_type ) ; <nl> + auto mean = ops : : Placeholder ( s . WithOpName ( " mean " ) , tf_type ) ; <nl> + auto variance = ops : : Placeholder ( s . WithOpName ( " variance " ) , tf_type ) ; <nl> + typename T : : Attrs attrs ; <nl> + attrs . data_format_ = data_format ; <nl> + attrs . is_training_ = is_training ; <nl> + if ( epsilon > 0 ) { <nl> + attrs . epsilon_ = epsilon ; <nl> + } else { <nl> + EXPECT_GE ( epsilon , 0 ) ; <nl> + } <nl> + return T ( s . WithOpName ( " my_batchnorm " ) , x , scale , offset , mean , variance , <nl> + attrs ) <nl> + . operation . node ( ) <nl> + - > def ( ) ; <nl> + } <nl> + <nl> + TEST_P ( OpConverterTest1 , ConvertFusedBatchNorm ) { <nl> + using OpFunc = std : : function < NodeDef ( DataType , std : : string , bool , float ) > ; <nl> + std : : vector < OpFunc > get_node_def_vec { <nl> + CreateFusedBatchNormOp < ops : : FusedBatchNorm > , <nl> + CreateFusedBatchNormOp < ops : : FusedBatchNormV2 > , <nl> + CreateFusedBatchNormOp < ops : : FusedBatchNormV3 > } ; <nl> + <nl> + struct TestParam { <nl> + std : : string data_format ; <nl> + int tensor_input_idx ; / / Index of an input that will be provided as tensor . <nl> + bool is_training ; <nl> + float epsilon ; <nl> + Status conversion_status ; <nl> + bool keep_channel_unknown ; <nl> + } ; <nl> + <nl> + struct NodeInput { <nl> + std : : string name ; <nl> + std : : vector < int > dims ; <nl> + std : : vector < float > val ; <nl> + } ; <nl> + std : : vector < NodeInput > node_input { <nl> + { " x " , { 2 , 3 , 2 , 1 } , { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 } } , <nl> + { " scale " , { 3 } , { 7 , 8 , 9 } } , <nl> + { " offset " , { 3 } , { 10 , 20 , 30 } } , <nl> + { " mean " , { 3 } , { 1 , 2 , 3 } } , <nl> + { " variance " , { 3 } , { 4 , 5 , 6 } } } ; <nl> + <nl> + std : : vector < float > expected_output { 10 . 0 , 13 . 495633 , 23 . 574135 , 27 . 148273 , <nl> + 37 . 342354 , 41 . 013527 , 30 . 9738 , 34 . 469433 , <nl> + 45 . 018955 , 48 . 59309 , 59 . 369415 , 63 . 04059 } ; <nl> + for ( auto get_node_def : get_node_def_vec ) { <nl> + NodeDef tmp_node_def = get_node_def ( tf_type , " NCHW " , true , 0 ) ; <nl> + std : : string op_name = tmp_node_def . op ( ) ; <nl> + std : : vector < TestParam > test_param { <nl> + { " NHWC " , 0 , false , 0 , <nl> + errors : : Unimplemented ( StrCat ( <nl> + op_name , " only supports data_format = NCHW , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 0 , true , 0 , <nl> + errors : : Unimplemented ( StrCat ( <nl> + op_name , " only supports is_training = false , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 1 , false , 0 , <nl> + errors : : Unimplemented ( StrCat ( " The input \ " scale \ " for " , op_name , <nl> + " must be a constant , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 2 , false , 0 , <nl> + errors : : Unimplemented ( StrCat ( " The input \ " offset \ " for " , op_name , <nl> + " must be a constant , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 3 , false , 0 , <nl> + errors : : Unimplemented ( StrCat ( " The input \ " mean \ " for " , op_name , <nl> + " must be a constant , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 4 , false , 0 , <nl> + errors : : Unimplemented ( StrCat ( " The input \ " variance \ " for " , op_name , <nl> + " must be a constant , at my_batchnorm " ) ) } , <nl> + { " NCHW " , 0 , false , 0 . 01 } } ; / / The last one is the only test that runs . <nl> + if ( trt_mode = = TrtTestMode : : kDynamicShape ) { <nl> + test_param . push_back ( <nl> + { " NCHW " , 0 , false , 0 . 01 , <nl> + errors : : InvalidArgument ( <nl> + " Channel dimension must be static , at my_batchnorm " ) , <nl> + true } ) ; <nl> + } <nl> + for ( auto p : test_param ) { <nl> + Reset ( ) ; <nl> + NodeDef node_def = <nl> + get_node_def ( tf_type , p . data_format , p . is_training , p . epsilon ) ; <nl> + for ( int i = 0 ; i < node_input . size ( ) ; i + + ) { <nl> + if ( i = = 0 | | i = = p . tensor_input_idx ) { <nl> + / / The first input ( x ) is always added as a tensor , and it hase shape <nl> + / / NCHW . The other inputs are per channel values ( 1D , size C ) . <nl> + / / <nl> + / / In implicit batch mode , it is not possible to add any of the 1D <nl> + / / inputs as a tensor : the first dim is always treated as batch dim in <nl> + / / implicit batch mode , and that has to agree for all tensors . We have <nl> + / / two input tensors with shapes NCHW and C and in general N ! = C . <nl> + / / The converter already picked up N from the fist input , and reports <nl> + / / an error when we try to add any other tensors with not matching <nl> + / / first dim . <nl> + / / <nl> + / / This restriction does not apply in explicit batch mode : the tensors <nl> + / / can have different first dim . The converter still expects that only <nl> + / / the first arg is a tensor . TODO ( tfeher ) Check if one can relax this <nl> + / / restriction . <nl> + Status expected_status = <nl> + ( i ! = 0 & & trt_mode = = TrtTestMode : : kImplicitBatch ) <nl> + ? errors : : InvalidArgument ( <nl> + StrCat ( " Batch size doesn ' t match for tensor " , <nl> + node_input [ i ] . name , <nl> + " : Provided batch size does not match " <nl> + " converter batch size : 3 vs 2 " ) ) <nl> + : Status : : OK ( ) ; <nl> + std : : vector < int > partial_input_shape ; <nl> + if ( i = = 0 & & trt_mode = = TrtTestMode : : kDynamicShape & & <nl> + ! p . keep_channel_unknown ) { <nl> + / / keep channel dim static ( known ) <nl> + partial_input_shape . resize ( 4 , - 1 ) ; <nl> + partial_input_shape [ 1 ] = node_input [ i ] . dims [ 1 ] ; <nl> + } <nl> + AddTestTensor ( node_input [ i ] . name , node_input [ i ] . dims , tf_type , <nl> + node_input [ i ] . val , partial_input_shape , <nl> + expected_status ) ; <nl> + <nl> + } else { <nl> + AddTestWeights ( node_input [ i ] . name , node_input [ i ] . dims , <nl> + node_input [ i ] . val , tf_type ) ; <nl> + } <nl> + } <nl> + TestOpConverter ( " my_batchnorm " , node_def , node_input [ 0 ] . dims , <nl> + p . conversion_status , Status : : OK ( ) , <nl> + ArrayFloatNear ( expected_output ) ) ; <nl> + } <nl> + } <nl> + } / / namespace convert <nl> + <nl> TEST_P ( OpConverterTest1 , ConvertTranspose ) { <nl> / / Get the NodeDef for Transpose . <nl> Scope s = Scope : : NewRootScope ( ) ; <nl>
|
Add dynamic shape test to ConvertFusedBatchNorm
|
tensorflow/tensorflow
|
45591fac1d5a9042e205832e60c2fc4bfaeadfdc
|
2020-07-20T14:56:22Z
|
new file mode 100644 <nl> index 000000000000 . . 0eaab81045e6 <nl> mmm / dev / null <nl> ppp b / CODEOWNERS <nl> <nl> + # This is a comment . <nl> + # Each line is a file pattern followed by one or more owners . <nl> + <nl> + / aten / @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / torch / @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / docs / source @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / test @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / tools @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / README . md @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / setup . py @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl> + / requirements . txt @ apaszke @ soumith @ colesbury @ gchanan @ zdevito @ ezyang <nl>
|
Add a CODEOWNERS file ( )
|
pytorch/pytorch
|
0469926ba3f6eea6b1af82e2b254954c94d8d32a
|
2018-04-04T17:18:00Z
|
mmm a / Examples / ReinforcementLearning / DeepQNeuralNetwork . py <nl> ppp b / Examples / ReinforcementLearning / DeepQNeuralNetwork . py <nl> def __init__ ( self , input_shape , nb_actions , <nl> Dense ( 256 , init = he_uniform ( scale = 0 . 01 ) ) , <nl> Dense ( nb_actions , activation = None , init = he_uniform ( scale = 0 . 01 ) ) <nl> ] ) <nl> + self . _action_value_net . update_signature ( Tensor [ input_shape ] ) <nl> <nl> # Define the loss , using Huber Loss ( More robust to outliers ) <nl> @ Function <nl>
|
Missing update_signature call
|
microsoft/CNTK
|
638ef8594ec6dd906ccaba0b90e7a135c5723b91
|
2017-03-30T09:01:21Z
|
mmm a / src / AggregateFunctions / AggregateFunctionAny . cpp <nl> ppp b / src / AggregateFunctions / AggregateFunctionAny . cpp <nl> AggregateFunctionPtr createAggregateFunctionAnyHeavy ( const std : : string & name , c <nl> <nl> } <nl> <nl> - void registerAggregateFunctionsMinMaxAny ( AggregateFunctionFactory & factory ) <nl> + void registerAggregateFunctionsAny ( AggregateFunctionFactory & factory ) <nl> { <nl> AggregateFunctionProperties properties = { . returns_default_when_only_null = false , . is_order_dependent = true } ; <nl> <nl> mmm a / src / AggregateFunctions / AggregateFunctionMax . cpp <nl> ppp b / src / AggregateFunctions / AggregateFunctionMax . cpp <nl> AggregateFunctionPtr createAggregateFunctionArgMax ( const std : : string & name , con <nl> <nl> } <nl> <nl> - void registerAggregateFunctionsMinMaxAny ( AggregateFunctionFactory & factory ) <nl> + void registerAggregateFunctionsMax ( AggregateFunctionFactory & factory ) <nl> { <nl> factory . registerFunction ( " max " , createAggregateFunctionMax , AggregateFunctionFactory : : CaseInsensitive ) ; <nl> <nl> mmm a / src / AggregateFunctions / AggregateFunctionMin . cpp <nl> ppp b / src / AggregateFunctions / AggregateFunctionMin . cpp <nl> AggregateFunctionPtr createAggregateFunctionArgMin ( const std : : string & name , con <nl> <nl> } <nl> <nl> - void registerAggregateFunctionsMinMaxAny ( AggregateFunctionFactory & factory ) <nl> + void registerAggregateFunctionsMin ( AggregateFunctionFactory & factory ) <nl> { <nl> factory . registerFunction ( " min " , createAggregateFunctionMin , AggregateFunctionFactory : : CaseInsensitive ) ; <nl> <nl> mmm a / src / AggregateFunctions / registerAggregateFunctions . cpp <nl> ppp b / src / AggregateFunctions / registerAggregateFunctions . cpp <nl> void registerAggregateFunctionsQuantile ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionsSequenceMatch ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionWindowFunnel ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionRate ( AggregateFunctionFactory & ) ; <nl> - void registerAggregateFunctionsMinMaxAny ( AggregateFunctionFactory & ) ; <nl> + void registerAggregateFunctionsMin ( AggregateFunctionFactory & ) ; <nl> + void registerAggregateFunctionsMax ( AggregateFunctionFactory & ) ; <nl> + void registerAggregateFunctionsAny ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionsStatisticsStable ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionsStatisticsSimple ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctionSum ( AggregateFunctionFactory & ) ; <nl> void registerAggregateFunctions ( ) <nl> registerAggregateFunctionsSequenceMatch ( factory ) ; <nl> registerAggregateFunctionWindowFunnel ( factory ) ; <nl> registerAggregateFunctionRate ( factory ) ; <nl> - registerAggregateFunctionsMinMaxAny ( factory ) ; <nl> + registerAggregateFunctionsMin ( factory ) ; <nl> + registerAggregateFunctionsMax ( factory ) ; <nl> + registerAggregateFunctionsAny ( factory ) ; <nl> registerAggregateFunctionsStatisticsStable ( factory ) ; <nl> registerAggregateFunctionsStatisticsSimple ( factory ) ; <nl> registerAggregateFunctionSum ( factory ) ; <nl> mmm a / src / AggregateFunctions / ya . make <nl> ppp b / src / AggregateFunctions / ya . make <nl> PEERDIR ( <nl> <nl> SRCS ( <nl> AggregateFunctionAggThrow . cpp <nl> + AggregateFunctionAny . cpp <nl> AggregateFunctionArray . cpp <nl> AggregateFunctionAvg . cpp <nl> AggregateFunctionAvgWeighted . cpp <nl> SRCS ( <nl> AggregateFunctionIf . cpp <nl> AggregateFunctionMLMethod . cpp <nl> AggregateFunctionMannWhitney . cpp <nl> + AggregateFunctionMax . cpp <nl> AggregateFunctionMaxIntersections . cpp <nl> AggregateFunctionMerge . cpp <nl> - AggregateFunctionMinMaxAny . cpp <nl> + AggregateFunctionMin . cpp <nl> AggregateFunctionNull . cpp <nl> AggregateFunctionOrFill . cpp <nl> AggregateFunctionQuantile . cpp <nl>
|
Fix build
|
ClickHouse/ClickHouse
|
47b177d175fd0fc0d75508c0e721e33fd494b235
|
2020-12-21T05:51:11Z
|
mmm a / folly / Range . h <nl> ppp b / folly / Range . h <nl> <nl> # include < cstring > <nl> # include < glog / logging . h > <nl> # include < iosfwd > <nl> + # include < limits . h > <nl> # include < stdexcept > <nl> # include < string > <nl> # include < type_traits > <nl>
|
fix missing header in Range . h
|
facebook/folly
|
6c5fcdd08180e421fefef67d7915c2d9249f16d2
|
2015-02-02T21:14:10Z
|
mmm a / core / io / resource_loader . cpp <nl> ppp b / core / io / resource_loader . cpp <nl> Ref < ResourceImportMetadata > ResourceLoader : : load_import_metadata ( const String & p <nl> break ; <nl> } <nl> <nl> + <nl> return ret ; <nl> <nl> } <nl> mmm a / core / object . cpp <nl> ppp b / core / object . cpp <nl> bool Object : : is_queued_for_deletion ( ) const { <nl> void Object : : set_edited ( bool p_edited ) { <nl> <nl> _edited = p_edited ; <nl> + _edited_version + + ; <nl> } <nl> <nl> bool Object : : is_edited ( ) const { <nl> bool Object : : is_edited ( ) const { <nl> return _edited ; <nl> <nl> } <nl> + <nl> + uint32_t Object : : get_edited_version ( ) const { <nl> + <nl> + return _edited_version ; <nl> + } <nl> # endif <nl> <nl> Object : : Object ( ) { <nl> Object : : Object ( ) { <nl> # ifdef TOOLS_ENABLED <nl> <nl> _edited = false ; <nl> + _edited_version = 0 ; <nl> # endif <nl> <nl> # ifdef DEBUG_ENABLED <nl> mmm a / core / object . h <nl> ppp b / core / object . h <nl> friend void postinitialize_handler ( Object * ) ; <nl> bool _can_translate ; <nl> # ifdef TOOLS_ENABLED <nl> bool _edited ; <nl> + uint32_t _edited_version ; <nl> # endif <nl> ScriptInstance * script_instance ; <nl> RefPtr script ; <nl> friend class ObjectTypeDB ; <nl> # ifdef TOOLS_ENABLED <nl> void set_edited ( bool p_edited ) ; <nl> bool is_edited ( ) const ; <nl> + uint32_t get_edited_version ( ) const ; / / this function is used to check when something changed beyond a point , it ' s used mainly for generating previews <nl> # endif <nl> <nl> void set_script_instance ( ScriptInstance * p_instance ) ; <nl> mmm a / core / os / main_loop . cpp <nl> ppp b / core / os / main_loop . cpp <nl> void MainLoop : : _bind_methods ( ) { <nl> BIND_VMETHOD ( MethodInfo ( " _initialize " ) ) ; <nl> BIND_VMETHOD ( MethodInfo ( " _iteration " , PropertyInfo ( Variant : : REAL , " delta " ) ) ) ; <nl> BIND_VMETHOD ( MethodInfo ( " _idle " , PropertyInfo ( Variant : : REAL , " delta " ) ) ) ; <nl> + BIND_VMETHOD ( MethodInfo ( " _drop_files " , PropertyInfo ( Variant : : STRING_ARRAY , " files " ) , PropertyInfo ( Variant : : INT , " screen " ) ) ) ; <nl> BIND_VMETHOD ( MethodInfo ( " _finalize " ) ) ; <nl> <nl> BIND_CONSTANT ( NOTIFICATION_WM_MOUSE_ENTER ) ; <nl> bool MainLoop : : idle ( float p_time ) { <nl> <nl> return false ; <nl> } <nl> + <nl> + void MainLoop : : drop_files ( const Vector < String > & p_files , int p_from_screen ) { <nl> + <nl> + <nl> + if ( get_script_instance ( ) ) <nl> + get_script_instance ( ) - > call ( " _drop_files " , p_files , p_from_screen ) ; <nl> + <nl> + } <nl> + <nl> void MainLoop : : finish ( ) { <nl> <nl> if ( get_script_instance ( ) ) { <nl> mmm a / core / os / main_loop . h <nl> ppp b / core / os / main_loop . h <nl> class MainLoop : public Object { <nl> virtual bool idle ( float p_time ) ; <nl> virtual void finish ( ) ; <nl> <nl> + virtual void drop_files ( const Vector < String > & p_files , int p_from_screen = 0 ) ; <nl> + <nl> void set_init_script ( const Ref < Script > & p_init_script ) ; <nl> <nl> MainLoop ( ) ; <nl> mmm a / core / resource . cpp <nl> ppp b / core / resource . cpp <nl> Ref < ResourceImportMetadata > Resource : : get_import_metadata ( ) const { <nl> <nl> } <nl> <nl> + # ifdef TOOLS_ENABLED <nl> + <nl> + uint32_t Resource : : hash_edited_version ( ) const { <nl> + <nl> + uint32_t hash = hash_djb2_one_32 ( get_edited_version ( ) ) ; <nl> + <nl> + List < PropertyInfo > plist ; <nl> + get_property_list ( & plist ) ; <nl> + <nl> + for ( List < PropertyInfo > : : Element * E = plist . front ( ) ; E ; E = E - > next ( ) ) { <nl> + <nl> + if ( E - > get ( ) . type = = Variant : : OBJECT & & E - > get ( ) . hint = = PROPERTY_HINT_RESOURCE_TYPE ) { <nl> + RES res = get ( E - > get ( ) . name ) ; <nl> + if ( res . is_valid ( ) ) { <nl> + hash = hash_djb2_one_32 ( res - > hash_edited_version ( ) , hash ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return hash ; <nl> + <nl> + } <nl> + <nl> + # endif <nl> + <nl> <nl> Resource : : Resource ( ) { <nl> <nl> Resource : : Resource ( ) { <nl> } <nl> <nl> <nl> + <nl> + <nl> Resource : : ~ Resource ( ) { <nl> <nl> if ( path_cache ! = " " ) <nl> mmm a / core / resource . h <nl> ppp b / core / resource . h <nl> friend class ResourceCache ; <nl> Ref < ResourceImportMetadata > get_import_metadata ( ) const ; <nl> <nl> <nl> + <nl> + <nl> # ifdef TOOLS_ENABLED <nl> <nl> + uint32_t hash_edited_version ( ) const ; <nl> + <nl> virtual void set_last_modified_time ( uint64_t p_time ) { last_modified_time = p_time ; } <nl> uint64_t get_last_modified_time ( ) const { return last_modified_time ; } <nl> <nl> mmm a / drivers / gles2 / rasterizer_gles2 . cpp <nl> ppp b / drivers / gles2 / rasterizer_gles2 . cpp <nl> void RasterizerGLES2 : : _update_shader ( Shader * p_shader ) const { <nl> } <nl> <nl> <nl> - void RasterizerGLES2 : : _add_geometry ( const Geometry * p_geometry , const InstanceData * p_instance , const Geometry * p_geometry_cmp , const GeometryOwner * p_owner ) { <nl> + void RasterizerGLES2 : : _add_geometry ( const Geometry * p_geometry , const InstanceData * p_instance , const Geometry * p_geometry_cmp , const GeometryOwner * p_owner , int p_material ) { <nl> <nl> Material * m = NULL ; <nl> - RID m_src = p_instance - > material_override . is_valid ( ) ? p_instance - > material_override : p_geometry - > material ; <nl> + RID m_src = p_instance - > material_override . is_valid ( ) ? p_instance - > material_override : ( p_material > = 0 ? p_instance - > materials [ p_material ] : p_geometry - > material ) ; <nl> <nl> # ifdef DEBUG_ENABLED <nl> if ( current_debug = = VS : : SCENARIO_DEBUG_OVERDRAW ) { <nl> void RasterizerGLES2 : : add_mesh ( const RID & p_mesh , const InstanceData * p_data ) { <nl> <nl> for ( int i = 0 ; i < ssize ; i + + ) { <nl> <nl> + int mat_idx = p_data - > materials [ i ] . is_valid ( ) ? i : - 1 ; <nl> Surface * s = mesh - > surfaces [ i ] ; <nl> - _add_geometry ( s , p_data , s , NULL ) ; <nl> + _add_geometry ( s , p_data , s , NULL , mat_idx ) ; <nl> } <nl> <nl> mesh - > last_pass = frame ; <nl> mmm a / drivers / gles2 / rasterizer_gles2 . h <nl> ppp b / drivers / gles2 / rasterizer_gles2 . h <nl> class RasterizerGLES2 : public Rasterizer { <nl> <nl> Plane camera_plane ; <nl> <nl> - void _add_geometry ( const Geometry * p_geometry , const InstanceData * p_instance , const Geometry * p_geometry_cmp , const GeometryOwner * p_owner ) ; <nl> + void _add_geometry ( const Geometry * p_geometry , const InstanceData * p_instance , const Geometry * p_geometry_cmp , const GeometryOwner * p_owner , int p_material = - 1 ) ; <nl> void _render_list_forward ( RenderList * p_render_list , const Transform & p_view_transform , const Transform & p_view_transform_inverse , const CameraMatrix & p_projection , bool p_reverse_cull = false , bool p_fragment_light = false , bool p_alpha_pass = false ) ; <nl> <nl> / / void _setup_light ( LightInstance * p_instance , int p_idx ) ; <nl> mmm a / platform / windows / os_windows . cpp <nl> ppp b / platform / windows / os_windows . cpp <nl> LRESULT OS_Windows : : WndProc ( HWND hWnd , UINT uMsg , WPARAM wParam , LPARAM lParam ) { <nl> } <nl> <nl> } break ; <nl> + case WM_DROPFILES : { <nl> + <nl> + HDROP hDropInfo = NULL ; <nl> + hDropInfo = ( HDROP ) wParam ; <nl> + const int buffsize = 4096 ; <nl> + wchar_t buf [ buffsize ] ; <nl> + <nl> + int fcount = DragQueryFileW ( hDropInfo , 0xFFFFFFFF , NULL , 0 ) ; <nl> + <nl> + Vector < String > files ; <nl> + <nl> + for ( int i = 0 ; i < fcount ; i + + ) { <nl> + <nl> + DragQueryFileW ( hDropInfo , i , buf , buffsize ) ; <nl> + String file = buf ; <nl> + files . push_back ( file ) ; <nl> + } <nl> + <nl> + if ( files . size ( ) & & main_loop ) { <nl> + main_loop - > drop_files ( files , 0 ) ; <nl> + } <nl> + <nl> + <nl> + } break ; <nl> + <nl> + <nl> <nl> default : { <nl> <nl> void OS_Windows : : initialize ( const VideoMode & p_desired , int p_video_driver , int p_ <nl> <nl> _ensure_data_dir ( ) ; <nl> <nl> + DragAcceptFiles ( hWnd , true ) ; <nl> + <nl> <nl> } <nl> <nl> mmm a / scene / 3d / mesh_instance . cpp <nl> ppp b / scene / 3d / mesh_instance . cpp <nl> <nl> # include " skeleton . h " <nl> # include " physics_body . h " <nl> # include " body_shape . h " <nl> - <nl> - <nl> + # include " scene / scene_string_names . h " <nl> + # include " core_string_names . h " <nl> bool MeshInstance : : _set ( const StringName & p_name , const Variant & p_value ) { <nl> <nl> / / this is not _too_ bad performance wise , really . it only arrives here if the property was not set anywhere else . <nl> bool MeshInstance : : _set ( const StringName & p_name , const Variant & p_value ) { <nl> <nl> <nl> Map < StringName , MorphTrack > : : Element * E = morph_tracks . find ( p_name ) ; <nl> - if ( ! E ) <nl> - return false ; <nl> + if ( E ) { <nl> + E - > get ( ) . value = p_value ; <nl> + VisualServer : : get_singleton ( ) - > instance_set_morph_target_weight ( get_instance ( ) , E - > get ( ) . idx , E - > get ( ) . value ) ; <nl> + return true ; <nl> + } <nl> <nl> - E - > get ( ) . value = p_value ; <nl> - VisualServer : : get_singleton ( ) - > instance_set_morph_target_weight ( get_instance ( ) , E - > get ( ) . idx , E - > get ( ) . value ) ; <nl> + if ( p_name . operator String ( ) . begins_with ( " material / " ) ) { <nl> + int idx = p_name . operator String ( ) . get_slicec ( ' / ' , 1 ) . to_int ( ) ; <nl> + if ( idx > = materials . size ( ) | | idx < 0 ) <nl> + return false ; <nl> <nl> - return true ; <nl> + set_surface_material ( idx , p_value ) ; <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> } <nl> <nl> bool MeshInstance : : _get ( const StringName & p_name , Variant & r_ret ) const { <nl> bool MeshInstance : : _get ( const StringName & p_name , Variant & r_ret ) const { <nl> return false ; <nl> <nl> const Map < StringName , MorphTrack > : : Element * E = morph_tracks . find ( p_name ) ; <nl> - if ( ! E ) <nl> - return false ; <nl> - <nl> - r_ret = E - > get ( ) . value ; <nl> + if ( E ) { <nl> + r_ret = E - > get ( ) . value ; <nl> + return true ; <nl> + } <nl> <nl> - return true ; <nl> + if ( p_name . operator String ( ) . begins_with ( " material / " ) ) { <nl> + int idx = p_name . operator String ( ) . get_slicec ( ' / ' , 1 ) . to_int ( ) ; <nl> + if ( idx > = materials . size ( ) | | idx < 0 ) <nl> + return false ; <nl> + r_ret = materials [ idx ] ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> void MeshInstance : : _get_property_list ( List < PropertyInfo > * p_list ) const { <nl> void MeshInstance : : _get_property_list ( List < PropertyInfo > * p_list ) const { <nl> for ( List < String > : : Element * E = ls . front ( ) ; E ; E = E - > next ( ) ) { <nl> p_list - > push_back ( PropertyInfo ( Variant : : REAL , E - > get ( ) , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " ) ) ; <nl> } <nl> + <nl> + if ( mesh . is_valid ( ) ) { <nl> + for ( int i = 0 ; i < mesh - > get_surface_count ( ) ; i + + ) { <nl> + p_list - > push_back ( PropertyInfo ( Variant : : OBJECT , " material / " + itos ( i ) , PROPERTY_HINT_RESOURCE_TYPE , " Material " ) ) ; <nl> + } <nl> + } <nl> } <nl> <nl> <nl> void MeshInstance : : _get_property_list ( List < PropertyInfo > * p_list ) const { <nl> <nl> void MeshInstance : : set_mesh ( const Ref < Mesh > & p_mesh ) { <nl> <nl> + if ( mesh = = p_mesh ) <nl> + return ; <nl> + <nl> + if ( mesh . is_valid ( ) ) { <nl> + mesh - > disconnect ( CoreStringNames : : get_singleton ( ) - > changed , this , SceneStringNames : : get_singleton ( ) - > _mesh_changed ) ; <nl> + materials . clear ( ) ; <nl> + } <nl> + <nl> mesh = p_mesh ; <nl> <nl> morph_tracks . clear ( ) ; <nl> void MeshInstance : : set_mesh ( const Ref < Mesh > & p_mesh ) { <nl> mt . value = 0 ; <nl> morph_tracks [ " morph / " + String ( mesh - > get_morph_target_name ( i ) ) ] = mt ; <nl> } <nl> + <nl> + mesh - > connect ( CoreStringNames : : get_singleton ( ) - > changed , this , SceneStringNames : : get_singleton ( ) - > _mesh_changed ) ; <nl> + materials . resize ( mesh - > get_surface_count ( ) ) ; <nl> + <nl> set_base ( mesh - > get_rid ( ) ) ; <nl> } else { <nl> <nl> set_base ( RID ( ) ) ; <nl> } <nl> <nl> - _change_notify ( " mesh " ) ; <nl> + _change_notify ( ) ; <nl> } <nl> Ref < Mesh > MeshInstance : : get_mesh ( ) const { <nl> <nl> void MeshInstance : : _notification ( int p_what ) { <nl> } <nl> <nl> <nl> + void MeshInstance : : set_surface_material ( int p_surface , const Ref < Material > & p_material ) { <nl> + <nl> + ERR_FAIL_INDEX ( p_surface , materials . size ( ) ) ; <nl> + <nl> + materials [ p_surface ] = p_material ; <nl> + <nl> + if ( materials [ p_surface ] . is_valid ( ) ) <nl> + VS : : get_singleton ( ) - > instance_set_surface_material ( get_instance ( ) , p_surface , materials [ p_surface ] - > get_rid ( ) ) ; <nl> + else <nl> + VS : : get_singleton ( ) - > instance_set_surface_material ( get_instance ( ) , p_surface , RID ( ) ) ; <nl> + <nl> + } <nl> + <nl> + Ref < Material > MeshInstance : : get_surface_material ( int p_surface ) const { <nl> + <nl> + ERR_FAIL_INDEX_V ( p_surface , materials . size ( ) , Ref < Material > ( ) ) ; <nl> + <nl> + return materials [ p_surface ] ; <nl> + } <nl> + <nl> + <nl> + void MeshInstance : : _mesh_changed ( ) { <nl> + <nl> + materials . resize ( mesh - > get_surface_count ( ) ) ; <nl> + } <nl> + <nl> void MeshInstance : : _bind_methods ( ) { <nl> <nl> ObjectTypeDB : : bind_method ( _MD ( " set_mesh " , " mesh : Mesh " ) , & MeshInstance : : set_mesh ) ; <nl> void MeshInstance : : _bind_methods ( ) { <nl> ObjectTypeDB : : set_method_flags ( " MeshInstance " , " create_trimesh_collision " , METHOD_FLAGS_DEFAULT ) ; <nl> ObjectTypeDB : : bind_method ( _MD ( " create_convex_collision " ) , & MeshInstance : : create_convex_collision ) ; <nl> ObjectTypeDB : : set_method_flags ( " MeshInstance " , " create_convex_collision " , METHOD_FLAGS_DEFAULT ) ; <nl> + ObjectTypeDB : : bind_method ( _MD ( " _mesh_changed " ) , & MeshInstance : : _mesh_changed ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " mesh / mesh " , PROPERTY_HINT_RESOURCE_TYPE , " Mesh " ) , _SCS ( " set_mesh " ) , _SCS ( " get_mesh " ) ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : NODE_PATH , " mesh / skeleton " ) , _SCS ( " set_skeleton_path " ) , _SCS ( " get_skeleton_path " ) ) ; <nl> } <nl> mmm a / scene / 3d / mesh_instance . h <nl> ppp b / scene / 3d / mesh_instance . h <nl> class MeshInstance : public GeometryInstance { <nl> } ; <nl> <nl> Map < StringName , MorphTrack > morph_tracks ; <nl> + Vector < Ref < Material > > materials ; <nl> <nl> + void _mesh_changed ( ) ; <nl> void _resolve_skeleton_path ( ) ; <nl> <nl> protected : <nl> class MeshInstance : public GeometryInstance { <nl> void set_skeleton_path ( const NodePath & p_skeleton ) ; <nl> NodePath get_skeleton_path ( ) ; <nl> <nl> + void set_surface_material ( int p_surface , const Ref < Material > & p_material ) ; <nl> + Ref < Material > get_surface_material ( int p_surface ) const ; <nl> + <nl> Node * create_trimesh_collision_node ( ) ; <nl> void create_trimesh_collision ( ) ; <nl> <nl> mmm a / scene / main / scene_main_loop . cpp <nl> ppp b / scene / main / scene_main_loop . cpp <nl> void SceneTree : : _live_edit_reparent_node_func ( const NodePath & p_at , const NodePat <nl> <nl> <nl> # endif <nl> + <nl> + <nl> + void SceneTree : : drop_files ( const Vector < String > & p_files , int p_from_screen ) { <nl> + <nl> + emit_signal ( " files_dropped " , p_files , p_from_screen ) ; <nl> + MainLoop : : drop_files ( p_files , p_from_screen ) ; <nl> + } <nl> + <nl> void SceneTree : : _bind_methods ( ) { <nl> <nl> <nl> void SceneTree : : _bind_methods ( ) { <nl> ADD_SIGNAL ( MethodInfo ( " idle_frame " ) ) ; <nl> ADD_SIGNAL ( MethodInfo ( " fixed_frame " ) ) ; <nl> <nl> + ADD_SIGNAL ( MethodInfo ( " files_dropped " , PropertyInfo ( Variant : : STRING_ARRAY , " files " ) , PropertyInfo ( Variant : : INT , " screen " ) ) ) ; <nl> + <nl> BIND_CONSTANT ( GROUP_CALL_DEFAULT ) ; <nl> BIND_CONSTANT ( GROUP_CALL_REVERSE ) ; <nl> BIND_CONSTANT ( GROUP_CALL_REALTIME ) ; <nl> mmm a / scene / main / scene_main_loop . h <nl> ppp b / scene / main / scene_main_loop . h <nl> friend class Viewport ; <nl> <nl> static SceneTree * get_singleton ( ) { return singleton ; } <nl> <nl> + void drop_files ( const Vector < String > & p_files , int p_from_screen = 0 ) ; <nl> <nl> SceneTree ( ) ; <nl> ~ SceneTree ( ) ; <nl> mmm a / scene / resources / mesh . cpp <nl> ppp b / scene / resources / mesh . cpp <nl> <nl> # include " scene / resources / concave_polygon_shape . h " <nl> # include " scene / resources / convex_polygon_shape . h " <nl> # include " surface_tool . h " <nl> - <nl> static const char * _array_name [ ] = { <nl> " vertex_array " , <nl> " normal_array " , <nl> void Mesh : : add_surface ( PrimitiveType p_primitive , const Array & p_arrays , const Arr <nl> <nl> triangle_mesh = Ref < TriangleMesh > ( ) ; <nl> _change_notify ( ) ; <nl> + emit_changed ( ) ; <nl> <nl> } <nl> <nl> void Mesh : : surface_remove ( int p_idx ) { <nl> triangle_mesh = Ref < TriangleMesh > ( ) ; <nl> _recompute_aabb ( ) ; <nl> _change_notify ( ) ; <nl> + emit_changed ( ) ; <nl> } <nl> <nl> <nl> void Mesh : : add_surface_from_mesh_data ( const Geometry : : MeshData & p_mesh_data ) { <nl> <nl> surfaces . push_back ( s ) ; <nl> _change_notify ( ) ; <nl> + <nl> + emit_changed ( ) ; <nl> } <nl> <nl> RID Mesh : : get_rid ( ) const { <nl> mmm a / scene / scene_string_names . cpp <nl> ppp b / scene / scene_string_names . cpp <nl> SceneStringNames : : SceneStringNames ( ) { <nl> path_pp = NodePath ( " . . " ) ; <nl> <nl> _default = StaticCString : : create ( " default " ) ; <nl> + <nl> + for ( int i = 0 ; i < MAX_MATERIALS ; i + + ) { <nl> + <nl> + mesh_materials [ i ] = " material / " + itos ( i ) ; <nl> + } <nl> + <nl> + _mesh_changed = StaticCString : : create ( " _mesh_changed " ) ; <nl> } <nl> mmm a / scene / scene_string_names . h <nl> ppp b / scene / scene_string_names . h <nl> friend void unregister_scene_types ( ) ; <nl> <nl> StringName node_configuration_warning_changed ; <nl> <nl> + enum { <nl> + MAX_MATERIALS = 32 <nl> + } ; <nl> + StringName mesh_materials [ MAX_MATERIALS ] ; <nl> + StringName _mesh_changed ; <nl> + <nl> } ; <nl> <nl> <nl> mmm a / servers / visual / rasterizer . h <nl> ppp b / servers / visual / rasterizer . h <nl> class Rasterizer { <nl> RID skeleton ; <nl> RID material_override ; <nl> RID sampled_light ; <nl> + Vector < RID > materials ; <nl> Vector < RID > light_instances ; <nl> Vector < float > morph_values ; <nl> BakedLightData * baked_light ; <nl> mmm a / servers / visual / visual_server_raster . cpp <nl> ppp b / servers / visual / visual_server_raster . cpp <nl> void VisualServerRaster : : mesh_add_custom_surface ( RID p_mesh , const Variant & p_dat <nl> void VisualServerRaster : : mesh_add_surface ( RID p_mesh , PrimitiveType p_primitive , const Array & p_arrays , const Array & p_blend_shapes , bool p_alpha_sort ) { <nl> <nl> VS_CHANGED ; <nl> - _dependency_queue_update ( p_mesh , true ) ; <nl> + _dependency_queue_update ( p_mesh , true , true ) ; <nl> rasterizer - > mesh_add_surface ( p_mesh , p_primitive , p_arrays , p_blend_shapes , p_alpha_sort ) ; <nl> <nl> } <nl> VisualServer : : PrimitiveType VisualServerRaster : : mesh_surface_get_primitive_type ( <nl> void VisualServerRaster : : mesh_remove_surface ( RID p_mesh , int p_surface ) { <nl> <nl> rasterizer - > mesh_remove_surface ( p_mesh , p_surface ) ; <nl> + _dependency_queue_update ( p_mesh , true , true ) ; <nl> } <nl> <nl> int VisualServerRaster : : mesh_get_surface_count ( RID p_mesh ) const { <nl> void VisualServerRaster : : mesh_clear ( RID p_mesh ) { <nl> while ( rasterizer - > mesh_get_surface_count ( p_mesh ) ) { <nl> rasterizer - > mesh_remove_surface ( p_mesh , 0 ) ; <nl> } <nl> + <nl> + _dependency_queue_update ( p_mesh , true , true ) ; <nl> } <nl> <nl> <nl> Variant VisualServerRaster : : environment_fx_get_param ( RID p_env , EnvironmentFxPara <nl> <nl> / * SCENARIO API * / <nl> <nl> - void VisualServerRaster : : _dependency_queue_update ( RID p_rid , bool p_update_aabb ) { <nl> + void VisualServerRaster : : _dependency_queue_update ( RID p_rid , bool p_update_aabb , bool p_update_materials ) { <nl> <nl> Map < RID , Set < RID > > : : Element * E = instance_dependency_map . find ( p_rid ) ; <nl> <nl> void VisualServerRaster : : _dependency_queue_update ( RID p_rid , bool p_update_aabb ) <nl> while ( I ) { <nl> <nl> Instance * ins = instance_owner . get ( I - > get ( ) ) ; <nl> - _instance_queue_update ( ins , p_update_aabb ) ; <nl> + _instance_queue_update ( ins , p_update_aabb , p_update_materials ) ; <nl> <nl> I = I - > next ( ) ; <nl> } <nl> <nl> } <nl> <nl> - void VisualServerRaster : : _instance_queue_update ( Instance * p_instance , bool p_update_aabb ) { <nl> + void VisualServerRaster : : _instance_queue_update ( Instance * p_instance , bool p_update_aabb , bool p_update_materials ) { <nl> <nl> if ( p_update_aabb ) <nl> p_instance - > update_aabb = true ; <nl> + if ( p_update_materials ) <nl> + p_instance - > update_materials = true ; <nl> <nl> if ( p_instance - > update ) <nl> return ; <nl> void VisualServerRaster : : instance_set_base ( RID p_instance , RID p_base ) { <nl> } <nl> <nl> instance - > data . morph_values . clear ( ) ; <nl> + instance - > data . materials . clear ( ) ; <nl> <nl> } <nl> <nl> void VisualServerRaster : : instance_set_base ( RID p_instance , RID p_base ) { <nl> if ( rasterizer - > is_mesh ( p_base ) ) { <nl> instance - > base_type = INSTANCE_MESH ; <nl> instance - > data . morph_values . resize ( rasterizer - > mesh_get_morph_target_count ( p_base ) ) ; <nl> + instance - > data . materials . resize ( rasterizer - > mesh_get_surface_count ( p_base ) ) ; <nl> } else if ( rasterizer - > is_multimesh ( p_base ) ) { <nl> instance - > base_type = INSTANCE_MULTIMESH ; <nl> } else if ( rasterizer - > is_immediate ( p_base ) ) { <nl> float VisualServerRaster : : instance_get_morph_target_weight ( RID p_instance , int p_ <nl> return instance - > data . morph_values [ p_shape ] ; <nl> } <nl> <nl> + void VisualServerRaster : : instance_set_surface_material ( RID p_instance , int p_surface , RID p_material ) { <nl> + <nl> + VS_CHANGED ; <nl> + Instance * instance = instance_owner . get ( p_instance ) ; <nl> + ERR_FAIL_COND ( ! instance ) ; <nl> + ERR_FAIL_INDEX ( p_surface , instance - > data . materials . size ( ) ) ; <nl> + instance - > data . materials [ p_surface ] = p_material ; <nl> + } <nl> + <nl> + <nl> void VisualServerRaster : : instance_set_transform ( RID p_instance , const Transform & p_transform ) { <nl> VS_CHANGED ; <nl> Instance * instance = instance_owner . get ( p_instance ) ; <nl> void VisualServerRaster : : _update_instance ( Instance * p_instance ) { <nl> <nl> } <nl> <nl> + <nl> if ( p_instance - > aabb . has_no_surface ( ) ) <nl> return ; <nl> <nl> void VisualServerRaster : : _update_instances ( ) { <nl> if ( instance - > update_aabb ) <nl> _update_instance_aabb ( instance ) ; <nl> <nl> + if ( instance - > update_materials ) { <nl> + if ( instance - > base_type = = INSTANCE_MESH ) { <nl> + instance - > data . materials . resize ( rasterizer - > mesh_get_surface_count ( instance - > base_rid ) ) ; <nl> + } <nl> + } <nl> + <nl> _update_instance ( instance ) ; <nl> <nl> instance - > update = false ; <nl> instance - > update_aabb = false ; <nl> + instance - > update_materials = false ; <nl> instance - > update_next = 0 ; <nl> } <nl> } <nl> mmm a / servers / visual / visual_server_raster . h <nl> ppp b / servers / visual / visual_server_raster . h <nl> class VisualServerRaster : public VisualServer { <nl> Scenario * scenario ; <nl> bool update ; <nl> bool update_aabb ; <nl> + bool update_materials ; <nl> Instance * update_next ; <nl> InstanceType base_type ; <nl> <nl> class VisualServerRaster : public VisualServer { <nl> draw_range_end = 0 ; <nl> extra_margin = 0 ; <nl> visible_in_all_rooms = false ; <nl> + update_aabb = false ; <nl> + update_materials = false ; <nl> <nl> baked_light = NULL ; <nl> baked_light_info = NULL ; <nl> class VisualServerRaster : public VisualServer { <nl> <nl> void _portal_disconnect ( Instance * p_portal , bool p_cleanup = false ) ; <nl> void _portal_attempt_connect ( Instance * p_portal ) ; <nl> - void _dependency_queue_update ( RID p_rid , bool p_update_aabb = false ) ; <nl> - _FORCE_INLINE_ void _instance_queue_update ( Instance * p_instance , bool p_update_aabb = false ) ; <nl> + void _dependency_queue_update ( RID p_rid , bool p_update_aabb = false , bool p_update_materials = false ) ; <nl> + _FORCE_INLINE_ void _instance_queue_update ( Instance * p_instance , bool p_update_aabb = false , bool p_update_materials = false ) ; <nl> void _update_instances ( ) ; <nl> void _update_instance_aabb ( Instance * p_instance ) ; <nl> void _update_instance ( Instance * p_instance ) ; <nl> class VisualServerRaster : public VisualServer { <nl> virtual void instance_set_morph_target_weight ( RID p_instance , int p_shape , float p_weight ) ; <nl> virtual float instance_get_morph_target_weight ( RID p_instance , int p_shape ) const ; <nl> <nl> + virtual void instance_set_surface_material ( RID p_instance , int p_surface , RID p_material ) ; <nl> + <nl> + <nl> virtual void instance_set_transform ( RID p_instance , const Transform & p_transform ) ; <nl> virtual Transform instance_get_transform ( RID p_instance ) const ; <nl> <nl> mmm a / servers / visual / visual_server_wrap_mt . h <nl> ppp b / servers / visual / visual_server_wrap_mt . h <nl> class VisualServerWrapMT : public VisualServer { <nl> FUNC3 ( instance_set_morph_target_weight , RID , int , float ) ; <nl> FUNC2RC ( float , instance_get_morph_target_weight , RID , int ) ; <nl> <nl> + FUNC3 ( instance_set_surface_material , RID , int , RID ) ; <nl> + <nl> FUNC2 ( instance_set_transform , RID , const Transform & ) ; <nl> FUNC1RC ( Transform , instance_get_transform , RID ) ; <nl> <nl> mmm a / servers / visual_server . h <nl> ppp b / servers / visual_server . h <nl> class VisualServer : public Object { <nl> virtual void instance_set_morph_target_weight ( RID p_instance , int p_shape , float p_weight ) = 0 ; <nl> virtual float instance_get_morph_target_weight ( RID p_instance , int p_shape ) const = 0 ; <nl> <nl> + virtual void instance_set_surface_material ( RID p_instance , int p_surface , RID p_material ) = 0 ; <nl> + <nl> virtual void instance_attach_skeleton ( RID p_instance , RID p_skeleton ) = 0 ; <nl> virtual RID instance_get_skeleton ( RID p_instance ) const = 0 ; <nl> <nl> mmm a / tools / editor / create_dialog . cpp <nl> ppp b / tools / editor / create_dialog . cpp <nl> void CreateDialog : : set_base_type ( const String & p_base ) { <nl> _update_search ( ) ; <nl> } <nl> <nl> + String CreateDialog : : get_selected_type ( ) { <nl> + <nl> + TreeItem * selected = search_options - > get_selected ( ) ; <nl> + if ( selected ) <nl> + return selected - > get_text ( 0 ) ; <nl> + else <nl> + return String ( ) ; <nl> + } <nl> + <nl> Object * CreateDialog : : instance_selected ( ) { <nl> <nl> TreeItem * selected = search_options - > get_selected ( ) ; <nl> mmm a / tools / editor / create_dialog . h <nl> ppp b / tools / editor / create_dialog . h <nl> class CreateDialog : public ConfirmationDialog { <nl> public : <nl> <nl> Object * instance_selected ( ) ; <nl> + String get_selected_type ( ) ; <nl> <nl> void set_base_type ( const String & p_base ) ; <nl> String get_base_type ( ) const ; <nl> mmm a / tools / editor / editor_file_system . cpp <nl> ppp b / tools / editor / editor_file_system . cpp <nl> bool EditorFileSystemDirectory : : is_missing_sources ( int p_idx ) const { <nl> return false ; <nl> } <nl> <nl> + bool EditorFileSystemDirectory : : have_sources_changed ( int p_idx ) const { <nl> + <nl> + ERR_FAIL_INDEX_V ( p_idx , files . size ( ) , false ) ; <nl> + return files [ p_idx ] - > meta . sources_changed ; <nl> + <nl> + } <nl> + <nl> + int EditorFileSystemDirectory : : get_source_count ( int p_idx ) const { <nl> + <nl> + ERR_FAIL_INDEX_V ( p_idx , files . size ( ) , 0 ) ; <nl> + if ( ! files [ p_idx ] - > meta . enabled ) <nl> + return 0 ; <nl> + <nl> + } <nl> + String EditorFileSystemDirectory : : get_source_file ( int p_idx , int p_source ) const { <nl> + <nl> + ERR_FAIL_INDEX_V ( p_idx , files . size ( ) , String ( ) ) ; <nl> + ERR_FAIL_INDEX_V ( p_source , files [ p_idx ] - > meta . sources . size ( ) , String ( ) ) ; <nl> + if ( ! files [ p_idx ] - > meta . enabled ) <nl> + return String ( ) ; <nl> + <nl> + return files [ p_idx ] - > meta . sources [ p_source ] . path ; <nl> + <nl> + } <nl> + bool EditorFileSystemDirectory : : is_source_file_missing ( int p_idx , int p_source ) const { <nl> + <nl> + ERR_FAIL_INDEX_V ( p_idx , files . size ( ) , false ) ; <nl> + ERR_FAIL_INDEX_V ( p_source , files [ p_idx ] - > meta . sources . size ( ) , false ) ; <nl> + if ( ! files [ p_idx ] - > meta . enabled ) <nl> + return false ; <nl> + <nl> + return files [ p_idx ] - > meta . sources [ p_source ] . missing ; <nl> + } <nl> + <nl> + <nl> StringName EditorFileSystemDirectory : : get_file_type ( int p_idx ) const { <nl> <nl> ERR_FAIL_INDEX_V ( p_idx , files . size ( ) , " " ) ; <nl> EditorFileSystemDirectory : : ImportMeta EditorFileSystem : : _get_meta ( const String & <nl> EditorFileSystemDirectory : : ImportMeta m ; <nl> if ( imd . is_null ( ) ) { <nl> m . enabled = false ; <nl> + m . sources_changed = false ; <nl> } else { <nl> m . enabled = true ; <nl> + m . sources_changed = false ; <nl> + <nl> for ( int i = 0 ; i < imd - > get_source_count ( ) ; i + + ) { <nl> EditorFileSystemDirectory : : ImportMeta : : Source s ; <nl> s . path = imd - > get_source_path ( i ) ; <nl> void EditorFileSystem : : _scan_new_dir ( EditorFileSystemDirectory * p_dir , DirAccess <nl> ia . dir = p_dir ; <nl> ia . file = E - > get ( ) ; <nl> scan_actions . push_back ( ia ) ; <nl> + fi - > meta . sources_changed = true ; <nl> + } else { <nl> + fi - > meta . sources_changed = false ; <nl> } <nl> + <nl> + } else { <nl> + fi - > meta . sources_changed = true ; <nl> } <nl> <nl> p_dir - > files . push_back ( fi ) ; <nl> void EditorFileSystem : : _scan_fs_changes ( EditorFileSystemDirectory * p_dir , const S <nl> ia . dir = p_dir ; <nl> ia . file = f ; <nl> scan_actions . push_back ( ia ) ; <nl> + fi - > meta . sources_changed = true ; <nl> + } else { <nl> + fi - > meta . sources_changed = false ; <nl> } <nl> <nl> } else { <nl> void EditorFileSystem : : _scan_fs_changes ( EditorFileSystemDirectory * p_dir , const S <nl> ia . dir = p_dir ; <nl> ia . file = p_dir - > files [ i ] - > file ; <nl> scan_actions . push_back ( ia ) ; <nl> + p_dir - > files [ i ] - > meta . sources_changed = true ; <nl> + } else { <nl> + p_dir - > files [ i ] - > meta . sources_changed = false ; <nl> } <nl> } <nl> <nl> String EditorFileSystem : : get_file_type ( const String & p_file ) const { <nl> <nl> } <nl> <nl> + EditorFileSystemDirectory * EditorFileSystem : : find_file ( const String & p_file , int * r_index ) const { <nl> + <nl> + if ( ! filesystem | | scanning ) <nl> + return NULL ; <nl> + <nl> + EditorFileSystemDirectory * fs = NULL ; <nl> + int cpos = - 1 ; <nl> + if ( ! _find_file ( p_file , & fs , cpos ) ) { <nl> + <nl> + return NULL ; <nl> + } <nl> + <nl> + <nl> + if ( r_index ) <nl> + * r_index = cpos ; <nl> + <nl> + return fs ; <nl> + } <nl> + <nl> <nl> EditorFileSystemDirectory * EditorFileSystem : : get_path ( const String & p_path ) { <nl> <nl> mmm a / tools / editor / editor_file_system . h <nl> ppp b / tools / editor / editor_file_system . h <nl> class EditorFileSystemDirectory : public Object { <nl> String path ; <nl> String md5 ; <nl> uint64_t modified_time ; <nl> - bool missing ; <nl> + bool missing ; <nl> <nl> } ; <nl> <nl> class EditorFileSystemDirectory : public Object { <nl> String import_editor ; <nl> Vector < String > deps ; <nl> bool enabled ; <nl> + bool sources_changed ; <nl> <nl> } ; <nl> <nl> friend class EditorFileSystem ; <nl> StringName get_file_type ( int p_idx ) const ; <nl> bool get_file_meta ( int p_idx ) const ; <nl> bool is_missing_sources ( int p_idx ) const ; <nl> + bool have_sources_changed ( int p_idx ) const ; <nl> Vector < String > get_missing_sources ( int p_idx ) const ; <nl> Vector < String > get_file_deps ( int p_idx ) const ; <nl> + int get_source_count ( int p_idx ) const ; <nl> + String get_source_file ( int p_idx , int p_source ) const ; <nl> + bool is_source_file_missing ( int p_idx , int p_source ) const ; <nl> <nl> EditorFileSystemDirectory * get_parent ( ) ; <nl> <nl> class EditorFileSystem : public Node { <nl> String find_resource_from_source ( const String & p_path ) const ; <nl> EditorFileSystemDirectory * get_path ( const String & p_path ) ; <nl> String get_file_type ( const String & p_file ) const ; <nl> + EditorFileSystemDirectory * find_file ( const String & p_file , int * r_index ) const ; <nl> EditorFileSystem ( ) ; <nl> ~ EditorFileSystem ( ) ; <nl> } ; <nl> mmm a / tools / editor / editor_import_export . cpp <nl> ppp b / tools / editor / editor_import_export . cpp <nl> void EditorImportPlugin : : _bind_methods ( ) { <nl> ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( " import_dialog " , PropertyInfo ( Variant : : STRING , " from " ) ) ) ; <nl> ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( Variant : : INT , " import " , PropertyInfo ( Variant : : STRING , " path " ) , PropertyInfo ( Variant : : OBJECT , " from " , PROPERTY_HINT_RESOURCE_TYPE , " ResourceImportMetadata " ) ) ) ; <nl> ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( Variant : : RAW_ARRAY , " custom_export " , PropertyInfo ( Variant : : STRING , " path " ) , PropertyInfo ( Variant : : OBJECT , " platform " , PROPERTY_HINT_RESOURCE_TYPE , " EditorExportPlatform " ) ) ) ; <nl> + ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( " import_from_drop " , PropertyInfo ( Variant : : STRING_ARRAY , " files " ) , PropertyInfo ( Variant : : STRING , " dest_path " ) ) ) ; <nl> + ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( " reimport_multiple_files " , PropertyInfo ( Variant : : STRING_ARRAY , " files " ) ) ) ; <nl> + ObjectTypeDB : : add_virtual_method ( get_type_static ( ) , MethodInfo ( Variant : : BOOL , " can_reimport_multiple_files " ) ) ; <nl> <nl> / / BIND_VMETHOD ( mi ) ; <nl> } <nl> Error EditorImportPlugin : : import ( const String & p_path , const Ref < ResourceImportM <nl> <nl> Vector < uint8_t > EditorImportPlugin : : custom_export ( const String & p_path , const Ref < EditorExportPlatform > & p_platform ) { <nl> <nl> - if ( get_script_instance ( ) & & get_script_instance ( ) - > has_method ( " _custom_export " ) ) { <nl> - get_script_instance ( ) - > call ( " _custom_export " , p_path , p_platform ) ; <nl> + if ( get_script_instance ( ) & & get_script_instance ( ) - > has_method ( " custom_export " ) ) { <nl> + get_script_instance ( ) - > call ( " custom_export " , p_path , p_platform ) ; <nl> } <nl> <nl> return Vector < uint8_t > ( ) ; <nl> } <nl> <nl> + bool EditorImportPlugin : : can_reimport_multiple_files ( ) const { <nl> + <nl> + if ( get_script_instance ( ) & & get_script_instance ( ) - > has_method ( " can_reimport_multiple_files " ) ) { <nl> + return get_script_instance ( ) - > call ( " can_reimport_multiple_files " ) ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + void EditorImportPlugin : : reimport_multiple_files ( const Vector < String > & p_list ) { <nl> + <nl> + if ( get_script_instance ( ) & & get_script_instance ( ) - > has_method ( " reimport_multiple_files " ) ) { <nl> + get_script_instance ( ) - > call ( " reimport_multiple_files " , p_list ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + void EditorImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + if ( get_script_instance ( ) & & get_script_instance ( ) - > has_method ( " import_from_drop " ) ) { <nl> + get_script_instance ( ) - > call ( " import_from_drop " , p_drop , p_dest_path ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> EditorImportPlugin : : EditorImportPlugin ( ) { <nl> <nl> <nl> mmm a / tools / editor / editor_import_export . h <nl> ppp b / tools / editor / editor_import_export . h <nl> class EditorImportPlugin : public Reference { <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> virtual Error import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) ; <nl> + virtual void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> + virtual void reimport_multiple_files ( const Vector < String > & p_list ) ; <nl> + virtual bool can_reimport_multiple_files ( ) const ; <nl> virtual Vector < uint8_t > custom_export ( const String & p_path , const Ref < EditorExportPlatform > & p_platform ) ; <nl> <nl> EditorImportPlugin ( ) ; <nl> mmm a / tools / editor / editor_node . cpp <nl> ppp b / tools / editor / editor_node . cpp <nl> void EditorNode : : _notification ( int p_what ) { <nl> get_tree ( ) - > get_root ( ) - > set_as_audio_listener ( false ) ; <nl> get_tree ( ) - > get_root ( ) - > set_as_audio_listener_2d ( false ) ; <nl> get_tree ( ) - > set_auto_accept_quit ( false ) ; <nl> + get_tree ( ) - > connect ( " files_dropped " , this , " _dropped_files " ) ; <nl> / / VisualServer : : get_singleton ( ) - > viewport_set_hide_canvas ( editor - > get_scene_root ( ) - > get_viewport ( ) , false ) ; <nl> <nl> / / import_monitor - > scan_changes ( ) ; <nl> void EditorNode : : _notification ( int p_what ) { <nl> _menu_option_confirm ( DEPENDENCY_LOAD_CHANGED_IMAGES , true ) ; <nl> } <nl> <nl> + waiting_for_sources_changed = true ; <nl> EditorFileSystem : : get_singleton ( ) - > scan_sources ( ) ; <nl> <nl> } <nl> void EditorNode : : _fs_changed ( ) { <nl> <nl> void EditorNode : : _sources_changed ( bool p_exist ) { <nl> <nl> + if ( p_exist & & bool ( EditorSettings : : get_singleton ( ) - > get ( " import / automatic_reimport_on_sources_changed " ) ) ) { <nl> + p_exist = false ; <nl> + <nl> + List < String > changed_sources ; <nl> + EditorFileSystem : : get_singleton ( ) - > get_changed_sources ( & changed_sources ) ; <nl> + <nl> + <nl> + EditorProgress ep ( " reimport " , TTR ( " Re - Importing " ) , changed_sources . size ( ) ) ; <nl> + int step_idx = 0 ; <nl> + <nl> + for ( List < String > : : Element * E = changed_sources . front ( ) ; E ; E = E - > next ( ) ) { <nl> + <nl> + ep . step ( TTR ( " Importing : " ) + " " + E - > get ( ) , step_idx + + ) ; <nl> + <nl> + Ref < ResourceImportMetadata > rimd = ResourceLoader : : load_import_metadata ( E - > get ( ) ) ; <nl> + ERR_CONTINUE ( rimd . is_null ( ) ) ; <nl> + String editor = rimd - > get_editor ( ) ; <nl> + if ( editor . begins_with ( " texture_ " ) ) { <nl> + editor = " texture " ; / / compatibility fix for old versions <nl> + } <nl> + Ref < EditorImportPlugin > eip = EditorImportExport : : get_singleton ( ) - > get_import_plugin_by_name ( editor ) ; <nl> + ERR_CONTINUE ( eip . is_null ( ) ) ; <nl> + Error err = eip - > import ( E - > get ( ) , rimd ) ; <nl> + if ( err ! = OK ) { <nl> + EditorNode : : add_io_error ( " Error Re Importing : \ n " + E - > get ( ) ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + EditorFileSystem : : get_singleton ( ) - > scan_sources ( ) ; <nl> + waiting_for_sources_changed = false ; <nl> + <nl> + return ; <nl> + } <nl> + <nl> + <nl> if ( p_exist ) { <nl> <nl> sources_button - > set_icon ( gui_base - > get_icon ( " DependencyChanged " , " EditorIcons " ) ) ; <nl> void EditorNode : : _sources_changed ( bool p_exist ) { <nl> <nl> } <nl> <nl> + waiting_for_sources_changed = false ; <nl> + <nl> } <nl> <nl> void EditorNode : : _vp_resized ( ) { <nl> void EditorNode : : _rebuild_import_menu ( ) <nl> { <nl> PopupMenu * p = import_menu - > get_popup ( ) ; <nl> p - > clear ( ) ; <nl> - p - > add_item ( TTR ( " Node From Scene " ) , FILE_IMPORT_SUBSCENE ) ; <nl> - p - > add_separator ( ) ; <nl> + / / p - > add_item ( TTR ( " Node From Scene " ) , FILE_IMPORT_SUBSCENE ) ; <nl> + / / p - > add_separator ( ) ; <nl> for ( int i = 0 ; i < editor_import_export - > get_import_plugin_count ( ) ; i + + ) { <nl> p - > add_item ( editor_import_export - > get_import_plugin ( i ) - > get_visible_name ( ) , IMPORT_PLUGIN_BASE + i ) ; <nl> } <nl> - p - > add_separator ( ) ; <nl> - p - > add_item ( TTR ( " Re - Import . . " ) , SETTINGS_IMPORT ) ; <nl> + / / p - > add_separator ( ) ; <nl> + / / p - > add_item ( TTR ( " Re - Import . . " ) , SETTINGS_IMPORT ) ; <nl> } <nl> <nl> void EditorNode : : _node_renamed ( ) { <nl> void EditorNode : : _menu_option_confirm ( int p_option , bool p_confirmed ) { <nl> <nl> <nl> } break ; <nl> + <nl> default : { <nl> <nl> if ( p_option > = OBJECT_METHOD_BASE ) { <nl> Variant EditorNode : : drag_resource ( const Ref < Resource > & p_res , Control * p_from ) { <nl> TextureFrame * drag_preview = memnew ( TextureFrame ) ; <nl> Label * label = memnew ( Label ) ; <nl> <nl> + waiting_for_sources_changed = true ; / / <nl> Ref < Texture > preview ; <nl> <nl> { <nl> Variant EditorNode : : drag_files_and_dirs ( const Vector < String > & p_files , Control * <nl> <nl> } <nl> <nl> + <nl> + void EditorNode : : _dropped_files ( const Vector < String > & p_files , int p_screen ) { <nl> + <nl> + String cur_path = scenes_dock - > get_current_path ( ) ; <nl> + for ( int i = 0 ; i < EditorImportExport : : get_singleton ( ) - > get_import_plugin_count ( ) ; i + + ) { <nl> + EditorImportExport : : get_singleton ( ) - > get_import_plugin ( i ) - > import_from_drop ( p_files , cur_path ) ; <nl> + } <nl> + } <nl> + <nl> void EditorNode : : _bind_methods ( ) { <nl> <nl> <nl> void EditorNode : : _bind_methods ( ) { <nl> ObjectTypeDB : : bind_method ( " _toggle_search_bar " , & EditorNode : : _toggle_search_bar ) ; <nl> ObjectTypeDB : : bind_method ( " _clear_search_box " , & EditorNode : : _clear_search_box ) ; <nl> ObjectTypeDB : : bind_method ( " _clear_undo_history " , & EditorNode : : _clear_undo_history ) ; <nl> + ObjectTypeDB : : bind_method ( " _dropped_files " , & EditorNode : : _dropped_files ) ; <nl> + <nl> + <nl> <nl> ObjectTypeDB : : bind_method ( _MD ( " add_editor_import_plugin " , " plugin " ) , & EditorNode : : add_editor_import_plugin ) ; <nl> ObjectTypeDB : : bind_method ( _MD ( " remove_editor_import_plugin " , " plugin " ) , & EditorNode : : remove_editor_import_plugin ) ; <nl> EditorNode : : EditorNode ( ) { <nl> file_server = memnew ( EditorFileServer ) ; <nl> <nl> <nl> - editor_import_export - > add_import_plugin ( Ref < EditorTextureImportPlugin > ( memnew ( EditorTextureImportPlugin ( this , EditorTextureImportPlugin : : MODE_TEXTURE_2D ) ) ) ) ; <nl> - editor_import_export - > add_import_plugin ( Ref < EditorTextureImportPlugin > ( memnew ( EditorTextureImportPlugin ( this , EditorTextureImportPlugin : : MODE_ATLAS ) ) ) ) ; <nl> - editor_import_export - > add_import_plugin ( Ref < EditorTextureImportPlugin > ( memnew ( EditorTextureImportPlugin ( this , EditorTextureImportPlugin : : MODE_LARGE ) ) ) ) ; <nl> - editor_import_export - > add_import_plugin ( Ref < EditorTextureImportPlugin > ( memnew ( EditorTextureImportPlugin ( this , EditorTextureImportPlugin : : MODE_TEXTURE_3D ) ) ) ) ; <nl> + editor_import_export - > add_import_plugin ( Ref < EditorTextureImportPlugin > ( memnew ( EditorTextureImportPlugin ( this ) ) ) ) ; <nl> Ref < EditorSceneImportPlugin > _scene_import = memnew ( EditorSceneImportPlugin ( this ) ) ; <nl> Ref < EditorSceneImporterCollada > _collada_import = memnew ( EditorSceneImporterCollada ) ; <nl> _scene_import - > add_importer ( _collada_import ) ; <nl> EditorNode : : EditorNode ( ) { <nl> _load_docks ( ) ; <nl> <nl> <nl> + <nl> } <nl> <nl> <nl> mmm a / tools / editor / editor_node . h <nl> ppp b / tools / editor / editor_node . h <nl> class EditorNode : public Node { <nl> String open_navigate ; <nl> bool changing_scene ; <nl> <nl> + bool waiting_for_sources_changed ; <nl> + <nl> uint32_t circle_step_msec ; <nl> uint64_t circle_step_frame ; <nl> int circle_step ; <nl> class EditorNode : public Node { <nl> void _add_to_recent_scenes ( const String & p_scene ) ; <nl> void _update_recent_scenes ( ) ; <nl> void _open_recent_scene ( int p_idx ) ; <nl> + void _dropped_files ( const Vector < String > & p_files , int p_screen ) ; <nl> / / void _open_recent_scene_confirm ( ) ; <nl> String _recent_scene ; <nl> <nl> class EditorNode : public Node { <nl> void save_resource ( const Ref < Resource > & p_resource ) ; <nl> void save_resource_as ( const Ref < Resource > & p_resource , const String & p_at_path = String ( ) ) ; <nl> <nl> + void merge_from_scene ( ) { _menu_option_confirm ( FILE_IMPORT_SUBSCENE , false ) ; } <nl> + <nl> static bool has_unsaved_changes ( ) { return singleton - > unsaved_cache ; } <nl> <nl> static HBoxContainer * get_menu_hb ( ) { return singleton - > menu_hb ; } <nl> mmm a / tools / editor / editor_resource_preview . cpp <nl> ppp b / tools / editor / editor_resource_preview . cpp <nl> void EditorResourcePreview : : _preview_ready ( const String & p_str , const Ref < Texture <nl> / / print_line ( " preview is ready " ) ; <nl> preview_mutex - > lock ( ) ; <nl> <nl> + String path = p_str ; <nl> + uint32_t hash = 0 ; <nl> + <nl> + if ( p_str . begins_with ( " ID : " ) ) { <nl> + hash = p_str . get_slicec ( ' : ' , 2 ) . to_int ( ) ; <nl> + path = " ID : " + p_str . get_slicec ( ' : ' , 1 ) ; <nl> + } <nl> + <nl> Item item ; <nl> item . order = order + + ; <nl> item . preview = p_texture ; <nl> - cache [ p_str ] = item ; <nl> + item . last_hash = hash ; <nl> + <nl> + cache [ path ] = item ; <nl> <nl> Object * recv = ObjectDB : : get_instance ( id ) ; <nl> if ( recv ) { <nl> - recv - > call_deferred ( p_func , p_str , p_texture , p_ud ) ; <nl> + recv - > call_deferred ( p_func , path , p_texture , p_ud ) ; <nl> } <nl> <nl> preview_mutex - > unlock ( ) ; <nl> void EditorResourcePreview : : _preview_ready ( const String & p_str , const Ref < Texture <nl> <nl> Ref < Texture > EditorResourcePreview : : _generate_preview ( const QueueItem & p_item , const String & cache_base ) { <nl> <nl> - String type = ResourceLoader : : get_resource_type ( p_item . path ) ; <nl> + String type ; <nl> + <nl> + if ( p_item . resource . is_valid ( ) ) <nl> + type = p_item . resource - > get_type ( ) ; <nl> + else <nl> + type = ResourceLoader : : get_resource_type ( p_item . path ) ; <nl> / / print_line ( " resource type is : " + type ) ; <nl> <nl> if ( type = = " " ) <nl> Ref < Texture > EditorResourcePreview : : _generate_preview ( const QueueItem & p_item , co <nl> for ( int i = 0 ; i < preview_generators . size ( ) ; i + + ) { <nl> if ( ! preview_generators [ i ] - > handles ( type ) ) <nl> continue ; <nl> - generated = preview_generators [ i ] - > generate_from_path ( p_item . path ) ; <nl> + if ( p_item . resource . is_valid ( ) ) { <nl> + generated = preview_generators [ i ] - > generate ( p_item . resource ) ; <nl> + } else { <nl> + generated = preview_generators [ i ] - > generate_from_path ( p_item . path ) ; <nl> + } <nl> <nl> break ; <nl> } <nl> <nl> - if ( generated . is_valid ( ) ) { <nl> - / / print_line ( " was generated " ) ; <nl> - int thumbnail_size = EditorSettings : : get_singleton ( ) - > get ( " file_dialog / thumbnail_size " ) ; <nl> - / / wow it generated a preview . . . save cache <nl> - ResourceSaver : : save ( cache_base + " . png " , generated ) ; <nl> - FileAccess * f = FileAccess : : open ( cache_base + " . txt " , FileAccess : : WRITE ) ; <nl> - f - > store_line ( itos ( thumbnail_size ) ) ; <nl> - f - > store_line ( itos ( FileAccess : : get_modified_time ( p_item . path ) ) ) ; <nl> - f - > store_line ( FileAccess : : get_md5 ( p_item . path ) ) ; <nl> - memdelete ( f ) ; <nl> - } else { <nl> - / / print_line ( " was not generated " ) ; <nl> + if ( ! p_item . resource . is_valid ( ) ) { <nl> + / / cache the preview in case it ' s a resource on disk <nl> + if ( generated . is_valid ( ) ) { <nl> + / / print_line ( " was generated " ) ; <nl> + int thumbnail_size = EditorSettings : : get_singleton ( ) - > get ( " file_dialog / thumbnail_size " ) ; <nl> + / / wow it generated a preview . . . save cache <nl> + ResourceSaver : : save ( cache_base + " . png " , generated ) ; <nl> + FileAccess * f = FileAccess : : open ( cache_base + " . txt " , FileAccess : : WRITE ) ; <nl> + f - > store_line ( itos ( thumbnail_size ) ) ; <nl> + f - > store_line ( itos ( FileAccess : : get_modified_time ( p_item . path ) ) ) ; <nl> + f - > store_line ( FileAccess : : get_md5 ( p_item . path ) ) ; <nl> + memdelete ( f ) ; <nl> + } else { <nl> + / / print_line ( " was not generated " ) ; <nl> <nl> + } <nl> } <nl> <nl> return generated ; <nl> void EditorResourcePreview : : _thread ( ) { <nl> <nl> if ( cache . has ( item . path ) ) { <nl> / / already has it because someone loaded it , just let it know it ' s ready <nl> + if ( item . resource . is_valid ( ) ) { <nl> + item . path + = " : " + itos ( cache [ item . path ] . last_hash ) ; / / keep last hash ( see description of what this is in condition below ) <nl> + } <nl> call_deferred ( " _preview_ready " , item . path , cache [ item . path ] . preview , item . id , item . function , item . userdata ) ; <nl> <nl> + } else if ( item . resource . is_valid ( ) ) { <nl> + <nl> + texture = _generate_preview ( item , String ( ) ) ; <nl> + / / adding hash to the end of path ( should be ID : < objid > : < hash > ) because of 5 argument limit to call_deferred <nl> + call_deferred ( " _preview_ready " , item . path + " : " + itos ( item . resource - > hash_edited_version ( ) ) , texture , item . id , item . function , item . userdata ) ; <nl> + <nl> } else { <nl> <nl> <nl> void EditorResourcePreview : : _thread ( ) { <nl> <nl> <nl> <nl> + void EditorResourcePreview : : queue_edited_resource_preview ( const Ref < Resource > & p_res , Object * p_receiver , const StringName & p_receiver_func , const Variant & p_userdata ) { <nl> + <nl> + ERR_FAIL_NULL ( p_receiver ) ; <nl> + ERR_FAIL_COND ( ! p_res . is_valid ( ) ) ; <nl> + <nl> + preview_mutex - > lock ( ) ; <nl> + <nl> + String path_id = " ID : " + itos ( p_res - > get_instance_ID ( ) ) ; <nl> + if ( cache . has ( path_id ) & & cache [ path_id ] . last_hash = = p_res - > hash_edited_version ( ) ) { <nl> + <nl> + cache [ path_id ] . order = order + + ; <nl> + p_receiver - > call_deferred ( p_receiver_func , path_id , cache [ path_id ] . preview , p_userdata ) ; <nl> + preview_mutex - > unlock ( ) ; <nl> + return ; <nl> + <nl> + } <nl> + <nl> + / / print_line ( " send to thread " + p_path ) ; <nl> + QueueItem item ; <nl> + item . function = p_receiver_func ; <nl> + item . id = p_receiver - > get_instance_ID ( ) ; <nl> + item . resource = p_res ; <nl> + item . path = path_id ; <nl> + item . userdata = p_userdata ; <nl> + <nl> + queue . push_back ( item ) ; <nl> + preview_mutex - > unlock ( ) ; <nl> + preview_sem - > post ( ) ; <nl> + } <nl> <nl> void EditorResourcePreview : : queue_resource_preview ( const String & p_path , Object * p_receiver , const StringName & p_receiver_func , const Variant & p_userdata ) { <nl> <nl> void EditorResourcePreview : : queue_resource_preview ( const String & p_path , Object * <nl> p_receiver - > call_deferred ( p_receiver_func , p_path , cache [ p_path ] . preview , p_userdata ) ; <nl> preview_mutex - > unlock ( ) ; <nl> return ; <nl> - <nl> } <nl> <nl> / / print_line ( " send to thread " + p_path ) ; <nl> mmm a / tools / editor / editor_resource_preview . h <nl> ppp b / tools / editor / editor_resource_preview . h <nl> class EditorResourcePreview : public Node { <nl> static EditorResourcePreview * singleton ; <nl> <nl> struct QueueItem { <nl> + Ref < Resource > resource ; <nl> String path ; <nl> ObjectID id ; <nl> StringName function ; <nl> class EditorResourcePreview : public Node { <nl> struct Item { <nl> Ref < Texture > preview ; <nl> int order ; <nl> + uint32_t last_hash ; <nl> } ; <nl> <nl> int order ; <nl> class EditorResourcePreview : public Node { <nl> static EditorResourcePreview * get_singleton ( ) ; <nl> <nl> / / callback funtion is callback ( String p_path , Ref < Texture > preview , Variant udata ) preview null if could not load <nl> - void queue_resource_preview ( const String & p_path , Object * p_receiver , const StringName & p_receiver_func , const Variant & p_userdata ) ; <nl> + void queue_resource_preview ( const String & p_res , Object * p_receiver , const StringName & p_receiver_func , const Variant & p_userdata ) ; <nl> + void queue_edited_resource_preview ( const Ref < Resource > & p_path , Object * p_receiver , const StringName & p_receiver_func , const Variant & p_userdata ) ; <nl> <nl> void add_preview_generator ( const Ref < EditorResourcePreviewGenerator > & p_generator ) ; <nl> <nl> mmm a / tools / editor / editor_settings . cpp <nl> ppp b / tools / editor / editor_settings . cpp <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> set ( " resources / save_compressed_resources " , true ) ; <nl> set ( " resources / auto_reload_modified_images " , true ) ; <nl> <nl> + set ( " import / automatic_reimport_on_sources_changed " , true ) ; <nl> + <nl> if ( p_extra_config . is_valid ( ) ) { <nl> <nl> if ( p_extra_config - > has_section ( " init_projects " ) & & p_extra_config - > has_section_key ( " init_projects " , " list " ) ) { <nl> Binary files a / tools / editor / icons / icon_dependency_changed . png and b / tools / editor / icons / icon_dependency_changed . png differ <nl> Binary files a / tools / editor / icons / icon_dependency_ok . png and b / tools / editor / icons / icon_dependency_ok . png differ <nl> mmm a / tools / editor / io_plugins / editor_font_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_font_import_plugin . cpp <nl> class EditorFontImportDialog : public ConfirmationDialog { <nl> } <nl> } <nl> <nl> + <nl> + void set_source_and_dest ( const String & p_font , const String & p_dest ) { <nl> + source - > get_line_edit ( ) - > set_text ( p_font ) ; <nl> + dest - > get_line_edit ( ) - > set_text ( p_dest ) ; <nl> + _prop_changed ( ) ; <nl> + } <nl> + <nl> EditorFontImportDialog ( EditorFontImportPlugin * p_plugin ) { <nl> plugin = p_plugin ; <nl> VBoxContainer * vbc = memnew ( VBoxContainer ) ; <nl> Error EditorFontImportPlugin : : import ( const String & p_path , const Ref < ResourceImp <nl> <nl> } <nl> <nl> + void EditorFontImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + String ext = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + String file = p_drop [ i ] . get_file ( ) ; <nl> + if ( ext = = " ttf " | | ext = = " otf " | | ext = = " fnt " ) { <nl> + <nl> + import_dialog ( ) ; <nl> + dialog - > set_source_and_dest ( p_drop [ i ] , p_dest_path . plus_file ( file . basename ( ) + " . fnt " ) ) ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> <nl> EditorFontImportPlugin : : EditorFontImportPlugin ( EditorNode * p_editor ) { <nl> <nl> mmm a / tools / editor / io_plugins / editor_font_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_font_import_plugin . h <nl> class EditorFontImportPlugin : public EditorImportPlugin { <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> virtual Error import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) ; <nl> + virtual void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> <nl> <nl> EditorFontImportPlugin ( EditorNode * p_editor ) ; <nl> mmm a / tools / editor / io_plugins / editor_mesh_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_mesh_import_plugin . cpp <nl> String EditorMeshImportPlugin : : get_name ( ) const { <nl> } <nl> String EditorMeshImportPlugin : : get_visible_name ( ) const { <nl> <nl> - return " 3D Mesh " ; <nl> + return " Mesh " ; <nl> } <nl> void EditorMeshImportPlugin : : import_dialog ( const String & p_from ) { <nl> <nl> Error EditorMeshImportPlugin : : import ( const String & p_path , const Ref < ResourceImp <nl> } <nl> <nl> <nl> + void EditorMeshImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + <nl> + Vector < String > files ; <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + String ext = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + String file = p_drop [ i ] . get_file ( ) ; <nl> + if ( ext = = " obj " ) { <nl> + <nl> + files . push_back ( p_drop [ i ] ) ; <nl> + } <nl> + } <nl> + <nl> + if ( files . size ( ) ) { <nl> + import_dialog ( ) ; <nl> + dialog - > _choose_files ( files ) ; <nl> + dialog - > _choose_save_dir ( p_dest_path ) ; <nl> + } <nl> + } <nl> + <nl> EditorMeshImportPlugin : : EditorMeshImportPlugin ( EditorNode * p_editor ) { <nl> <nl> dialog = memnew ( EditorMeshImportDialog ( this ) ) ; <nl> mmm a / tools / editor / io_plugins / editor_mesh_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_mesh_import_plugin . h <nl> class EditorMeshImportPlugin : public EditorImportPlugin { <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> virtual Error import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) ; <nl> + void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> <nl> <nl> EditorMeshImportPlugin ( EditorNode * p_editor ) ; <nl> mmm a / tools / editor / io_plugins / editor_sample_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_sample_import_plugin . cpp <nl> void EditorSampleImportPlugin : : _compress_ima_adpcm ( const Vector < float > & p_data , D <nl> EditorSampleImportPlugin * EditorSampleImportPlugin : : singleton = NULL ; <nl> <nl> <nl> + void EditorSampleImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + <nl> + Vector < String > files ; <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + String ext = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + <nl> + if ( ext = = " wav " ) { <nl> + <nl> + files . push_back ( p_drop [ i ] ) ; <nl> + } <nl> + } <nl> + <nl> + if ( files . size ( ) ) { <nl> + import_dialog ( ) ; <nl> + dialog - > _choose_files ( files ) ; <nl> + dialog - > _choose_save_dir ( p_dest_path ) ; <nl> + } <nl> + } <nl> + <nl> + void EditorSampleImportPlugin : : reimport_multiple_files ( const Vector < String > & p_list ) { <nl> + <nl> + if ( p_list . size ( ) = = 0 ) <nl> + return ; <nl> + <nl> + Vector < String > sources ; <nl> + for ( int i = 0 ; i < p_list . size ( ) ; i + + ) { <nl> + int idx ; <nl> + EditorFileSystemDirectory * efsd = EditorFileSystem : : get_singleton ( ) - > find_file ( p_list [ i ] , & idx ) ; <nl> + if ( efsd ) { <nl> + for ( int j = 0 ; j < efsd - > get_source_count ( idx ) ; j + + ) { <nl> + String file = expand_source_path ( efsd - > get_source_file ( idx , j ) ) ; <nl> + if ( sources . find ( file ) = = - 1 ) { <nl> + sources . push_back ( file ) ; <nl> + } <nl> + <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( sources . size ( ) ) { <nl> + <nl> + dialog - > popup_import ( p_list [ 0 ] ) ; <nl> + dialog - > _choose_files ( sources ) ; <nl> + dialog - > _choose_save_dir ( p_list [ 0 ] . get_base_dir ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + bool EditorSampleImportPlugin : : can_reimport_multiple_files ( ) const { <nl> + <nl> + return true ; <nl> + } <nl> <nl> EditorSampleImportPlugin : : EditorSampleImportPlugin ( EditorNode * p_editor ) { <nl> <nl> Vector < uint8_t > EditorSampleExportPlugin : : custom_export ( String & p_path , const Ref <nl> } <nl> <nl> <nl> + <nl> EditorSampleExportPlugin : : EditorSampleExportPlugin ( ) { <nl> <nl> } <nl> mmm a / tools / editor / io_plugins / editor_sample_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_sample_import_plugin . h <nl> class EditorSampleImportPlugin : public EditorImportPlugin { <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> virtual Error import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) ; <nl> + void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> + virtual void reimport_multiple_files ( const Vector < String > & p_list ) ; <nl> + virtual bool can_reimport_multiple_files ( ) const ; <nl> <nl> <nl> EditorSampleImportPlugin ( EditorNode * p_editor ) ; <nl> mmm a / tools / editor / io_plugins / editor_scene_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_scene_import_plugin . cpp <nl> <nl> # include " scene / 3d / physics_body . h " <nl> # include " scene / 3d / portal . h " <nl> # include " scene / 3d / vehicle_body . h " <nl> + # include " tools / editor / create_dialog . h " <nl> # include " os / os . h " <nl> <nl> <nl> class EditorImportAnimationOptions : public VBoxContainer { <nl> Tree * optimization_tree ; <nl> Vector < TreeItem * > items ; <nl> <nl> + <nl> bool updating ; <nl> bool validating ; <nl> <nl> class EditorSceneImportDialog : public ConfirmationDialog { <nl> EditorFileDialog * script_select ; <nl> EditorDirDialog * save_select ; <nl> OptionButton * texture_action ; <nl> + CreateDialog * root_type_choose ; <nl> <nl> ConfirmationDialog * confirm_open ; <nl> <nl> class EditorSceneImportDialog : public ConfirmationDialog { <nl> Map < Ref < Mesh > , Ref < Shape > > collision_map ; <nl> ConfirmationDialog * error_dialog ; <nl> <nl> - OptionButton * this_import ; <nl> - OptionButton * next_import ; <nl> + Button * root_type ; <nl> + CheckBox * root_default ; <nl> + <nl> + <nl> + void _root_default_pressed ( ) ; <nl> + void _root_type_pressed ( ) ; <nl> + void _set_root_type ( ) ; <nl> <nl> void _choose_file ( const String & p_path ) ; <nl> void _choose_save_file ( const String & p_path ) ; <nl> class EditorSceneImportDialog : public ConfirmationDialog { <nl> static void _bind_methods ( ) ; <nl> public : <nl> <nl> + void setup_popup ( const String & p_from , const String & p_to_path ) { <nl> + _choose_file ( p_from ) ; <nl> + _choose_save_file ( p_to_path ) ; <nl> + } <nl> + <nl> Error import ( const String & p_from , const String & p_to , const String & p_preset ) ; <nl> void popup_import ( const String & p_from ) ; <nl> EditorSceneImportDialog ( EditorNode * p_editor , EditorSceneImportPlugin * p_plugin ) ; <nl> void EditorSceneImportDialog : : _import ( bool p_and_open ) { <nl> rim - > set_option ( " animation_filters " , animation_options - > get_filter ( ) ) ; <nl> rim - > set_option ( " animation_clips " , animation_options - > get_clips ( ) ) ; <nl> rim - > set_option ( " post_import_script " , script_path - > get_text ( ) ) ; <nl> - rim - > set_option ( " import_this_time " , this_import - > get_selected ( ) ) ; <nl> - rim - > set_option ( " import_next_time " , next_import - > get_selected ( ) ) ; <nl> rim - > set_option ( " reimport " , true ) ; <nl> + if ( ! root_default - > is_pressed ( ) ) { <nl> + rim - > set_option ( " root_type " , root_type - > get_text ( ) ) ; <nl> + } <nl> <nl> List < String > missing ; <nl> Error err = plugin - > import1 ( rim , & scene , & missing ) ; <nl> void EditorSceneImportDialog : : popup_import ( const String & p_from ) { <nl> if ( rimd - > has_option ( " animation_optimizer_max_angle " ) ) <nl> animation_options - > set_optimize_max_angle ( rimd - > get_option ( " animation_optimizer_max_angle " ) ) ; <nl> <nl> + if ( rimd - > has_option ( " root_type " ) ) { <nl> + root_default - > set_pressed ( false ) ; <nl> + String type = rimd - > get_option ( " root_type " ) ; <nl> + root_type - > set_text ( type ) ; <nl> + root_type - > set_disabled ( false ) ; <nl> + <nl> + if ( has_icon ( type , " EditorIcons " ) ) { <nl> + root_type - > set_icon ( get_icon ( type , " EditorIcons " ) ) ; <nl> + } else { <nl> + root_type - > set_icon ( get_icon ( " Object " , " EditorIcons " ) ) ; <nl> + } <nl> + <nl> + } else { <nl> + root_default - > set_pressed ( true ) ; <nl> + root_type - > set_disabled ( true ) ; <nl> + } <nl> <nl> script_path - > set_text ( rimd - > get_option ( " post_import_script " ) ) ; <nl> - if ( rimd - > has_option ( " import_this_time " ) ) <nl> - this_import - > select ( rimd - > get_option ( " import_this_time " ) ) ; <nl> - if ( rimd - > has_option ( " import_next_time " ) ) <nl> - next_import - > select ( rimd - > get_option ( " import_next_time " ) ) ; <nl> <nl> save_path - > set_text ( p_from . get_base_dir ( ) ) ; <nl> import_path - > set_text ( EditorImportPlugin : : expand_source_path ( rimd - > get_source_path ( 0 ) ) ) ; <nl> void EditorSceneImportDialog : : _notification ( int p_what ) { <nl> <nl> List < String > extensions ; <nl> file_select - > clear_filters ( ) ; <nl> + root_type - > set_icon ( get_icon ( " Spatial " , " EditorIcons " ) ) ; <nl> + root_type - > set_text ( " Spatial " ) ; <nl> + root_type - > set_disabled ( true ) ; <nl> <nl> for ( int i = 0 ; i < plugin - > get_importers ( ) . size ( ) ; i + + ) { <nl> plugin - > get_importers ( ) [ i ] - > get_extensions ( & extensions ) ; <nl> void EditorSceneImportDialog : : _dialog_hid ( ) { <nl> wip_rimd = Ref < ResourceImportMetadata > ( ) ; <nl> } <nl> } <nl> + void EditorSceneImportDialog : : _root_default_pressed ( ) { <nl> + <nl> + root_type - > set_disabled ( root_default - > is_pressed ( ) ) ; <nl> + } <nl> + <nl> + void EditorSceneImportDialog : : _root_type_pressed ( ) { <nl> + <nl> + <nl> + root_type_choose - > popup ( false ) ; <nl> + } <nl> + <nl> + <nl> + void EditorSceneImportDialog : : _set_root_type ( ) { <nl> <nl> + String type = root_type_choose - > get_selected_type ( ) ; <nl> + if ( type = = String ( ) ) <nl> + return ; <nl> + root_type - > set_text ( type ) ; <nl> + if ( has_icon ( type , " EditorIcons " ) ) { <nl> + root_type - > set_icon ( get_icon ( type , " EditorIcons " ) ) ; <nl> + } else { <nl> + root_type - > set_icon ( get_icon ( " Object " , " EditorIcons " ) ) ; <nl> + } <nl> + } <nl> <nl> void EditorSceneImportDialog : : _bind_methods ( ) { <nl> <nl> void EditorSceneImportDialog : : _bind_methods ( ) { <nl> ObjectTypeDB : : bind_method ( " _dialog_hid " , & EditorSceneImportDialog : : _dialog_hid ) ; <nl> ObjectTypeDB : : bind_method ( " _import_confirm " , & EditorSceneImportDialog : : _import_confirm ) ; <nl> ObjectTypeDB : : bind_method ( " _open_and_import " , & EditorSceneImportDialog : : _open_and_import ) ; <nl> + ObjectTypeDB : : bind_method ( " _root_default_pressed " , & EditorSceneImportDialog : : _root_default_pressed ) ; <nl> + ObjectTypeDB : : bind_method ( " _root_type_pressed " , & EditorSceneImportDialog : : _root_type_pressed ) ; <nl> + ObjectTypeDB : : bind_method ( " _set_root_type " , & EditorSceneImportDialog : : _set_root_type ) ; <nl> + <nl> <nl> ADD_SIGNAL ( MethodInfo ( " imported " , PropertyInfo ( Variant : : OBJECT , " scene " ) ) ) ; <nl> } <nl> <nl> <nl> <nl> - <nl> const EditorSceneImportDialog : : FlagInfo EditorSceneImportDialog : : scene_flag_names [ ] = { <nl> <nl> { EditorSceneImportPlugin : : SCENE_FLAG_REMOVE_NOIMP , ( " Actions " ) , " Remove Nodes ( - noimp ) " , true } , <nl> EditorSceneImportDialog : : EditorSceneImportDialog ( EditorNode * p_editor , EditorSce <nl> error_dialog - > get_ok ( ) - > set_text ( TTR ( " Accept " ) ) ; <nl> / / error_dialog - > get_cancel ( ) - > hide ( ) ; <nl> <nl> + <nl> + HBoxContainer * custom_root_hb = memnew ( HBoxContainer ) ; <nl> + vbc - > add_margin_child ( TTR ( " Custom Root Node Type : " ) , custom_root_hb ) ; <nl> + root_type = memnew ( Button ) ; <nl> + root_type - > set_h_size_flags ( SIZE_EXPAND_FILL ) ; <nl> + root_type - > set_text_align ( Button : : ALIGN_LEFT ) ; <nl> + root_type - > connect ( " pressed " , this , " _root_type_pressed " ) ; <nl> + custom_root_hb - > add_child ( root_type ) ; <nl> + <nl> + root_default = memnew ( CheckBox ) ; <nl> + root_default - > set_text ( " Auto " ) ; <nl> + root_default - > set_pressed ( true ) ; <nl> + root_default - > connect ( " pressed " , this , " _root_default_pressed " ) ; <nl> + custom_root_hb - > add_child ( root_default ) ; <nl> + <nl> + <nl> + / * <nl> this_import = memnew ( OptionButton ) ; <nl> this_import - > add_item ( TTR ( " Overwrite Existing Scene " ) ) ; <nl> this_import - > add_item ( TTR ( " Overwrite Existing , Keep Materials " ) ) ; <nl> EditorSceneImportDialog : : EditorSceneImportDialog ( EditorNode * p_editor , EditorSce <nl> next_import - > add_item ( TTR ( " Keep Existing , Merge with New " ) ) ; <nl> next_import - > add_item ( TTR ( " Keep Existing , Ignore New " ) ) ; <nl> vbc - > add_margin_child ( TTR ( " Next Time : " ) , next_import ) ; <nl> - <nl> + * / <nl> set_hide_on_ok ( false ) ; <nl> <nl> GLOBAL_DEF ( " import / shared_textures " , " res : / / " ) ; <nl> EditorSceneImportDialog : : EditorSceneImportDialog ( EditorNode * p_editor , EditorSce <nl> <nl> import_hb - > add_constant_override ( " separation " , 30 ) ; <nl> <nl> + <nl> VBoxContainer * ovb = memnew ( VBoxContainer ) ; <nl> ovb - > set_h_size_flags ( SIZE_EXPAND_FILL ) ; <nl> import_hb - > add_child ( ovb ) ; <nl> EditorSceneImportDialog : : EditorSceneImportDialog ( EditorNode * p_editor , EditorSce <nl> wip_open = false ; <nl> / / texture_options - > set_format ( EditorImport : : IMAGE_FORMAT_C ) ; <nl> <nl> + root_type_choose = memnew ( CreateDialog ) ; <nl> + add_child ( root_type_choose ) ; <nl> + root_type_choose - > set_base_type ( " Node " ) ; <nl> + root_type_choose - > connect ( " create " , this , " _set_root_type " ) ; <nl> } <nl> <nl> <nl> String EditorSceneImportPlugin : : get_name ( ) const { <nl> <nl> String EditorSceneImportPlugin : : get_visible_name ( ) const { <nl> <nl> - return " 3D Scene " ; <nl> + return " Scene " ; <nl> } <nl> <nl> void EditorSceneImportPlugin : : import_dialog ( const String & p_from ) { <nl> Node * EditorSceneImportPlugin : : _fix_node ( Node * p_node , Node * p_root , Map < Ref < Mesh > <nl> } <nl> <nl> <nl> - void EditorSceneImportPlugin : : _merge_existing_node ( Node * p_node , Node * p_imported_scene , Set < Ref < Resource > > & checked_resources , Set < Node * > & checked_nodes ) { <nl> - <nl> - <nl> - NodePath path = p_node - > get_import_path ( ) ; <nl> - <nl> - if ( ! path . is_empty ( ) & & p_imported_scene - > has_node ( path ) ) { <nl> - <nl> - Node * imported_node = p_imported_scene - > get_node ( path ) ; <nl> - <nl> - if ( imported_node - > get_type ( ) = = p_node - > get_type ( ) ) { <nl> - / / same thing , check what it is <nl> - <nl> - if ( p_node - > get_type ( ) = = " MeshInstance " ) { <nl> - <nl> - / / merge mesh instance , this is a special case ! <nl> - MeshInstance * mi_imported = imported_node - > cast_to < MeshInstance > ( ) ; <nl> - MeshInstance * mi_node = p_node - > cast_to < MeshInstance > ( ) ; <nl> - <nl> - Ref < Mesh > mesh_imported = mi_imported - > get_mesh ( ) ; <nl> - Ref < Mesh > mesh_node = mi_node - > get_mesh ( ) ; <nl> - <nl> - if ( mesh_node . is_null ( ) & & mesh_imported . is_valid ( ) ) { <nl> - <nl> - mi_node - > set_mesh ( mesh_imported ) ; <nl> - <nl> - } else if ( mesh_node . is_valid ( ) & & mesh_imported . is_valid ( ) ) { <nl> - <nl> - if ( checked_resources . has ( mesh_imported ) ) { <nl> - <nl> - mi_node - > set_mesh ( mesh_imported ) ; <nl> - } else { <nl> - / / mix up meshes <nl> - / / import new geometry but keep materials <nl> - for ( int i = 0 ; i < mesh_imported - > get_surface_count ( ) ; i + + ) { <nl> - <nl> - String name = mesh_imported - > surface_get_name ( i ) ; <nl> - <nl> - for ( int j = 0 ; j < mesh_node - > get_surface_count ( ) ; j + + ) { <nl> - <nl> - Ref < Material > mat = mesh_node - > surface_get_material ( j ) ; <nl> - if ( mat . is_valid ( ) & & mesh_node - > surface_get_name ( j ) = = name ) { <nl> - <nl> - mesh_imported - > surface_set_material ( i , mat ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - / / was imported , do nothing further <nl> - checked_resources . insert ( mesh_imported ) ; <nl> - mi_node - > set_mesh ( mesh_imported ) ; <nl> - } <nl> - <nl> - } <nl> - } else if ( p_node - > get_type ( ) = = " Path " ) { <nl> - / / for paths , overwrite path <nl> - Path * path_imported = imported_node - > cast_to < Path > ( ) ; <nl> - Path * path_node = p_node - > cast_to < Path > ( ) ; <nl> - <nl> - if ( path_imported - > get_curve ( ) . is_valid ( ) ) { <nl> - <nl> - path_node - > set_curve ( path_imported - > get_curve ( ) ) ; <nl> - } <nl> - } else if ( p_node - > get_type ( ) = = " Portal " ) { <nl> - / / for paths , overwrite path <nl> - <nl> - Portal * portal_imported = imported_node - > cast_to < Portal > ( ) ; <nl> - Portal * portal_node = p_node - > cast_to < Portal > ( ) ; <nl> - <nl> - portal_node - > set_shape ( portal_imported - > get_shape ( ) ) ; <nl> - <nl> - } else if ( p_node - > get_type ( ) = = " Room " ) { <nl> - / / for paths , overwrite path <nl> - <nl> - Room * room_imported = imported_node - > cast_to < Room > ( ) ; <nl> - Room * room_node = p_node - > cast_to < Room > ( ) ; <nl> - <nl> - room_node - > set_room ( room_imported - > get_room ( ) ) ; <nl> <nl> - } else if ( p_node - > get_type ( ) = = " Skeleton " ) { <nl> - / / for paths , overwrite path <nl> - <nl> - Skeleton * skeleton_imported = imported_node - > cast_to < Skeleton > ( ) ; <nl> - Skeleton * skeleton_node = p_node - > cast_to < Skeleton > ( ) ; <nl> - <nl> - / / use imported bones , obviously <nl> - skeleton_node - > clear_bones ( ) ; <nl> - for ( int i = 0 ; i < skeleton_imported - > get_bone_count ( ) ; i + + ) { <nl> - <nl> - skeleton_node - > add_bone ( skeleton_imported - > get_bone_name ( i ) ) ; <nl> - skeleton_node - > set_bone_parent ( i , skeleton_imported - > get_bone_parent ( i ) ) ; <nl> - skeleton_node - > set_bone_rest ( i , skeleton_imported - > get_bone_rest ( i ) ) ; <nl> - / / skeleton_node - > set_bone_pose ( i , skeleton_imported - > get_bone_pose ( i ) ) ; / / not in a scene , will throw errors <nl> - } <nl> - } <nl> - else if ( p_node - > get_type ( ) = = " AnimationPlayer " ) { <nl> - / / for paths , overwrite path <nl> - AnimationPlayer * aplayer_imported = imported_node - > cast_to < AnimationPlayer > ( ) ; <nl> - AnimationPlayer * aplayer_node = p_node - > cast_to < AnimationPlayer > ( ) ; <nl> - <nl> - / / use imported bones , obviously <nl> - List < StringName > anims ; <nl> - List < StringName > existing_anims ; <nl> - aplayer_imported - > get_animation_list ( & anims ) ; <nl> - aplayer_node - > get_animation_list ( & existing_anims ) ; <nl> - <nl> - / / use imported animations <nl> - for ( List < StringName > : : Element * N = anims . front ( ) ; N ; N = N - > next ( ) ) { <nl> - <nl> - Ref < Animation > candidate = aplayer_imported - > get_animation ( N - > get ( ) ) ; <nl> - <nl> - if ( aplayer_node - > has_animation ( N - > get ( ) ) ) { <nl> - <nl> - Ref < Animation > found = aplayer_node - > get_animation ( N - > get ( ) ) ; <nl> - <nl> - candidate - > set_loop ( found - > has_loop ( ) ) ; <nl> - candidate - > set_step ( found - > get_step ( ) ) ; <nl> - <nl> - / / For each track candidate <nl> - for ( int i = 0 ; i < candidate - > get_track_count ( ) ; i + + ) { <nl> - <nl> - NodePath track_path = candidate - > track_get_path ( i ) ; <nl> - / / For each track existing <nl> - for ( int x = 0 ; x < found - > get_track_count ( ) ; x + + ) { <nl> - <nl> - NodePath path_to_compare = found - > track_get_path ( x ) ; <nl> - <nl> - if ( track_path . hash ( ) = = path_to_compare . hash ( ) & & candidate - > track_get_type ( x ) = = found - > track_get_type ( i ) ) { <nl> - <nl> - / / Tracks matches <nl> - if ( candidate - > track_get_interpolation_type ( i ) ! = found - > track_get_interpolation_type ( x ) ) <nl> - candidate - > track_set_interpolation_type ( i , found - > track_get_interpolation_type ( x ) ) ; <nl> - if ( candidate - > track_get_type ( i ) = = Animation : : TYPE_VALUE & & candidate - > value_track_is_continuous ( i ) ! = found - > value_track_is_continuous ( x ) ) <nl> - candidate - > value_track_set_continuous ( i , found - > value_track_is_continuous ( x ) ) ; <nl> - <nl> - / / Key transitions might have changed , but the animation remained unchanged <nl> - if ( candidate - > track_get_key_count ( i ) = = found - > track_get_key_count ( x ) ) { <nl> - for ( int k = 0 ; k < candidate - > track_get_key_count ( i ) ; k + + ) { <nl> - <nl> - if ( candidate - > track_get_key_transition ( i , k ) ! = found - > track_get_key_transition ( x , k ) ) <nl> - candidate - > track_set_key_transition ( i , k , found - > track_get_key_transition ( x , k ) ) ; <nl> - } <nl> - } <nl> - <nl> - } <nl> - <nl> - } <nl> - } <nl> - <nl> - / / Append function callbacks and values <nl> - for ( int x = 0 ; x < found - > get_track_count ( ) ; x + + ) { <nl> - if ( found - > track_get_type ( x ) = = Animation : : TYPE_METHOD | | found - > track_get_type ( x ) = = Animation : : TYPE_VALUE ) <nl> - candidate - > add_track ( found - > track_get_type ( x ) , candidate - > get_track_count ( ) ) ; <nl> - <nl> - for ( int k = 0 ; k < found - > track_get_key_count ( x ) ; k + + ) <nl> - candidate - > track_insert_key ( x , found - > track_get_key_time ( x , k ) , found - > track_get_key_value ( x , k ) , found - > track_get_key_transition ( x , k ) ) ; <nl> - } <nl> - } <nl> - <nl> - aplayer_node - > add_animation ( N - > get ( ) , candidate ) ; <nl> - } <nl> - <nl> - } else if ( p_node - > get_type ( ) = = " CollisionShape " ) { <nl> - / / for paths , overwrite path <nl> - <nl> - CollisionShape * collision_imported = imported_node - > cast_to < CollisionShape > ( ) ; <nl> - CollisionShape * collision_node = p_node - > cast_to < CollisionShape > ( ) ; <nl> - <nl> - collision_node - > set_shape ( collision_imported - > get_shape ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - if ( p_node - > cast_to < Spatial > ( ) & & imported_node - > cast_to < Spatial > ( ) ) { <nl> - / / apply transform if changed <nl> - Spatial * snode = p_node - > cast_to < Spatial > ( ) ; <nl> - Spatial * simp = imported_node - > cast_to < Spatial > ( ) ; <nl> - <nl> - if ( snode - > get_import_transform ( ) = = snode - > get_transform ( ) ) { <nl> - / / not moved , apply new <nl> - snode - > set_import_transform ( simp - > get_transform ( ) ) ; <nl> - snode - > set_transform ( simp - > get_transform ( ) ) ; <nl> - } else if ( snode - > get_import_transform ( ) = = simp - > get_import_transform ( ) ) { <nl> - / / do nothing , nothing changed keep local changes <nl> - } else { <nl> - / / changed both , imported and edited , merge <nl> - Transform local_xform = snode - > get_import_transform ( ) . affine_inverse ( ) * snode - > get_transform ( ) ; <nl> - snode - > set_import_transform ( simp - > get_import_transform ( ) ) ; <nl> - snode - > set_transform ( simp - > get_import_transform ( ) * local_xform ) ; <nl> - } <nl> - } <nl> - <nl> - checked_nodes . insert ( imported_node ) ; <nl> - <nl> - } <nl> - # if 0 <nl> - else { <nl> - <nl> - if ( p_node ! = p_root & & p_existing - > has_node ( p_root - > get_path_to ( p_node - > get_parent ( ) ) ) ) { <nl> - <nl> - Node * parent = p_existing - > get_node ( p_root - > get_path_to ( p_node - > get_parent ( ) ) ) ; <nl> - NodePath path = p_root - > get_path_to ( p_node ) ; <nl> - <nl> - / / add it . . because not existing in existing scene <nl> - Object * o = ObjectTypeDB : : instance ( p_existing - > get_type ( ) ) ; <nl> - Node * n = NULL ; <nl> - if ( o ) <nl> - n = o - > cast_to < Node > ( ) ; <nl> - <nl> - if ( n ) { <nl> - <nl> - List < PropertyInfo > pl ; <nl> - p_existing - > get_property_list ( & pl ) ; <nl> - for ( List < PropertyInfo > : : Element * E = pl . front ( ) ; E ; E = E - > next ( ) ) { <nl> - if ( ! ( E - > get ( ) . usage & PROPERTY_USAGE_STORAGE ) ) <nl> - continue ; <nl> - n - > set ( E - > get ( ) . name , p_existing - > get ( E - > get ( ) . name ) ) ; <nl> - } <nl> - <nl> - parent - > add_child ( n ) ; <nl> - <nl> - valid = true ; <nl> - } <nl> - } <nl> - <nl> - } <nl> - # endif <nl> - <nl> - for ( int i = 0 ; i < p_node - > get_child_count ( ) ; i + + ) { <nl> - _merge_existing_node ( p_node - > get_child ( i ) , p_imported_scene , checked_resources , checked_nodes ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void EditorSceneImportPlugin : : _add_new_nodes ( Node * p_node , Node * p_imported , Node * p_imported_scene , Node * p_existing_scene , Set < Node * > & checked_nodes ) { <nl> - <nl> - <nl> - for ( int i = 0 ; i < p_imported - > get_child_count ( ) ; i + + ) { <nl> - <nl> - <nl> - Node * imported_node = p_imported - > get_child ( i ) ; <nl> - <nl> - if ( imported_node - > get_owner ( ) ! = p_imported_scene ) { <nl> - / / print_line ( " skipping because not imported at " + String ( imported_node - > get_name ( ) ) ) ; <nl> - continue ; / / end of the road <nl> - } <nl> - <nl> - Vector < StringName > nn ; <nl> - nn . push_back ( imported_node - > get_name ( ) ) ; <nl> - NodePath imported_path ( nn , false ) ; <nl> - / / print_line ( " check for : " + String ( imported_path ) ) ; <nl> - <nl> - if ( ! p_node - > has_node ( imported_path ) & & ! checked_nodes . has ( imported_node ) ) { <nl> - / / not there , re - add it <nl> - / / add it . . because not existing in existing scene <nl> - Object * o = ObjectTypeDB : : instance ( imported_node - > get_type ( ) ) ; <nl> - Node * n = NULL ; <nl> - if ( o ) <nl> - n = o - > cast_to < Node > ( ) ; <nl> - <nl> - / / print_line ( " creating node of same type . . " ) ; <nl> - <nl> - if ( n ) { <nl> - <nl> - / / print_line ( " copy props and add " ) ; <nl> - List < PropertyInfo > pl ; <nl> - imported_node - > get_property_list ( & pl ) ; <nl> - for ( List < PropertyInfo > : : Element * E = pl . front ( ) ; E ; E = E - > next ( ) ) { <nl> - if ( ! ( E - > get ( ) . usage & PROPERTY_USAGE_STORAGE ) ) <nl> - continue ; <nl> - n - > set ( E - > get ( ) . name , imported_node - > get ( E - > get ( ) . name ) ) ; <nl> - } <nl> - <nl> - p_node - > add_child ( n ) ; <nl> - n - > set_owner ( p_existing_scene ) ; <nl> - } <nl> - <nl> - } else { <nl> - / / print_line ( " already exists " ) ; <nl> - } <nl> - <nl> - <nl> - if ( p_node - > has_node ( imported_path ) ) { <nl> - <nl> - Node * other_node = p_node - > get_node ( imported_path ) ; <nl> - <nl> - _add_new_nodes ( other_node , imported_node , p_imported_scene , p_existing_scene , checked_nodes ) ; <nl> - <nl> - } <nl> - <nl> - } <nl> - } <nl> - <nl> - <nl> - void EditorSceneImportPlugin : : _merge_scenes ( Node * p_node , Node * p_imported ) { <nl> - <nl> - Set < Ref < Resource > > checked_resources ; <nl> - Set < Node * > checked_nodes ; <nl> - _merge_existing_node ( p_node , p_imported , checked_resources , checked_nodes ) ; <nl> - _add_new_nodes ( p_node , p_imported , p_imported , p_node , checked_nodes ) ; <nl> - / / add existing . . ? <nl> - } <nl> - <nl> - <nl> - void EditorSceneImportPlugin : : _scan_materials ( Node * p_base , Node * p_node , Map < String , Ref < Material > > & mesh_materials , Map < String , Ref < Material > > & override_materials ) { <nl> - <nl> - if ( ! p_base & & p_node - > get_owner ( ) ! = p_base ) <nl> - return ; <nl> - MeshInstance * mi = p_node - > cast_to < MeshInstance > ( ) ; <nl> - <nl> - if ( mi ) { <nl> - if ( mi - > get_material_override ( ) . is_valid ( ) ) { <nl> - String path = p_base - > get_path_to ( p_node ) ; <nl> - override_materials [ path ] = mi - > get_material_override ( ) ; <nl> - } <nl> - Ref < Mesh > mesh = mi - > get_mesh ( ) ; <nl> - if ( mesh . is_valid ( ) ) { <nl> - <nl> - for ( int i = 0 ; i < mesh - > get_surface_count ( ) ; i + + ) { <nl> - <nl> - String name = mesh - > get_name ( ) + " : " + mesh - > surface_get_name ( i ) ; <nl> - if ( ! mesh_materials . has ( name ) ) { <nl> - mesh_materials [ name ] = mesh - > surface_get_material ( i ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - for ( int i = 0 ; i < p_node - > get_child_count ( ) ; i + + ) { <nl> - _scan_materials ( p_base , p_node - > get_child ( i ) , mesh_materials , override_materials ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void EditorSceneImportPlugin : : _apply_materials ( Node * p_base , Node * p_node , Map < String , Ref < Material > > & mesh_materials , Map < String , Ref < Material > > & override_materials , Set < Ref < Mesh > > & meshes_processed ) { <nl> - <nl> - if ( p_node ! = p_base & & p_node - > get_owner ( ) ! = p_base ) <nl> - return ; <nl> - <nl> - MeshInstance * mi = p_node - > cast_to < MeshInstance > ( ) ; <nl> - <nl> - if ( mi ) { <nl> - <nl> - print_line ( " is mesh " + String ( p_node - > get_name ( ) ) ) ; <nl> - String path = p_base - > get_path_to ( p_node ) ; <nl> - if ( override_materials . has ( path ) ) { <nl> - print_line ( " is in material overrides " ) ; <nl> - mi - > set_material_override ( override_materials [ path ] ) ; <nl> - } <nl> - <nl> - Ref < Mesh > mesh = mi - > get_mesh ( ) ; <nl> - if ( mesh . is_valid ( ) & & ! meshes_processed . has ( mesh ) ) { <nl> - print_line ( " mesh was not processed " ) ; <nl> - meshes_processed . insert ( mesh ) ; <nl> - for ( int i = 0 ; i < mesh - > get_surface_count ( ) ; i + + ) { <nl> - <nl> - String name = mesh - > get_name ( ) + " : " + mesh - > surface_get_name ( i ) ; <nl> - print_line ( " name for surface " + itos ( i ) + " : " + name ) ; <nl> - if ( mesh_materials . has ( name ) ) { <nl> - <nl> - Ref < Material > mat = mesh_materials [ name ] ; <nl> - mesh - > surface_set_material ( i , mat ) ; <nl> - print_line ( " overriding ! " ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - for ( int i = 0 ; i < p_node - > get_child_count ( ) ; i + + ) { <nl> - _apply_materials ( p_base , p_node - > get_child ( i ) , mesh_materials , override_materials , meshes_processed ) ; <nl> - } <nl> - } <nl> - <nl> - void EditorSceneImportPlugin : : _merge_materials ( Node * p_node , Node * p_imported ) { <nl> - <nl> - Map < String , Ref < Material > > mesh_materials ; <nl> - Map < String , Ref < Material > > override_materials ; <nl> - <nl> - _scan_materials ( p_node , p_node , mesh_materials , override_materials ) ; <nl> - <nl> - for ( Map < String , Ref < Material > > : : Element * E = mesh_materials . front ( ) ; E ; E = E - > next ( ) ) { <nl> - print_line ( " Mats : " + String ( E - > key ( ) ) ) ; <nl> - } <nl> - <nl> - for ( Map < String , Ref < Material > > : : Element * E = override_materials . front ( ) ; E ; E = E - > next ( ) ) { <nl> - print_line ( " Overrides : " + String ( E - > key ( ) ) ) ; <nl> - } <nl> - <nl> - Set < Ref < Mesh > > mp ; <nl> - _apply_materials ( p_imported , p_imported , mesh_materials , override_materials , mp ) ; <nl> - <nl> - <nl> - } <nl> <nl> # if 0 <nl> <nl> Error EditorSceneImportPlugin : : import1 ( const Ref < ResourceImportMetadata > & p_from <nl> return err ; <nl> } <nl> <nl> + if ( from - > has_option ( " root_type " ) ) { <nl> + String type = from - > get_option ( " root_type " ) ; <nl> + Object * base = ObjectTypeDB : : instance ( type ) ; <nl> + Node * base_node = NULL ; <nl> + if ( base ) <nl> + base_node = base - > cast_to < Node > ( ) ; <nl> + <nl> + if ( base_node ) { <nl> + <nl> + scene - > replace_by ( base_node ) ; <nl> + memdelete ( scene ) ; <nl> + scene = base_node ; <nl> + } <nl> + } <nl> + <nl> _tag_import_paths ( scene , scene ) ; <nl> <nl> * r_node = scene ; <nl> Error EditorSceneImportPlugin : : import2 ( Node * scene , const String & p_dest_path , c <nl> } <nl> } <nl> <nl> - Error err = EditorTextureImportPlugin : : get_singleton ( EditorTextureImportPlugin : : MODE_TEXTURE_3D ) - > import ( target_path , imd ) ; <nl> + Error err = EditorTextureImportPlugin : : get_singleton ( ) - > import ( target_path , imd ) ; <nl> <nl> } <nl> } <nl> <nl> <nl> - / / / BEFORE SAVING - MERGE <nl> - <nl> - <nl> - if ( import_action ! = SCENE_UPDATE_REPLACE_WITH_NEW ) { <nl> - <nl> - <nl> - progress . step ( TTR ( " Merging . . " ) , 103 ) ; <nl> - <nl> - FileAccess * fa = FileAccess : : create ( FileAccess : : ACCESS_RESOURCES ) ; <nl> - <nl> - if ( fa - > file_exists ( p_dest_path ) ) { <nl> - <nl> - <nl> - / / try to merge <nl> - <nl> - Ref < PackedScene > s = ResourceLoader : : load ( p_dest_path ) ; <nl> - if ( s . is_valid ( ) ) { <nl> - <nl> - Node * existing = s - > instance ( true ) ; <nl> - <nl> - if ( existing ) { <nl> - <nl> - <nl> - switch ( import_action ) { <nl> - <nl> - case SCENE_UPDATE_REPLACE_WITH_NEW : break ; <nl> - case SCENE_UPDATE_REPLACE_WITH_NEW_KEEP_MATERIALS : { <nl> - <nl> - _merge_materials ( existing , scene ) ; <nl> - memdelete ( existing ) ; <nl> - <nl> - } break ; <nl> - case SCENE_UPDATE_KEEP_OLD_MERGE_CHANGES : { <nl> - <nl> - _merge_scenes ( existing , scene ) ; <nl> - memdelete ( scene ) ; <nl> - scene = existing ; <nl> - <nl> - } break ; <nl> - case SCENE_UPDATE_KEEP_OLD : { <nl> - <nl> - memdelete ( scene ) ; <nl> - scene = existing ; <nl> - } break ; <nl> - } <nl> - <nl> - } <nl> - } <nl> - <nl> - } <nl> - <nl> - memdelete ( fa ) ; <nl> - } <nl> - <nl> <nl> progress . step ( TTR ( " Saving . . " ) , 104 ) ; <nl> <nl> void EditorSceneImportPlugin : : add_importer ( const Ref < EditorSceneImporter > & p_imp <nl> importers . push_back ( p_importer ) ; <nl> } <nl> <nl> + void EditorSceneImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + List < String > extensions ; <nl> + for ( int i = 0 ; i < importers . size ( ) ; i + + ) { <nl> + importers [ i ] - > get_extensions ( & extensions ) ; <nl> + } <nl> + / / bool warn_compatible = false ; <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + <nl> + String extension = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + <nl> + for ( List < String > : : Element * E = extensions . front ( ) ; E ; E = E - > next ( ) ) { <nl> + <nl> + if ( E - > get ( ) = = extension ) { <nl> + <nl> + dialog - > popup_import ( String ( ) ) ; <nl> + dialog - > setup_popup ( p_drop [ i ] , p_dest_path ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } <nl> + <nl> <nl> EditorSceneImportPlugin : : EditorSceneImportPlugin ( EditorNode * p_editor ) { <nl> <nl> mmm a / tools / editor / io_plugins / editor_scene_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_scene_import_plugin . h <nl> <nl> # include " tools / editor / io_plugins / editor_texture_import_plugin . h " <nl> # include " scene / resources / animation . h " <nl> <nl> + <nl> class EditorNode ; <nl> class EditorSceneImportDialog ; <nl> <nl> class EditorSceneImportPlugin : public EditorImportPlugin { <nl> void _create_clips ( Node * scene , const Array & p_clips , bool p_bake_all ) ; <nl> void _filter_anim_tracks ( Ref < Animation > anim , Set < String > & keep ) ; <nl> void _filter_tracks ( Node * scene , const String & p_text ) ; <nl> - void _merge_existing_node ( Node * p_node , Node * p_imported_scene , Set < Ref < Resource > > & checked_resources , Set < Node * > & checked_nodes ) ; <nl> - <nl> - void _add_new_nodes ( Node * p_node , Node * p_imported , Node * p_imported_scene , Node * p_existing_scene , Set < Node * > & checked_nodes ) ; <nl> void _optimize_animations ( Node * scene , float p_max_lin_error , float p_max_ang_error , float p_max_angle ) ; <nl> <nl> - void _merge_scenes ( Node * p_node , Node * p_imported ) ; <nl> - void _scan_materials ( Node * p_base , Node * p_node , Map < String , Ref < Material > > & mesh_materials , Map < String , Ref < Material > > & override_materials ) ; <nl> - void _apply_materials ( Node * p_base , Node * p_node , Map < String , Ref < Material > > & mesh_materials , Map < String , Ref < Material > > & override_materials , Set < Ref < Mesh > > & meshes_processed ) ; <nl> - void _merge_materials ( Node * p_node , Node * p_imported ) ; <nl> - <nl> void _tag_import_paths ( Node * p_scene , Node * p_node ) ; <nl> <nl> public : <nl> class EditorSceneImportPlugin : public EditorImportPlugin { <nl> SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY = 1 < < 30 , <nl> } ; <nl> <nl> - enum SceneUpdate { <nl> - SCENE_UPDATE_REPLACE_WITH_NEW , <nl> - SCENE_UPDATE_REPLACE_WITH_NEW_KEEP_MATERIALS , <nl> - SCENE_UPDATE_KEEP_OLD_MERGE_CHANGES , <nl> - SCENE_UPDATE_KEEP_OLD , <nl> - } ; <nl> - <nl> <nl> virtual String get_name ( ) const ; <nl> virtual String get_visible_name ( ) const ; <nl> class EditorSceneImportPlugin : public EditorImportPlugin { <nl> void add_importer ( const Ref < EditorSceneImporter > & p_importer ) ; <nl> const Vector < Ref < EditorSceneImporter > > & get_importers ( ) { return importers ; } <nl> <nl> + virtual void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> + <nl> EditorSceneImportPlugin ( EditorNode * p_editor = NULL ) ; <nl> <nl> <nl> mmm a / tools / editor / io_plugins / editor_texture_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_texture_import_plugin . cpp <nl> <nl> # include " io / md5 . h " <nl> # include " io / marshalls . h " <nl> # include " globals . h " <nl> + # include " scene / gui / check_button . h " <nl> + # include " scene / gui / button_group . h " <nl> + # include " scene / gui / margin_container . h " <nl> <nl> static const char * flag_names [ ] = { <nl> ( " Streaming Format " ) , <nl> void EditorImportTextureOptions : : _notification ( int p_what ) { <nl> <nl> void EditorImportTextureOptions : : show_2d_notice ( ) { <nl> <nl> - notice_for_2d - > show ( ) ; <nl> + / / notice_for_2d - > show ( ) ; <nl> } <nl> <nl> EditorImportTextureOptions : : EditorImportTextureOptions ( ) { <nl> <nl> <nl> + add_constant_override ( " separation " , 3 ) ; <nl> updating = false ; <nl> format = memnew ( OptionButton ) ; <nl> <nl> EditorImportTextureOptions : : EditorImportTextureOptions ( ) { <nl> <nl> add_margin_child ( TTR ( " Texture Options " ) , flags , true ) ; <nl> <nl> - notice_for_2d = memnew ( Label ) ; <nl> - notice_for_2d - > set_text ( TTR ( " NOTICE : You are not forced to import textures for 2D projects . Just copy your . jpg or . png files to your project , and change export options later . Atlases can be generated on export too . " ) ) ; <nl> - notice_for_2d - > set_custom_minimum_size ( Size2 ( 0 , 50 ) ) ; <nl> - notice_for_2d - > set_autowrap ( true ) ; <nl> - add_child ( notice_for_2d ) ; <nl> - notice_for_2d - > hide ( ) ; <nl> <nl> } <nl> <nl> class EditorTextureImportDialog : public ConfirmationDialog { <nl> OBJ_TYPE ( EditorTextureImportDialog , ConfirmationDialog ) ; <nl> <nl> <nl> + <nl> + HBoxContainer * mode_hb ; <nl> + CheckBox * mode_check [ EditorTextureImportPlugin : : MODE_MAX ] ; <nl> + <nl> EditorImportTextureOptions * texture_options ; <nl> <nl> + EditorTextureImportPlugin : : Mode mode ; <nl> / / EditorNode * editor ; <nl> <nl> LineEdit * import_path ; <nl> class EditorTextureImportDialog : public ConfirmationDialog { <nl> ConfirmationDialog * error_dialog ; <nl> CheckButton * crop_source ; <nl> SpinBox * size ; <nl> - bool atlas ; <nl> - bool large ; <nl> + <nl> + MarginContainer * size_mc ; <nl> + Label * size_label ; <nl> + <nl> + Label * source_label ; <nl> + Label * notice_for_2d ; <nl> <nl> EditorTextureImportPlugin * plugin ; <nl> <nl> + void _mode_changed ( int p_mode ) ; <nl> void _choose_files ( const Vector < String > & p_path ) ; <nl> void _choose_file ( const String & p_path ) ; <nl> void _choose_save_dir ( const String & p_path ) ; <nl> class EditorTextureImportDialog : public ConfirmationDialog { <nl> static void _bind_methods ( ) ; <nl> public : <nl> <nl> + <nl> + void setup_multiple_import_3d ( const Vector < String > & p_path , const String & p_dest ) { <nl> + <nl> + _mode_changed ( EditorTextureImportPlugin : : MODE_TEXTURE_3D ) ; <nl> + _choose_files ( p_path ) ; <nl> + _choose_save_dir ( p_dest ) ; <nl> + } <nl> + <nl> + void add_sources_and_dest ( const Vector < String > & p_path , const String & p_dest ) { <nl> + <nl> + _choose_files ( p_path ) ; <nl> + _choose_save_dir ( p_dest ) ; <nl> + } <nl> + <nl> Error import ( const String & p_from , const String & p_to , const String & p_preset ) ; <nl> void popup_import ( const String & p_from = String ( ) ) ; <nl> - EditorTextureImportDialog ( EditorTextureImportPlugin * p_plugin = NULL , bool p_2d = false , bool p_atlas = false , bool p_large = false ) ; <nl> + EditorTextureImportDialog ( EditorTextureImportPlugin * p_plugin = NULL ) ; <nl> } ; <nl> <nl> <nl> void EditorTextureImportDialog : : _import ( ) { <nl> } <nl> <nl> <nl> - if ( ! atlas & & ! large & & ! DirAccess : : exists ( save_path - > get_text ( ) ) ) { <nl> + if ( mode ! = EditorTextureImportPlugin : : MODE_ATLAS & & mode ! = EditorTextureImportPlugin : : MODE_LARGE & & ! DirAccess : : exists ( save_path - > get_text ( ) ) ) { <nl> error_dialog - > set_text ( TTR ( " Target path must exist . " ) ) ; <nl> error_dialog - > popup_centered_minsize ( ) ; <nl> return ; <nl> } <nl> <nl> - if ( atlas ) { / / atlas <nl> + if ( mode = = EditorTextureImportPlugin : : MODE_ATLAS ) { / / atlas <nl> <nl> if ( files . size ( ) = = 0 ) { <nl> <nl> void EditorTextureImportDialog : : _import ( ) { <nl> imd - > set_option ( " atlas_size " , int ( size - > get_val ( ) ) ) ; <nl> imd - > set_option ( " large " , false ) ; <nl> imd - > set_option ( " crop " , crop_source - > is_pressed ( ) ) ; <nl> + imd - > set_option ( " mode " , mode ) ; <nl> <nl> Error err = plugin - > import ( dst_file , imd ) ; <nl> if ( err ) { <nl> void EditorTextureImportDialog : : _import ( ) { <nl> return ; <nl> <nl> } <nl> - } else if ( large ) { / / atlas <nl> + } else if ( mode = = EditorTextureImportPlugin : : MODE_LARGE ) { / / large <nl> <nl> if ( files . size ( ) ! = 1 ) { <nl> <nl> void EditorTextureImportDialog : : _import ( ) { <nl> imd - > set_option ( " large " , true ) ; <nl> imd - > set_option ( " large_cell_size " , int ( size - > get_val ( ) ) ) ; <nl> imd - > set_option ( " crop " , crop_source - > is_pressed ( ) ) ; <nl> + imd - > set_option ( " mode " , mode ) ; <nl> <nl> Error err = plugin - > import ( dst_file , imd ) ; <nl> if ( err ) { <nl> void EditorTextureImportDialog : : _import ( ) { <nl> imd - > set_option ( " quality " , texture_options - > get_quality ( ) ) ; <nl> imd - > set_option ( " atlas " , false ) ; <nl> imd - > set_option ( " large " , false ) ; <nl> + imd - > set_option ( " mode " , mode ) ; <nl> <nl> Error err = plugin - > import ( dst_file , imd ) ; <nl> if ( err ) { <nl> void EditorTextureImportDialog : : _browse ( ) { <nl> <nl> void EditorTextureImportDialog : : _browse_target ( ) { <nl> <nl> - if ( atlas | | large ) { <nl> + if ( mode = = EditorTextureImportPlugin : : MODE_ATLAS | | mode = = EditorTextureImportPlugin : : MODE_LARGE ) { <nl> save_file_select - > popup_centered_ratio ( ) ; <nl> } else { <nl> save_select - > popup_centered_ratio ( ) ; <nl> void EditorTextureImportDialog : : _browse_target ( ) { <nl> <nl> void EditorTextureImportDialog : : popup_import ( const String & p_from ) { <nl> <nl> - popup_centered ( Size2 ( 400 , 400 ) ) ; <nl> + popup_centered ( Size2 ( 600 , 500 ) ) ; <nl> if ( p_from ! = " " ) { <nl> Ref < ResourceImportMetadata > rimd = ResourceLoader : : load_import_metadata ( p_from ) ; <nl> ERR_FAIL_COND ( ! rimd . is_valid ( ) ) ; <nl> <nl> - if ( plugin - > get_mode ( ) = = EditorTextureImportPlugin : : MODE_ATLAS | | plugin - > get_mode ( ) = = EditorTextureImportPlugin : : MODE_LARGE ) <nl> + if ( rimd - > has_option ( " mode " ) ) { <nl> + / / new imported stuff uses this option <nl> + _mode_changed ( rimd - > get_option ( " mode " ) ) ; <nl> + } else { <nl> + / / this one is for compatibility , will have to guess it <nl> + if ( rimd - > has_option ( " atlas " ) & & rimd - > get_option ( " atlas " ) ) { <nl> + _mode_changed ( EditorTextureImportPlugin : : MODE_ATLAS ) ; <nl> + } else if ( rimd - > has_option ( " large " ) & & rimd - > get_option ( " large " ) ) { <nl> + _mode_changed ( EditorTextureImportPlugin : : MODE_LARGE ) ; <nl> + } else { <nl> + / / guess by usage of mipmaps . . ? <nl> + _mode_changed ( EditorTextureImportPlugin : : MODE_TEXTURE_2D ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + if ( mode = = EditorTextureImportPlugin : : MODE_ATLAS | | mode = = EditorTextureImportPlugin : : MODE_LARGE ) <nl> save_path - > set_text ( p_from ) ; <nl> else <nl> save_path - > set_text ( p_from . get_base_dir ( ) ) ; <nl> Error EditorTextureImportDialog : : import ( const String & p_from , const String & p_to <nl> return OK ; <nl> } <nl> <nl> + void EditorTextureImportDialog : : _mode_changed ( int p_mode ) { <nl> + <nl> + mode = EditorTextureImportPlugin : : Mode ( p_mode ) ; <nl> + <nl> + for ( int i = 0 ; i < EditorTextureImportPlugin : : MODE_MAX ; i + + ) { <nl> + mode_check [ i ] - > set_pressed ( i = = mode ) ; <nl> + } <nl> + <nl> + if ( p_mode = = EditorTextureImportPlugin : : MODE_ATLAS ) { <nl> + <nl> + size_label - > set_text ( TTR ( " Max Texture Size : " ) ) ; <nl> + size - > set_val ( 2048 ) ; <nl> + crop_source - > show ( ) ; <nl> + size_label - > show ( ) ; <nl> + size - > show ( ) ; <nl> + <nl> + texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> + texture_options - > set_quality ( 0 . 7 ) ; <nl> + texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSY ) ; <nl> + set_title ( TTR ( " Import Textures for Atlas ( 2D ) " ) ) ; <nl> + <nl> + } else { <nl> + crop_source - > hide ( ) ; <nl> + } <nl> + <nl> + <nl> + if ( p_mode = = EditorTextureImportPlugin : : MODE_LARGE ) { <nl> + <nl> + size_label - > set_text ( TTR ( " Cell Size : " ) ) ; <nl> + size - > set_val ( 256 ) ; <nl> + size_label - > show ( ) ; <nl> + size - > show ( ) ; <nl> + <nl> + file_select - > set_mode ( EditorFileDialog : : MODE_OPEN_FILE ) ; <nl> + save_file_select - > add_filter ( " * . ltex ; " + TTR ( " Large Texture " ) ) ; <nl> + <nl> + texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> + texture_options - > set_quality ( 0 . 7 ) ; <nl> + texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS ) ; <nl> + set_title ( TTR ( " Import Large Textures ( 2D ) " ) ) ; <nl> + source_label - > set_text ( TTR ( " Source Texture " ) ) ; <nl> + <nl> + } else { <nl> + file_select - > set_mode ( EditorFileDialog : : MODE_OPEN_FILES ) ; <nl> + save_file_select - > add_filter ( " * . tex ; " + TTR ( " Base Atlas Texture " ) ) ; <nl> + source_label - > set_text ( TTR ( " Source Texture ( s ) " ) ) ; <nl> + } <nl> + <nl> + if ( p_mode = = EditorTextureImportPlugin : : MODE_TEXTURE_2D ) { <nl> + <nl> + size_label - > hide ( ) ; <nl> + size - > hide ( ) ; <nl> + <nl> + texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> + texture_options - > set_quality ( 0 . 7 ) ; <nl> + texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSY ) ; <nl> + notice_for_2d - > show ( ) ; <nl> + set_title ( TTR ( " Import Textures for 2D " ) ) ; <nl> + <nl> + } else { <nl> + notice_for_2d - > hide ( ) ; <nl> + } <nl> + <nl> + if ( p_mode = = EditorTextureImportPlugin : : MODE_TEXTURE_3D ) { <nl> + <nl> + size_label - > hide ( ) ; <nl> + size - > hide ( ) ; <nl> + / / texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_ ) ; <nl> + / / texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS ) ; <nl> + texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER | EditorTextureImportPlugin : : IMAGE_FLAG_REPEAT ) ; <nl> + texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_RAM ) ; <nl> + set_title ( TTR ( " Import Textures for 3D " ) ) ; <nl> + } <nl> + } <nl> + <nl> void EditorTextureImportDialog : : _bind_methods ( ) { <nl> <nl> <nl> void EditorTextureImportDialog : : _bind_methods ( ) { <nl> ObjectTypeDB : : bind_method ( " _import " , & EditorTextureImportDialog : : _import ) ; <nl> ObjectTypeDB : : bind_method ( " _browse " , & EditorTextureImportDialog : : _browse ) ; <nl> ObjectTypeDB : : bind_method ( " _browse_target " , & EditorTextureImportDialog : : _browse_target ) ; <nl> + ObjectTypeDB : : bind_method ( " _mode_changed " , & EditorTextureImportDialog : : _mode_changed ) ; <nl> / / ADD_SIGNAL ( MethodInfo ( " imported " , PropertyInfo ( Variant : : OBJECT , " scene " ) ) ) ; <nl> } <nl> <nl> - EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * p_plugin , bool p_2d , bool p_atlas , bool p_large ) { <nl> + EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * p_plugin ) { <nl> + <nl> + <nl> + <nl> <nl> <nl> - atlas = p_atlas ; <nl> - large = p_large ; <nl> plugin = p_plugin ; <nl> set_title ( TTR ( " Import Textures " ) ) ; <nl> <nl> + mode_hb = memnew ( HBoxContainer ) ; <nl> + add_child ( mode_hb ) ; <nl> + set_child_rect ( mode_hb ) ; <nl> + <nl> + VBoxContainer * vbcg = memnew ( VBoxContainer ) ; <nl> + <nl> + <nl> + mode_hb - > add_child ( vbcg ) ; <nl> + mode_hb - > add_constant_override ( " separation " , 15 ) ; <nl> + ButtonGroup * bg = memnew ( ButtonGroup ) ; <nl> + vbcg - > add_margin_child ( " Import Mode " , bg ) ; <nl> + <nl> + for ( int i = 0 ; i < EditorTextureImportPlugin : : MODE_MAX ; i + + ) { <nl> + String mode_name [ EditorTextureImportPlugin : : MODE_MAX ] = { <nl> + TTR ( " 2D Texture " ) , <nl> + TTR ( " 3D Texture " ) , <nl> + TTR ( " Atlas Texture " ) , <nl> + TTR ( " Large Texture " ) <nl> + } ; <nl> + <nl> + <nl> + mode_check [ i ] = memnew ( CheckBox ) ; <nl> + bg - > add_child ( mode_check [ i ] ) ; <nl> + mode_check [ i ] - > set_text ( mode_name [ i ] ) ; <nl> + mode_check [ i ] - > connect ( " pressed " , this , " _mode_changed " , varray ( i ) ) ; <nl> + } <nl> <nl> VBoxContainer * vbc = memnew ( VBoxContainer ) ; <nl> - add_child ( vbc ) ; <nl> - set_child_rect ( vbc ) ; <nl> + mode_hb - > add_child ( vbc ) ; <nl> + vbc - > set_h_size_flags ( SIZE_EXPAND_FILL ) ; <nl> + vbc - > add_constant_override ( " separation " , 4 ) ; <nl> <nl> + notice_for_2d = memnew ( Label ) ; <nl> + notice_for_2d - > set_text ( TTR ( " NOTICE : Importing 2D textures is not mandatory . Just copy png / jpg files to the project . " ) ) ; <nl> + / / notice_for_2d - > set_custom_minimum_size ( Size2 ( 0 , 50 ) ) ; <nl> + notice_for_2d - > set_autowrap ( true ) ; <nl> + notice_for_2d - > hide ( ) ; <nl> + vbcg - > add_child ( notice_for_2d ) ; <nl> + notice_for_2d - > set_v_size_flags ( SIZE_EXPAND_FILL ) ; <nl> + notice_for_2d - > set_valign ( Label : : VALIGN_BOTTOM ) ; <nl> <nl> VBoxContainer * source_vb = memnew ( VBoxContainer ) ; <nl> - if ( large ) <nl> - vbc - > add_margin_child ( TTR ( " Source Texture : " ) , source_vb ) ; <nl> - else <nl> - vbc - > add_margin_child ( TTR ( " Source Texture ( s ) : " ) , source_vb ) ; <nl> + MarginContainer * source_mc = vbc - > add_margin_child ( TTR ( " Source Texture ( s ) : " ) , source_vb ) ; <nl> + <nl> + source_label = vbc - > get_child ( source_mc - > get_index ( ) - 1 ) - > cast_to < Label > ( ) ; <nl> <nl> HBoxContainer * hbc = memnew ( HBoxContainer ) ; <nl> source_vb - > add_child ( hbc ) ; <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> crop_source - > set_pressed ( true ) ; <nl> source_vb - > add_child ( crop_source ) ; <nl> crop_source - > set_text ( TTR ( " Crop empty space . " ) ) ; <nl> - if ( ! p_atlas ) <nl> - crop_source - > hide ( ) ; <nl> <nl> <nl> Button * import_choose = memnew ( Button ) ; <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> size - > set_min ( 128 ) ; <nl> size - > set_max ( 16384 ) ; <nl> <nl> - if ( p_atlas ) { <nl> - size - > set_val ( 2048 ) ; <nl> - vbc - > add_margin_child ( TTR ( " Max Texture Size : " ) , size ) ; <nl> - } else { <nl> - size - > set_val ( 256 ) ; <nl> - vbc - > add_margin_child ( TTR ( " Cell Size : " ) , size ) ; <nl> - } <nl> + <nl> + size - > set_val ( 256 ) ; <nl> + size_mc = vbc - > add_margin_child ( TTR ( " Cell Size : " ) , size ) ; <nl> + size_label = vbc - > get_child ( size_mc - > get_index ( ) - 1 ) - > cast_to < Label > ( ) ; <nl> <nl> <nl> save_path = memnew ( LineEdit ) ; <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> file_select = memnew ( EditorFileDialog ) ; <nl> file_select - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ; <nl> add_child ( file_select ) ; <nl> - if ( ! large ) <nl> - file_select - > set_mode ( EditorFileDialog : : MODE_OPEN_FILES ) ; <nl> - else <nl> - file_select - > set_mode ( EditorFileDialog : : MODE_OPEN_FILE ) ; <nl> + <nl> file_select - > connect ( " files_selected " , this , " _choose_files " ) ; <nl> file_select - > connect ( " file_selected " , this , " _choose_file " ) ; <nl> <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> add_child ( save_file_select ) ; <nl> save_file_select - > set_mode ( EditorFileDialog : : MODE_SAVE_FILE ) ; <nl> save_file_select - > clear_filters ( ) ; <nl> - if ( large ) <nl> - save_file_select - > add_filter ( " * . ltex ; " + TTR ( " Large Texture " ) ) ; <nl> - else <nl> - save_file_select - > add_filter ( " * . tex ; " + TTR ( " Base Atlas Texture " ) ) ; <nl> + <nl> save_file_select - > connect ( " file_selected " , this , " _choose_save_dir " ) ; <nl> <nl> save_select = memnew ( EditorDirDialog ) ; <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> vbc - > add_child ( texture_options ) ; <nl> texture_options - > set_v_size_flags ( SIZE_EXPAND_FILL ) ; <nl> <nl> - if ( atlas ) { <nl> - <nl> - texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> - texture_options - > set_quality ( 0 . 7 ) ; <nl> - texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSY ) ; <nl> - / / texture_options - > show_2d_notice ( ) ; <nl> - set_title ( TTR ( " Import Textures for Atlas ( 2D ) " ) ) ; <nl> - } else if ( large ) { <nl> - <nl> - texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> - texture_options - > set_quality ( 0 . 7 ) ; <nl> - texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS ) ; <nl> - texture_options - > show_2d_notice ( ) ; <nl> - set_title ( TTR ( " Import Large Textures ( 2D ) " ) ) ; <nl> - <nl> - } else if ( p_2d ) { <nl> - <nl> - texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS | EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER ) ; <nl> - texture_options - > set_quality ( 0 . 7 ) ; <nl> - texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_DISK_LOSSY ) ; <nl> - texture_options - > show_2d_notice ( ) ; <nl> - set_title ( TTR ( " Import Textures for 2D " ) ) ; <nl> - } else { <nl> - <nl> - / / texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_ ) ; <nl> - / / texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_NO_MIPMAPS ) ; <nl> - texture_options - > set_flags ( EditorTextureImportPlugin : : IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin : : IMAGE_FLAG_FILTER | EditorTextureImportPlugin : : IMAGE_FLAG_REPEAT ) ; <nl> - texture_options - > set_format ( EditorTextureImportPlugin : : IMAGE_FORMAT_COMPRESS_RAM ) ; <nl> - set_title ( TTR ( " Import Textures for 3D " ) ) ; <nl> - } <nl> + _mode_changed ( EditorTextureImportPlugin : : MODE_TEXTURE_3D ) ; <nl> <nl> <nl> / / GLOBAL_DEF ( " import / shared_textures " , " res : / / " ) ; <nl> EditorTextureImportDialog : : EditorTextureImportDialog ( EditorTextureImportPlugin * <nl> <nl> String EditorTextureImportPlugin : : get_name ( ) const { <nl> <nl> + return " texture " ; <nl> + # if 0 / / old names , kept for compatibility reference <nl> switch ( mode ) { <nl> case MODE_TEXTURE_2D : { <nl> <nl> String EditorTextureImportPlugin : : get_name ( ) const { <nl> <nl> } <nl> <nl> - return " " ; <nl> <nl> + return " " ; <nl> + # endif <nl> } <nl> <nl> String EditorTextureImportPlugin : : get_visible_name ( ) const { <nl> <nl> - switch ( mode ) { <nl> - case MODE_TEXTURE_2D : { <nl> - <nl> - return " 2D Texture " ; <nl> - } break ; <nl> - case MODE_TEXTURE_3D : { <nl> - <nl> - return " 3D Texture " ; <nl> - <nl> - } break ; <nl> - case MODE_ATLAS : { <nl> - <nl> - return " 2D Atlas Texture " ; <nl> - } break ; <nl> - case MODE_LARGE : { <nl> - <nl> - return " 2D Large Texture " ; <nl> - } break ; <nl> - <nl> - } <nl> - <nl> - return " " ; <nl> + return " Texture " ; <nl> <nl> } <nl> void EditorTextureImportPlugin : : import_dialog ( const String & p_from ) { <nl> Vector < uint8_t > EditorTextureImportPlugin : : custom_export ( const String & p_path , c <nl> return ret ; <nl> } <nl> <nl> + void EditorTextureImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + Vector < String > valid ; <nl> + <nl> + List < String > valid_extensions ; <nl> + ImageLoader : : get_recognized_extensions ( & valid_extensions ) ; <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + <nl> + String extension = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + <nl> + for ( List < String > : : Element * E = valid_extensions . front ( ) ; E ; E = E - > next ( ) ) { <nl> + <nl> + if ( E - > get ( ) = = extension ) { <nl> + valid . push_back ( p_drop [ i ] ) ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( valid . size ( ) ) { <nl> + dialog - > popup_import ( ) ; <nl> + dialog - > setup_multiple_import_3d ( valid , p_dest_path ) ; <nl> + } <nl> + } <nl> + <nl> + void EditorTextureImportPlugin : : reimport_multiple_files ( const Vector < String > & p_list ) { <nl> + <nl> + Vector < String > valid ; <nl> + <nl> + <nl> + bool warning = false ; <nl> + for ( int i = 0 ; i < p_list . size ( ) ; i + + ) { <nl> + <nl> + Ref < ResourceImportMetadata > rimd = ResourceLoader : : load_import_metadata ( p_list [ i ] ) ; <nl> + String type = rimd - > get_editor ( ) ; <nl> + if ( type = = " texture " | | type . begins_with ( " texture_ " ) ) { <nl> + <nl> + if ( ( rimd - > has_option ( " atlas " ) & & rimd - > get_option ( " atlas " ) ) | | ( rimd - > has_option ( " large " ) & & rimd - > get_option ( " large " ) ) ) { <nl> + warning = true ; <nl> + continue ; <nl> + } <nl> + <nl> + valid . push_back ( p_list [ i ] ) ; <nl> + } <nl> + } <nl> + <nl> + if ( valid . size ( ) ) { <nl> + <nl> + dialog - > popup_import ( valid [ 0 ] ) ; <nl> + <nl> + Vector < String > sources ; <nl> + for ( int i = 0 ; i < valid . size ( ) ; i + + ) { <nl> + int idx ; <nl> + EditorFileSystemDirectory * efsd = EditorFileSystem : : get_singleton ( ) - > find_file ( valid [ i ] , & idx ) ; <nl> + if ( efsd ) { <nl> + for ( int j = 0 ; j < efsd - > get_source_count ( idx ) ; j + + ) { <nl> + String file = expand_source_path ( efsd - > get_source_file ( idx , j ) ) ; <nl> + if ( sources . find ( file ) = = - 1 ) { <nl> + sources . push_back ( file ) ; <nl> + } <nl> + <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( sources . size ( ) ) { <nl> + <nl> + dialog - > add_sources_and_dest ( sources , valid [ 0 ] . get_base_dir ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool EditorTextureImportPlugin : : can_reimport_multiple_files ( ) const { <nl> + <nl> + return true ; <nl> + <nl> + } <nl> + <nl> + <nl> <nl> - EditorTextureImportPlugin * EditorTextureImportPlugin : : singleton [ EditorTextureImportPlugin : : MODE_MAX ] = { NULL , NULL , NULL , NULL } ; <nl> + EditorTextureImportPlugin * EditorTextureImportPlugin : : singleton = NULL ; <nl> <nl> - EditorTextureImportPlugin : : EditorTextureImportPlugin ( EditorNode * p_editor , Mode p_mode ) { <nl> + EditorTextureImportPlugin : : EditorTextureImportPlugin ( EditorNode * p_editor ) { <nl> <nl> - singleton [ p_mode ] = this ; <nl> - editor = p_editor ; <nl> - mode = p_mode ; <nl> - dialog = memnew ( EditorTextureImportDialog ( this , p_mode = = MODE_TEXTURE_2D | | p_mode = = MODE_ATLAS | | p_mode = = MODE_LARGE , p_mode = = MODE_ATLAS , p_mode = = MODE_LARGE ) ) ; <nl> + singleton = this ; <nl> + editor = p_editor ; <nl> + dialog = memnew ( EditorTextureImportDialog ( this ) ) ; <nl> editor - > get_gui_base ( ) - > add_child ( dialog ) ; <nl> <nl> } <nl> mmm a / tools / editor / io_plugins / editor_texture_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_texture_import_plugin . h <nl> class EditorTextureImportPlugin : public EditorImportPlugin { <nl> <nl> <nl> private : <nl> - Mode mode ; <nl> + <nl> EditorNode * editor ; <nl> EditorTextureImportDialog * dialog ; <nl> - static EditorTextureImportPlugin * singleton [ MODE_MAX ] ; <nl> + static EditorTextureImportPlugin * singleton ; <nl> / / used by other importers such as mesh <nl> <nl> Error _process_texture_data ( Ref < ImageTexture > & texture , int format , float quality , int flags , EditorExportPlatform : : ImageCompression p_compr , int tex_flags , float shrink ) ; <nl> class EditorTextureImportPlugin : public EditorImportPlugin { <nl> public : <nl> <nl> <nl> - static EditorTextureImportPlugin * get_singleton ( Mode p_mode ) { return singleton [ p_mode ] ; } <nl> + static EditorTextureImportPlugin * get_singleton ( ) { return singleton ; } <nl> <nl> enum ImageFormat { <nl> <nl> class EditorTextureImportPlugin : public EditorImportPlugin { <nl> IMAGE_FLAG_USE_ANISOTROPY = 1024 , / / convert image to linear <nl> } ; <nl> <nl> - Mode get_mode ( ) const { return mode ; } <nl> virtual String get_name ( ) const ; <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> class EditorTextureImportPlugin : public EditorImportPlugin { <nl> virtual Error import2 ( const String & p_path , const Ref < ResourceImportMetadata > & p_from , EditorExportPlatform : : ImageCompression p_compr , bool p_external = false ) ; <nl> virtual Vector < uint8_t > custom_export ( const String & p_path , const Ref < EditorExportPlatform > & p_platform ) ; <nl> <nl> + virtual void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> + virtual void reimport_multiple_files ( const Vector < String > & p_list ) ; <nl> + virtual bool can_reimport_multiple_files ( ) const ; <nl> <nl> - EditorTextureImportPlugin ( EditorNode * p_editor = NULL , Mode p_mode = MODE_TEXTURE_2D ) ; <nl> + EditorTextureImportPlugin ( EditorNode * p_editor = NULL ) ; <nl> } ; <nl> <nl> <nl> class EditorImportTextureOptions : public VBoxContainer { <nl> HSlider * quality ; <nl> Tree * flags ; <nl> Vector < TreeItem * > items ; <nl> - Label * notice_for_2d ; <nl> + <nl> <nl> bool updating ; <nl> <nl> mmm a / tools / editor / io_plugins / editor_translation_import_plugin . cpp <nl> ppp b / tools / editor / io_plugins / editor_translation_import_plugin . cpp <nl> void EditorTranslationImportPlugin : : import_dialog ( const String & p_from ) { <nl> dialog - > popup_import ( p_from ) ; <nl> } <nl> <nl> + <nl> + <nl> + void EditorTranslationImportPlugin : : import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) { <nl> + <nl> + <nl> + for ( int i = 0 ; i < p_drop . size ( ) ; i + + ) { <nl> + String ext = p_drop [ i ] . extension ( ) . to_lower ( ) ; <nl> + <nl> + if ( ext = = " csv " ) { <nl> + <nl> + import_dialog ( ) ; <nl> + dialog - > _choose_file ( p_drop [ i ] ) ; <nl> + dialog - > _choose_save_dir ( p_dest_path ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + <nl> + } <nl> + <nl> Error EditorTranslationImportPlugin : : import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) { <nl> <nl> Ref < ResourceImportMetadata > from = p_from ; <nl> mmm a / tools / editor / io_plugins / editor_translation_import_plugin . h <nl> ppp b / tools / editor / io_plugins / editor_translation_import_plugin . h <nl> class EditorTranslationImportPlugin : public EditorImportPlugin { <nl> virtual String get_visible_name ( ) const ; <nl> virtual void import_dialog ( const String & p_from = " " ) ; <nl> virtual Error import ( const String & p_path , const Ref < ResourceImportMetadata > & p_from ) ; <nl> + void import_from_drop ( const Vector < String > & p_drop , const String & p_dest_path ) ; <nl> <nl> <nl> EditorTranslationImportPlugin ( EditorNode * p_editor ) ; <nl> mmm a / tools / editor / plugins / mesh_editor_plugin . cpp <nl> ppp b / tools / editor / plugins / mesh_editor_plugin . cpp <nl> void MeshEditor : : edit ( Ref < Mesh > p_mesh ) { <nl> rot_x = 0 ; <nl> rot_y = 0 ; <nl> _update_rotation ( ) ; <nl> + <nl> + AABB aabb = mesh - > get_aabb ( ) ; <nl> + Vector3 ofs = aabb . pos + aabb . size * 0 . 5 ; <nl> + aabb . pos - = ofs ; <nl> + float m = MAX ( aabb . size . x , aabb . size . y ) * 0 . 5 ; <nl> + if ( m ! = 0 ) { <nl> + m = 1 . 0 / m ; <nl> + m * = 0 . 5 ; <nl> + / / print_line ( " scale : " + rtos ( m ) ) ; <nl> + Transform xform ; <nl> + xform . basis . scale ( Vector3 ( m , m , m ) ) ; <nl> + xform . origin = - xform . basis . xform ( ofs ) ; / / - ofs * m ; <nl> + xform . origin . z - = aabb . size . z * 2 ; <nl> + mesh_instance - > set_transform ( xform ) ; <nl> + } <nl> + <nl> } <nl> <nl> } <nl> mmm a / tools / editor / property_editor . cpp <nl> ppp b / tools / editor / property_editor . cpp <nl> void CustomPropertyEditor : : config_value_editors ( int p_amount , int p_columns , int <nl> <nl> } <nl> <nl> + <nl> void CustomPropertyEditor : : _bind_methods ( ) { <nl> <nl> ObjectTypeDB : : bind_method ( " _focus_enter " , & CustomPropertyEditor : : _focus_enter ) ; <nl> void CustomPropertyEditor : : _bind_methods ( ) { <nl> ObjectTypeDB : : bind_method ( " _menu_option " , & CustomPropertyEditor : : _menu_option ) ; <nl> <nl> <nl> + <nl> ADD_SIGNAL ( MethodInfo ( " variant_changed " ) ) ; <nl> ADD_SIGNAL ( MethodInfo ( " resource_edit_request " ) ) ; <nl> } <nl> void PropertyEditor : : set_item_text ( TreeItem * p_item , int p_type , const String & p <nl> } <nl> } <nl> <nl> + if ( ! res - > is_type ( " Texture " ) ) { <nl> + / / texture already previews via itself <nl> + EditorResourcePreview : : get_singleton ( ) - > queue_edited_resource_preview ( res , this , " _resource_preview_done " , p_item - > get_instance_ID ( ) ) ; <nl> + } <nl> + <nl> <nl> <nl> } <nl> void PropertyEditor : : update_tree ( ) { <nl> } else if ( res . is_valid ( ) ) { <nl> item - > set_tooltip ( 1 , res - > get_name ( ) + " ( " + res - > get_type ( ) + " ) " ) ; <nl> } <nl> + if ( ! res - > is_type ( " Texture " ) ) { <nl> + / / texture already previews via itself <nl> + EditorResourcePreview : : get_singleton ( ) - > queue_edited_resource_preview ( res , this , " _resource_preview_done " , item - > get_instance_ID ( ) ) ; <nl> + } <nl> <nl> } <nl> <nl> void PropertyEditor : : _filter_changed ( const String & p_text ) { <nl> update_tree ( ) ; <nl> } <nl> <nl> + <nl> + <nl> + void PropertyEditor : : _resource_preview_done ( const String & p_path , const Ref < Texture > & p_preview , Variant p_ud ) { <nl> + <nl> + if ( p_preview . is_null ( ) ) <nl> + return ; / / don ' t bother with empty preview <nl> + <nl> + ObjectID id = p_ud ; <nl> + Object * obj = ObjectDB : : get_instance ( id ) ; <nl> + <nl> + if ( ! obj ) <nl> + return ; <nl> + <nl> + TreeItem * ti = obj - > cast_to < TreeItem > ( ) ; <nl> + <nl> + ERR_FAIL_COND ( ! ti ) ; <nl> + <nl> + int tw = EditorSettings : : get_singleton ( ) - > get ( " property_editor / texture_preview_width " ) ; <nl> + <nl> + ti - > set_icon ( 1 , p_preview ) ; / / should be scaled I think ? <nl> + ti - > set_icon_max_width ( 1 , tw ) ; <nl> + ti - > set_text ( 1 , " " ) ; <nl> + } <nl> void PropertyEditor : : _bind_methods ( ) { <nl> <nl> ObjectTypeDB : : bind_method ( " _item_edited " , & PropertyEditor : : _item_edited ) ; <nl> void PropertyEditor : : _bind_methods ( ) { <nl> ObjectTypeDB : : bind_method ( " _set_range_def " , & PropertyEditor : : _set_range_def ) ; <nl> ObjectTypeDB : : bind_method ( " _filter_changed " , & PropertyEditor : : _filter_changed ) ; <nl> ObjectTypeDB : : bind_method ( " update_tree " , & PropertyEditor : : update_tree ) ; <nl> + ObjectTypeDB : : bind_method ( " _resource_preview_done " , & PropertyEditor : : _resource_preview_done ) ; <nl> <nl> ObjectTypeDB : : bind_method ( _MD ( " get_drag_data_fw " ) , & PropertyEditor : : get_drag_data_fw ) ; <nl> ObjectTypeDB : : bind_method ( _MD ( " can_drop_data_fw " ) , & PropertyEditor : : can_drop_data_fw ) ; <nl> mmm a / tools / editor / property_editor . h <nl> ppp b / tools / editor / property_editor . h <nl> class CustomPropertyEditor : public Popup { <nl> void config_value_editors ( int p_amount , int p_columns , int p_label_w , const List < String > & p_strings ) ; <nl> void config_action_buttons ( const List < String > & p_strings ) ; <nl> <nl> + <nl> protected : <nl> <nl> void _notification ( int p_what ) ; <nl> class PropertyEditor : public Control { <nl> bool can_drop_data_fw ( const Point2 & p_point , const Variant & p_data , Control * p_from ) const ; <nl> void drop_data_fw ( const Point2 & p_point , const Variant & p_data , Control * p_from ) ; <nl> <nl> + void _resource_preview_done ( const String & p_path , const Ref < Texture > & p_preview , Variant p_ud ) ; <nl> <nl> UndoRedo * undo_redo ; <nl> protected : <nl> mmm a / tools / editor / scene_tree_dock . cpp <nl> ppp b / tools / editor / scene_tree_dock . cpp <nl> void SceneTreeDock : : _tool_selected ( int p_tool , bool p_confirm_override ) { <nl> } <nl> <nl> } break ; <nl> + case TOOL_MERGE_FROM_SCENE : { <nl> + <nl> + EditorNode : : get_singleton ( ) - > merge_from_scene ( ) ; <nl> + } break ; <nl> case TOOL_NEW_SCENE_FROM : { <nl> <nl> Node * scene = editor_data - > get_edited_scene_root ( ) ; <nl> void SceneTreeDock : : _tree_rmb ( const Vector2 & p_menu_pos ) { <nl> <nl> if ( selection . size ( ) = = 1 ) { <nl> menu - > add_separator ( ) ; <nl> + menu - > add_item ( TTR ( " Merge From Scene " ) , TOOL_MERGE_FROM_SCENE ) ; <nl> menu - > add_item ( TTR ( " Save Branch as Scene " ) , TOOL_NEW_SCENE_FROM ) ; <nl> } <nl> menu - > add_separator ( ) ; <nl> mmm a / tools / editor / scene_tree_dock . h <nl> ppp b / tools / editor / scene_tree_dock . h <nl> class SceneTreeDock : public VBoxContainer { <nl> TOOL_DUPLICATE , <nl> TOOL_REPARENT , <nl> TOOL_NEW_SCENE_FROM , <nl> + TOOL_MERGE_FROM_SCENE , <nl> TOOL_MULTI_EDIT , <nl> TOOL_ERASE , <nl> TOOL_BUTTON_MAX <nl> mmm a / tools / editor / scenes_dock . cpp <nl> ppp b / tools / editor / scenes_dock . cpp <nl> String ScenesDock : : get_selected_path ( ) const { <nl> return " res : / / " + path ; <nl> } <nl> <nl> + String ScenesDock : : get_current_path ( ) const { <nl> + <nl> + return path ; <nl> + } <nl> <nl> void ScenesDock : : _thumbnail_done ( const String & p_path , const Ref < Texture > & p_preview , const Variant & p_udata ) { <nl> <nl> void ScenesDock : : _search ( EditorFileSystemDirectory * p_path , List < FileInfo > * match <nl> fi . name = file ; <nl> fi . type = p_path - > get_file_type ( i ) ; <nl> fi . path = p_path - > get_file_path ( i ) ; <nl> + if ( p_path - > get_file_meta ( i ) ) { <nl> + if ( p_path - > is_missing_sources ( i ) ) { <nl> + fi . import_status = 3 ; <nl> + } else if ( p_path - > have_sources_changed ( i ) ) { <nl> + fi . import_status = 2 ; <nl> + } else { <nl> + fi . import_status = 1 ; <nl> + } <nl> + } else { <nl> + fi . import_status = 0 ; <nl> + } <nl> + for ( int j = 0 ; j < p_path - > get_source_count ( i ) ; j + + ) { <nl> + String s = EditorImportPlugin : : expand_source_path ( p_path - > get_source_file ( i , j ) ) ; <nl> + if ( p_path - > is_source_file_missing ( i , j ) ) { <nl> + s + = " ( Missing ) " ; <nl> + } <nl> + fi . sources . push_back ( s ) ; <nl> + } <nl> + <nl> matches - > push_back ( fi ) ; <nl> if ( matches - > size ( ) > p_max_items ) <nl> return ; <nl> void ScenesDock : : _update_files ( bool p_keep_selection ) { <nl> fi . name = efd - > get_file ( i ) ; <nl> fi . path = path . plus_file ( fi . name ) ; <nl> fi . type = efd - > get_file_type ( i ) ; <nl> + if ( efd - > get_file_meta ( i ) ) { <nl> + if ( efd - > is_missing_sources ( i ) ) { <nl> + fi . import_status = 3 ; <nl> + } else if ( efd - > have_sources_changed ( i ) ) { <nl> + fi . import_status = 2 ; <nl> + } else { <nl> + fi . import_status = 1 ; <nl> + } <nl> + <nl> + for ( int j = 0 ; j < efd - > get_source_count ( i ) ; j + + ) { <nl> + String s = EditorImportPlugin : : expand_source_path ( efd - > get_source_file ( i , j ) ) ; <nl> + if ( efd - > is_source_file_missing ( i , j ) ) { <nl> + s + = " ( Missing ) " ; <nl> + } <nl> + fi . sources . push_back ( s ) ; <nl> + } <nl> + } else { <nl> + fi . import_status = 0 ; <nl> + } <nl> + <nl> + <nl> <nl> filelist . push_back ( fi ) ; <nl> } <nl> void ScenesDock : : _update_files ( bool p_keep_selection ) { <nl> <nl> Ref < Texture > type_icon ; <nl> <nl> - if ( has_icon ( type , ei ) ) { <nl> - type_icon = get_icon ( type , ei ) ; <nl> - } else { <nl> - type_icon = get_icon ( oi , ei ) ; <nl> + String tooltip = fname ; <nl> + <nl> + if ( E - > get ( ) . import_status = = 0 ) { <nl> + <nl> + if ( has_icon ( type , ei ) ) { <nl> + type_icon = get_icon ( type , ei ) ; <nl> + } else { <nl> + type_icon = get_icon ( oi , ei ) ; <nl> + } <nl> + } else if ( E - > get ( ) . import_status = = 1 ) { <nl> + type_icon = get_icon ( " DependencyOk " , " EditorIcons " ) ; <nl> + } else if ( E - > get ( ) . import_status = = 2 ) { <nl> + type_icon = get_icon ( " DependencyChanged " , " EditorIcons " ) ; <nl> + tooltip + " \ nStatus : Needs Re - Import " ; <nl> + } else if ( E - > get ( ) . import_status = = 3 ) { <nl> + type_icon = get_icon ( " ImportFail " , " EditorIcons " ) ; <nl> + tooltip + " \ nStatus : Missing Dependencies " ; <nl> + } <nl> + <nl> + if ( E - > get ( ) . sources . size ( ) ) { <nl> + for ( int i = 0 ; i < E - > get ( ) . sources . size ( ) ; i + + ) { <nl> + tooltip + = " \ nSource : " + E - > get ( ) . sources [ i ] ; <nl> + } <nl> } <nl> <nl> + <nl> + <nl> if ( use_thumbnails ) { <nl> files - > add_item ( fname , file_thumbnail , true ) ; <nl> files - > set_item_metadata ( files - > get_item_count ( ) - 1 , fp ) ; <nl> void ScenesDock : : _update_files ( bool p_keep_selection ) { <nl> if ( cselection . has ( fname ) ) <nl> files - > select ( files - > get_item_count ( ) - 1 , false ) ; <nl> <nl> + files - > set_item_tooltip ( files - > get_item_count ( ) - 1 , tooltip ) ; <nl> + <nl> + <nl> } <nl> <nl> <nl> void ScenesDock : : _file_option ( int p_option ) { <nl> case FILE_INFO : { <nl> <nl> } break ; <nl> + case FILE_REIMPORT : { <nl> + <nl> + <nl> + Vector < String > reimport ; <nl> + for ( int i = 0 ; i < files - > get_item_count ( ) ; i + + ) { <nl> + <nl> + if ( ! files - > is_selected ( i ) ) <nl> + continue ; <nl> + <nl> + String path = files - > get_item_metadata ( i ) ; <nl> + reimport . push_back ( path ) ; <nl> + } <nl> + <nl> + ERR_FAIL_COND ( reimport . size ( ) = = 0 ) ; <nl> + <nl> + Ref < ResourceImportMetadata > rimd = ResourceLoader : : load_import_metadata ( reimport [ 0 ] ) ; <nl> + ERR_FAIL_COND ( ! rimd . is_valid ( ) ) ; <nl> + String editor = rimd - > get_editor ( ) ; <nl> + <nl> + if ( editor . begins_with ( " texture_ " ) ) { / / compatibility fix for old texture format <nl> + editor = " texture " ; <nl> + } <nl> + <nl> + Ref < EditorImportPlugin > rimp = EditorImportExport : : get_singleton ( ) - > get_import_plugin_by_name ( editor ) ; <nl> + ERR_FAIL_COND ( ! rimp . is_valid ( ) ) ; <nl> + <nl> + if ( reimport . size ( ) = = 1 ) { <nl> + rimp - > import_dialog ( reimport [ 0 ] ) ; <nl> + } else { <nl> + rimp - > reimport_multiple_files ( reimport ) ; <nl> + <nl> + } <nl> + <nl> + } break ; <nl> <nl> } <nl> } <nl> void ScenesDock : : _files_list_rmb_select ( int p_item , const Vector2 & p_pos ) { <nl> Vector < String > filenames ; <nl> <nl> bool all_scenes = true ; <nl> + bool all_can_reimport = true ; <nl> + Set < String > types ; <nl> <nl> for ( int i = 0 ; i < files - > get_item_count ( ) ; i + + ) { <nl> <nl> void ScenesDock : : _files_list_rmb_select ( int p_item , const Vector2 & p_pos ) { <nl> } <nl> <nl> <nl> + EditorFileSystemDirectory * efsd = NULL ; <nl> + int pos ; <nl> + <nl> + efsd = EditorFileSystem : : get_singleton ( ) - > find_file ( path , & pos ) ; <nl> + <nl> + if ( efsd ) { <nl> + <nl> + <nl> + if ( ! efsd - > get_file_meta ( pos ) ) { <nl> + all_can_reimport = false ; <nl> + <nl> + <nl> + } else { <nl> + Ref < ResourceImportMetadata > rimd = ResourceLoader : : load_import_metadata ( path ) ; <nl> + if ( rimd . is_valid ( ) ) { <nl> + <nl> + String editor = rimd - > get_editor ( ) ; <nl> + if ( editor . begins_with ( " texture_ " ) ) { / / compatibility fix for old texture format <nl> + editor = " texture " ; <nl> + } <nl> + types . insert ( editor ) ; <nl> + <nl> + } else { <nl> + all_can_reimport = false ; <nl> + <nl> + } <nl> + } <nl> + } else { <nl> + all_can_reimport = false ; <nl> + <nl> + } <nl> + <nl> filenames . push_back ( path ) ; <nl> if ( EditorFileSystem : : get_singleton ( ) - > get_file_type ( path ) ! = " PackedScene " ) <nl> all_scenes = false ; <nl> void ScenesDock : : _files_list_rmb_select ( int p_item , const Vector2 & p_pos ) { <nl> file_options - > add_item ( TTR ( " Move To . . " ) , FILE_MOVE ) ; <nl> } <nl> <nl> + <nl> file_options - > add_item ( TTR ( " Delete " ) , FILE_REMOVE ) ; <nl> + <nl> / / file_options - > add_item ( TTR ( " Info " ) , FILE_INFO ) ; <nl> <nl> file_options - > add_separator ( ) ; <nl> file_options - > add_item ( TTR ( " Show In File Manager " ) , FILE_SHOW_IN_EXPLORER ) ; <nl> <nl> + if ( all_can_reimport & & types . size ( ) = = 1 ) { / / all can reimport and are of the same type <nl> + <nl> + <nl> + bool valid = true ; <nl> + Ref < EditorImportPlugin > rimp = EditorImportExport : : get_singleton ( ) - > get_import_plugin_by_name ( types . front ( ) - > get ( ) ) ; <nl> + if ( rimp . is_valid ( ) ) { <nl> + <nl> + if ( filenames . size ( ) > 1 & & ! rimp - > can_reimport_multiple_files ( ) ) { <nl> + valid = false ; <nl> + } <nl> + } else { <nl> + valid = false ; <nl> + } <nl> + <nl> + if ( valid ) { <nl> + file_options - > add_separator ( ) ; <nl> + file_options - > add_item ( TTR ( " Re - Import . . " ) , FILE_REIMPORT ) ; <nl> + } <nl> + } <nl> + <nl> file_options - > set_pos ( files - > get_global_pos ( ) + p_pos ) ; <nl> file_options - > popup ( ) ; <nl> <nl> mmm a / tools / editor / scenes_dock . h <nl> ppp b / tools / editor / scenes_dock . h <nl> class ScenesDock : public VBoxContainer { <nl> String name ; <nl> String path ; <nl> StringName type ; <nl> + int import_status ; / / 0 not imported , 1 - ok , 2 - must reimport , 3 - broken <nl> + Vector < String > sources ; <nl> <nl> bool operator < ( const FileInfo & fi ) const { <nl> return name < fi . name ; <nl> class ScenesDock : public VBoxContainer { <nl> public : <nl> <nl> String get_selected_path ( ) const ; <nl> + <nl> + String get_current_path ( ) const ; <nl> void focus_on_filter ( ) ; <nl> <nl> void fix_dependencies ( const String & p_for_file ) ; <nl>
|
Changed import workflow
|
godotengine/godot
|
8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da
|
2016-05-27T17:19:11Z
|
mmm a / src / core / lib / iomgr / error . h <nl> ppp b / src / core / lib / iomgr / error . h <nl> <nl> # include < grpc / status . h > <nl> # include < grpc / support / time . h > <nl> <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> / / / Opaque representation of an error . <nl> / / / Errors are refcounted objects that represent the result of an operation . <nl> / / / Ownership laws : <nl> bool grpc_log_if_error ( const char * what , grpc_error * error , const char * file , <nl> # define GRPC_LOG_IF_ERROR ( what , error ) \ <nl> grpc_log_if_error ( ( what ) , ( error ) , __FILE__ , __LINE__ ) <nl> <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> # endif / * GRPC_CORE_LIB_IOMGR_ERROR_H * / <nl> mmm a / src / cpp / common / channel_filter . h <nl> ppp b / src / cpp / common / channel_filter . h <nl> <nl> # include < vector > <nl> <nl> # include " src / core / lib / channel / channel_stack . h " <nl> + # include " src / core / lib / security / context / security_context . h " <nl> # include " src / core / lib / surface / channel_init . h " <nl> # include " src / core / lib / transport / metadata_batch . h " <nl> <nl> <nl> / / / " name - of - filter " , GRPC_SERVER_CHANNEL , INT_MAX , nullptr ) ; <nl> / / / \ endcode <nl> <nl> - / / / Forward declaration to avoid including the file <nl> - / / / " src / core / lib / security / context / security_context . h " <nl> - struct grpc_client_security_context ; <nl> - struct grpc_server_security_context ; <nl> - <nl> namespace grpc { <nl> <nl> / / / A C + + wrapper for the \ c grpc_metadata_batch struct . <nl>
|
Merge pull request from markdroth / header_fix
|
grpc/grpc
|
e5c744d9850a763639b2e7001cf2487e1c76133b
|
2016-10-07T14:16:15Z
|
mmm a / modules / photo / doc / cloning . rst <nl> ppp b / modules / photo / doc / cloning . rst <nl> region , giving its contents a flat aspect . Here Canny Edge Detector is used . <nl> The algorithm assumes that the color of the source image is close to that of the destination . This assumption means that when the colors don ' t match , the source image color gets tinted toward the color of the destination image . <nl> <nl> . . [ PM03 ] Patrick Perez , Michel Gangnet , Andrew Blake , " Poisson image editing " , ACM Transactions on Graphics ( SIGGRAPH ) , 2003 . <nl> - <nl> mmm a / modules / photo / doc / decolor . rst <nl> ppp b / modules / photo / doc / decolor . rst <nl> Transforms a color image to a grayscale image . It is a basic tool in digital pri <nl> <nl> . . ocv : function : : void decolor ( InputArray src , OutputArray grayscale , OutputArray color_boost ) <nl> <nl> - : param src : Input 8 - bit 3 - channel image . <nl> + : param src : Input 8 - bit 3 - channel image . <nl> <nl> : param grayscale : Output 8 - bit 1 - channel image . <nl> <nl> mmm a / modules / photo / src / npr . hpp <nl> ppp b / modules / photo / src / npr . hpp <nl> void Domain_Filter : : compute_Rfilter ( Mat & output , Mat & hz , float sigma_h ) <nl> { <nl> for ( int c = 0 ; c < channel ; c + + ) <nl> { <nl> - temp . at < float > ( i , j * channel + c ) = temp . at < float > ( i , j * channel + c ) + <nl> + temp . at < float > ( i , j * channel + c ) = temp . at < float > ( i , j * channel + c ) + <nl> ( temp . at < float > ( i , ( j - 1 ) * channel + c ) - temp . at < float > ( i , j * channel + c ) ) * V . at < float > ( i , j ) ; <nl> } <nl> } <nl> mmm a / samples / cpp / tutorial_code / photo / decolorization / decolor . cpp <nl> ppp b / samples / cpp / tutorial_code / photo / decolorization / decolor . cpp <nl> <nl> * <nl> * This tutorial demonstrates how to use OpenCV Decolorization Module . <nl> * <nl> + * Input : <nl> + * Color Image <nl> + * <nl> * Output : <nl> * 1 ) Grayscale image <nl> * 2 ) Color boost image <nl> using namespace cv ; <nl> <nl> int main ( int argc , char * argv [ ] ) <nl> { <nl> + CV_Assert ( argc = = 2 ) ; <nl> Mat I ; <nl> I = imread ( argv [ 1 ] ) ; <nl> <nl>
|
removed build error
|
opencv/opencv
|
88d05a89d46f18a908ea9869736fe70a59ea43d9
|
2014-07-28T18:45:11Z
|
mmm a / . github / CODEOWNERS <nl> ppp b / . github / CODEOWNERS <nl> <nl> / src / objective - c / * * @ muxi @ makdharma @ a11r @ nicolasnoble @ ctiller <nl> / src / php / * * @ stanley - cheung @ murgatroid99 @ a11r @ nicolasnoble @ ctiller <nl> / src / python / * * @ nathanielmanistaatgoogle @ kpayson64 @ mehrdada <nl> + / src / python / grpcio / grpc_core_dependencies . py @ a11y @ ctiller @ nicolasnoble @ nathanielmanistaatgoogle @ kpayson64 @ mehrdada <nl> / src / ruby / * * @ apolcyn @ murgatroid99 @ a11r @ nicolasnoble @ ctiller <nl> / test / build / * * @ ctiller @ markdroth @ dgquintas @ a11r @ nicolasnoble <nl> / test / core / * * @ ctiller @ markdroth @ dgquintas <nl> new file mode 100644 <nl> index 00000000000 . . 78d54ec96b3 <nl> mmm / dev / null <nl> ppp b / src / python / grpcio / OWNERS <nl> <nl> + @ a11y grpc_core_dependencies . py <nl> + @ ctiller grpc_core_dependencies . py <nl> + @ nicolasnoble grpc_core_dependencies . py <nl>
|
Merge pull request from nicolasnoble / owners - for - gencode
|
grpc/grpc
|
6a5ff252f8ca6bf709e56759e4ad10f7a3d7234b
|
2017-07-14T15:45:22Z
|
mmm a / src / SConscript <nl> ppp b / src / SConscript <nl> SOURCES = { <nl> inspector . cc <nl> interpreter - irregexp . cc <nl> isolate . cc <nl> + json - parser . cc <nl> jsregexp . cc <nl> lithium - allocator . cc <nl> lithium . cc <nl> mmm a / src / conversions . cc <nl> ppp b / src / conversions . cc <nl> double StringToDouble ( UnicodeCache * unicode_cache , <nl> empty_string_val ) ; <nl> } <nl> <nl> + double StringToDouble ( UnicodeCache * unicode_cache , <nl> + Vector < const uc16 > str , <nl> + int flags , <nl> + double empty_string_val ) { <nl> + const uc16 * end = str . start ( ) + str . length ( ) ; <nl> + return InternalStringToDouble ( unicode_cache , str . start ( ) , end , flags , <nl> + empty_string_val ) ; <nl> + } <nl> + <nl> <nl> const char * DoubleToCString ( double v , Vector < char > buffer ) { <nl> switch ( fpclassify ( v ) ) { <nl> mmm a / src / conversions . h <nl> ppp b / src / conversions . h <nl> double StringToDouble ( UnicodeCache * unicode_cache , <nl> Vector < const char > str , <nl> int flags , <nl> double empty_string_val = 0 ) ; <nl> + double StringToDouble ( UnicodeCache * unicode_cache , <nl> + Vector < const uc16 > str , <nl> + int flags , <nl> + double empty_string_val = 0 ) ; <nl> / / This version expects a zero - terminated character array . <nl> double StringToDouble ( UnicodeCache * unicode_cache , <nl> const char * str , <nl> mmm a / src / factory . cc <nl> ppp b / src / factory . cc <nl> Handle < String > Factory : : LookupSymbol ( Vector < const char > string ) { <nl> String ) ; <nl> } <nl> <nl> + / / Symbols are created in the old generation ( data space ) . <nl> + Handle < String > Factory : : LookupSymbol ( Handle < String > string ) { <nl> + CALL_HEAP_FUNCTION ( isolate ( ) , <nl> + isolate ( ) - > heap ( ) - > LookupSymbol ( * string ) , <nl> + String ) ; <nl> + } <nl> + <nl> Handle < String > Factory : : LookupAsciiSymbol ( Vector < const char > string ) { <nl> CALL_HEAP_FUNCTION ( isolate ( ) , <nl> isolate ( ) - > heap ( ) - > LookupAsciiSymbol ( string ) , <nl> String ) ; <nl> } <nl> <nl> + <nl> + Handle < String > Factory : : LookupAsciiSymbol ( Handle < SeqAsciiString > string , <nl> + int from , <nl> + int length ) { <nl> + CALL_HEAP_FUNCTION ( isolate ( ) , <nl> + isolate ( ) - > heap ( ) - > LookupAsciiSymbol ( string , <nl> + from , <nl> + length ) , <nl> + String ) ; <nl> + } <nl> + <nl> + <nl> Handle < String > Factory : : LookupTwoByteSymbol ( Vector < const uc16 > string ) { <nl> CALL_HEAP_FUNCTION ( isolate ( ) , <nl> isolate ( ) - > heap ( ) - > LookupTwoByteSymbol ( string ) , <nl> mmm a / src / factory . h <nl> ppp b / src / factory . h <nl> class Factory { <nl> PretenureFlag pretenure ) ; <nl> <nl> Handle < String > LookupSymbol ( Vector < const char > str ) ; <nl> + Handle < String > LookupSymbol ( Handle < String > str ) ; <nl> Handle < String > LookupAsciiSymbol ( Vector < const char > str ) ; <nl> + Handle < String > LookupAsciiSymbol ( Handle < SeqAsciiString > , <nl> + int from , <nl> + int length ) ; <nl> Handle < String > LookupTwoByteSymbol ( Vector < const uc16 > str ) ; <nl> Handle < String > LookupAsciiSymbol ( const char * str ) { <nl> return LookupSymbol ( CStrVector ( str ) ) ; <nl> mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> MaybeObject * Heap : : LookupAsciiSymbol ( Vector < const char > string ) { <nl> } <nl> <nl> <nl> + MaybeObject * Heap : : LookupAsciiSymbol ( Handle < SeqAsciiString > string , <nl> + int from , <nl> + int length ) { <nl> + Object * symbol = NULL ; <nl> + Object * new_table ; <nl> + { MaybeObject * maybe_new_table = <nl> + symbol_table ( ) - > LookupSubStringAsciiSymbol ( string , <nl> + from , <nl> + length , <nl> + & symbol ) ; <nl> + if ( ! maybe_new_table - > ToObject ( & new_table ) ) return maybe_new_table ; <nl> + } <nl> + / / Can ' t use set_symbol_table because SymbolTable : : cast knows that <nl> + / / SymbolTable is a singleton and checks for identity . <nl> + roots_ [ kSymbolTableRootIndex ] = new_table ; <nl> + ASSERT ( symbol ! = NULL ) ; <nl> + return symbol ; <nl> + } <nl> + <nl> + <nl> MaybeObject * Heap : : LookupTwoByteSymbol ( Vector < const uc16 > string ) { <nl> Object * symbol = NULL ; <nl> Object * new_table ; <nl> mmm a / src / heap . h <nl> ppp b / src / heap . h <nl> class Heap { <nl> return LookupSymbol ( CStrVector ( str ) ) ; <nl> } <nl> MUST_USE_RESULT MaybeObject * LookupSymbol ( String * str ) ; <nl> + MUST_USE_RESULT MaybeObject * LookupAsciiSymbol ( Handle < SeqAsciiString > string , <nl> + int from , <nl> + int length ) ; <nl> + <nl> bool LookupSymbolIfExists ( String * str , String * * symbol ) ; <nl> bool LookupTwoCharsSymbolIfExists ( String * str , String * * symbol ) ; <nl> <nl> new file mode 100644 <nl> index 00000000000 . . b18d1ec84b8 <nl> mmm / dev / null <nl> ppp b / src / json - parser . cc <nl> <nl> + / / Copyright 2011 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # include " v8 . h " <nl> + <nl> + # include " char - predicates - inl . h " <nl> + # include " conversions . h " <nl> + # include " json - parser . h " <nl> + # include " messages . h " <nl> + # include " spaces . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + <nl> + Handle < Object > JsonParser : : ParseJson ( Handle < String > source ) { <nl> + isolate_ = source - > map ( ) - > isolate ( ) ; <nl> + source_ = Handle < String > ( source - > TryFlattenGetString ( ) ) ; <nl> + source_length_ = source_ - > length ( ) - 1 ; <nl> + <nl> + / / Optimized fast case where we only have ascii characters . <nl> + if ( source_ - > IsSeqAsciiString ( ) ) { <nl> + is_sequential_ascii_ = true ; <nl> + seq_source_ = Handle < SeqAsciiString > : : cast ( source_ ) ; <nl> + } else { <nl> + is_sequential_ascii_ = false ; <nl> + } <nl> + <nl> + / / Set initial position right before the string . <nl> + position_ = - 1 ; <nl> + / / Advance to the first character ( posibly EOS ) <nl> + Advance ( ) ; <nl> + Next ( ) ; <nl> + Handle < Object > result = ParseJsonValue ( ) ; <nl> + if ( result . is_null ( ) | | Next ( ) ! = Token : : EOS ) { <nl> + / / Parse failed . Scanner ' s current token is the unexpected token . <nl> + Token : : Value token = current_ . token ; <nl> + <nl> + const char * message ; <nl> + const char * name_opt = NULL ; <nl> + <nl> + switch ( token ) { <nl> + case Token : : EOS : <nl> + message = " unexpected_eos " ; <nl> + break ; <nl> + case Token : : NUMBER : <nl> + message = " unexpected_token_number " ; <nl> + break ; <nl> + case Token : : STRING : <nl> + message = " unexpected_token_string " ; <nl> + break ; <nl> + case Token : : IDENTIFIER : <nl> + case Token : : FUTURE_RESERVED_WORD : <nl> + message = " unexpected_token_identifier " ; <nl> + break ; <nl> + default : <nl> + message = " unexpected_token " ; <nl> + name_opt = Token : : String ( token ) ; <nl> + ASSERT ( name_opt ! = NULL ) ; <nl> + break ; <nl> + } <nl> + <nl> + Factory * factory = isolate ( ) - > factory ( ) ; <nl> + MessageLocation location ( factory - > NewScript ( source ) , <nl> + current_ . beg_pos , <nl> + current_ . end_pos ) ; <nl> + Handle < JSArray > array ; <nl> + if ( name_opt = = NULL ) { <nl> + array = factory - > NewJSArray ( 0 ) ; <nl> + } else { <nl> + Handle < String > name = factory - > NewStringFromUtf8 ( CStrVector ( name_opt ) ) ; <nl> + Handle < FixedArray > element = factory - > NewFixedArray ( 1 ) ; <nl> + element - > set ( 0 , * name ) ; <nl> + array = factory - > NewJSArrayWithElements ( element ) ; <nl> + } <nl> + Handle < Object > result = factory - > NewSyntaxError ( message , array ) ; <nl> + isolate ( ) - > Throw ( * result , & location ) ; <nl> + return Handle < Object > : : null ( ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + <nl> + / / Parse any JSON value . <nl> + Handle < Object > JsonParser : : ParseJsonValue ( ) { <nl> + Token : : Value token = Next ( ) ; <nl> + switch ( token ) { <nl> + case Token : : STRING : <nl> + return GetString ( false ) ; <nl> + case Token : : NUMBER : <nl> + return isolate ( ) - > factory ( ) - > NewNumber ( number_ ) ; <nl> + case Token : : FALSE_LITERAL : <nl> + return isolate ( ) - > factory ( ) - > false_value ( ) ; <nl> + case Token : : TRUE_LITERAL : <nl> + return isolate ( ) - > factory ( ) - > true_value ( ) ; <nl> + case Token : : NULL_LITERAL : <nl> + return isolate ( ) - > factory ( ) - > null_value ( ) ; <nl> + case Token : : LBRACE : <nl> + return ParseJsonObject ( ) ; <nl> + case Token : : LBRACK : <nl> + return ParseJsonArray ( ) ; <nl> + default : <nl> + return ReportUnexpectedToken ( ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / Parse a JSON object . Scanner must be right after ' { ' token . <nl> + Handle < Object > JsonParser : : ParseJsonObject ( ) { <nl> + Handle < JSFunction > object_constructor ( <nl> + isolate ( ) - > global_context ( ) - > object_function ( ) ) ; <nl> + Handle < JSObject > json_object = <nl> + isolate ( ) - > factory ( ) - > NewJSObject ( object_constructor ) ; <nl> + <nl> + if ( Peek ( ) = = Token : : RBRACE ) { <nl> + Next ( ) ; <nl> + } else { <nl> + do { <nl> + if ( Next ( ) ! = Token : : STRING ) { <nl> + return ReportUnexpectedToken ( ) ; <nl> + } <nl> + Handle < String > key = GetString ( true ) ; <nl> + if ( Next ( ) ! = Token : : COLON ) { <nl> + return ReportUnexpectedToken ( ) ; <nl> + } <nl> + <nl> + Handle < Object > value = ParseJsonValue ( ) ; <nl> + if ( value . is_null ( ) ) return Handle < Object > : : null ( ) ; <nl> + <nl> + uint32_t index ; <nl> + if ( key - > AsArrayIndex ( & index ) ) { <nl> + SetOwnElement ( json_object , index , value , kNonStrictMode ) ; <nl> + } else if ( key - > Equals ( isolate ( ) - > heap ( ) - > Proto_symbol ( ) ) ) { <nl> + SetPrototype ( json_object , value ) ; <nl> + } else { <nl> + SetLocalPropertyIgnoreAttributes ( json_object , key , value , NONE ) ; <nl> + } <nl> + } while ( Next ( ) = = Token : : COMMA ) ; <nl> + if ( current_ . token ! = Token : : RBRACE ) { <nl> + return ReportUnexpectedToken ( ) ; <nl> + } <nl> + } <nl> + return json_object ; <nl> + } <nl> + <nl> + / / Parse a JSON array . Scanner must be right after ' [ ' token . <nl> + Handle < Object > JsonParser : : ParseJsonArray ( ) { <nl> + ZoneScope zone_scope ( isolate ( ) , DELETE_ON_EXIT ) ; <nl> + ZoneList < Handle < Object > > elements ( 4 ) ; <nl> + <nl> + Token : : Value token = Peek ( ) ; <nl> + if ( token = = Token : : RBRACK ) { <nl> + Next ( ) ; <nl> + } else { <nl> + do { <nl> + Handle < Object > element = ParseJsonValue ( ) ; <nl> + if ( element . is_null ( ) ) return Handle < Object > : : null ( ) ; <nl> + elements . Add ( element ) ; <nl> + token = Next ( ) ; <nl> + } while ( token = = Token : : COMMA ) ; <nl> + if ( token ! = Token : : RBRACK ) { <nl> + return ReportUnexpectedToken ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / Allocate a fixed array with all the elements . <nl> + Handle < FixedArray > fast_elements = <nl> + isolate ( ) - > factory ( ) - > NewFixedArray ( elements . length ( ) ) ; <nl> + <nl> + for ( int i = 0 , n = elements . length ( ) ; i < n ; i + + ) { <nl> + fast_elements - > set ( i , * elements [ i ] ) ; <nl> + } <nl> + <nl> + return isolate ( ) - > factory ( ) - > NewJSArrayWithElements ( fast_elements ) ; <nl> + } <nl> + <nl> + <nl> + Token : : Value JsonParser : : Next ( ) { <nl> + current_ = next_ ; <nl> + ScanJson ( ) ; <nl> + return current_ . token ; <nl> + } <nl> + <nl> + void JsonParser : : ScanJson ( ) { <nl> + if ( source_ - > IsSeqAsciiString ( ) ) { <nl> + is_sequential_ascii_ = true ; <nl> + } else { <nl> + is_sequential_ascii_ = false ; <nl> + } <nl> + <nl> + Token : : Value token ; <nl> + do { <nl> + / / Remember the position of the next token <nl> + next_ . beg_pos = position_ ; <nl> + switch ( c0_ ) { <nl> + case ' \ t ' : <nl> + case ' \ r ' : <nl> + case ' \ n ' : <nl> + case ' ' : <nl> + Advance ( ) ; <nl> + token = Token : : WHITESPACE ; <nl> + break ; <nl> + case ' { ' : <nl> + Advance ( ) ; <nl> + token = Token : : LBRACE ; <nl> + break ; <nl> + case ' } ' : <nl> + Advance ( ) ; <nl> + token = Token : : RBRACE ; <nl> + break ; <nl> + case ' [ ' : <nl> + Advance ( ) ; <nl> + token = Token : : LBRACK ; <nl> + break ; <nl> + case ' ] ' : <nl> + Advance ( ) ; <nl> + token = Token : : RBRACK ; <nl> + break ; <nl> + case ' : ' : <nl> + Advance ( ) ; <nl> + token = Token : : COLON ; <nl> + break ; <nl> + case ' , ' : <nl> + Advance ( ) ; <nl> + token = Token : : COMMA ; <nl> + break ; <nl> + case ' " ' : <nl> + token = ScanJsonString ( ) ; <nl> + break ; <nl> + case ' - ' : <nl> + case ' 0 ' : <nl> + case ' 1 ' : <nl> + case ' 2 ' : <nl> + case ' 3 ' : <nl> + case ' 4 ' : <nl> + case ' 5 ' : <nl> + case ' 6 ' : <nl> + case ' 7 ' : <nl> + case ' 8 ' : <nl> + case ' 9 ' : <nl> + token = ScanJsonNumber ( ) ; <nl> + break ; <nl> + case ' t ' : <nl> + token = ScanJsonIdentifier ( " true " , Token : : TRUE_LITERAL ) ; <nl> + break ; <nl> + case ' f ' : <nl> + token = ScanJsonIdentifier ( " false " , Token : : FALSE_LITERAL ) ; <nl> + break ; <nl> + case ' n ' : <nl> + token = ScanJsonIdentifier ( " null " , Token : : NULL_LITERAL ) ; <nl> + break ; <nl> + default : <nl> + if ( c0_ < 0 ) { <nl> + Advance ( ) ; <nl> + token = Token : : EOS ; <nl> + } else { <nl> + Advance ( ) ; <nl> + token = Token : : ILLEGAL ; <nl> + } <nl> + } <nl> + } while ( token = = Token : : WHITESPACE ) ; <nl> + <nl> + next_ . end_pos = position_ ; <nl> + next_ . token = token ; <nl> + } <nl> + <nl> + <nl> + Token : : Value JsonParser : : ScanJsonIdentifier ( const char * text , <nl> + Token : : Value token ) { <nl> + while ( * text ! = ' \ 0 ' ) { <nl> + if ( c0_ ! = * text ) return Token : : ILLEGAL ; <nl> + Advance ( ) ; <nl> + text + + ; <nl> + } <nl> + return token ; <nl> + } <nl> + <nl> + <nl> + Token : : Value JsonParser : : ScanJsonNumber ( ) { <nl> + bool negative = false ; <nl> + <nl> + if ( c0_ = = ' - ' ) { <nl> + Advance ( ) ; <nl> + negative = true ; <nl> + } <nl> + if ( c0_ = = ' 0 ' ) { <nl> + Advance ( ) ; <nl> + / / Prefix zero is only allowed if it ' s the only digit before <nl> + / / a decimal point or exponent . <nl> + if ( ' 0 ' < = c0_ & & c0_ < = ' 9 ' ) return Token : : ILLEGAL ; <nl> + } else { <nl> + int i = 0 ; <nl> + int digits = 0 ; <nl> + if ( c0_ < ' 1 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> + do { <nl> + i = i * 10 + c0_ - ' 0 ' ; <nl> + digits + + ; <nl> + Advance ( ) ; <nl> + } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> + if ( c0_ ! = ' . ' & & c0_ ! = ' e ' & & c0_ ! = ' E ' & & digits < 10 ) { <nl> + number_ = ( negative ? - i : i ) ; <nl> + return Token : : NUMBER ; <nl> + } <nl> + } <nl> + if ( c0_ = = ' . ' ) { <nl> + Advance ( ) ; <nl> + if ( c0_ < ' 0 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> + do { <nl> + Advance ( ) ; <nl> + } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> + } <nl> + if ( AsciiAlphaToLower ( c0_ ) = = ' e ' ) { <nl> + Advance ( ) ; <nl> + if ( c0_ = = ' - ' | | c0_ = = ' + ' ) Advance ( ) ; <nl> + if ( c0_ < ' 0 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> + do { <nl> + Advance ( ) ; <nl> + } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> + } <nl> + if ( is_sequential_ascii_ ) { <nl> + Vector < const char > chars ( seq_source_ - > GetChars ( ) + next_ . beg_pos , <nl> + position_ - next_ . beg_pos ) ; <nl> + number_ = StringToDouble ( isolate ( ) - > unicode_cache ( ) , <nl> + chars , <nl> + NO_FLAGS , / / Hex , octal or trailing junk . <nl> + OS : : nan_value ( ) ) ; <nl> + } else { <nl> + Vector < char > buffer = Vector < char > : : New ( position_ - next_ . beg_pos ) ; <nl> + String : : WriteToFlat ( * source_ , buffer . start ( ) , next_ . beg_pos , position_ ) ; <nl> + Vector < const char > result = <nl> + Vector < const char > ( reinterpret_cast < const char * > ( buffer . start ( ) ) , <nl> + position_ - next_ . beg_pos ) ; <nl> + number_ = StringToDouble ( isolate ( ) - > unicode_cache ( ) , <nl> + result , <nl> + NO_FLAGS , / / Hex , octal or trailing junk . <nl> + 0 . 0 ) ; <nl> + buffer . Dispose ( ) ; <nl> + } <nl> + return Token : : NUMBER ; <nl> + } <nl> + <nl> + Token : : Value JsonParser : : SlowScanJsonString ( ) { <nl> + / / The currently scanned ascii characters . <nl> + Handle < String > ascii ( isolate ( ) - > factory ( ) - > NewSubString ( source_ , <nl> + next_ . beg_pos + 1 , <nl> + position_ ) ) ; <nl> + Handle < String > two_byte = <nl> + isolate ( ) - > factory ( ) - > NewRawTwoByteString ( kInitialSpecialStringSize , <nl> + NOT_TENURED ) ; <nl> + Handle < SeqTwoByteString > seq_two_byte = <nl> + Handle < SeqTwoByteString > : : cast ( two_byte ) ; <nl> + <nl> + int allocation_count = 1 ; <nl> + int count = 0 ; <nl> + <nl> + while ( c0_ ! = ' " ' ) { <nl> + / / Create new seq string <nl> + if ( count > = kInitialSpecialStringSize * allocation_count ) { <nl> + allocation_count + + ; <nl> + int new_size = allocation_count * kInitialSpecialStringSize ; <nl> + Handle < String > new_two_byte = <nl> + isolate ( ) - > factory ( ) - > NewRawTwoByteString ( new_size , <nl> + NOT_TENURED ) ; <nl> + uc16 * char_start = <nl> + Handle < SeqTwoByteString > : : cast ( new_two_byte ) - > GetChars ( ) ; <nl> + String : : WriteToFlat ( * seq_two_byte , char_start , 0 , count ) ; <nl> + seq_two_byte = Handle < SeqTwoByteString > : : cast ( new_two_byte ) ; <nl> + } <nl> + <nl> + / / Check for control character ( 0x00 - 0x1f ) or unterminated string ( < 0 ) . <nl> + if ( c0_ < 0x20 ) return Token : : ILLEGAL ; <nl> + if ( c0_ ! = ' \ \ ' ) { <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , c0_ ) ; <nl> + Advance ( ) ; <nl> + } else { <nl> + Advance ( ) ; <nl> + switch ( c0_ ) { <nl> + case ' " ' : <nl> + case ' \ \ ' : <nl> + case ' / ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , c0_ ) ; <nl> + break ; <nl> + case ' b ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , ' \ x08 ' ) ; <nl> + break ; <nl> + case ' f ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , ' \ x0c ' ) ; <nl> + break ; <nl> + case ' n ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , ' \ x0a ' ) ; <nl> + break ; <nl> + case ' r ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , ' \ x0d ' ) ; <nl> + break ; <nl> + case ' t ' : <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , ' \ x09 ' ) ; <nl> + break ; <nl> + case ' u ' : { <nl> + uc32 value = 0 ; <nl> + for ( int i = 0 ; i < 4 ; i + + ) { <nl> + Advance ( ) ; <nl> + int digit = HexValue ( c0_ ) ; <nl> + if ( digit < 0 ) { <nl> + return Token : : ILLEGAL ; <nl> + } <nl> + value = value * 16 + digit ; <nl> + } <nl> + seq_two_byte - > SeqTwoByteStringSet ( count + + , value ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + return Token : : ILLEGAL ; <nl> + } <nl> + Advance ( ) ; <nl> + } <nl> + } <nl> + / / Advance past the last ' " ' . <nl> + ASSERT_EQ ( ' " ' , c0_ ) ; <nl> + Advance ( ) ; <nl> + <nl> + / / Shrink the the string to our length . <nl> + isolate ( ) - > heap ( ) - > <nl> + new_space ( ) - > <nl> + ShrinkStringAtAllocationBoundary < SeqTwoByteString > ( * seq_two_byte , <nl> + count ) ; <nl> + string_val_ = isolate ( ) - > factory ( ) - > NewConsString ( ascii , seq_two_byte ) ; <nl> + return Token : : STRING ; <nl> + } <nl> + <nl> + <nl> + Token : : Value JsonParser : : ScanJsonString ( ) { <nl> + ASSERT_EQ ( ' " ' , c0_ ) ; <nl> + / / Set string_val to null . If string_val is not set we assume an <nl> + / / ascii string begining at next_ . beg_pos + 1 to next_ . end_pos - 1 . <nl> + string_val_ = Handle < String > : : null ( ) ; <nl> + Advance ( ) ; <nl> + / / Fast case for ascii only without escape characters . <nl> + while ( c0_ ! = ' " ' ) { <nl> + / / Check for control character ( 0x00 - 0x1f ) or unterminated string ( < 0 ) . <nl> + if ( c0_ < 0x20 ) return Token : : ILLEGAL ; <nl> + if ( c0_ ! = ' \ \ ' & & c0_ < kMaxAsciiCharCode ) { <nl> + Advance ( ) ; <nl> + } else { <nl> + return SlowScanJsonString ( ) ; <nl> + } <nl> + } <nl> + ASSERT_EQ ( ' " ' , c0_ ) ; <nl> + / / Advance past the last ' " ' . <nl> + Advance ( ) ; <nl> + return Token : : STRING ; <nl> + } <nl> + <nl> + Handle < String > JsonParser : : GetString ( ) { <nl> + return GetString ( false ) ; <nl> + } <nl> + <nl> + Handle < String > JsonParser : : GetSymbol ( ) { <nl> + Handle < String > result = GetString ( true ) ; <nl> + if ( result - > IsSymbol ( ) ) return result ; <nl> + return isolate ( ) - > factory ( ) - > LookupSymbol ( result ) ; <nl> + } <nl> + <nl> + Handle < String > JsonParser : : GetString ( bool hint_symbol ) { <nl> + / / We have a non ascii string , return that . <nl> + if ( ! string_val_ . is_null ( ) ) return string_val_ ; <nl> + <nl> + if ( is_sequential_ascii_ & & hint_symbol ) { <nl> + Handle < SeqAsciiString > seq = Handle < SeqAsciiString > : : cast ( source_ ) ; <nl> + / / The current token includes the ' " ' in both ends . <nl> + int length = current_ . end_pos - current_ . beg_pos - 2 ; <nl> + return isolate ( ) - > factory ( ) - > LookupAsciiSymbol ( seq_source_ , <nl> + current_ . beg_pos + 1 , <nl> + length ) ; <nl> + } <nl> + / / The current token includes the ' " ' in both ends . <nl> + return isolate ( ) - > factory ( ) - > NewSubString ( <nl> + source_ , current_ . beg_pos + 1 , current_ . end_pos - 1 ) ; <nl> + } <nl> + <nl> + } } / / namespace v8 : : internal <nl> new file mode 100644 <nl> index 00000000000 . . e4ddda07a76 <nl> mmm / dev / null <nl> ppp b / src / json - parser . h <nl> <nl> + / / Copyright 2011 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # ifndef V8_JSON_PARSER_H_ <nl> + # define V8_JSON_PARSER_H_ <nl> + <nl> + # include " token . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + / / A simple json parser . <nl> + class JsonParser BASE_EMBEDDED { <nl> + public : <nl> + static Handle < Object > Parse ( Handle < String > source ) { <nl> + return JsonParser ( ) . ParseJson ( source ) ; <nl> + } <nl> + <nl> + static const int kEndOfString = - 1 ; <nl> + <nl> + private : <nl> + / / Parse a string containing a single JSON value . <nl> + Handle < Object > ParseJson ( Handle < String > source ) ; <nl> + <nl> + inline void Advance ( ) { <nl> + if ( position_ > = source_length_ ) { <nl> + position_ + + ; <nl> + c0_ = kEndOfString ; <nl> + } else if ( is_sequential_ascii_ ) { <nl> + position_ + + ; <nl> + c0_ = seq_source_ - > SeqAsciiStringGet ( position_ ) ; <nl> + } else { <nl> + position_ + + ; <nl> + c0_ = source_ - > Get ( position_ ) ; <nl> + } <nl> + } <nl> + <nl> + inline Isolate * isolate ( ) { return isolate_ ; } <nl> + <nl> + / / Get the string for the current string token . <nl> + Handle < String > GetString ( bool hint_symbol ) ; <nl> + Handle < String > GetString ( ) ; <nl> + Handle < String > GetSymbol ( ) ; <nl> + <nl> + / / Scan a single JSON token . The JSON lexical grammar is specified in the <nl> + / / ECMAScript 5 standard , section 15 . 12 . 1 . 1 . <nl> + / / Recognizes all of the single - character tokens directly , or calls a function <nl> + / / to scan a number , string or identifier literal . <nl> + / / The only allowed whitespace characters between tokens are tab , <nl> + / / carriage - return , newline and space . <nl> + void ScanJson ( ) ; <nl> + <nl> + / / A JSON string ( production JSONString ) is subset of valid JavaScript string <nl> + / / literals . The string must only be double - quoted ( not single - quoted ) , and <nl> + / / the only allowed backslash - escapes are " , / , \ , b , f , n , r , t and <nl> + / / four - digit hex escapes ( uXXXX ) . Any other use of backslashes is invalid . <nl> + Token : : Value ScanJsonString ( ) ; <nl> + / / Slow version for unicode support , uses the first ascii_count characters , <nl> + / / as first part of a ConsString <nl> + Token : : Value SlowScanJsonString ( ) ; <nl> + <nl> + / / A JSON number ( production JSONNumber ) is a subset of the valid JavaScript <nl> + / / decimal number literals . <nl> + / / It includes an optional minus sign , must have at least one <nl> + / / digit before and after a decimal point , may not have prefixed zeros ( unless <nl> + / / the integer part is zero ) , and may include an exponent part ( e . g . , " e - 10 " ) . <nl> + / / Hexadecimal and octal numbers are not allowed . <nl> + Token : : Value ScanJsonNumber ( ) ; <nl> + <nl> + / / Used to recognizes one of the literals " true " , " false " , or " null " . These <nl> + / / are the only valid JSON identifiers ( productions JSONBooleanLiteral , <nl> + / / JSONNullLiteral ) . <nl> + Token : : Value ScanJsonIdentifier ( const char * text , Token : : Value token ) ; <nl> + <nl> + / / Parse a single JSON value from input ( grammar production JSONValue ) . <nl> + / / A JSON value is either a ( double - quoted ) string literal , a number literal , <nl> + / / one of " true " , " false " , or " null " , or an object or array literal . <nl> + Handle < Object > ParseJsonValue ( ) ; <nl> + <nl> + / / Parse a JSON object literal ( grammar production JSONObject ) . <nl> + / / An object literal is a squiggly - braced and comma separated sequence <nl> + / / ( possibly empty ) of key / value pairs , where the key is a JSON string <nl> + / / literal , the value is a JSON value , and the two are separated by a colon . <nl> + / / A JSON array dosn ' t allow numbers and identifiers as keys , like a <nl> + / / JavaScript array . <nl> + Handle < Object > ParseJsonObject ( ) ; <nl> + <nl> + / / Parses a JSON array literal ( grammar production JSONArray ) . An array <nl> + / / literal is a square - bracketed and comma separated sequence ( possibly empty ) <nl> + / / of JSON values . <nl> + / / A JSON array doesn ' t allow leaving out values from the sequence , nor does <nl> + / / it allow a terminal comma , like a JavaScript array does . <nl> + Handle < Object > ParseJsonArray ( ) ; <nl> + <nl> + <nl> + / / Mark that a parsing error has happened at the current token , and <nl> + / / return a null handle . Primarily for readability . <nl> + Handle < Object > ReportUnexpectedToken ( ) { return Handle < Object > : : null ( ) ; } <nl> + <nl> + / / Peek at the next token . <nl> + Token : : Value Peek ( ) { return next_ . token ; } <nl> + / / Scan the next token and return the token scanned on the last call . <nl> + Token : : Value Next ( ) ; <nl> + <nl> + struct TokenInfo { <nl> + TokenInfo ( ) : token ( Token : : ILLEGAL ) , <nl> + beg_pos ( 0 ) , <nl> + end_pos ( 0 ) { } <nl> + Token : : Value token ; <nl> + int beg_pos ; <nl> + int end_pos ; <nl> + } ; <nl> + <nl> + static const int kInitialSpecialStringSize = 100 ; <nl> + <nl> + <nl> + private : <nl> + Handle < String > source_ ; <nl> + int source_length_ ; <nl> + Handle < SeqAsciiString > seq_source_ ; <nl> + <nl> + bool is_sequential_ascii_ ; <nl> + / / Current and next token <nl> + TokenInfo current_ ; <nl> + TokenInfo next_ ; <nl> + Isolate * isolate_ ; <nl> + uc32 c0_ ; <nl> + int position_ ; <nl> + <nl> + <nl> + Handle < String > string_val_ ; <nl> + double number_ ; <nl> + } ; <nl> + <nl> + } } / / namespace v8 : : internal <nl> + <nl> + # endif / / V8_JSON_PARSER_H_ <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> bool String : : IsEqualTo ( Vector < const char > str ) { <nl> bool String : : IsAsciiEqualTo ( Vector < const char > str ) { <nl> int slen = length ( ) ; <nl> if ( str . length ( ) ! = slen ) return false ; <nl> - for ( int i = 0 ; i < slen ; i + + ) { <nl> - if ( Get ( i ) ! = static_cast < uint16_t > ( str [ i ] ) ) return false ; <nl> + if ( this - > IsSeqAsciiString ( ) ) { <nl> + SeqAsciiString * seq = SeqAsciiString : : cast ( this ) ; <nl> + char * ch = seq - > GetChars ( ) ; <nl> + for ( int i = 0 ; i < slen ; i + + , ch + + ) { <nl> + if ( * ch ! = str [ i ] ) return false ; <nl> + } <nl> + } else { <nl> + for ( int i = 0 ; i < slen ; i + + ) { <nl> + if ( Get ( i ) ! = static_cast < uint16_t > ( str [ i ] ) ) return false ; <nl> + } <nl> } <nl> return true ; <nl> } <nl> class AsciiSymbolKey : public SequentialSymbolKey < char > { <nl> } ; <nl> <nl> <nl> + class SubStringAsciiSymbolKey : public HashTableKey { <nl> + public : <nl> + explicit SubStringAsciiSymbolKey ( Handle < SeqAsciiString > string , <nl> + int from , <nl> + int length ) <nl> + : string_ ( string ) , from_ ( from ) , length_ ( length ) { } <nl> + <nl> + uint32_t Hash ( ) { <nl> + ASSERT ( length_ > = 0 ) ; <nl> + ASSERT ( from_ + length_ < = string_ - > length ( ) ) ; <nl> + StringHasher hasher ( length_ ) ; <nl> + <nl> + / / Very long strings have a trivial hash that doesn ' t inspect the <nl> + / / string contents . <nl> + if ( hasher . has_trivial_hash ( ) ) { <nl> + hash_field_ = hasher . GetHashField ( ) ; <nl> + } else { <nl> + int i = 0 ; <nl> + / / Do the iterative array index computation as long as there is a <nl> + / / chance this is an array index . <nl> + while ( i < length_ & & hasher . is_array_index ( ) ) { <nl> + hasher . AddCharacter ( static_cast < uc32 > ( <nl> + string_ - > SeqAsciiStringGet ( i + from_ ) ) ) ; <nl> + i + + ; <nl> + } <nl> + <nl> + / / Process the remaining characters without updating the array <nl> + / / index . <nl> + while ( i < length_ ) { <nl> + hasher . AddCharacterNoIndex ( static_cast < uc32 > ( <nl> + string_ - > SeqAsciiStringGet ( i + from_ ) ) ) ; <nl> + i + + ; <nl> + } <nl> + hash_field_ = hasher . GetHashField ( ) ; <nl> + } <nl> + <nl> + uint32_t result = hash_field_ > > String : : kHashShift ; <nl> + ASSERT ( result ! = 0 ) ; / / Ensure that the hash value of 0 is never computed . <nl> + return result ; <nl> + } <nl> + <nl> + <nl> + uint32_t HashForObject ( Object * other ) { <nl> + return String : : cast ( other ) - > Hash ( ) ; <nl> + } <nl> + <nl> + bool IsMatch ( Object * string ) { <nl> + Vector < const char > chars ( string_ - > GetChars ( ) + from_ , length_ ) ; <nl> + return String : : cast ( string ) - > IsAsciiEqualTo ( chars ) ; <nl> + } <nl> + <nl> + MaybeObject * AsObject ( ) { <nl> + if ( hash_field_ = = 0 ) Hash ( ) ; <nl> + Vector < const char > chars ( string_ - > GetChars ( ) + from_ , length_ ) ; <nl> + return HEAP - > AllocateAsciiSymbol ( chars , hash_field_ ) ; <nl> + } <nl> + <nl> + private : <nl> + Handle < SeqAsciiString > string_ ; <nl> + int from_ ; <nl> + int length_ ; <nl> + uint32_t hash_field_ ; <nl> + } ; <nl> + <nl> + <nl> class TwoByteSymbolKey : public SequentialSymbolKey < uc16 > { <nl> public : <nl> explicit TwoByteSymbolKey ( Vector < const uc16 > str ) <nl> MaybeObject * SymbolTable : : LookupAsciiSymbol ( Vector < const char > str , <nl> } <nl> <nl> <nl> + MaybeObject * SymbolTable : : LookupSubStringAsciiSymbol ( Handle < SeqAsciiString > str , <nl> + int from , <nl> + int length , <nl> + Object * * s ) { <nl> + SubStringAsciiSymbolKey key ( str , from , length ) ; <nl> + return LookupKey ( & key , s ) ; <nl> + } <nl> + <nl> + <nl> MaybeObject * SymbolTable : : LookupTwoByteSymbol ( Vector < const uc16 > str , <nl> Object * * s ) { <nl> TwoByteSymbolKey key ( str ) ; <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class SymbolTableShape { <nl> static const int kEntrySize = 1 ; <nl> } ; <nl> <nl> + class SeqAsciiString ; <nl> + <nl> / / SymbolTable . <nl> / / <nl> / / No special elements in the prefix and the element size is 1 <nl> class SymbolTable : public HashTable < SymbolTableShape , HashTableKey * > { <nl> MUST_USE_RESULT MaybeObject * LookupSymbol ( Vector < const char > str , Object * * s ) ; <nl> MUST_USE_RESULT MaybeObject * LookupAsciiSymbol ( Vector < const char > str , <nl> Object * * s ) ; <nl> + MUST_USE_RESULT MaybeObject * LookupSubStringAsciiSymbol ( <nl> + Handle < SeqAsciiString > str , <nl> + int from , <nl> + int length , <nl> + Object * * s ) ; <nl> MUST_USE_RESULT MaybeObject * LookupTwoByteSymbol ( Vector < const uc16 > str , <nl> Object * * s ) ; <nl> MUST_USE_RESULT MaybeObject * LookupString ( String * key , Object * * s ) ; <nl> mmm a / src / parser . cc <nl> ppp b / src / parser . cc <nl> Expression * Parser : : NewThrowError ( Handle < String > constructor , <nl> scanner ( ) . location ( ) . beg_pos ) ; <nl> } <nl> <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / JSON <nl> - <nl> - Handle < Object > JsonParser : : ParseJson ( Handle < String > script , <nl> - UC16CharacterStream * source ) { <nl> - scanner_ . Initialize ( source ) ; <nl> - stack_overflow_ = false ; <nl> - Handle < Object > result = ParseJsonValue ( ) ; <nl> - if ( result . is_null ( ) | | scanner_ . Next ( ) ! = Token : : EOS ) { <nl> - if ( stack_overflow_ ) { <nl> - / / Scanner failed . <nl> - isolate ( ) - > StackOverflow ( ) ; <nl> - } else { <nl> - / / Parse failed . Scanner ' s current token is the unexpected token . <nl> - Token : : Value token = scanner_ . current_token ( ) ; <nl> - <nl> - const char * message ; <nl> - const char * name_opt = NULL ; <nl> - <nl> - switch ( token ) { <nl> - case Token : : EOS : <nl> - message = " unexpected_eos " ; <nl> - break ; <nl> - case Token : : NUMBER : <nl> - message = " unexpected_token_number " ; <nl> - break ; <nl> - case Token : : STRING : <nl> - message = " unexpected_token_string " ; <nl> - break ; <nl> - case Token : : IDENTIFIER : <nl> - case Token : : FUTURE_RESERVED_WORD : <nl> - message = " unexpected_token_identifier " ; <nl> - break ; <nl> - default : <nl> - message = " unexpected_token " ; <nl> - name_opt = Token : : String ( token ) ; <nl> - ASSERT ( name_opt ! = NULL ) ; <nl> - break ; <nl> - } <nl> - <nl> - Scanner : : Location source_location = scanner_ . location ( ) ; <nl> - Factory * factory = isolate ( ) - > factory ( ) ; <nl> - MessageLocation location ( factory - > NewScript ( script ) , <nl> - source_location . beg_pos , <nl> - source_location . end_pos ) ; <nl> - Handle < JSArray > array ; <nl> - if ( name_opt = = NULL ) { <nl> - array = factory - > NewJSArray ( 0 ) ; <nl> - } else { <nl> - Handle < String > name = factory - > NewStringFromUtf8 ( CStrVector ( name_opt ) ) ; <nl> - Handle < FixedArray > element = factory - > NewFixedArray ( 1 ) ; <nl> - element - > set ( 0 , * name ) ; <nl> - array = factory - > NewJSArrayWithElements ( element ) ; <nl> - } <nl> - Handle < Object > result = factory - > NewSyntaxError ( message , array ) ; <nl> - isolate ( ) - > Throw ( * result , & location ) ; <nl> - return Handle < Object > : : null ( ) ; <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - <nl> - Handle < String > JsonParser : : GetString ( ) { <nl> - int literal_length = scanner_ . literal_length ( ) ; <nl> - if ( literal_length = = 0 ) { <nl> - return isolate ( ) - > factory ( ) - > empty_string ( ) ; <nl> - } <nl> - if ( scanner_ . is_literal_ascii ( ) ) { <nl> - return isolate ( ) - > factory ( ) - > NewStringFromAscii ( <nl> - scanner_ . literal_ascii_string ( ) ) ; <nl> - } else { <nl> - return isolate ( ) - > factory ( ) - > NewStringFromTwoByte ( <nl> - scanner_ . literal_uc16_string ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - Handle < String > JsonParser : : GetSymbol ( ) { <nl> - int literal_length = scanner_ . literal_length ( ) ; <nl> - if ( literal_length = = 0 ) { <nl> - return isolate ( ) - > factory ( ) - > empty_string ( ) ; <nl> - } <nl> - if ( scanner_ . is_literal_ascii ( ) ) { <nl> - return isolate ( ) - > factory ( ) - > LookupAsciiSymbol ( <nl> - scanner_ . literal_ascii_string ( ) ) ; <nl> - } else { <nl> - return isolate ( ) - > factory ( ) - > LookupTwoByteSymbol ( <nl> - scanner_ . literal_uc16_string ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Parse any JSON value . <nl> - Handle < Object > JsonParser : : ParseJsonValue ( ) { <nl> - Token : : Value token = scanner_ . Next ( ) ; <nl> - switch ( token ) { <nl> - case Token : : STRING : <nl> - return GetString ( ) ; <nl> - case Token : : NUMBER : <nl> - return isolate ( ) - > factory ( ) - > NewNumber ( scanner_ . number ( ) ) ; <nl> - case Token : : FALSE_LITERAL : <nl> - return isolate ( ) - > factory ( ) - > false_value ( ) ; <nl> - case Token : : TRUE_LITERAL : <nl> - return isolate ( ) - > factory ( ) - > true_value ( ) ; <nl> - case Token : : NULL_LITERAL : <nl> - return isolate ( ) - > factory ( ) - > null_value ( ) ; <nl> - case Token : : LBRACE : <nl> - return ParseJsonObject ( ) ; <nl> - case Token : : LBRACK : <nl> - return ParseJsonArray ( ) ; <nl> - default : <nl> - return ReportUnexpectedToken ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Parse a JSON object . Scanner must be right after ' { ' token . <nl> - Handle < Object > JsonParser : : ParseJsonObject ( ) { <nl> - Handle < JSFunction > object_constructor ( <nl> - isolate ( ) - > global_context ( ) - > object_function ( ) ) ; <nl> - Handle < JSObject > json_object = <nl> - isolate ( ) - > factory ( ) - > NewJSObject ( object_constructor ) ; <nl> - if ( scanner_ . peek ( ) = = Token : : RBRACE ) { <nl> - scanner_ . Next ( ) ; <nl> - } else { <nl> - if ( StackLimitCheck ( isolate ( ) ) . HasOverflowed ( ) ) { <nl> - stack_overflow_ = true ; <nl> - return Handle < Object > : : null ( ) ; <nl> - } <nl> - do { <nl> - if ( scanner_ . Next ( ) ! = Token : : STRING ) { <nl> - return ReportUnexpectedToken ( ) ; <nl> - } <nl> - Handle < String > key = GetSymbol ( ) ; <nl> - if ( scanner_ . Next ( ) ! = Token : : COLON ) { <nl> - return ReportUnexpectedToken ( ) ; <nl> - } <nl> - Handle < Object > value = ParseJsonValue ( ) ; <nl> - if ( value . is_null ( ) ) return Handle < Object > : : null ( ) ; <nl> - uint32_t index ; <nl> - if ( key - > AsArrayIndex ( & index ) ) { <nl> - SetOwnElement ( json_object , index , value , kNonStrictMode ) ; <nl> - } else if ( key - > Equals ( isolate ( ) - > heap ( ) - > Proto_symbol ( ) ) ) { <nl> - / / We can ' t remove the __proto__ accessor since it ' s hardcoded <nl> - / / in several places . Instead go along and add the value as <nl> - / / the prototype of the created object if possible . <nl> - SetPrototype ( json_object , value ) ; <nl> - } else { <nl> - SetLocalPropertyIgnoreAttributes ( json_object , key , value , NONE ) ; <nl> - } <nl> - } while ( scanner_ . Next ( ) = = Token : : COMMA ) ; <nl> - if ( scanner_ . current_token ( ) ! = Token : : RBRACE ) { <nl> - return ReportUnexpectedToken ( ) ; <nl> - } <nl> - } <nl> - return json_object ; <nl> - } <nl> - <nl> - <nl> - / / Parse a JSON array . Scanner must be right after ' [ ' token . <nl> - Handle < Object > JsonParser : : ParseJsonArray ( ) { <nl> - ZoneScope zone_scope ( isolate ( ) , DELETE_ON_EXIT ) ; <nl> - ZoneList < Handle < Object > > elements ( 4 ) ; <nl> - <nl> - Token : : Value token = scanner_ . peek ( ) ; <nl> - if ( token = = Token : : RBRACK ) { <nl> - scanner_ . Next ( ) ; <nl> - } else { <nl> - if ( StackLimitCheck ( isolate ( ) ) . HasOverflowed ( ) ) { <nl> - stack_overflow_ = true ; <nl> - return Handle < Object > : : null ( ) ; <nl> - } <nl> - do { <nl> - Handle < Object > element = ParseJsonValue ( ) ; <nl> - if ( element . is_null ( ) ) return Handle < Object > : : null ( ) ; <nl> - elements . Add ( element ) ; <nl> - token = scanner_ . Next ( ) ; <nl> - } while ( token = = Token : : COMMA ) ; <nl> - if ( token ! = Token : : RBRACK ) { <nl> - return ReportUnexpectedToken ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / Allocate a fixed array with all the elements . <nl> - Handle < FixedArray > fast_elements = <nl> - isolate ( ) - > factory ( ) - > NewFixedArray ( elements . length ( ) ) ; <nl> - <nl> - for ( int i = 0 , n = elements . length ( ) ; i < n ; i + + ) { <nl> - fast_elements - > set ( i , * elements [ i ] ) ; <nl> - } <nl> - <nl> - return isolate ( ) - > factory ( ) - > NewJSArrayWithElements ( fast_elements ) ; <nl> - } <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / Regular expressions <nl> <nl> mmm a / src / parser . h <nl> ppp b / src / parser . h <nl> class CompileTimeValue : public AllStatic { <nl> DISALLOW_IMPLICIT_CONSTRUCTORS ( CompileTimeValue ) ; <nl> } ; <nl> <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / JSON PARSING <nl> - <nl> - / / JSON is a subset of JavaScript , as specified in , e . g . , the ECMAScript 5 <nl> - / / specification section 15 . 12 . 1 ( and appendix A . 8 ) . <nl> - / / The grammar is given section 15 . 12 . 1 . 2 ( and appendix A . 8 . 2 ) . <nl> - class JsonParser BASE_EMBEDDED { <nl> - public : <nl> - / / Parse JSON input as a single JSON value . <nl> - / / Returns null handle and sets exception if parsing failed . <nl> - static Handle < Object > Parse ( Handle < String > source ) { <nl> - if ( source - > IsExternalTwoByteString ( ) ) { <nl> - ExternalTwoByteStringUC16CharacterStream stream ( <nl> - Handle < ExternalTwoByteString > : : cast ( source ) , 0 , source - > length ( ) ) ; <nl> - return JsonParser ( ) . ParseJson ( source , & stream ) ; <nl> - } else { <nl> - GenericStringUC16CharacterStream stream ( source , 0 , source - > length ( ) ) ; <nl> - return JsonParser ( ) . ParseJson ( source , & stream ) ; <nl> - } <nl> - } <nl> - <nl> - private : <nl> - JsonParser ( ) <nl> - : isolate_ ( Isolate : : Current ( ) ) , <nl> - scanner_ ( isolate_ - > unicode_cache ( ) ) { } <nl> - ~ JsonParser ( ) { } <nl> - <nl> - Isolate * isolate ( ) { return isolate_ ; } <nl> - <nl> - / / Parse a string containing a single JSON value . <nl> - Handle < Object > ParseJson ( Handle < String > script , UC16CharacterStream * source ) ; <nl> - / / Parse a single JSON value from input ( grammar production JSONValue ) . <nl> - / / A JSON value is either a ( double - quoted ) string literal , a number literal , <nl> - / / one of " true " , " false " , or " null " , or an object or array literal . <nl> - Handle < Object > ParseJsonValue ( ) ; <nl> - / / Parse a JSON object literal ( grammar production JSONObject ) . <nl> - / / An object literal is a squiggly - braced and comma separated sequence <nl> - / / ( possibly empty ) of key / value pairs , where the key is a JSON string <nl> - / / literal , the value is a JSON value , and the two are separated by a colon . <nl> - / / A JSON array dosn ' t allow numbers and identifiers as keys , like a <nl> - / / JavaScript array . <nl> - Handle < Object > ParseJsonObject ( ) ; <nl> - / / Parses a JSON array literal ( grammar production JSONArray ) . An array <nl> - / / literal is a square - bracketed and comma separated sequence ( possibly empty ) <nl> - / / of JSON values . <nl> - / / A JSON array doesn ' t allow leaving out values from the sequence , nor does <nl> - / / it allow a terminal comma , like a JavaScript array does . <nl> - Handle < Object > ParseJsonArray ( ) ; <nl> - <nl> - / / Mark that a parsing error has happened at the current token , and <nl> - / / return a null handle . Primarily for readability . <nl> - Handle < Object > ReportUnexpectedToken ( ) { return Handle < Object > : : null ( ) ; } <nl> - / / Converts the currently parsed literal to a JavaScript String . <nl> - Handle < String > GetString ( ) ; <nl> - / / Converts the currently parsed literal to a JavaScript Symbol String . <nl> - Handle < String > GetSymbol ( ) ; <nl> - <nl> - Isolate * isolate_ ; <nl> - JsonScanner scanner_ ; <nl> - bool stack_overflow_ ; <nl> - } ; <nl> } } / / namespace v8 : : internal <nl> <nl> # endif / / V8_PARSER_H_ <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> <nl> # include " execution . h " <nl> # include " global - handles . h " <nl> # include " jsregexp . h " <nl> + # include " json - parser . h " <nl> # include " liveedit . h " <nl> # include " liveobjectlist - inl . h " <nl> # include " parser . h " <nl> mmm a / src / scanner . cc <nl> ppp b / src / scanner . cc <nl> void V8JavaScriptScanner : : Initialize ( UC16CharacterStream * source ) { <nl> } <nl> <nl> <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / JsonScanner <nl> - <nl> - JsonScanner : : JsonScanner ( UnicodeCache * unicode_cache ) <nl> - : Scanner ( unicode_cache ) { } <nl> - <nl> - <nl> - void JsonScanner : : Initialize ( UC16CharacterStream * source ) { <nl> - source_ = source ; <nl> - Init ( ) ; <nl> - / / Skip initial whitespace . <nl> - SkipJsonWhiteSpace ( ) ; <nl> - / / Preload first token as look - ahead . <nl> - ScanJson ( ) ; <nl> - } <nl> - <nl> - <nl> - Token : : Value JsonScanner : : Next ( ) { <nl> - / / BUG 1215673 : Find a thread safe way to set a stack limit in <nl> - / / pre - parse mode . Otherwise , we cannot safely pre - parse from other <nl> - / / threads . <nl> - current_ = next_ ; <nl> - / / Check for stack - overflow before returning any tokens . <nl> - ScanJson ( ) ; <nl> - return current_ . token ; <nl> - } <nl> - <nl> - <nl> - bool JsonScanner : : SkipJsonWhiteSpace ( ) { <nl> - int start_position = source_pos ( ) ; <nl> - / / JSON WhiteSpace is tab , carrige - return , newline and space . <nl> - while ( c0_ = = ' ' | | c0_ = = ' \ n ' | | c0_ = = ' \ r ' | | c0_ = = ' \ t ' ) { <nl> - Advance ( ) ; <nl> - } <nl> - return source_pos ( ) ! = start_position ; <nl> - } <nl> - <nl> - <nl> - void JsonScanner : : ScanJson ( ) { <nl> - next_ . literal_chars = NULL ; <nl> - Token : : Value token ; <nl> - do { <nl> - / / Remember the position of the next token <nl> - next_ . location . beg_pos = source_pos ( ) ; <nl> - switch ( c0_ ) { <nl> - case ' \ t ' : <nl> - case ' \ r ' : <nl> - case ' \ n ' : <nl> - case ' ' : <nl> - Advance ( ) ; <nl> - token = Token : : WHITESPACE ; <nl> - break ; <nl> - case ' { ' : <nl> - Advance ( ) ; <nl> - token = Token : : LBRACE ; <nl> - break ; <nl> - case ' } ' : <nl> - Advance ( ) ; <nl> - token = Token : : RBRACE ; <nl> - break ; <nl> - case ' [ ' : <nl> - Advance ( ) ; <nl> - token = Token : : LBRACK ; <nl> - break ; <nl> - case ' ] ' : <nl> - Advance ( ) ; <nl> - token = Token : : RBRACK ; <nl> - break ; <nl> - case ' : ' : <nl> - Advance ( ) ; <nl> - token = Token : : COLON ; <nl> - break ; <nl> - case ' , ' : <nl> - Advance ( ) ; <nl> - token = Token : : COMMA ; <nl> - break ; <nl> - case ' " ' : <nl> - token = ScanJsonString ( ) ; <nl> - break ; <nl> - case ' - ' : <nl> - case ' 0 ' : <nl> - case ' 1 ' : <nl> - case ' 2 ' : <nl> - case ' 3 ' : <nl> - case ' 4 ' : <nl> - case ' 5 ' : <nl> - case ' 6 ' : <nl> - case ' 7 ' : <nl> - case ' 8 ' : <nl> - case ' 9 ' : <nl> - token = ScanJsonNumber ( ) ; <nl> - break ; <nl> - case ' t ' : <nl> - token = ScanJsonIdentifier ( " true " , Token : : TRUE_LITERAL ) ; <nl> - break ; <nl> - case ' f ' : <nl> - token = ScanJsonIdentifier ( " false " , Token : : FALSE_LITERAL ) ; <nl> - break ; <nl> - case ' n ' : <nl> - token = ScanJsonIdentifier ( " null " , Token : : NULL_LITERAL ) ; <nl> - break ; <nl> - default : <nl> - if ( c0_ < 0 ) { <nl> - Advance ( ) ; <nl> - token = Token : : EOS ; <nl> - } else { <nl> - Advance ( ) ; <nl> - token = Select ( Token : : ILLEGAL ) ; <nl> - } <nl> - } <nl> - } while ( token = = Token : : WHITESPACE ) ; <nl> - <nl> - next_ . location . end_pos = source_pos ( ) ; <nl> - next_ . token = token ; <nl> - } <nl> - <nl> - <nl> - Token : : Value JsonScanner : : ScanJsonString ( ) { <nl> - ASSERT_EQ ( ' " ' , c0_ ) ; <nl> - Advance ( ) ; <nl> - LiteralScope literal ( this ) ; <nl> - while ( c0_ ! = ' " ' ) { <nl> - / / Check for control character ( 0x00 - 0x1f ) or unterminated string ( < 0 ) . <nl> - if ( c0_ < 0x20 ) return Token : : ILLEGAL ; <nl> - if ( c0_ ! = ' \ \ ' ) { <nl> - AddLiteralCharAdvance ( ) ; <nl> - } else { <nl> - Advance ( ) ; <nl> - switch ( c0_ ) { <nl> - case ' " ' : <nl> - case ' \ \ ' : <nl> - case ' / ' : <nl> - AddLiteralChar ( c0_ ) ; <nl> - break ; <nl> - case ' b ' : <nl> - AddLiteralChar ( ' \ x08 ' ) ; <nl> - break ; <nl> - case ' f ' : <nl> - AddLiteralChar ( ' \ x0c ' ) ; <nl> - break ; <nl> - case ' n ' : <nl> - AddLiteralChar ( ' \ x0a ' ) ; <nl> - break ; <nl> - case ' r ' : <nl> - AddLiteralChar ( ' \ x0d ' ) ; <nl> - break ; <nl> - case ' t ' : <nl> - AddLiteralChar ( ' \ x09 ' ) ; <nl> - break ; <nl> - case ' u ' : { <nl> - uc32 value = 0 ; <nl> - for ( int i = 0 ; i < 4 ; i + + ) { <nl> - Advance ( ) ; <nl> - int digit = HexValue ( c0_ ) ; <nl> - if ( digit < 0 ) { <nl> - return Token : : ILLEGAL ; <nl> - } <nl> - value = value * 16 + digit ; <nl> - } <nl> - AddLiteralChar ( value ) ; <nl> - break ; <nl> - } <nl> - default : <nl> - return Token : : ILLEGAL ; <nl> - } <nl> - Advance ( ) ; <nl> - } <nl> - } <nl> - literal . Complete ( ) ; <nl> - Advance ( ) ; <nl> - return Token : : STRING ; <nl> - } <nl> - <nl> - <nl> - Token : : Value JsonScanner : : ScanJsonNumber ( ) { <nl> - LiteralScope literal ( this ) ; <nl> - bool negative = false ; <nl> - <nl> - if ( c0_ = = ' - ' ) { <nl> - AddLiteralCharAdvance ( ) ; <nl> - negative = true ; <nl> - } <nl> - if ( c0_ = = ' 0 ' ) { <nl> - AddLiteralCharAdvance ( ) ; <nl> - / / Prefix zero is only allowed if it ' s the only digit before <nl> - / / a decimal point or exponent . <nl> - if ( ' 0 ' < = c0_ & & c0_ < = ' 9 ' ) return Token : : ILLEGAL ; <nl> - } else { <nl> - int i = 0 ; <nl> - int digits = 0 ; <nl> - if ( c0_ < ' 1 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> - do { <nl> - i = i * 10 + c0_ - ' 0 ' ; <nl> - digits + + ; <nl> - AddLiteralCharAdvance ( ) ; <nl> - } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> - if ( c0_ ! = ' . ' & & c0_ ! = ' e ' & & c0_ ! = ' E ' & & digits < 10 ) { <nl> - number_ = ( negative ? - i : i ) ; <nl> - return Token : : NUMBER ; <nl> - } <nl> - } <nl> - if ( c0_ = = ' . ' ) { <nl> - AddLiteralCharAdvance ( ) ; <nl> - if ( c0_ < ' 0 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> - do { <nl> - AddLiteralCharAdvance ( ) ; <nl> - } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> - } <nl> - if ( AsciiAlphaToLower ( c0_ ) = = ' e ' ) { <nl> - AddLiteralCharAdvance ( ) ; <nl> - if ( c0_ = = ' - ' | | c0_ = = ' + ' ) AddLiteralCharAdvance ( ) ; <nl> - if ( c0_ < ' 0 ' | | c0_ > ' 9 ' ) return Token : : ILLEGAL ; <nl> - do { <nl> - AddLiteralCharAdvance ( ) ; <nl> - } while ( c0_ > = ' 0 ' & & c0_ < = ' 9 ' ) ; <nl> - } <nl> - literal . Complete ( ) ; <nl> - ASSERT_NOT_NULL ( next_ . literal_chars ) ; <nl> - number_ = StringToDouble ( unicode_cache_ , <nl> - next_ . literal_chars - > ascii_literal ( ) , <nl> - NO_FLAGS , / / Hex , octal or trailing junk . <nl> - OS : : nan_value ( ) ) ; <nl> - return Token : : NUMBER ; <nl> - } <nl> - <nl> - <nl> - Token : : Value JsonScanner : : ScanJsonIdentifier ( const char * text , <nl> - Token : : Value token ) { <nl> - LiteralScope literal ( this ) ; <nl> - while ( * text ! = ' \ 0 ' ) { <nl> - if ( c0_ ! = * text ) return Token : : ILLEGAL ; <nl> - Advance ( ) ; <nl> - text + + ; <nl> - } <nl> - if ( unicode_cache_ - > IsIdentifierPart ( c0_ ) ) return Token : : ILLEGAL ; <nl> - literal . Complete ( ) ; <nl> - return token ; <nl> - } <nl> - <nl> - <nl> } } / / namespace v8 : : internal <nl> mmm a / src / scanner . h <nl> ppp b / src / scanner . h <nl> class V8JavaScriptScanner : public JavaScriptScanner { <nl> } ; <nl> <nl> <nl> - class JsonScanner : public Scanner { <nl> - public : <nl> - explicit JsonScanner ( UnicodeCache * unicode_cache ) ; <nl> - <nl> - void Initialize ( UC16CharacterStream * source ) ; <nl> - <nl> - / / Returns the next token . <nl> - Token : : Value Next ( ) ; <nl> - <nl> - / / Returns the value of a number token . <nl> - double number ( ) { <nl> - return number_ ; <nl> - } <nl> - <nl> - <nl> - protected : <nl> - / / Skip past JSON whitespace ( only space , tab , newline and carrige - return ) . <nl> - bool SkipJsonWhiteSpace ( ) ; <nl> - <nl> - / / Scan a single JSON token . The JSON lexical grammar is specified in the <nl> - / / ECMAScript 5 standard , section 15 . 12 . 1 . 1 . <nl> - / / Recognizes all of the single - character tokens directly , or calls a function <nl> - / / to scan a number , string or identifier literal . <nl> - / / The only allowed whitespace characters between tokens are tab , <nl> - / / carriage - return , newline and space . <nl> - void ScanJson ( ) ; <nl> - <nl> - / / A JSON number ( production JSONNumber ) is a subset of the valid JavaScript <nl> - / / decimal number literals . <nl> - / / It includes an optional minus sign , must have at least one <nl> - / / digit before and after a decimal point , may not have prefixed zeros ( unless <nl> - / / the integer part is zero ) , and may include an exponent part ( e . g . , " e - 10 " ) . <nl> - / / Hexadecimal and octal numbers are not allowed . <nl> - Token : : Value ScanJsonNumber ( ) ; <nl> - <nl> - / / A JSON string ( production JSONString ) is subset of valid JavaScript string <nl> - / / literals . The string must only be double - quoted ( not single - quoted ) , and <nl> - / / the only allowed backslash - escapes are " , / , \ , b , f , n , r , t and <nl> - / / four - digit hex escapes ( uXXXX ) . Any other use of backslashes is invalid . <nl> - Token : : Value ScanJsonString ( ) ; <nl> - <nl> - / / Used to recognizes one of the literals " true " , " false " , or " null " . These <nl> - / / are the only valid JSON identifiers ( productions JSONBooleanLiteral , <nl> - / / JSONNullLiteral ) . <nl> - Token : : Value ScanJsonIdentifier ( const char * text , Token : : Value token ) ; <nl> - <nl> - / / Holds the value of a scanned number token . <nl> - double number_ ; <nl> - } ; <nl> - <nl> } } / / namespace v8 : : internal <nl> <nl> # endif / / V8_SCANNER_H_ <nl>
|
Create stand - alone json parser ( including scanner ) .
|
v8/v8
|
3c7e1d7015284d4e5bb540382ef78878deabede2
|
2011-05-24T12:16:23Z
|
mmm a / test / wasm - js / tests . tar . gz . sha1 <nl> ppp b / test / wasm - js / tests . tar . gz . sha1 <nl> @ @ - 1 + 1 @ @ <nl> - f5f37994cf87612032658e0456f5213b752b3256 <nl> \ No newline at end of file <nl> + 998b2870df79bf5ae83eb80aa6adb4ec3110d197 <nl> \ No newline at end of file <nl> mmm a / test / wasm - spec - tests / testcfg . py <nl> ppp b / test / wasm - spec - tests / testcfg . py <nl> <nl> <nl> proposal_flags = [ { <nl> ' name ' : ' reference - types ' , <nl> - ' flags ' : [ ' - - experimental - wasm - anyref ' , <nl> - ' - - no - experimental - wasm - bulk - memory ' ] <nl> + ' flags ' : [ ' - - experimental - wasm - anyref ' ] <nl> } , <nl> { <nl> ' name ' : ' bulk - memory - operations ' , <nl> mmm a / test / wasm - spec - tests / tests . tar . gz . sha1 <nl> ppp b / test / wasm - spec - tests / tests . tar . gz . sha1 <nl> @ @ - 1 + 1 @ @ <nl> - 30a4f6aed5a27a33455d2af7dcfb90ffe0c189c7 <nl> \ No newline at end of file <nl> + 61d66d9a4019b8799d4be29b82424c5e5a4fb8b2 <nl> \ No newline at end of file <nl> mmm a / test / wasm - spec - tests / wasm - spec - tests . status <nl> ppp b / test / wasm - spec - tests / wasm - spec - tests . status <nl> <nl> ' proposals / multi - value / call ' : [ FAIL ] , <nl> ' proposals / multi - value / if ' : [ FAIL ] , <nl> ' proposals / multi - value / func ' : [ FAIL ] , <nl> + <nl> + # TODO ( v8 : 10156 ) : Spec tests are failing after rebasing the reference - types <nl> + # proposal on the bulk - operations proposal . <nl> + ' proposals / reference - types / elem ' : [ FAIL ] , <nl> + ' proposals / reference - types / ref_func ' : [ FAIL ] , <nl> + ' proposals / reference - types / table_fill ' : [ FAIL ] , <nl> + ' proposals / reference - types / table_grow ' : [ FAIL ] , <nl> + ' proposals / reference - types / select ' : [ FAIL ] , <nl> + ' proposals / reference - types / br_table ' : [ FAIL ] , <nl> } ] , # ALWAYS <nl> <nl> [ ' arch = = mipsel or arch = = mips64el or arch = = mips or arch = = mips64 ' , { <nl>
|
[ wasm ] Update spec tests
|
v8/v8
|
3fa30b25fdb4c99b6463b712fa1f354539e238bf
|
2020-01-24T16:48:11Z
|
mmm a / js / server / modules / org / arangodb / foxx / templateEngine . js <nl> ppp b / js / server / modules / org / arangodb / foxx / templateEngine . js <nl> _ . extend ( Engine . prototype , { <nl> modelInstance = collectionStart . toLowerCase ( ) + modelBase ; <nl> repositoryName = collectionStart . toUpperCase ( ) + repositoryBase ; <nl> repositoryInstance = collectionStart . toLowerCase ( ) + repositoryBase ; <nl> - repositoryPath = ' . . / repositories / ' + collectionName ; <nl> - modelPath = ' . . / models / ' + modelName . toLowerCase ( ) ; <nl> + repositoryPath = ' repositories / ' + collectionName ; <nl> + modelPath = ' models / ' + modelName . toLowerCase ( ) ; <nl> <nl> this . collectionNames . push ( collectionName ) ; <nl> this . controllers . push ( { <nl> mmm a / js / server / modules / org / arangodb / foxx / templates / controller . js . tmpl <nl> ppp b / js / server / modules / org / arangodb / foxx / templates / controller . js . tmpl <nl> var _ = require ( ' underscore ' ) ; <nl> var joi = require ( ' joi ' ) ; <nl> var Foxx = require ( ' org / arangodb / foxx ' ) ; <nl> var ArangoError = require ( ' org / arangodb ' ) . ArangoError ; <nl> - var < % = repository % > = require ( ' < % = repositoryPath % > ' ) ; <nl> - var < % = model % > = require ( ' < % = modelPath % > ' ) ; <nl> + var < % = repository % > = require ( ' . . / < % = repositoryPath % > ' ) ; <nl> + var < % = model % > = require ( ' . . / < % = modelPath % > ' ) ; <nl> var controller = new Foxx . Controller ( applicationContext ) ; <nl> <nl> var < % = modelInstance % > IdSchema = joi . string ( ) . required ( ) <nl>
|
Fix
|
arangodb/arangodb
|
ce8ddcfe1da9e7429c6247c8adfea53d91521a04
|
2015-11-16T17:50:37Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> set ( BIN_ARANGOVPACK arangovpack ) <nl> set ( TEST_BASICS_SUITE basics_suite ) <nl> set ( TEST_GEO_SUITE geo_suite ) <nl> set ( PACKAGES_LIST ) <nl> + set ( COPY_PACKAGES_LIST ) <nl> set ( CLEAN_PACKAGES_LIST ) <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> add_custom_target ( packages <nl> DEPENDS $ { PACKAGES_LIST } <nl> ) <nl> <nl> + add_custom_target ( copy_packages <nl> + DEPENDS $ { COPY_PACKAGES_LIST } <nl> + ) <nl> + <nl> add_custom_target ( clean_packages <nl> DEPENDS $ { CLEAN_PACKAGES_LIST } <nl> ) <nl> mmm a / Installation / Jenkins / build . sh <nl> ppp b / Installation / Jenkins / build . sh <nl> while [ $ # - gt 0 ] ; do <nl> shift <nl> ; ; <nl> <nl> + - - snap ) <nl> + CONFIGURE_OPTIONS = " $ { CONFIGURE_OPTIONS } - DUSE_SNAPCRAFT = ON - DSNAP_PORT = 8533 " <nl> + shift <nl> + ; ; <nl> + <nl> - - parallel ) <nl> shift <nl> PARALLEL_BUILDS = $ 1 <nl> mmm a / cmake / packages / bundle . cmake <nl> ppp b / cmake / packages / bundle . cmake <nl> add_custom_target ( package - arongodb - server - bundle <nl> <nl> list ( APPEND PACKAGES_LIST package - arongodb - server - bundle ) <nl> <nl> - add_custom_target ( copy_packages <nl> + add_custom_target ( copy_bundle_packages <nl> COMMAND cp * . dmg $ { PACKAGE_TARGET_DIR } ) <nl> + <nl> + list ( APPEND COPY_PACKAGES_LIST copy_bundle_packages ) <nl> mmm a / cmake / packages / deb . cmake <nl> ppp b / cmake / packages / deb . cmake <nl> add_custom_target ( package - arongodb - client <nl> list ( APPEND PACKAGES_LIST package - arongodb - client ) <nl> <nl> <nl> - add_custom_target ( copy_packages <nl> + add_custom_target ( copy_deb_packages <nl> COMMAND cp * . deb $ { PACKAGE_TARGET_DIR } ) <nl> <nl> + list ( APPEND COPY_PACKAGES_LIST copy_deb_packages ) <nl> + <nl> add_custom_target ( remove_packages <nl> COMMAND rm - f * . deb <nl> COMMAND rm - rf _CPack_Packages <nl> mmm a / cmake / packages / nsis . cmake <nl> ppp b / cmake / packages / nsis . cmake <nl> add_custom_target ( package - arongodb - client - nsis <nl> <nl> list ( APPEND PACKAGES_LIST package - arongodb - client - nsis ) <nl> <nl> - add_custom_target ( copy_packages <nl> + add_custom_target ( copy_nsis_packages <nl> COMMAND cp * . exe $ { PACKAGE_TARGET_DIR } ) <nl> <nl> + list ( APPEND COPY_PACKAGES_LIST copy_nsis_packages ) <nl> + <nl> add_custom_target ( remove_packages <nl> COMMAND rm - f * . zip <nl> COMMAND rm - f * . exe <nl> mmm a / cmake / packages / rpm . cmake <nl> ppp b / cmake / packages / rpm . cmake <nl> list ( APPEND PACKAGES_LIST package - arongodb - server ) <nl> # <nl> # list ( APPEND PACKAGES_LIST package - arongodb - client ) <nl> <nl> - add_custom_target ( copy_packages <nl> + add_custom_target ( copy_rpm_packages <nl> COMMAND cp * . rpm $ { PACKAGE_TARGET_DIR } ) <nl> <nl> + list ( APPEND COPY_PACKAGES_LIST copy_rpm_packages ) <nl> + <nl> add_custom_target ( remove_packages <nl> COMMAND rm - f * . rpm <nl> COMMAND rm - rf _CPack_Packages <nl> mmm a / cmake / packages / snap . cmake <nl> ppp b / cmake / packages / snap . cmake <nl> if ( SNAPCRAFT_FOUND ) <nl> WORKING_DIRECTORY $ { SNAPCRAFT_SOURCE_DIR } <nl> ) <nl> <nl> + add_custom_target ( copy_snap_packages <nl> + COMMAND cp * . snap $ { PACKAGE_TARGET_DIR } ) <nl> + <nl> + list ( APPEND COPY_PACKAGES_LIST copy_snap_packages ) <nl> + <nl> list ( APPEND PACKAGES_LIST snap ) <nl> endif ( ) <nl>
|
Sub - class copy_packages target for snap
|
arangodb/arangodb
|
893a7ab2b489dd3d6eae0956fcb3e65927827924
|
2016-10-28T13:57:02Z
|
mmm a / src / btree / operations . hpp <nl> ppp b / src / btree / operations . hpp <nl> void check_and_handle_underfull ( value_sizer_t < void > * sizer , transaction_t * txn , <nl> bool get_superblock_metainfo ( transaction_t * txn , buf_lock_t * superblock , const std : : vector < char > & key , std : : vector < char > * value_out ) ; <nl> void get_superblock_metainfo ( transaction_t * txn , buf_lock_t * superblock , std : : vector < std : : pair < std : : vector < char > , std : : vector < char > > > * kv_pairs_out ) ; <nl> <nl> + # if SLICE_ALT <nl> + void set_superblock_metainfo ( alt : : alt_buf_lock_t * superblock , <nl> + const std : : vector < char > & key , <nl> + const std : : vector < char > & value ) ; <nl> + # endif <nl> void set_superblock_metainfo ( transaction_t * txn , buf_lock_t * superblock , const std : : vector < char > & key , const std : : vector < char > & value ) ; <nl> <nl> void delete_superblock_metainfo ( transaction_t * txn , buf_lock_t * superblock , const std : : vector < char > & key ) ; <nl> mmm a / src / btree / operations . tcc <nl> ppp b / src / btree / operations . tcc <nl> void find_keyvalue_location_for_write ( <nl> keyvalue_location_out - > buf . swap ( buf ) ; <nl> } <nl> <nl> + # if SLICE_ALT <nl> + template < class Value > <nl> + void find_keyvalue_location_for_read ( <nl> + superblock_t * superblock , const btree_key_t * key , <nl> + keyvalue_location_t < Value > * keyvalue_location_out , <nl> + btree_stats_t * stats , profile : : trace_t * trace ) { <nl> + # else <nl> template < class Value > <nl> void find_keyvalue_location_for_read ( <nl> transaction_t * txn , superblock_t * superblock , const btree_key_t * key , <nl> keyvalue_location_t < Value > * keyvalue_location_out , <nl> eviction_priority_t root_eviction_priority , btree_stats_t * stats , <nl> profile : : trace_t * trace ) { <nl> + # endif <nl> stats - > pm_keys_read . record ( ) ; <nl> + # if SLICE_ALT <nl> + value_sizer_t < Value > sizer ( superblock - > expose_buf ( ) . cache ( ) - > max_block_size ( ) ) ; <nl> + # else <nl> value_sizer_t < Value > sizer ( txn - > get_cache ( ) - > get_block_size ( ) ) ; <nl> + # endif <nl> <nl> - block_id_t node_id = superblock - > get_root_block_id ( ) ; <nl> - rassert ( node_id ! = SUPERBLOCK_ID ) ; <nl> + const block_id_t root_id = superblock - > get_root_block_id ( ) ; <nl> + rassert ( root_id ! = SUPERBLOCK_ID ) ; <nl> <nl> - if ( node_id = = NULL_BLOCK_ID ) { <nl> + if ( root_id = = NULL_BLOCK_ID ) { <nl> / / There is no root , so the tree is empty . <nl> superblock - > release ( ) ; <nl> return ; <nl> } <nl> <nl> + # if SLICE_ALT <nl> + alt : : alt_buf_lock_t buf ; <nl> + # else <nl> buf_lock_t buf ; <nl> + # endif <nl> { <nl> profile : : starter_t starter ( " Acquire a block for read . " , trace ) ; <nl> - buf_lock_t tmp ( txn , node_id , rwi_read ) ; <nl> + # if SLICE_ALT <nl> + alt : : alt_buf_lock_t tmp ( superblock - > expose_buf ( ) , root_id , <nl> + alt : : alt_access_t : : read ) ; <nl> + superblock - > release ( ) ; <nl> + / / RSI : Use std : : move here thx . <nl> + buf . swap ( tmp ) ; <nl> + # else <nl> + buf_lock_t tmp ( txn , root_id , rwi_read ) ; <nl> tmp . set_eviction_priority ( root_eviction_priority ) ; <nl> buf . swap ( tmp ) ; <nl> + # endif <nl> } <nl> <nl> + # if ! SLICE_ALT <nl> superblock - > release ( ) ; <nl> + # endif <nl> <nl> # ifndef NDEBUG <nl> - node : : validate ( & sizer , reinterpret_cast < const node_t * > ( buf . get_data_read ( ) ) ) ; <nl> + # if SLICE_ALT <nl> + { <nl> + alt : : alt_buf_read_t read ( & buf ) ; <nl> + node : : validate ( & sizer , static_cast < const node_t * > ( read . get_data_read ( ) ) ) ; <nl> + } <nl> + # else <nl> + node : : validate ( & sizer , static_cast < const node_t * > ( buf . get_data_read ( ) ) ) ; <nl> + # endif <nl> # endif / / NDEBUG <nl> <nl> - while ( node : : is_internal ( reinterpret_cast < const node_t * > ( buf . get_data_read ( ) ) ) ) { <nl> - node_id = internal_node : : lookup ( reinterpret_cast < const internal_node_t * > ( buf . get_data_read ( ) ) , key ) ; <nl> + # if SLICE_ALT <nl> + for ( ; ; ) { <nl> + { <nl> + alt : : alt_buf_read_t read ( & buf ) ; <nl> + if ( ! node : : is_internal ( static_cast < const node_t * > ( read . get_data_read ( ) ) ) ) { <nl> + break ; <nl> + } <nl> + } <nl> + # else <nl> + while ( node : : is_internal ( static_cast < const node_t * > ( buf . get_data_read ( ) ) ) ) { <nl> + # endif <nl> + # if SLICE_ALT <nl> + block_id_t node_id ; <nl> + { <nl> + alt : : alt_buf_read_t read ( & buf ) ; <nl> + const internal_node_t * node <nl> + = static_cast < const internal_node_t * > ( read . get_data_read ( ) ) ; <nl> + node_id = internal_node : : lookup ( node , key ) ; <nl> + } <nl> + # else <nl> + const block_id_t node_id = internal_node : : lookup ( static_cast < const internal_node_t * > ( buf . get_data_read ( ) ) , key ) ; <nl> + # endif <nl> rassert ( node_id ! = NULL_BLOCK_ID & & node_id ! = SUPERBLOCK_ID ) ; <nl> <nl> { <nl> profile : : starter_t starter ( " Acquire a block for read . " , trace ) ; <nl> + # if SLICE_ALT <nl> + alt : : alt_buf_lock_t tmp ( & buf , node_id , alt : : alt_access_t : : read ) ; <nl> + buf . reset_buf_lock ( ) ; <nl> + / / RSI : Make this std : : move assignment . <nl> + buf . swap ( tmp ) ; <nl> + # else <nl> buf_lock_t tmp ( txn , node_id , rwi_read ) ; <nl> tmp . set_eviction_priority ( incr_priority ( buf . get_eviction_priority ( ) ) ) ; <nl> buf . swap ( tmp ) ; <nl> + # endif <nl> } <nl> <nl> # ifndef NDEBUG <nl> - node : : validate ( & sizer , reinterpret_cast < const node_t * > ( buf . get_data_read ( ) ) ) ; <nl> + # if SLICE_ALT <nl> + { <nl> + alt : : alt_buf_read_t read ( & buf ) ; <nl> + node : : validate ( & sizer , static_cast < const node_t * > ( read . get_data_read ( ) ) ) ; <nl> + } <nl> + # else <nl> + node : : validate ( & sizer , static_cast < const node_t * > ( buf . get_data_read ( ) ) ) ; <nl> + # endif <nl> # endif / / NDEBUG <nl> } <nl> <nl> / / Got down to the leaf , now probe it . <nl> - const leaf_node_t * leaf = reinterpret_cast < const leaf_node_t * > ( buf . get_data_read ( ) ) ; <nl> + # if SLICE_ALT <nl> scoped_malloc_t < Value > value ( sizer . max_possible_size ( ) ) ; <nl> - if ( leaf : : lookup ( & sizer , leaf , key , value . get ( ) ) ) { <nl> + bool value_found ; <nl> + { <nl> + alt : : alt_buf_read_t read ( & buf ) ; <nl> + const leaf_node_t * leaf <nl> + = static_cast < const leaf_node_t * > ( read . get_data_read ( ) ) ; <nl> + value_found = leaf : : lookup ( & sizer , leaf , key , value . get ( ) ) ; <nl> + } <nl> + # else <nl> + const leaf_node_t * leaf = static_cast < const leaf_node_t * > ( buf . get_data_read ( ) ) ; <nl> + scoped_malloc_t < Value > value ( sizer . max_possible_size ( ) ) ; <nl> + const bool value_found = leaf : : lookup ( & sizer , leaf , key , value . get ( ) ) ; <nl> + # endif <nl> + if ( value_found ) { <nl> + / / RSI : Use std : : move assignment for buf . <nl> keyvalue_location_out - > buf . swap ( buf ) ; <nl> keyvalue_location_out - > there_originally_was_value = true ; <nl> keyvalue_location_out - > value = std : : move ( value ) ; <nl> mmm a / src / btree / slice . cc <nl> ppp b / src / btree / slice . cc <nl> <nl> # if SLICE_ALT <nl> using alt : : alt_access_t ; <nl> using alt : : alt_buf_lock_t ; <nl> + using alt : : alt_buf_parent_t ; <nl> using alt : : alt_cache_t ; <nl> using alt : : alt_txn_t ; <nl> # endif <nl> void btree_slice_t : : create ( cache_t * cache , block_id_t superblock_id , transaction <nl> # endif <nl> <nl> # if SLICE_ALT <nl> - alt_buf_write_t sb_write ( & superblock ) ; <nl> + alt : : alt_buf_write_t sb_write ( & superblock ) ; <nl> auto sb = static_cast < btree_superblock_t * > ( sb_write . get_data_write ( ) ) ; <nl> # else <nl> btree_superblock_t * sb = static_cast < btree_superblock_t * > ( superblock . get_data_write ( ) ) ; <nl> # endif <nl> + # if SLICE_ALT <nl> + bzero ( sb , parent . cache ( ) - > get_block_size ( ) . value ( ) ) ; <nl> + # else <nl> bzero ( sb , cache - > get_block_size ( ) . value ( ) ) ; <nl> + # endif <nl> <nl> / / sb - > metainfo_blob has been properly zeroed . <nl> sb - > magic = btree_superblock_t : : expected_magic ; <nl> void btree_slice_t : : create ( cache_t * cache , block_id_t superblock_id , transaction <nl> sb - > stat_block = NULL_BLOCK_ID ; <nl> sb - > sindex_block = NULL_BLOCK_ID ; <nl> <nl> + # if SLICE_ALT <nl> + set_superblock_metainfo ( & superblock , metainfo_key , metainfo_value ) ; <nl> + # else <nl> set_superblock_metainfo ( txn , & superblock , metainfo_key , metainfo_value ) ; <nl> + # endif <nl> <nl> # if SLICE_ALT <nl> - alt_buf_lock_t sindex_block ( & superblock , alt_access_t : : write ) ; <nl> + alt : : alt_buf_lock_t sindex_block ( & superblock , alt_create_t : : create ) ; <nl> # else <nl> buf_lock_t sindex_block ( txn ) ; <nl> # endif <nl> + # if SLICE_ALT <nl> + initialize_secondary_indexes ( & sindex_block ) ; <nl> + # else <nl> initialize_secondary_indexes ( txn , & sindex_block ) ; <nl> + # endif <nl> sb - > sindex_block = sindex_block . get_block_id ( ) ; <nl> } <nl> <nl>
|
Made find_keyvalue_location_for_read support the alt cache .
|
rethinkdb/rethinkdb
|
cee6ddbdd213ad8387731085eae5e6ccb03aeeff
|
2013-11-15T01:37:10Z
|
mmm a / test / IRGen / nested_types . sil <nl> ppp b / test / IRGen / nested_types . sil <nl> bb0 ( % 0 : $ @ thick Outer . Inner . Type ) : <nl> / / CHECK : [ [ T0 : % . * ] ] = call % swift . type * @ _TMaC12nested_types5Outer ( ) <nl> / / CHECK - NEXT : ret % swift . type * [ [ T0 ] ] <nl> <nl> - / / CHECK - LABEL : define { { | protected } } % swift . type * @ _TMaVC12nested_types5Outer5Inner ( ) <nl> + / / CHECK - LABEL : define { { | protected } } % swift . type * @ _TMaVC12nested_types5Outer5Inner ( ) <nl> / / CHECK : [ [ T0 : % . * ] ] = load % swift . type * , % swift . type * * @ _TMLVC12nested_types5Outer5Inner <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = icmp eq % swift . type * [ [ T0 ] ] , null <nl> / / CHECK - NEXT : br i1 [ [ T1 ] ] <nl>
|
Fix the other instance of this test error .
|
apple/swift
|
e7e7aa44a4653109111746fd196ee515204b85ad
|
2016-03-25T21:14:19Z
|
mmm a / hphp / hack / src / decl / decl_hint . ml <nl> ppp b / hphp / hack / src / decl / decl_hint . ml <nl> and hint_ p env = function <nl> | Hoption h - > <nl> let h = hint env h in <nl> Toption h <nl> - | Hfun ( is_coroutine , hl , b , h ) - > <nl> + | Hfun ( is_coroutine , hl , vh , h ) - > <nl> let paraml = List . map hl begin fun ( p , _ as x ) - > <nl> { fp_pos = p ; <nl> fp_name = None ; <nl> and hint_ p env = function <nl> end in <nl> let ret = hint env h in <nl> let arity_min = List . length paraml in <nl> - let arity = if b <nl> - then Fellipsis arity_min <nl> - else Fstandard ( arity_min , arity_min ) <nl> + let arity = match vh with <nl> + | Hvariadic _ - > Fellipsis arity_min <nl> + | Hnon_variadic - > Fstandard ( arity_min , arity_min ) <nl> in <nl> Tfun { <nl> ft_pos = p ; <nl> mmm a / hphp / hack / src / naming / naming . ml <nl> ppp b / hphp / hack / src / naming / naming . ml <nl> module Make ( GetLocals : GetLocals ) = struct <nl> | Hsoft h - > <nl> let h = hint ~ allow_retonly env h <nl> in snd h <nl> - | Hfun ( is_coroutine , hl , opt , h ) - > <nl> - N . Hfun ( is_coroutine , List . map hl ( hint env ) , opt , <nl> + | Hfun ( is_coroutine , hl , variadic_hint , h ) - > <nl> + let variadic_hint = match variadic_hint with <nl> + | Hvariadic Some ( h ) - > N . Hvariadic ( Some ( hint env h ) ) <nl> + | Hvariadic None - > N . Hvariadic ( None ) <nl> + | Hnon_variadic - > N . Hnon_variadic in <nl> + N . Hfun ( is_coroutine , List . map hl ( hint env ) , variadic_hint , <nl> hint ~ allow_retonly : true env h ) <nl> | Happly ( ( p , _x ) as id , hl ) - > <nl> let hint_id = <nl> mmm a / hphp / hack / src / naming / nast . ml <nl> ppp b / hphp / hack / src / naming / nast . ml <nl> <nl> ( * @ generated from nast . src . ml by hphp / hack / tools / ppx / ppx_gen . * ) <nl> - ( * SourceShasum < < 19f66ff5e38469b999f5de6649b9a6b09087f06f > > * ) <nl> + ( * SourceShasum < < 5ef4017d2ec159361a359279bf6e20b282b27a30 > > * ) <nl> <nl> ( * DO NOT EDIT MANUALLY . * ) <nl> [ @ @ @ ocaml . text <nl> and show_is_coroutine : is_coroutine - > Ppx_deriving_runtime . string = <nl> fun x - > Format . asprintf " % a " pp_is_coroutine x <nl> <nl> type hint = ( Pos . t * hint_ ) <nl> + and variadic_hint = <nl> + | Hvariadic of hint option <nl> + | Hnon_variadic <nl> and hint_ = <nl> | Hoption of hint <nl> - | Hfun of is_coroutine * hint list * bool * hint <nl> + | Hfun of is_coroutine * hint list * variadic_hint * hint <nl> | Htuple of hint list <nl> | Happly of sid * hint list <nl> | Hshape of nast_shape_info <nl> let rec pp_hint : Format . formatter - > hint - > Ppx_deriving_runtime . unit = <nl> and show_hint : hint - > Ppx_deriving_runtime . string = <nl> fun x - > Format . asprintf " % a " pp_hint x <nl> <nl> + and pp_variadic_hint : <nl> + Format . formatter - > variadic_hint - > Ppx_deriving_runtime . unit = <nl> + let __0 ( ) = pp_hint in <nl> + ( ( let open ! Ppx_deriving_runtime in <nl> + fun fmt - > <nl> + function <nl> + | Hvariadic a0 - > <nl> + ( Format . fprintf fmt " ( @ [ < 2 > Hvariadic @ " ; <nl> + ( ( function <nl> + | None - > Format . pp_print_string fmt " None " <nl> + | Some x - > <nl> + ( Format . pp_print_string fmt " ( Some " ; <nl> + ( ( __0 ( ) ) fmt ) x ; <nl> + Format . pp_print_string fmt " ) " ) ) ) a0 ; <nl> + Format . fprintf fmt " @ ] ) " ) <nl> + | Hnon_variadic - > Format . pp_print_string fmt " Hnon_variadic " ) <nl> + [ @ ocaml . warning " - A " ] ) <nl> + <nl> + and show_variadic_hint : variadic_hint - > Ppx_deriving_runtime . string = <nl> + fun x - > Format . asprintf " % a " pp_variadic_hint x <nl> + <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> - let __16 ( ) = pp_tprim <nl> + let __17 ( ) = pp_tprim <nl> + <nl> + and __16 ( ) = pp_hint <nl> <nl> and __15 ( ) = pp_hint <nl> <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> <nl> and __11 ( ) = pp_hint <nl> <nl> - and __10 ( ) = pp_hint <nl> + and __10 ( ) = pp_sid <nl> <nl> - and __9 ( ) = pp_sid <nl> + and __9 ( ) = pp_hint <nl> <nl> - and __8 ( ) = pp_hint <nl> + and __8 ( ) = pp_nast_shape_info <nl> <nl> - and __7 ( ) = pp_nast_shape_info <nl> + and __7 ( ) = pp_hint <nl> <nl> - and __6 ( ) = pp_hint <nl> + and __6 ( ) = pp_sid <nl> <nl> - and __5 ( ) = pp_sid <nl> + and __5 ( ) = pp_hint <nl> <nl> and __4 ( ) = pp_hint <nl> <nl> - and __3 ( ) = pp_hint <nl> + and __3 ( ) = pp_variadic_hint <nl> <nl> and __2 ( ) = pp_hint <nl> <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> true ) false x ) ; <nl> Format . fprintf fmt " @ , ] @ ] " ) ) a1 ) ; <nl> Format . fprintf fmt " , @ " ; <nl> - ( Format . fprintf fmt " % B " ) a2 ) ; <nl> + ( ( __3 ( ) ) fmt ) a2 ) ; <nl> Format . fprintf fmt " , @ " ; <nl> - ( ( __3 ( ) ) fmt ) a3 ) ; <nl> + ( ( __4 ( ) ) fmt ) a3 ) ; <nl> Format . fprintf fmt " @ , ) ) @ ] " ) <nl> | Htuple a0 - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Htuple @ " ; <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> ( fun sep - > <nl> fun x - > <nl> if sep then Format . fprintf fmt " ; @ " ; <nl> - ( ( __4 ( ) ) fmt ) x ; <nl> + ( ( __5 ( ) ) fmt ) x ; <nl> true ) false x ) ; <nl> Format . fprintf fmt " @ , ] @ ] " ) ) a0 ; <nl> Format . fprintf fmt " @ ] ) " ) <nl> | Happly ( a0 , a1 ) - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Happly ( @ , " ; <nl> - ( ( ( __5 ( ) ) fmt ) a0 ; <nl> + ( ( ( __6 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " , @ " ; <nl> ( ( fun x - > <nl> Format . fprintf fmt " @ [ < 2 > [ " ; <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> ( fun sep - > <nl> fun x - > <nl> if sep then Format . fprintf fmt " ; @ " ; <nl> - ( ( __6 ( ) ) fmt ) x ; <nl> + ( ( __7 ( ) ) fmt ) x ; <nl> true ) false x ) ; <nl> Format . fprintf fmt " @ , ] @ ] " ) ) a1 ) ; <nl> Format . fprintf fmt " @ , ) ) @ ] " ) <nl> | Hshape a0 - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Hshape @ " ; <nl> - ( ( __7 ( ) ) fmt ) a0 ; <nl> + ( ( __8 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " @ ] ) " ) <nl> | Haccess ( a0 , a1 ) - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Haccess ( @ , " ; <nl> - ( ( ( __8 ( ) ) fmt ) a0 ; <nl> + ( ( ( __9 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " , @ " ; <nl> ( ( fun x - > <nl> Format . fprintf fmt " @ [ < 2 > [ " ; <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> ( fun sep - > <nl> fun x - > <nl> if sep then Format . fprintf fmt " ; @ " ; <nl> - ( ( __9 ( ) ) fmt ) x ; <nl> + ( ( __10 ( ) ) fmt ) x ; <nl> true ) false x ) ; <nl> Format . fprintf fmt " @ , ] @ ] " ) ) a1 ) ; <nl> Format . fprintf fmt " @ , ) ) @ ] " ) <nl> and pp_hint_ : Format . formatter - > hint_ - > Ppx_deriving_runtime . unit = <nl> | None - > Format . pp_print_string fmt " None " <nl> | Some x - > <nl> ( Format . pp_print_string fmt " ( Some " ; <nl> - ( ( __10 ( ) ) fmt ) x ; <nl> + ( ( __11 ( ) ) fmt ) x ; <nl> Format . pp_print_string fmt " ) " ) ) ) a0 ; <nl> Format . fprintf fmt " , @ " ; <nl> ( ( function <nl> | None - > Format . pp_print_string fmt " None " <nl> | Some x - > <nl> ( Format . pp_print_string fmt " ( Some " ; <nl> - ( ( __11 ( ) ) fmt ) x ; <nl> + ( ( __12 ( ) ) fmt ) x ; <nl> Format . pp_print_string fmt " ) " ) ) ) a1 ) ; <nl> Format . fprintf fmt " @ , ) ) @ ] " ) <nl> | Hdarray ( a0 , a1 ) - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Hdarray ( @ , " ; <nl> - ( ( ( __12 ( ) ) fmt ) a0 ; <nl> + ( ( ( __13 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " , @ " ; <nl> - ( ( __13 ( ) ) fmt ) a1 ) ; <nl> + ( ( __14 ( ) ) fmt ) a1 ) ; <nl> Format . fprintf fmt " @ , ) ) @ ] " ) <nl> | Hvarray a0 - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Hvarray @ " ; <nl> - ( ( __14 ( ) ) fmt ) a0 ; <nl> + ( ( __15 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " @ ] ) " ) <nl> | Hvarray_or_darray a0 - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Hvarray_or_darray @ " ; <nl> - ( ( __15 ( ) ) fmt ) a0 ; <nl> + ( ( __16 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " @ ] ) " ) <nl> | Hprim a0 - > <nl> ( Format . fprintf fmt " ( @ [ < 2 > Hprim @ " ; <nl> - ( ( __16 ( ) ) fmt ) a0 ; <nl> + ( ( __17 ( ) ) fmt ) a0 ; <nl> Format . fprintf fmt " @ ] ) " ) <nl> | Hthis - > Format . pp_print_string fmt " Hthis " ) <nl> [ @ ocaml . warning " - A " ] ) <nl> mmm a / hphp / hack / src / naming / nast . src . ml <nl> ppp b / hphp / hack / src / naming / nast . src . ml <nl> module ShapeMap = Ast . ShapeMap <nl> type is_coroutine = bool [ @ @ deriving show ] <nl> <nl> type hint = Pos . t * hint_ <nl> + and variadic_hint = <nl> + | Hvariadic of hint option <nl> + | Hnon_variadic <nl> and hint_ = <nl> | Hoption of hint <nl> - | Hfun of is_coroutine * hint list * bool * hint <nl> + | Hfun of is_coroutine * hint list * variadic_hint * hint <nl> | Htuple of hint list <nl> | Happly of sid * hint list <nl> | Hshape of nast_shape_info <nl> mmm a / hphp / hack / src / parser / ast . ml <nl> ppp b / hphp / hack / src / parser / ast . ml <nl> and fun_ = { <nl> <nl> and is_coroutine = bool <nl> and hint = Pos . t * hint_ <nl> + and variadic_hint = <nl> + | Hvariadic of hint option <nl> + | Hnon_variadic <nl> and hint_ = <nl> | Hoption of hint <nl> - | Hfun of is_coroutine * hint list * is_variadic * hint <nl> + | Hfun of is_coroutine * hint list * variadic_hint * hint <nl> | Htuple of hint list <nl> | Happly of id * hint list <nl> | Hshape of shape_info <nl> mmm a / hphp / hack / src / parser / ast_visitors_endo . ml <nl> ppp b / hphp / hack / src / parser / ast_visitors_endo . ml <nl> class virtual [ ' self ] endo = <nl> let r1 = self # on_hint_ env c1 in if c0 = = r0 & & c1 = = r1 <nl> then this <nl> else ( r0 , r1 ) <nl> + method on_variadic_hint env this = <nl> + match this with <nl> + | Hvariadic c0 - > <nl> + let r0 = self # on_option self # on_hint env c0 in <nl> + if c0 = = r0 <nl> + then this <nl> + else Hvariadic r0 <nl> + | Hnon_variadic - > this <nl> method on_Hoption env this c0 = <nl> let r0 = self # on_hint env c0 in <nl> if c0 = = r0 then this else Hoption r0 <nl> method on_Hfun env this c0 c1 c2 c3 = <nl> let r0 = self # on_bool env c0 in <nl> let r1 = self # on_list self # on_hint env c1 in <nl> - let r2 = self # on_bool env c2 in <nl> + let r2 = self # on_variadic_hint env c2 in <nl> let r3 = self # on_hint env c3 in <nl> if c0 = = r0 & & c1 = = r1 & & c2 = = r2 & & c3 = = r3 <nl> then this <nl> mmm a / hphp / hack / src / parser / ast_visitors_endo . mli <nl> ppp b / hphp / hack / src / parser / ast_visitors_endo . mli <nl> class virtual [ ' b ] endo : <nl> Ast_visitors_ancestors . hint_ - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > Ast_visitors_ancestors . hint_ ; <nl> on_Hoption : ' c - > <nl> Ast_visitors_ancestors . hint_ - > <nl> class virtual [ ' b ] endo : <nl> Ast_visitors_ancestors . hint_ - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > Ast_visitors_ancestors . hint_ <nl> method on_Hoption : <nl> ' c - > <nl> class virtual [ ' b ] endo : <nl> ' c - > <nl> Ast_visitors_ancestors . user_attribute - > <nl> Ast_visitors_ancestors . user_attribute <nl> + method on_variadic_hint : <nl> + ' c - > <nl> + Ast_visitors_ancestors . variadic_hint - > Ast_visitors_ancestors . variadic_hint <nl> method on_variance : <nl> ' c - > <nl> Ast_visitors_ancestors . variance - > Ast_visitors_ancestors . variance <nl> mmm a / hphp / hack / src / parser / ast_visitors_iter . ml <nl> ppp b / hphp / hack / src / parser / ast_visitors_iter . ml <nl> class virtual [ ' self ] iter = <nl> method on_hint env ( c0 , c1 ) = <nl> self # on_Pos_t env c0 ; <nl> self # on_hint_ env c1 ; <nl> + method on_variadic_hint env = function <nl> + | Hvariadic c0 - > self # on_option self # on_hint env c0 <nl> + | Hnon_variadic - > ( ) <nl> method on_Hoption = self # on_hint <nl> method on_Hfun env c0 c1 c2 c3 = <nl> self # on_bool env c0 ; <nl> self # on_list self # on_hint env c1 ; <nl> - self # on_bool env c2 ; <nl> + self # on_variadic_hint env c2 ; <nl> self # on_hint env c3 ; <nl> method on_Htuple = self # on_list self # on_hint <nl> method on_Happly env c0 c1 = <nl> mmm a / hphp / hack / src / parser / ast_visitors_iter . mli <nl> ppp b / hphp / hack / src / parser / ast_visitors_iter . mli <nl> class virtual [ ' b ] iter : <nl> on_Hfun : ' c - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > unit ; <nl> on_Hoption : ' c - > Ast_visitors_ancestors . hint - > unit ; <nl> on_Hshape : ' c - > Ast_visitors_ancestors . shape_info - > unit ; <nl> class virtual [ ' b ] iter : <nl> ' c - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > unit <nl> method on_Hoption : ' c - > Ast_visitors_ancestors . hint - > unit <nl> method on_Hshape : ' c - > Ast_visitors_ancestors . shape_info - > unit <nl> class virtual [ ' b ] iter : <nl> method on_uop : ' c - > Ast_visitors_ancestors . uop - > unit <nl> method on_user_attribute : <nl> ' c - > Ast_visitors_ancestors . user_attribute - > unit <nl> + method on_variadic_hint : ' c - > Ast_visitors_ancestors . variadic_hint - > unit <nl> method on_variance : ' c - > Ast_visitors_ancestors . variance - > unit <nl> end <nl> mmm a / hphp / hack / src / parser / ast_visitors_map . ml <nl> ppp b / hphp / hack / src / parser / ast_visitors_map . ml <nl> class virtual [ ' self ] map = <nl> method on_hint env ( c0 , c1 ) = <nl> let r0 = self # on_Pos_t env c0 in <nl> let r1 = self # on_hint_ env c1 in ( r0 , r1 ) <nl> + method on_variadic_hint env this = <nl> + match this with <nl> + | Hvariadic c0 - > <nl> + let r0 = self # on_option self # on_hint env c0 in <nl> + Hvariadic r0 <nl> + | Hnon_variadic - > Hnon_variadic <nl> method on_Hoption env c0 = <nl> let r0 = self # on_hint env c0 in Hoption r0 <nl> method on_Hfun env c0 c1 c2 c3 = <nl> let r0 = self # on_bool env c0 in <nl> let r1 = self # on_list self # on_hint env c1 in <nl> - let r2 = self # on_bool env c2 in <nl> + let r2 = self # on_variadic_hint env c2 in <nl> let r3 = self # on_hint env c3 in Hfun ( r0 , r1 , r2 , r3 ) <nl> method on_Htuple env c0 = <nl> let r0 = self # on_list self # on_hint env c0 in Htuple r0 <nl> mmm a / hphp / hack / src / parser / ast_visitors_map . mli <nl> ppp b / hphp / hack / src / parser / ast_visitors_map . mli <nl> class virtual [ ' c ] map : <nl> on_Hfun : ' d - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > Ast_visitors_ancestors . hint_ ; <nl> on_Hoption : ' d - > <nl> Ast_visitors_ancestors . hint - > <nl> class virtual [ ' c ] map : <nl> ' d - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > Ast_visitors_ancestors . hint_ <nl> method on_Hoption : <nl> ' d - > Ast_visitors_ancestors . hint - > Ast_visitors_ancestors . hint_ <nl> class virtual [ ' c ] map : <nl> ' d - > <nl> Ast_visitors_ancestors . user_attribute - > <nl> Ast_visitors_ancestors . user_attribute <nl> + method on_variadic_hint : <nl> + ' d - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> + Ast_visitors_ancestors . variadic_hint <nl> method on_variance : <nl> ' d - > <nl> Ast_visitors_ancestors . variance - > Ast_visitors_ancestors . variance <nl> mmm a / hphp / hack / src / parser / ast_visitors_reduce . ml <nl> ppp b / hphp / hack / src / parser / ast_visitors_reduce . ml <nl> class virtual [ ' self ] reduce = <nl> let r0 = self # on_Pos_t env c0 in <nl> let r1 = self # on_hint_ env c1 in <nl> self # add r0 r1 <nl> + method on_variadic_hint env = function <nl> + | Hvariadic c0 - > self # on_option self # on_hint env c0 <nl> + | Hnon_variadic - > self # e <nl> method on_Hoption = self # on_hint <nl> method on_Hfun env c0 c1 c2 c3 = <nl> let r0 = self # on_bool env c0 in <nl> let r1 = self # on_list self # on_hint env c1 in <nl> - let r2 = self # on_bool env c2 in <nl> + let r2 = self # on_variadic_hint env c2 in <nl> let r3 = self # on_hint env c3 in <nl> self # add ( self # add ( self # add r0 r1 ) r2 ) r3 <nl> method on_Htuple = self # on_list self # on_hint <nl> mmm a / hphp / hack / src / parser / ast_visitors_reduce . mli <nl> ppp b / hphp / hack / src / parser / ast_visitors_reduce . mli <nl> class virtual [ ' b ] reduce : <nl> on_Hfun : ' c - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > ' d ; <nl> on_Hoption : ' c - > Ast_visitors_ancestors . hint - > ' d ; <nl> on_Hshape : ' c - > Ast_visitors_ancestors . shape_info - > ' d ; <nl> class virtual [ ' b ] reduce : <nl> ' c - > <nl> Ast_visitors_ancestors . is_coroutine - > <nl> Ast_visitors_ancestors . hint list - > <nl> - Ast_visitors_ancestors . is_variadic - > <nl> + Ast_visitors_ancestors . variadic_hint - > <nl> Ast_visitors_ancestors . hint - > ' d <nl> method on_Hoption : ' c - > Ast_visitors_ancestors . hint - > ' d <nl> method on_Hshape : ' c - > Ast_visitors_ancestors . shape_info - > ' d <nl> class virtual [ ' b ] reduce : <nl> method on_uop : ' c - > Ast_visitors_ancestors . uop - > ' d <nl> method on_user_attribute : <nl> ' c - > Ast_visitors_ancestors . user_attribute - > ' d <nl> + method on_variadic_hint : ' c - > Ast_visitors_ancestors . variadic_hint - > ' d <nl> method on_variance : ' c - > Ast_visitors_ancestors . variance - > ' d <nl> end <nl> mmm a / hphp / hack / src / parser / full_fidelity_ast . ml <nl> ppp b / hphp / hack / src / parser / full_fidelity_ast . ml <nl> let rec pHint : hint parser = fun node env - > <nl> Hshape { si_allows_unknown_fields ; si_shape_field_list } <nl> | TupleTypeSpecifier { tuple_types ; _ } - > <nl> Htuple ( couldMap ~ f : pHint tuple_types env ) <nl> - <nl> | KeysetTypeSpecifier { keyset_type_keyword = kw ; keyset_type_type = ty ; _ } <nl> | VectorTypeSpecifier { vector_type_keyword = kw ; vector_type_type = ty ; _ } <nl> | ClassnameTypeSpecifier { classname_keyword = kw ; classname_type = ty ; _ } <nl> let rec pHint : hint parser = fun node env - > <nl> closure_parameter_types ; <nl> closure_return_type ; <nl> closure_coroutine ; _ } - > <nl> - let param_types = <nl> - List . map ~ f : ( fun x - > pHint x env ) <nl> - ( as_list closure_parameter_types ) <nl> + let make_variadic_hint variadic_type = <nl> + if is_missing variadic_type <nl> + then Hvariadic ( None ) <nl> + else Hvariadic ( Some ( pHint variadic_type env ) ) <nl> + in <nl> + let ( param_type_hints , variadic_hints ) = <nl> + List . partition_map ~ f : ( fun x - > <nl> + match syntax x with <nl> + | VariadicParameter { variadic_parameter_type = vtype ; _ } - > <nl> + ` Snd ( make_variadic_hint vtype ) <nl> + | _ - > ` Fst ( pHint x env ) ) <nl> + ( as_list closure_parameter_types ) <nl> + in <nl> + let hd_variadic_hint hints = <nl> + if List . length hints > 1 then begin <nl> + let pos = Pos . string ( Pos . to_absolute ( get_pos node ) ) in <nl> + let msg = Printf . sprintf <nl> + " % d variadic parameters found . There should be no more than one . " <nl> + ( List . length hints ) <nl> + in <nl> + invariant_failure pos msg <nl> + end ; <nl> + match List . hd hints with <nl> + | Some h - > h <nl> + | None - > Hnon_variadic <nl> in <nl> let is_coroutine = not ( is_missing closure_coroutine ) in <nl> - let is_variadic_param x = snd x = Htuple [ ] in <nl> Hfun <nl> ( is_coroutine <nl> - , List . filter ~ f : ( fun x - > not ( is_variadic_param x ) ) param_types <nl> - , List . exists ~ f : is_variadic_param param_types <nl> + , param_type_hints <nl> + , hd_variadic_hint variadic_hints <nl> , pHint closure_return_type env <nl> ) <nl> | TypeConstant { type_constant_left_type ; type_constant_right_type ; _ } - > <nl> let rec pHint : hint parser = fun node env - > <nl> | Happly ( b , [ ] ) - > Haccess ( b , child , [ ] ) <nl> | _ - > missing_syntax " type constant base " node env <nl> ) <nl> - | VariadicParameter _ - > <nl> - ( * Clever trick warning : empty tuple types indicating variadic params * ) <nl> - Htuple [ ] <nl> | _ - > missing_syntax " type hint " node env <nl> in <nl> get_pos node , pHint_ node env <nl> mmm a / hphp / hack / src / parser / parser_hack . ml <nl> ppp b / hphp / hack / src / parser / parser_hack . ml <nl> and hint_list_remain env = <nl> ( * function ( _ ) : _ * ) <nl> and hint_function env start ~ is_coroutine = <nl> expect env Tlp ; <nl> - let params , has_dots = hint_function_params env in <nl> + let params , variadic_hint = hint_function_params env in <nl> let ret = hint_return env in <nl> - Pos . btw start ( fst ret ) , Hfun ( is_coroutine , params , has_dots , ret ) <nl> + Pos . btw start ( fst ret ) , Hfun ( is_coroutine , params , variadic_hint , ret ) <nl> <nl> ( * ( parameter_1 , . . , parameter_n ) * ) <nl> and hint_function_params env = <nl> match L . token env . file env . lb with <nl> | Trp - > <nl> - ( [ ] , false ) <nl> + ( [ ] , Hnon_variadic ) <nl> | Tellipsis - > <nl> hint_function_params_close env ; <nl> - ( [ ] , true ) <nl> + ( [ ] , Hvariadic None ) <nl> | _ - > <nl> L . back env . lb ; <nl> hint_function_params_remain env <nl> and hint_function_params_remain env = <nl> match L . token env . file env . lb with <nl> | Tcomma - > <nl> if ! ( env . errors ) ! = error_state <nl> - then ( [ h ] , false ) <nl> + then ( [ h ] , Hnon_variadic ) <nl> else <nl> - let hl , has_dots = hint_function_params env in <nl> - ( h : : hl , has_dots ) <nl> + let hl , variadic_hint = hint_function_params env in <nl> + ( h : : hl , variadic_hint ) <nl> | Trp - > <nl> - ( [ h ] , false ) <nl> + ( [ h ] , Hnon_variadic ) <nl> | Tellipsis - > <nl> hint_function_params_close env ; <nl> - ( [ h ] , true ) <nl> + ( [ ] , Hvariadic ( Some h ) ) <nl> | _ - > <nl> error_expect env " ) " ; <nl> - ( [ h ] , false ) <nl> + ( [ h ] , Hnon_variadic ) <nl> <nl> and xhp_enum_decl_list env = <nl> match L . token env . file env . lb with <nl> mmm a / hphp / hack / src / typing / typing_instantiability . ml <nl> ppp b / hphp / hack / src / typing / typing_instantiability . ml <nl> class type [ ' a ] hint_visitor_type = object <nl> method on_array : ' a - > Nast . hint option - > Nast . hint option - > ' a <nl> method on_prim : ' a - > Nast . tprim - > ' a <nl> method on_option : ' a - > Nast . hint - > ' a <nl> - method on_fun : ' a - > bool - > Nast . hint list - > bool - > Nast . hint - > ' a <nl> + method on_fun : ' a - > bool - > Nast . hint list - > Nast . variadic_hint - > Nast . hint - > ' a <nl> method on_apply : ' a - > Nast . sid - > Nast . hint list - > ' a <nl> method on_shape : ' a - > nast_shape_info - > ' a <nl> method on_access : ' a - > Nast . hint - > Nast . sid list - > ' a <nl>
|
Update parser and AST to support typed variadics in function type hints
|
facebook/hhvm
|
feffc991ec34d3ab59ea5941051dfcb0e29e68df
|
2017-11-06T15:21:16Z
|
mmm a / python - package / xgboost / core . py <nl> ppp b / python - package / xgboost / core . py <nl> def feature_names ( self , feature_names ) : <nl> " " " <nl> if feature_names is not None : <nl> # validate feature name <nl> - if not isinstance ( feature_names , list ) : <nl> - feature_names = list ( feature_names ) <nl> + try : <nl> + if not isinstance ( feature_names , str ) : <nl> + feature_names = [ n for n in iter ( feature_names ) ] <nl> + else : <nl> + feature_names = [ feature_names ] <nl> + except TypeError : <nl> + feature_names = [ feature_names ] <nl> + <nl> if len ( feature_names ) ! = len ( set ( feature_names ) ) : <nl> raise ValueError ( ' feature_names must be unique ' ) <nl> if len ( feature_names ) ! = self . num_col ( ) : <nl> def feature_types ( self , feature_types ) : <nl> Labels for features . None will reset existing feature names <nl> " " " <nl> if feature_types is not None : <nl> - <nl> if self . _feature_names is None : <nl> msg = ' Unable to set feature types before setting names ' <nl> raise ValueError ( msg ) <nl> def feature_types ( self , feature_types ) : <nl> # single string will be applied to all columns <nl> feature_types = [ feature_types ] * self . num_col ( ) <nl> <nl> - if not isinstance ( feature_types , list ) : <nl> - feature_types = list ( feature_types ) <nl> + try : <nl> + if not isinstance ( feature_types , str ) : <nl> + feature_types = [ n for n in iter ( feature_types ) ] <nl> + else : <nl> + feature_types = [ feature_types ] <nl> + except TypeError : <nl> + feature_types = [ feature_types ] <nl> + <nl> if len ( feature_types ) ! = self . num_col ( ) : <nl> msg = ' feature_types must have the same length as data ' <nl> raise ValueError ( msg ) <nl>
|
Fix bug of using list ( x ) function when x is string ( )
|
dmlc/xgboost
|
3b62e75f2ef39f6794f5f63b4fa43dbc30e64c53
|
2018-07-30T14:36:34Z
|
mmm a / docs / SIL . rst <nl> ppp b / docs / SIL . rst <nl> unchecked_ref_bit_cast <nl> <nl> sil - instruction : : = ' unchecked_ref_bit_cast ' sil - operand ' to ' sil - type <nl> <nl> - % 1 = unchecked_trivial_bit_cast % 0 : $ Optional < Builtin . NativeObject > to $ Builtin . NativeObject <nl> + % 1 = unchecked_ref_bit_cast % 0 : $ Optional < Builtin . NativeObject > to $ Builtin . NativeObject <nl> / / % 0 must be an object . <nl> / / % 1 must be an object that is trivial iff % 0 is trivial and is non - trivial iff % 0 is non - trivial . <nl> <nl> mmm a / lib / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SILGen / SILGenExpr . cpp <nl> RValue RValueEmitter : : visitInjectIntoOptionalExpr ( InjectIntoOptionalExpr * E , <nl> return RValue ( SGF , E , bitcastMV ) ; <nl> } <nl> <nl> - / / Create a buffer for the result if this is an address - only optional . <nl> auto & optTL = SGF . getTypeLowering ( E - > getType ( ) ) ; <nl> + <nl> + / / It is a common occurrence to get conversions back and forth from T ! to T ? . <nl> + / / Peephole these by looking for a subexpression that is a BindOptionalExpr . <nl> + / / If we see one , we can produce a single instruction , which doesn ' t require <nl> + / / a CFG diamond . <nl> + if ( auto * BOE = dyn_cast < BindOptionalExpr > ( E - > getSubExpr ( ) ) ) { <nl> + / / If the subexpression type is exactly the same , then just peephole the <nl> + / / whole thing away . <nl> + if ( BOE - > getSubExpr ( ) - > getType ( ) - > isEqual ( E - > getType ( ) ) ) <nl> + return visit ( BOE - > getSubExpr ( ) , C ) ; <nl> + <nl> + OptionalTypeKind Kind = OTK_None ; ( void ) Kind ; <nl> + assert ( BOE - > getSubExpr ( ) - > getType ( ) - > getAnyOptionalObjectType ( Kind ) <nl> + - > isEqual ( E - > getType ( ) - > getAnyOptionalObjectType ( Kind ) ) ) ; <nl> + <nl> + if ( ! optTL . isAddressOnly ( ) ) { <nl> + auto subMV = SGF . emitRValueAsSingleValue ( BOE - > getSubExpr ( ) ) ; <nl> + SILValue result ; <nl> + if ( optTL . isTrivial ( ) ) <nl> + result = SGF . B . createUncheckedTrivialBitCast ( E , subMV . forward ( SGF ) , <nl> + optTL . getLoweredType ( ) ) ; <nl> + else <nl> + result = SGF . B . createUncheckedRefBitCast ( E , subMV . forward ( SGF ) , <nl> + optTL . getLoweredType ( ) ) ; <nl> + <nl> + return RValue ( SGF , E , <nl> + SGF . emitManagedRValueWithCleanup ( result , optTL ) ) ; <nl> + } <nl> + <nl> + / / If this is an address - only case , get the buffer we want the result in , <nl> + / / cast the address of it to the right type , then emit into it . <nl> + SILValue optAddr = SGF . getBufferForExprResult ( E , optTL . getLoweredType ( ) , C ) ; <nl> + <nl> + auto & subTL = SGF . getTypeLowering ( BOE - > getSubExpr ( ) - > getType ( ) ) ; <nl> + SILValue subAddr = SGF . B . createUncheckedAddrCast ( E , optAddr , <nl> + subTL . getLoweredType ( ) . getAddressType ( ) ) ; <nl> + <nl> + KnownAddressInitialization subInit ( subAddr ) ; <nl> + SGF . emitExprInto ( BOE - > getSubExpr ( ) , & subInit ) ; <nl> + <nl> + ManagedValue result = SGF . manageBufferForExprResult ( optAddr , optTL , C ) ; <nl> + if ( result . isInContext ( ) ) <nl> + return RValue ( ) ; <nl> + return RValue ( SGF , E , result ) ; <nl> + } <nl> + <nl> + <nl> + / / Create a buffer for the result if this is an address - only optional . <nl> if ( ! optTL . isAddressOnly ( ) ) { <nl> auto result = SGF . emitRValueAsSingleValue ( E - > getSubExpr ( ) ) ; <nl> result = SGF . getOptionalSomeValue ( E , result , optTL ) ; <nl> RValue RValueEmitter : : visitOptionalEvaluationExpr ( OptionalEvaluationExpr * E , <nl> / / Enter a cleanups scope . <nl> FullExpr scope ( SGF . Cleanups , E ) ; <nl> <nl> - SILBasicBlock * contBB = SGF . createBasicBlock ( ) ; <nl> - <nl> / / Install a new optional - failure destination just outside of the <nl> / / cleanups scope . <nl> SILBasicBlock * failureBB = SGF . createBasicBlock ( ) ; <nl> RValue RValueEmitter : : visitOptionalEvaluationExpr ( OptionalEvaluationExpr * E , <nl> / / This concludes the conditional scope . <nl> scope . pop ( ) ; <nl> <nl> + <nl> + / / In the usual case , the code will have emitted one or more branches to the <nl> + / / failure block . However , if the body is simple enough , we can end up with <nl> + / / no branches to the failureBB . Detect this and simplify the generated code <nl> + / / if so . <nl> + if ( failureBB - > pred_empty ( ) ) { <nl> + / / Remove the dead failureBB . <nl> + failureBB - > eraseFromParent ( ) ; <nl> + <nl> + / / The value we provide is the one we ' ve already got . <nl> + if ( ! isByAddress ) <nl> + return RValue ( SGF , E , <nl> + SGF . emitManagedRValueWithCleanup ( NormalArgument , optTL ) ) ; <nl> + <nl> + / / If we emitted into the provided context , we ' re done . <nl> + if ( usingProvidedContext ) <nl> + return RValue ( ) ; <nl> + <nl> + return RValue ( SGF , E , optTemp - > getManagedAddress ( ) ) ; <nl> + } <nl> + <nl> + <nl> + SILBasicBlock * contBB = SGF . createBasicBlock ( ) ; <nl> + <nl> / / Branch to the continuation block . <nl> if ( NormalArgument ) <nl> SGF . B . createBranch ( E , contBB , NormalArgument ) ; <nl> RValue RValueEmitter : : visitOptionalEvaluationExpr ( OptionalEvaluationExpr * E , <nl> / / Emit the continuation block . <nl> SGF . B . emitBlock ( contBB ) ; <nl> <nl> - / / If we emitted into the provided context , we ' re done . <nl> - if ( usingProvidedContext ) <nl> - return RValue ( ) ; <nl> - <nl> / / If this was done in SSA registers , then the value is provided as an <nl> / / argument to the block . <nl> if ( ! isByAddress ) { <nl> RValue RValueEmitter : : visitOptionalEvaluationExpr ( OptionalEvaluationExpr * E , <nl> return RValue ( SGF , E , SGF . emitManagedRValueWithCleanup ( arg , optTL ) ) ; <nl> } <nl> <nl> + / / If we emitted into the provided context , we ' re done . <nl> + if ( usingProvidedContext ) <nl> + return RValue ( ) ; <nl> + <nl> assert ( optTemp ) ; <nl> - auto result = optTemp - > getManagedAddress ( ) ; <nl> - if ( ! optTL . isAddressOnly ( ) ) { <nl> - auto optValue = SGF . B . createLoad ( E , result . forward ( SGF ) ) ; <nl> - result = SGF . emitManagedRValueWithCleanup ( optValue , optTL ) ; <nl> - } <nl> - <nl> - return RValue ( SGF , E , result ) ; <nl> + return RValue ( SGF , E , optTemp - > getManagedAddress ( ) ) ; <nl> } <nl> <nl> RValue RValueEmitter : : visitForceValueExpr ( ForceValueExpr * E , SGFContext C ) { <nl> mmm a / test / SILGen / implicitly_unwrapped_optional . swift <nl> ppp b / test / SILGen / implicitly_unwrapped_optional . swift <nl> func foo ( var f f : ( ( ) - > ( ) ) ! ) { <nl> / / CHECK - NEXT : [ [ F : % . * ] ] = alloc_box $ ImplicitlyUnwrappedOptional < ( ) - > ( ) > <nl> / / CHECK - NEXT : store [ [ T0 ] ] to [ [ F ] ] # 1 <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum_addr [ [ F ] ] # 1 <nl> - / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb2 <nl> + / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb3 <nl> / / If it does , project and load the value out of the implicitly unwrapped <nl> / / optional . . . <nl> / / CHECK : bb1 : <nl> func foo ( var f f : ( ( ) - > ( ) ) ! ) { <nl> / / CHECK - NEXT : [ [ FN1 : % . * ] ] = partial_apply [ [ T0 ] ] ( [ [ FN0 ] ] ) <nl> / / . . . . then call it <nl> / / CHECK - NEXT : apply [ [ FN1 ] ] ( ) <nl> - / / CHECK : br bb3 <nl> + / / CHECK : br bb2 <nl> / / ( first nothing block ) <nl> - / / CHECK : bb2 : <nl> + / / CHECK : bb3 : <nl> / / CHECK - NEXT : enum $ Optional < ( ) > , # Optional . None ! enumelt <nl> - / / CHECK - NEXT : br bb3 <nl> + / / CHECK - NEXT : br bb2 <nl> / / The rest of this is tested in optional . swift <nl> <nl> func wrap < T > ( x x : T ) - > T ! { return x } <nl> mmm a / test / SILGen / optional - cast . swift <nl> ppp b / test / SILGen / optional - cast . swift <nl> <nl> class A { } <nl> class B : A { } <nl> <nl> - func foo ( y : A ? ) { <nl> - var x = ( y as ? B ) <nl> - } <nl> - / / CHECK - DAG : sil hidden @ _TF4main3foo <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main3foo <nl> / / CHECK : [ [ X : % . * ] ] = alloc_box $ Optional < B > / / var x <nl> / / Check whether the temporary holds a value . <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum % 0 <nl> func foo ( y : A ? ) { <nl> / / Finish the present path . <nl> / / CHECK : [ [ CONT ] ] : <nl> / / CHECK - NEXT : br [ [ CONT2 : bb [ 0 - 9 ] + ] ] <nl> - / / Finish the not - present path . <nl> - / / CHECK : [ [ NOT_PRESENT ] ] : <nl> - / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } None <nl> - / / CHECK - NEXT : br [ [ CONT2 ] ] <nl> / / Finish . <nl> / / CHECK : [ [ CONT2 ] ] : <nl> / / CHECK - NEXT : strong_release [ [ X ] ] # 0 <nl> / / CHECK - NEXT : release_value % 0 <nl> - <nl> - func bar ( y : A ? ? ? ? ) { <nl> - var x = ( y as ? B ? ? ) <nl> + / / Finish the not - present path . <nl> + / / CHECK : [ [ NOT_PRESENT ] ] : <nl> + / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } None <nl> + / / CHECK - NEXT : br [ [ CONT2 ] ] <nl> + func foo ( y : A ? ) { <nl> + var x = ( y as ? B ) <nl> } <nl> - / / CHECK - DAG : sil hidden @ _TF4main3bar <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main3bar <nl> / / CHECK : [ [ X : % . * ] ] = alloc_box $ Optional < Optional < Optional < B > > > / / var x <nl> <nl> / / Check for Some ( . . . ) <nl> func bar ( y : A ? ? ? ? ) { <nl> / / CHECK - NEXT : br [ [ SWITCH_OB2 ] ] ( <nl> / / Switch out on the value in [ [ OB2 ] ] . <nl> / / CHECK : [ [ SWITCH_OB2 ] ] ( [ [ VAL : % [ 0 - 9 ] + ] ] : $ Optional < B > ) : <nl> - / / CHECK : [ [ T1 : % . * ] ] = select_enum [ [ VAL ] ] <nl> - / / CHECK - NEXT : cond_br [ [ T1 ] ] , [ [ IS_B2 : bb . * ] ] , [ [ NIL_DEPTH2 : bb [ 0 - 9 ] + ] ] <nl> - / / If it ' s present , set OB : = Some ( x ) . <nl> - / / CHECK : [ [ IS_B2 ] ] : <nl> - / / CHECK - NEXT : [ [ VALUE_B : % . * ] ] = unchecked_enum_data [ [ VAL ] ] <nl> - / / CHECK - NEXT : enum $ Optional < B > , # Optional . Some ! enumelt . 1 , [ [ VALUE_B ] ] <nl> - / / CHECK - NEXT : br [ [ DONE_DEPTH0 : bb [ 0 - 9 ] + ] ] ( <nl> - / / On various failure paths , set OB : = nil . <nl> - / / CHECK : [ [ NIL_DEPTH0 ] ] : <nl> - / / CHECK - NEXT : enum $ Optional < B > , # Optional . None ! enumelt <nl> - / / CHECK - NEXT : br [ [ DONE_DEPTH0 ] ] <nl> - / / Set OOB : = Some ( OB ) . <nl> - / / CHECK : [ [ DONE_DEPTH0 ] ] <nl> + / / CHECK : br [ [ DONE_DEPTH0 : bb [ 0 - 9 ] + ] ] <nl> + / / CHECK : [ [ DONE_DEPTH0 ] ] ( <nl> / / CHECK - NEXT : enum $ Optional < Optional < B > > , # Optional . Some ! enumelt . 1 , <nl> / / CHECK - NEXT : br [ [ DONE_DEPTH1 : bb [ 0 - 9 ] + ] ] <nl> - / / On various failure paths , set OOB : = nil . <nl> - / / CHECK : [ [ NIL_DEPTH1 ] ] : <nl> - / / CHECK - NEXT : enum $ Optional < Optional < B > > , # Optional . None ! enumelt <nl> - / / CHECK - NEXT : br [ [ DONE_DEPTH1 ] ] <nl> / / Set X : = Some ( OOB ) . <nl> / / CHECK : [ [ DONE_DEPTH1 ] ] <nl> / / CHECK - NEXT : enum $ Optional < Optional < Optional < B > > > , # Optional . Some ! enumelt . 1 , <nl> / / CHECK : br [ [ DONE_DEPTH2 : bb [ 0 - 9 ] + ] ] <nl> + / / CHECK : [ [ DONE_DEPTH2 ] ] <nl> + / / CHECK - NEXT : strong_release [ [ X ] ] # 0 <nl> + / / CHECK - NEXT : release_value % 0 <nl> + / / CHECK : return <nl> + / / On various failure paths , set OOB : = nil . <nl> + / / CHECK : [ [ NIL_DEPTH1 ] ] : <nl> + / / CHECK - NEXT : enum $ Optional < Optional < B > > , # Optional . None ! enumelt <nl> + / / CHECK - NEXT : br [ [ DONE_DEPTH1 ] ] <nl> / / On various failure paths , set X : = nil . <nl> / / CHECK : [ [ NIL_DEPTH2 ] ] : <nl> / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } None <nl> / / CHECK - NEXT : br [ [ DONE_DEPTH2 ] ] <nl> / / Done . <nl> - / / CHECK : [ [ DONE_DEPTH2 ] ] <nl> - / / CHECK - NEXT : strong_release [ [ X ] ] # 0 <nl> - / / CHECK - NEXT : release_value % 0 <nl> - <nl> - func baz ( y : AnyObject ? ) { <nl> - var x = ( y as ? B ) <nl> + func bar ( y : A ? ? ? ? ) { <nl> + var x = ( y as ? B ? ? ) <nl> } <nl> - / / CHECK - DAG : sil hidden @ _TF4main3baz <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main3baz <nl> / / CHECK : [ [ X : % . * ] ] = alloc_box $ Optional < B > / / var x <nl> / / CHECK - NEXT : retain_value % 0 <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum % 0 <nl> / / CHECK : [ [ VAL : % . * ] ] = unchecked_enum_data % 0 <nl> / / CHECK - NEXT : [ [ X_VALUE : % . * ] ] = init_enum_data_addr [ [ X ] ] # 1 : $ * Optional < B > , # Optional . Some <nl> / / CHECK - NEXT : checked_cast_br [ [ VAL ] ] : $ AnyObject to $ B , [ [ IS_B : bb . * ] ] , [ [ NOT_B : bb [ 0 - 9 ] + ] ] <nl> + func baz ( y : AnyObject ? ) { <nl> + var x = ( y as ? B ) <nl> + } <nl> + <nl> + <nl> + / / < rdar : / / problem / 17013042 > T ! < - > T ? conversions should not produce a diamond <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main18opt_to_opt_trivialFGSqSi_GSQSi_ <nl> + / / CHECK - NEXT : bb0 ( % 0 : $ Optional < Int > ) : <nl> + / / CHECK - NEXT : debug_value % 0 : $ Optional < Int > / / let x <nl> + / / CHECK - NEXT : % 2 = unchecked_trivial_bit_cast % 0 : $ Optional < Int > to $ ImplicitlyUnwrappedOptional < Int > <nl> + / / CHECK - NEXT : return % 2 : $ ImplicitlyUnwrappedOptional < Int > <nl> + / / CHECK - NEXT : } <nl> + func opt_to_opt_trivial ( x : Int ? ) - > Int ! { <nl> + return x <nl> + } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main20opt_to_opt_referenceFGSQCS_1C_GSqS0__ <nl> + / / CHECK - NEXT : bb0 ( % 0 : $ ImplicitlyUnwrappedOptional < C > ) : <nl> + / / CHECK - NEXT : debug_value % 0 : $ ImplicitlyUnwrappedOptional < C > / / let x <nl> + / / CHECK - NEXT : % 2 = unchecked_ref_bit_cast % 0 : $ ImplicitlyUnwrappedOptional < C > to $ Optional < C > <nl> + / / CHECK - NEXT : return % 2 : $ Optional < C > <nl> + / / CHECK - NEXT : } <nl> + func opt_to_opt_reference ( x : C ! ) - > C ? { return x } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _TF4main22opt_to_opt_addressOnlyU__FGSQQ__GSqQ__ <nl> + / / CHECK - NEXT : bb0 ( % 0 : $ * Optional < T > , % 1 : $ * ImplicitlyUnwrappedOptional < T > ) : <nl> + / / CHECK - NEXT : debug_value_addr % 1 : $ * ImplicitlyUnwrappedOptional < T > / / let x <nl> + / / CHECK - NEXT : % 3 = unchecked_addr_cast % 0 : $ * Optional < T > to $ * ImplicitlyUnwrappedOptional < T > <nl> + / / CHECK - NEXT : copy_addr [ take ] % 1 to [ initialization ] % 3 <nl> + func opt_to_opt_addressOnly < T > ( x : T ! ) - > T ? { return x } <nl> + <nl> + class C { } <nl> mmm a / test / SILGen / optional . swift <nl> ppp b / test / SILGen / optional . swift <nl> func testCall ( f : ( ( ) - > ( ) ) ? ) { <nl> / / CHECK : sil hidden @ { { . * } } testCall { { . * } } <nl> / / CHECK : bb0 ( [ [ T0 : % . * ] ] : $ Optional < ( ) - > ( ) > ) : <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum % 0 <nl> - / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb2 <nl> + / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb3 <nl> / / If it does , project and load the value out of the implicitly unwrapped <nl> / / optional . . . <nl> <nl> func testCall ( f : ( ( ) - > ( ) ) ? ) { <nl> / / CHECK - NEXT : [ [ FN1 : % . * ] ] = partial_apply [ [ T0 ] ] ( [ [ FN0 ] ] ) <nl> / / . . . . then call it <nl> / / CHECK - NEXT : apply [ [ FN1 ] ] ( ) <nl> - / / CHECK : br bb3 ( <nl> + / / CHECK : br bb2 ( <nl> / / ( first nothing block ) <nl> - / / CHECK : bb2 : <nl> + / / CHECK : bb3 : <nl> / / CHECK - NEXT : enum $ Optional < ( ) > , # Optional . None ! enumelt <nl> - / / CHECK - NEXT : br bb3 <nl> + / / CHECK - NEXT : br bb2 <nl> <nl> func testAddrOnlyCallResult < T > ( var f : ( ( ) - > T ) ? ) { <nl> var x = f ? ( ) <nl> func testAddrOnlyCallResult < T > ( var f : ( ( ) - > T ) ? ) { <nl> / / CHECK - NEXT : [ [ TEMP : % . * ] ] = init_enum_data_addr [ [ X ] ] <nl> / / Check whether ' f ' holds a value . <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum_addr [ [ F ] ] # 1 <nl> - / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb2 <nl> + / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb3 <nl> / / If so , pull out the value . . . <nl> / / CHECK : bb1 : <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = unchecked_take_enum_data_addr [ [ F ] ] # 1 <nl> func testAddrOnlyCallResult < T > ( var f : ( ( ) - > T ) ? ) { <nl> / / CHECK - NEXT : apply [ [ T1 ] ] ( [ [ TEMP ] ] ) <nl> / / . . . and coerce to T ? <nl> / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } Some <nl> - / / CHECK - NEXT : br bb3 <nl> - / / Nothing block . <nl> - / / CHECK : bb2 : <nl> - / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } None <nl> - / / CHECK - NEXT : br bb3 <nl> + / / CHECK - NEXT : br bb2 <nl> / / Continuation block . <nl> - / / CHECK : bb3 <nl> + / / CHECK : bb2 <nl> / / CHECK - NEXT : strong_release [ [ X ] ] # 0 <nl> / / CHECK - NEXT : strong_release [ [ F ] ] # 0 <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = tuple ( ) <nl> / / CHECK - NEXT : return [ [ T0 ] ] : $ ( ) <nl> <nl> + / / Nothing block . <nl> + / / CHECK : bb3 : <nl> + / / CHECK - NEXT : inject_enum_addr [ [ X ] ] { { . * } } None <nl> + / / CHECK - NEXT : br bb2 <nl> + <nl> + <nl> / / < rdar : / / problem / 15180622 > <nl> <nl> func wrap < T > ( x : T ) - > T ? { return x } <nl> func tuple_bind ( x : ( Int , String ) ? ) - > String ? { <nl> } <nl> <nl> <nl> - / / CHECK - LABEL : sil hidden @ _TF8optional15opt_to_impl_optFGSqSi_GSQSi_ <nl> - / / CHECK - NEXT : bb0 ( % 0 : $ Optional < Int > ) : <nl> - / / CHECK - NEXT : debug_value % 0 : $ Optional < Int > / / let x <nl> - / / CHECK : select_enum % 0 <nl> - / / CHECK - NEXT : cond_br { { . * } } , bb1 , bb2 <nl> - <nl> - / / CHECK : bb1 : <nl> - / / CHECK - NEXT : % 6 = unchecked_enum_data % 0 : $ Optional < Int > , # Optional . Some ! enumelt . 1 <nl> - / / CHECK - NEXT : % 7 = enum $ ImplicitlyUnwrappedOptional < Int > , # ImplicitlyUnwrappedOptional . Some ! enumelt . 1 , % 6 : $ Int <nl> - / / CHECK - NEXT : br bb3 ( % 7 : $ ImplicitlyUnwrappedOptional < Int > ) <nl> - <nl> - / / CHECK : bb2 : <nl> - / / CHECK - NEXT : % 9 = enum $ ImplicitlyUnwrappedOptional < Int > , # ImplicitlyUnwrappedOptional . None ! enumelt <nl> - / / CHECK - NEXT : br bb3 ( % 9 : $ ImplicitlyUnwrappedOptional < Int > ) <nl> - <nl> - / / CHECK : bb3 ( % 11 : $ ImplicitlyUnwrappedOptional < Int > ) : <nl> - / / CHECK - NEXT : return % 11 : $ ImplicitlyUnwrappedOptional < Int > <nl> - / / CHECK - NEXT : } <nl> - <nl> - func opt_to_impl_opt ( x : Int ? ) - > Int ! { <nl> - return x <nl> - } <nl> - <nl> - <nl>
|
implement < rdar : / / problem / 17013042 > T ! < - > T ? conversions should not produce a diamond
|
apple/swift
|
add4909d3567c4cb276003759bfd497a2cd2a308
|
2015-05-04T01:12:23Z
|
mmm a / hphp / hack / hhi / constants . hhi <nl> ppp b / hphp / hack / hhi / constants . hhi <nl> const int E_DEPRECATED = 1 < < 13 ; <nl> const int E_USER_DEPRECATED = 1 < < 14 ; <nl> const int E_ALL = ( 1 < < 15 ) - 1 ; <nl> const int E_STRICT = 1 < < 11 ; <nl> + <nl> + <nl> + / / Built in pseudoconstants <nl> + const int __LINE__ = 0 ; <nl> + const string __CLASS__ = ' ' ; <nl> + const string __TRAIT__ = ' ' ; <nl> + const string __FILE__ = ' ' ; <nl> + const string __DIR__ = ' ' ; <nl> + const string __FUNCTION__ = ' ' ; <nl> + const string __METHOD__ = ' ' ; <nl> + const string __NAMESPACE__ = ' ' ; <nl> mmm a / hphp / hack / src / emitter / emitter_expr . ml <nl> ppp b / hphp / hack / src / emitter / emitter_expr . ml <nl> and emit_expr env ( pos , expr_ as expr ) = <nl> { env with <nl> pending_closures = ( name , cstate , ( fun_ , vars ) ) : : env . pending_closures } <nl> <nl> + <nl> + | Id ( _ , id ) when SN . PseudoConsts . is_pseudo_const id - > unimpl " pseudo consts " <nl> ( * In this context , Id is a global constant * ) <nl> - ( * XXX : we should support all the pseudoconstants but Naming translates <nl> - * them to bogus strings and integers ! * ) <nl> | Id ( _ , id ) - > emit_Cns env id <nl> <nl> | Assert _ - > unimpl " Assert " <nl> mmm a / hphp / hack / src / hh_single_type_check . ml <nl> ppp b / hphp / hack / src / hh_single_type_check . ml <nl> let what_builtins mode = match mode with <nl> " ' name ' = > ? string , \ n " ^ <nl> " ' alias ' = > ? string , \ n " ^ <nl> " ) ; \ n " ^ <nl> - " function type_structure ( $ x , $ y ) ; \ n " <nl> + " function type_structure ( $ x , $ y ) ; \ n " ^ <nl> + " const int __LINE__ = 0 ; \ n " ^ <nl> + " const string __CLASS__ = ' ' ; \ n " ^ <nl> + " const string __TRAIT__ = ' ' ; \ n " ^ <nl> + " const string __FILE__ = ' ' ; \ n " ^ <nl> + " const string __DIR__ = ' ' ; \ n " ^ <nl> + " const string __FUNCTION__ = ' ' ; \ n " ^ <nl> + " const string __METHOD__ = ' ' ; \ n " ^ <nl> + " const string __NAMESPACE__ = ' ' ; \ n " <nl> + <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Helpers * ) <nl> mmm a / hphp / hack / src / naming / naming . ml <nl> ppp b / hphp / hack / src / naming / naming . ml <nl> and expr_ env = function <nl> | Float s - > N . Float s <nl> | String s - > N . String s <nl> | String2 idl - > N . String2 ( string2 env idl ) <nl> - | Id x - > <nl> - ( match snd x with <nl> - | const when const = SN . PseudoConsts . g__LINE__ - > N . Int x <nl> - | const when const = SN . PseudoConsts . g__CLASS__ - > <nl> - ( match ( fst env ) . current_cls with <nl> - | None - > Errors . illegal_CLASS ( fst x ) ; N . Any <nl> - | Some ( cid , _ ) - > <nl> - ( * this isn ' t quite correct when inside a trait , as <nl> - * __CLASS__ is replaced by the using class , but it ' s <nl> - * sufficient for typechecking purposes ( we require <nl> - * subclass to be compatible with the trait member / method <nl> - * declarations ) * ) <nl> - N . String cid ) <nl> - | const when const = SN . PseudoConsts . g__TRAIT__ - > <nl> - ( match ( fst env ) . current_cls with <nl> - | Some ( cid , Ctrait ) - > N . String cid <nl> - | _ - > Errors . illegal_TRAIT ( fst x ) ; N . Any ) <nl> - | const when <nl> - const = SN . PseudoConsts . g__FILE__ <nl> - | | const = SN . PseudoConsts . g__DIR__ <nl> - ( * could actually check that we are in a function , method , etc * ) <nl> - | | const = SN . PseudoConsts . g__FUNCTION__ <nl> - | | const = SN . PseudoConsts . g__METHOD__ <nl> - | | const = SN . PseudoConsts . g__NAMESPACE__ - > <nl> - N . String x <nl> - | _ - > N . Id ( Env . global_const env x ) <nl> - ) <nl> + | Id ( pos , const as x ) - > N . Id ( Env . global_const env x ) <nl> + <nl> | Lvar ( _ , x ) when x = SN . SpecialIdents . this - > N . This <nl> | Lvar ( pos , x ) when x = SN . SpecialIdents . placeholder - > <nl> N . Lplaceholder pos <nl> and expr_ env = function <nl> ( match ( expr env e1 ) , ( expr env e2 ) with <nl> | ( _ , N . String cl ) , ( _ , N . String meth ) - > <nl> N . Smethod_id ( Env . class_name env cl , meth ) <nl> + | ( _ , N . Id ( _ , const ) ) , ( _ , N . String meth ) <nl> + when const = SN . PseudoConsts . g__CLASS__ - > <nl> + ( * All of these that use current_cls aren ' t quite correct <nl> + * inside a trait , as the class should be the using class . <nl> + * It ' s sufficient for typechecking purposes ( we require <nl> + * subclass to be compatible with the trait member / method <nl> + * declarations ) . <nl> + * It * is * a problem for hh_emitter , though . * ) <nl> + ( match ( fst env ) . current_cls with <nl> + | Some ( cid , _ ) - > N . Smethod_id ( cid , meth ) <nl> + | None - > Errors . illegal_class_meth p ; N . Any ) <nl> | ( _ , N . Class_const ( N . CI cl , ( _ , mem ) ) ) , ( _ , N . String meth ) <nl> when mem = SN . Members . mClass - > <nl> N . Smethod_id ( Env . class_name env cl , meth ) <nl> mmm a / hphp / hack / src / naming / naming_special_names . ml <nl> ppp b / hphp / hack / src / naming / naming_special_names . ml <nl> end <nl> <nl> module PseudoConsts = struct <nl> <nl> - let g__LINE__ = " __LINE__ " <nl> - let g__CLASS__ = " __CLASS__ " <nl> - let g__TRAIT__ = " __TRAIT__ " <nl> - let g__FILE__ = " __FILE__ " <nl> - let g__DIR__ = " __DIR__ " <nl> - let g__FUNCTION__ = " __FUNCTION__ " <nl> - let g__METHOD__ = " __METHOD__ " <nl> - let g__NAMESPACE__ = " __NAMESPACE__ " <nl> + let g__LINE__ = " \ \ __LINE__ " <nl> + let g__CLASS__ = " \ \ __CLASS__ " <nl> + let g__TRAIT__ = " \ \ __TRAIT__ " <nl> + let g__FILE__ = " \ \ __FILE__ " <nl> + let g__DIR__ = " \ \ __DIR__ " <nl> + let g__FUNCTION__ = " \ \ __FUNCTION__ " <nl> + let g__METHOD__ = " \ \ __METHOD__ " <nl> + let g__NAMESPACE__ = " \ \ __NAMESPACE__ " <nl> + <nl> + let all_pseudo_consts = [ <nl> + g__LINE__ ; g__CLASS__ ; g__TRAIT__ ; g__FILE__ ; g__DIR__ ; <nl> + g__FUNCTION__ ; g__METHOD__ ; g__NAMESPACE__ <nl> + ] <nl> + let is_pseudo_const = <nl> + let h = HashSet . create 23 in <nl> + List . iter all_pseudo_consts ( HashSet . add h ) ; <nl> + fun x - > HashSet . mem h x <nl> <nl> end <nl> <nl> module Superglobals = struct <nl> ] <nl> <nl> let is_superglobal = <nl> - let h = Hashtbl . create 23 in <nl> - List . iter all_superglobals ( fun x - > Hashtbl . add h x true ) ; <nl> - fun x - > Hashtbl . mem h x <nl> + let h = HashSet . create 23 in <nl> + List . iter all_superglobals ( HashSet . add h ) ; <nl> + fun x - > HashSet . mem h x <nl> end <nl> mmm a / hphp / hack / src / typing / nastCheck . ml <nl> ppp b / hphp / hack / src / typing / nastCheck . ml <nl> and expr_ env = function <nl> | Smethod_id _ <nl> | Method_caller _ <nl> | This <nl> - | Id _ <nl> | Class_get _ <nl> | Class_const _ <nl> | Lvar _ | Lplaceholder _ - > ( ) <nl> + ( * Check that __CLASS__ and __TRAIT__ are used appropriately * ) <nl> + | Id ( pos , const ) - > <nl> + if SN . PseudoConsts . is_pseudo_const const then <nl> + if const = SN . PseudoConsts . g__CLASS__ then <nl> + ( match env . class_kind with <nl> + | Some _ - > ( ) <nl> + | _ - > Errors . illegal_CLASS pos ) <nl> + else if const = SN . PseudoConsts . g__TRAIT__ then <nl> + ( match env . class_kind with <nl> + | Some Ast . Ctrait - > ( ) <nl> + | _ - > Errors . illegal_TRAIT pos ) ; <nl> + ( ) <nl> | Array afl - > <nl> liter afield env afl ; <nl> ( ) <nl> and expr_ env = function <nl> liter expr env uel ; <nl> ( ) <nl> | Efun ( f , _ ) - > <nl> - let body = Nast . assert_named_body f . f_body in <nl> - func env f body ; ( ) <nl> + let env = { env with imm_ctrl_ctx = Toplevel } in <nl> + let body = Nast . assert_named_body f . f_body in <nl> + func env f body ; ( ) <nl> | Xml ( _ , attrl , el ) - > <nl> liter attribute env attrl ; <nl> liter expr env el ; <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and expr_ ~ in_cond ~ ( valkind : [ > ` lvalue | ` rvalue | ` other ] ) env ( p , e ) = <nl> let env , _class = instantiable_cid p env cid in <nl> env , ( Reason . Rwitness p , Tprim Tbool ) <nl> | Efun ( f , _idl ) - > <nl> - NastCheck . fun_ env f ( Nast . assert_named_body f . f_body ) ; <nl> let env , ft = fun_decl_in_env env f in <nl> ( * When creating a closure , the ' this ' type will mean the late bound type <nl> * of the current enclosing class <nl>
|
Rework how pseudoconsts are handled
|
facebook/hhvm
|
6a0cbd25229c0198205980ac10429adb94eaa450
|
2015-08-27T00:00:31Z
|
mmm a / atom / browser / api / lib / browser - window . coffee <nl> ppp b / atom / browser / api / lib / browser - window . coffee <nl> <nl> EventEmitter = require ( ' events ' ) . EventEmitter <nl> - IDWeakMap = process . atomBinding ( ' id_weak_map ' ) . IDWeakMap <nl> app = require ' app ' <nl> ipc = require ' ipc ' <nl> <nl> BrowserWindow = process . atomBinding ( ' window ' ) . BrowserWindow <nl> BrowserWindow : : __proto__ = EventEmitter . prototype <nl> <nl> - # Store all created windows in the weak map . <nl> - BrowserWindow . windows = new IDWeakMap <nl> - <nl> BrowserWindow : : _init = - > <nl> # Simulate the application menu on platforms other than OS X . <nl> if process . platform isnt ' darwin ' <nl> BrowserWindow : : _init = - > <nl> @ on ' focus ' , ( event ) = > <nl> app . emit ' browser - window - focus ' , event , this <nl> <nl> - # Remove the window from weak map immediately when it ' s destroyed , since we <nl> - # could be iterating windows before GC happened . <nl> - @ once ' closed ' , = > <nl> - BrowserWindow . windows . remove @ id if BrowserWindow . windows . has @ id <nl> - <nl> BrowserWindow : : setMenu = ( menu ) - > <nl> throw new TypeError ( ' Invalid menu ' ) unless menu is null or menu ? . constructor ? . name is ' Menu ' <nl> <nl> mmm a / atom / browser / lib / guest - window - manager . coffee <nl> ppp b / atom / browser / lib / guest - window - manager . coffee <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN ' , ( event , args . . . ) - > <nl> event . returnValue = createGuest event . sender , args . . . <nl> <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE ' , ( event , guestId ) - > <nl> - return unless BrowserWindow . windows . has guestId <nl> - BrowserWindow . windows . get ( guestId ) . destroy ( ) <nl> + BrowserWindow . fromId ( guestId ) ? . destroy ( ) <nl> <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD ' , ( event , guestId , method , args . . . ) - > <nl> - return unless BrowserWindow . windows . has guestId <nl> - BrowserWindow . windows . get ( guestId ) [ method ] args . . . <nl> + BrowserWindow . fromId ( guestId ) ? [ method ] args . . . <nl> <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE ' , ( event , guestId , message , targetOrigin ) - > <nl> - return unless BrowserWindow . windows . has guestId <nl> - guestContents = BrowserWindow . windows . get ( guestId ) . webContents <nl> - if guestContents . getUrl ( ) . indexOf ( targetOrigin ) is 0 or targetOrigin is ' * ' <nl> + guestContents = BrowserWindow . fromId ( guestId ) ? . webContents <nl> + if guestContents ? . getUrl ( ) . indexOf ( targetOrigin ) is 0 or targetOrigin is ' * ' <nl> guestContents . send ' ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE ' , message , targetOrigin <nl> <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE ' , ( event , message , targetOrigin ) - > <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE ' , ( event , mess <nl> embedder . send ' ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE ' , message , targetOrigin <nl> <nl> ipc . on ' ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD ' , ( event , guestId , method , args . . . ) - > <nl> - return unless BrowserWindow . windows . has guestId <nl> - BrowserWindow . windows . get ( guestId ) . webContents ? [ method ] args . . . <nl> + BrowserWindow . fromId ( guestId ) ? . webContents ? [ method ] args . . . <nl>
|
Remove usages of JS IDWeakMap in browser - window
|
electron/electron
|
8c83dfe918c3c1fa53776caf9e5217b36d8cf21b
|
2015-06-24T11:01:44Z
|
mmm a / test / SILGen / tuples . swift <nl> ppp b / test / SILGen / tuples . swift <nl> func testShuffleTuple ( ) { <nl> / / CHECK - NEXT : dealloc_stack [ [ TEMP ] ] <nl> pair = ( x : make_int ( ) , y : make_p ( ) ) <nl> } <nl> + <nl> + enum GenericEnum < T > { <nl> + case one ( T ) <nl> + <nl> + static var callback : ( T ) - > Void { fatalError ( ) } <nl> + } <nl> + <nl> + / / CHECK - LABEL : _T06tuples16testTupleUnsplatyyF <nl> + func testTupleUnsplat ( ) { <nl> + / / CHECK : debug_value [ [ X : % . + ] ] : $ Int , let , name " x " <nl> + / / CHECK : debug_value [ [ Y : % . + ] ] : $ Int , let , name " y " <nl> + let x = 1 , y = 2 <nl> + <nl> + / / CHECK : [ [ TUPLE : % . + ] ] = tuple ( [ [ X ] ] : $ Int , [ [ Y ] ] : $ Int ) <nl> + / / CHECK : enum $ GenericEnum < ( Int , Int ) > , # GenericEnum . one ! enumelt . 1 , [ [ TUPLE ] ] <nl> + _ = GenericEnum < ( Int , Int ) > . one ( ( x , y ) ) <nl> + / / CHECK : [ [ TUPLE : % . + ] ] = tuple ( [ [ X ] ] : $ Int , [ [ Y ] ] : $ Int ) <nl> + / / CHECK : enum $ GenericEnum < ( Int , Int ) > , # GenericEnum . one ! enumelt . 1 , [ [ TUPLE ] ] <nl> + _ = GenericEnum < ( Int , Int ) > . one ( x , y ) <nl> + <nl> + / / CHECK : [ [ THUNK : % . + ] ] = function_ref @ _T0Si_SitIxi_SiSiIxyy_TR <nl> + / / CHECK : [ [ REABSTRACTED : % . + ] ] = partial_apply [ [ THUNK ] ] ( { { % . + } } ) <nl> + / / CHECK : apply [ [ REABSTRACTED ] ] ( [ [ X ] ] , [ [ Y ] ] ) <nl> + _ = GenericEnum < ( Int , Int ) > . callback ( ( x , y ) ) <nl> + / / CHECK : [ [ THUNK : % . + ] ] = function_ref @ _T0Si_SitIxi_SiSiIxyy_TR <nl> + / / CHECK : [ [ REABSTRACTED : % . + ] ] = partial_apply [ [ THUNK ] ] ( { { % . + } } ) <nl> + / / CHECK : apply [ [ REABSTRACTED ] ] ( [ [ X ] ] , [ [ Y ] ] ) <nl> + _ = GenericEnum < ( Int , Int ) > . callback ( x , y ) <nl> + } / / CHECK : end sil function ' _T06tuples16testTupleUnsplatyyF ' <nl>
|
Merge pull request from jrose - apple / unsplat - test
|
apple/swift
|
46198c7f0119dc5109190d3d477ee13b1139af52
|
2017-01-28T01:35:38Z
|
mmm a / include / swift / Basic / Range . h <nl> ppp b / include / swift / Basic / Range . h <nl> template < class T > EnumeratorRange < T > enumerate ( T Begin , T End ) { <nl> return EnumeratorRange < T > ( Begin , End ) ; <nl> } <nl> <nl> - / / / An adaptor of std : : any_of for ranges . <nl> - template < class Range , class Predicate > <nl> - inline <nl> - bool <nl> - any_of ( Range R , Predicate P ) { <nl> - return std : : any_of ( R . begin ( ) , R . end ( ) , P ) ; <nl> - } <nl> - <nl> - / / / An adaptor of std : : all_of for ranges . <nl> - template < class Range , class Predicate > <nl> - inline <nl> - bool <nl> - all_of ( Range R , Predicate P ) { <nl> - return std : : all_of ( R . begin ( ) , R . end ( ) , P ) ; <nl> - } <nl> - <nl> / / / An adaptor of std : : none_of for ranges . <nl> template < class Range , class Predicate > <nl> inline <nl>
|
Use upstream versions of the any_of / all_of range adapters now that they are in LLVM ' s STLExtras .
|
apple/swift
|
28d63479baba60df535a7d7446b16c9b1e1eeae2
|
2016-02-06T19:22:26Z
|
mmm a / core / io / translation_loader_po . cpp <nl> ppp b / core / io / translation_loader_po . cpp <nl> <nl> <nl> RES TranslationLoaderPO : : load_translation ( FileAccess * f , Error * r_error , const String & p_path ) { <nl> <nl> - String l = f - > get_line ( ) ; <nl> - <nl> enum Status { <nl> <nl> STATUS_NONE , <nl>
|
Remove extraneous line in . po reader , which caused it to disregard first line
|
godotengine/godot
|
474eafbbf68036251666cc1c4e86a82876b59e61
|
2016-12-20T19:10:44Z
|
mmm a / tensorflow / core / grappler / utils / graph_view . cc <nl> ppp b / tensorflow / core / grappler / utils / graph_view . cc <nl> limitations under the License . <nl> <nl> # include " tensorflow / core / grappler / utils / graph_view . h " <nl> <nl> + # include < utility > <nl> + <nl> # include " absl / container / flat_hash_set . h " <nl> # include " absl / strings / str_cat . h " <nl> # include " absl / strings / str_join . h " <nl> limitations under the License . <nl> # include " tensorflow / core / graph / tensor_id . h " <nl> # include " tensorflow / core / grappler / op_types . h " <nl> # include " tensorflow / core / grappler / utils . h " <nl> + # include " tensorflow / core / grappler / utils / graph_view_internal . h " <nl> # include " tensorflow / core / lib / core / errors . h " <nl> # include " tensorflow / core / lib / gtl / map_util . h " <nl> <nl> void Mutation : : AddMutation ( <nl> node - > update_index_ = updated_nodes_ . size ( ) ; <nl> updated_nodes_ . emplace_back ( graph_view_ , node - > node_index_ ) ; <nl> mutate_fn ( & updated_nodes_ . back ( ) ) ; <nl> - } else { <nl> + } else if ( ! removed_nodes_ [ node - > node_index_ ] ) { <nl> auto & diff = updated_nodes_ [ node - > update_index_ ] ; <nl> - if ( ! diff . removed ) { <nl> - mutate_fn ( & diff ) ; <nl> - } <nl> + mutate_fn ( & diff ) ; <nl> } <nl> } <nl> <nl> void Mutation : : RemoveNode ( MutableNodeView * node ) { <nl> - AddMutation ( node , [ ] ( MutableNodeViewDiff * diff ) { <nl> - / / Clear existing MutableNodeViewDiff as when node is removed no change to <nl> - / / its internal state matter . <nl> - internal : : Reset ( diff ) ; <nl> - internal : : SetRemoved ( diff , true ) ; <nl> - } ) ; <nl> + auto & update_index = node - > update_index_ ; <nl> + if ( update_index ! = internal : : kMissingIndex ) { <nl> + if ( update_index < updated_nodes_ . size ( ) - 1 ) { <nl> + graph_view_ - > nodes_ [ updated_nodes_ . back ( ) . node_index ] . update_index_ = <nl> + update_index ; <nl> + std : : swap ( updated_nodes_ [ update_index ] , updated_nodes_ . back ( ) ) ; <nl> + } <nl> + updated_nodes_ . pop_back ( ) ; <nl> + update_index = internal : : kMissingIndex ; <nl> + } <nl> + removed_nodes_ [ node - > node_index_ ] = true ; <nl> } <nl> <nl> void Mutation : : UpdateNodeName ( MutableNodeView * node , absl : : string_view name ) { <nl> void Mutation : : RemoveNodeAttr ( const MutationNewNode & node , <nl> <nl> void Mutation : : ResetInternal ( ) { <nl> std : : vector < MutableNodeViewDiff > ( ) . swap ( updated_nodes_ ) ; <nl> + std : : vector < bool > ( graph_view_ - > NumNodes ( ) ) . swap ( removed_nodes_ ) ; <nl> std : : vector < MutationNewNodeHolder > ( ) . swap ( new_nodes_ ) ; <nl> } <nl> <nl> MutableGraphView : : MutableGraphView ( GraphDef * graph , Status * status ) <nl> return ; <nl> } <nl> AddFaninsInternal ( & fanins ) ; <nl> + mutation_ . ResetInternal ( ) ; <nl> * status = Status : : OK ( ) ; <nl> } <nl> <nl> Status MutableGraphView : : GetNodeNamesAndPartitionUpdatedNodes ( <nl> std : : vector < RenamedOrOverwrittenNode > * renamed_nodes , <nl> std : : vector < int > * inplace_nodes , <nl> std : : vector < int > * empty_diff_node_indices ) { <nl> + / / For all nodes to be removed and renamed , mark their original names as <nl> + / / missing and put associated node index in graph . <nl> for ( const auto & diff : mutation_ . updated_nodes_ ) { <nl> - / / For all nodes to be removed and renamed , mark their original names as <nl> - / / missing and put associated node index in graph . <nl> - if ( diff . removed | | diff . update_name ) { <nl> + if ( diff . update_name ) { <nl> const int index = diff . node_index ; <nl> const string & node_name = nodes_ [ index ] . GetName ( ) ; <nl> node_names - > emplace ( node_name , index ) ; <nl> } <nl> } <nl> <nl> + for ( int i = 0 ; i < mutation_ . removed_nodes_ . size ( ) ; + + i ) { <nl> + if ( mutation_ . removed_nodes_ [ i ] ) { <nl> + const string & node_name = nodes_ [ i ] . GetName ( ) ; <nl> + node_names - > emplace ( node_name , i ) ; <nl> + } <nl> + } <nl> + <nl> auto name_conflict = [ ] ( const absl : : string_view node_name ) { <nl> return errors : : InvalidArgument ( kMutableGraphViewApplyError , <nl> " multiple nodes with the name : ' " , node_name , <nl> Status MutableGraphView : : GetNodeNamesAndPartitionUpdatedNodes ( <nl> if ( internal : : IsEmpty ( & diff ) ) { <nl> empty_diff_node_indices - > emplace_back ( diff . node_index ) ; <nl> continue ; <nl> - } else if ( diff . removed ) { <nl> - continue ; <nl> } <nl> / / Get name of updated node after potential mutation . <nl> const string & node_name = <nl> Status MutableGraphView : : RemovedOrMissingNodeFanoutsWellFormed ( <nl> / / Check all fanouts of a single port . <nl> MutableNodeView * fanout_view = regular_fanout . node_view ( ) ; <nl> if ( fanout_view - > update_index_ = = internal : : kMissingIndex ) { <nl> - if ( ! overwritten_nodes [ fanout_view - > node_index_ ] ) { <nl> + if ( mutation_ . removed_nodes_ [ fanout_view - > node_index_ ] ) { <nl> + / / Fanout node will be removed , this can be ignored . <nl> + continue ; <nl> + } else if ( ! overwritten_nodes [ fanout_view - > node_index_ ] ) { <nl> / / Fanout is not updated or removed / overwritten . <nl> return bad_fanout ( fanout_view - > GetName ( ) , node_name_state . first ) ; <nl> } <nl> } else { <nl> auto & diff = mutation_ . updated_nodes_ [ fanout_view - > update_index_ ] ; <nl> - if ( diff . removed ) { <nl> - / / Fanout node will be removed , this can be ignored . <nl> - continue ; <nl> - } <nl> const int last_index = fanout_view - > NumRegularFanins ( ) - <nl> diff . num_regular_inputs_to_remove - 1 ; <nl> if ( regular_fanout . index ( ) > last_index ) { <nl> Status MutableGraphView : : RemovedOrMissingNodeFanoutsWellFormed ( <nl> for ( const auto & controlled_fanout : node_view . GetControlledFanouts ( ) ) { <nl> MutableNodeView * fanout_view = controlled_fanout . node_view ( ) ; <nl> if ( fanout_view - > update_index_ = = internal : : kMissingIndex ) { <nl> - if ( ! overwritten_nodes [ fanout_view - > node_index_ ] ) { <nl> + if ( mutation_ . removed_nodes_ [ fanout_view - > node_index_ ] ) { <nl> + / / Fanout node will be removed , this can be ignored . <nl> + continue ; <nl> + } else if ( ! overwritten_nodes [ fanout_view - > node_index_ ] ) { <nl> / / Fanout is not updated or removed / overwritten . <nl> return bad_fanout ( fanout_view - > GetName ( ) , node_name_state . first ) ; <nl> } <nl> } else { <nl> auto & diff = mutation_ . updated_nodes_ [ fanout_view - > update_index_ ] ; <nl> - if ( diff . removed ) { <nl> - / / Fanout node will be removed , this can be ignored . <nl> - continue ; <nl> - } <nl> / / Check if controlling fanin is removed . <nl> if ( diff . controlling_inputs_to_remove . find ( <nl> controlled_fanout . fanin_index_ ) = = <nl> Status MutableGraphView : : CheckNodeNamesAndFanins ( <nl> Status MutableGraphView : : CheckKernelRegisteredForNodes ( ) { <nl> Status s ; <nl> for ( auto & diff : mutation_ . updated_nodes_ ) { <nl> - if ( internal : : IsEmpty ( & diff ) | | diff . removed ) { <nl> + if ( internal : : IsEmpty ( & diff ) ) { <nl> continue ; <nl> } <nl> <nl> void MutableGraphView : : FixRenamedNodes ( <nl> nodes_ [ renamed . overwritten_node_index_ ] ; <nl> ReplaceNodeFanouts ( & renamed_node , & node_to_overwrite ) ; <nl> node_index_by_name_ . erase ( node_to_overwrite . GetName ( ) ) ; <nl> - if ( node_to_overwrite . update_index_ ! = internal : : kMissingIndex & & <nl> - mutation_ . updated_nodes_ [ node_to_overwrite . update_index_ ] . removed ) { <nl> - ( * overwritten_name_removed_nodes ) [ node_to_overwrite . update_index_ ] = <nl> - true ; <nl> + if ( mutation_ . removed_nodes_ [ node_to_overwrite . node_index_ ] ) { <nl> + ( * overwritten_name_removed_nodes ) [ node_to_overwrite . node_index_ ] = true ; <nl> } <nl> } else { <nl> / / No existing fanouts . <nl> void MutableGraphView : : AddNewNodes ( <nl> node_def - > mutable_device ( ) - > swap ( * new_node . node . mutable_device ( ) ) ; <nl> node_def - > mutable_input ( ) - > Clear ( ) ; <nl> node_def - > mutable_attr ( ) - > swap ( * new_node . node . mutable_attr ( ) ) ; <nl> - if ( node_view . update_index_ ! = internal : : kMissingIndex ) { <nl> - / / The only case for this to occur is if a node is explicitly marked for <nl> - / / removal . In that case , unlink it from it ' s associated <nl> - / / MutableNodeViewDiff . <nl> - mutation_ . updated_nodes_ [ node_view . update_index_ ] . node_index = <nl> - internal : : kMissingIndex ; <nl> - mutation_ . updated_nodes_ [ node_view . update_index_ ] . removed = false ; <nl> - node_view . update_index_ = internal : : kMissingIndex ; <nl> - } <nl> + mutation_ . removed_nodes_ [ node_index ] = false ; <nl> } else { <nl> / / New node . <nl> auto * new_node_def = graph_ - > add_node ( ) ; <nl> inline void MutableGraphView : : AddControllingFaninInternal ( <nl> <nl> void MutableGraphView : : ApplyNodeUpdates ( ) { <nl> for ( auto & diff : mutation_ . updated_nodes_ ) { <nl> - if ( diff . removed | | diff . node_index = = internal : : kMissingIndex | | <nl> - internal : : IsEmpty ( & diff ) ) { <nl> + if ( internal : : IsEmpty ( & diff ) ) { <nl> continue ; <nl> } <nl> MutableNodeView & node_view = nodes_ [ diff . node_index ] ; <nl> void MutableGraphView : : RemoveNodesInternal ( <nl> std : : vector < int > node_indices_to_remove ; <nl> node_indices_to_remove . reserve ( mutation_ . updated_nodes_ . size ( ) + <nl> overwritten_nodes . size ( ) ) ; <nl> - for ( int i = 0 ; i < mutation_ . updated_nodes_ . size ( ) ; + + i ) { <nl> - const auto & diff = mutation_ . updated_nodes_ [ i ] ; <nl> - if ( diff . removed ) { <nl> - auto & node = nodes_ [ diff . node_index ] ; <nl> + for ( int i = 0 ; i < mutation_ . removed_nodes_ . size ( ) ; + + i ) { <nl> + if ( mutation_ . removed_nodes_ [ i ] ) { <nl> + auto & node = nodes_ [ i ] ; <nl> RemoveAllFaninFanoutInternal ( & node ) ; <nl> - node_indices_to_remove . push_back ( diff . node_index ) ; <nl> + node_indices_to_remove . push_back ( i ) ; <nl> if ( ! overwritten_name_removed_nodes [ i ] ) { <nl> node_index_by_name_ . erase ( node . GetName ( ) ) ; <nl> } <nl> Status MutableGraphView : : ApplyMutationInternal ( ) { <nl> / / Node name and associated fanouts . <nl> absl : : flat_hash_map < string , NodeViewFanouts > renamed_fanouts ; <nl> / / Removed nodes where name was overwritten by a renamed node . <nl> - std : : vector < bool > overwritten_name_removed_nodes ( <nl> - mutation_ . updated_nodes_ . size ( ) ) ; <nl> + std : : vector < bool > overwritten_name_removed_nodes ( nodes_ . size ( ) ) ; <nl> / / Fix renaming of existing nodes by swapping fanouts and rehashing names . <nl> / / This will also overwrite removed or unmodified nodes . <nl> FixRenamedNodes ( & renamed_nodes , & renamed_fanouts , <nl> mmm a / tensorflow / core / grappler / utils / graph_view . h <nl> ppp b / tensorflow / core / grappler / utils / graph_view . h <nl> class Mutation { <nl> MutableGraphView * graph_view_ = nullptr ; <nl> int mutation_counter_ = 0 ; <nl> std : : vector < MutableNodeViewDiff > updated_nodes_ ; <nl> + std : : vector < bool > removed_nodes_ ; <nl> <nl> using MutationNewNodeHolder = internal : : NewNode < MutableGraphView > ; <nl> std : : vector < MutationNewNodeHolder > new_nodes_ ; <nl> mmm a / tensorflow / core / grappler / utils / graph_view_internal . h <nl> ppp b / tensorflow / core / grappler / utils / graph_view_internal . h <nl> struct NodeViewDiff { <nl> <nl> GraphViewT * graph_view ; <nl> int node_index ; <nl> - bool removed = false ; <nl> string name ; <nl> bool update_name = false ; <nl> string op ; <nl> struct NodeViewDiff { <nl> AttrValueMap processed_attrs ; <nl> } ; <nl> <nl> - / / Sets node for removal via diff . <nl> - template < typename GraphViewT > <nl> - inline void SetRemoved ( NodeViewDiff < GraphViewT > * diff , bool removed ) { <nl> - diff - > removed = removed ; <nl> - } <nl> - <nl> / / Updates node name . If ` name ` is the same as the name in the original node , <nl> / / the field will be cleared in the diff . <nl> template < typename GraphViewT > <nl> template < typename GraphViewT > <nl> inline bool IsEmpty ( NodeViewDiff < GraphViewT > * diff ) { <nl> ResizeByTrimmingEndForValue ( & diff - > regular_inputs_to_remove , false ) ; <nl> ResizeByTrimmingEndForValue ( & diff - > regular_inputs_to_add , EmptyTensorId ( ) ) ; <nl> - return ! diff - > removed & & ! diff - > update_name & & ! diff - > update_op & & <nl> - ! diff - > update_device & & diff - > regular_inputs_to_add . empty ( ) & & <nl> + return ! diff - > update_name & & ! diff - > update_op & & ! diff - > update_device & & <nl> + diff - > regular_inputs_to_add . empty ( ) & & <nl> diff - > regular_inputs_to_update . empty ( ) & & <nl> diff - > regular_inputs_to_remove . empty ( ) & & <nl> diff - > controlling_inputs_to_add . empty ( ) & & <nl> inline bool IsEmpty ( NodeViewDiff < GraphViewT > * diff ) { <nl> / / Resets and clears existing diff . <nl> template < typename GraphViewT > <nl> inline void Reset ( NodeViewDiff < GraphViewT > * diff ) { <nl> - diff - > removed = false ; <nl> diff - > name . clear ( ) ; <nl> diff - > update_name = false ; <nl> diff - > op . clear ( ) ; <nl> mmm a / tensorflow / core / grappler / utils / graph_view_internal_test . cc <nl> ppp b / tensorflow / core / grappler / utils / graph_view_internal_test . cc <nl> absl : : flat_hash_map < absl : : string_view , int > GetUpdatedNodeNames ( <nl> <nl> using MutableNodeViewDiff = NodeViewDiff < MutableGraphView > ; <nl> <nl> - TEST ( MutableNodeViewDiffTest , SetRemoved ) { <nl> - GraphDef graph = SimpleTestGraphForMutation ( ) ; <nl> - <nl> - Status s ; <nl> - MutableGraphView graph_view ( & graph , & s ) ; <nl> - TF_ASSERT_OK ( s ) ; <nl> - auto updated_node_names = GetUpdatedNodeNames ( & graph_view ) ; <nl> - <nl> - MutableNodeView * d_node = graph_view . GetNode ( " d " ) ; <nl> - ASSERT_NE ( d_node , nullptr ) ; <nl> - <nl> - MutableNodeViewDiff diff ( & graph_view , d_node - > node_index ( ) ) ; <nl> - EXPECT_TRUE ( IsEmpty ( & diff ) ) ; <nl> - EXPECT_TRUE ( IsWellFormed ( & diff , updated_node_names ) ) ; <nl> - <nl> - SetRemoved ( & diff , true ) ; <nl> - EXPECT_FALSE ( IsEmpty ( & diff ) ) ; <nl> - EXPECT_TRUE ( IsWellFormed ( & diff , updated_node_names ) ) ; <nl> - <nl> - SetRemoved ( & diff , false ) ; <nl> - EXPECT_TRUE ( IsEmpty ( & diff ) ) ; <nl> - EXPECT_TRUE ( IsWellFormed ( & diff , updated_node_names ) ) ; <nl> - } <nl> - <nl> TEST ( MutableNodeViewDiffTest , UpdateName ) { <nl> GraphDef graph = SimpleTestGraphForMutation ( ) ; <nl> <nl>
|
[ Grappler ] Move indicator of removed node in MutableGraphView : : Mutation out of MutableNodeViewDiff .
|
tensorflow/tensorflow
|
77095978f486c5c34565036915b4ea676735b9ba
|
2019-07-11T18:54:59Z
|
mmm a / lib / Driver / FineGrainedDependencyDriverGraph . cpp <nl> ppp b / lib / Driver / FineGrainedDependencyDriverGraph . cpp <nl> StringRef ModuleDepGraph : : getProvidingFilename ( <nl> const Optional < std : : string > swiftDeps ) const { <nl> if ( ! swiftDeps ) <nl> return " < unknown " ; <nl> + auto ext = llvm : : sys : : path : : extension ( * swiftDeps ) ; <nl> + if ( file_types : : lookupTypeForExtension ( ext ) = = <nl> + file_types : : TY_SwiftModuleFile ) { <nl> + return * swiftDeps ; <nl> + } <nl> const StringRef inputName = <nl> llvm : : sys : : path : : filename ( getJob ( swiftDeps ) - > getFirstSwiftPrimaryInput ( ) ) ; <nl> / / FineGrainedDependencyGraphTests work with simulated jobs with empty <nl>
|
Patch Out Use - Of - Stack - After - Free In Cross Module Dependencies
|
apple/swift
|
38b1da30bdea7c468ebdcd8cd289c9504eea2089
|
2020-10-07T17:18:57Z
|
mmm a / xbmc / addons / AddonDatabase . cpp <nl> ppp b / xbmc / addons / AddonDatabase . cpp <nl> bool CAddonDatabase : : GetAddons ( VECADDONS & addons ) <nl> m_pDS - > query ( sql . c_str ( ) ) ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - sql = PrepareSQL ( " select id from addon where addonID = ' % s ' order by version desc " , m_pDS - > fv ( 0 ) . get_asString ( ) . c_str ( ) ) ; <nl> - m_pDS2 - > query ( sql . c_str ( ) ) ; <nl> AddonPtr addon ; <nl> - if ( GetAddon ( m_pDS2 - > fv ( 0 ) . get_asInt ( ) , addon ) ) <nl> + if ( GetAddon ( m_pDS - > fv ( 0 ) . get_asString ( ) , addon ) ) <nl> addons . push_back ( addon ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> bool CAddonDatabase : : Search ( const CStdString & search , VECADDONS & addons ) <nl> if ( NULL = = m_pDS . get ( ) ) return false ; <nl> <nl> CStdString strSQL ; <nl> - strSQL = PrepareSQL ( " SELECT id FROM addon WHERE name LIKE ' % % % s % % ' OR summary LIKE ' % % % s % % ' OR description LIKE ' % % % s % % ' " , search . c_str ( ) , search . c_str ( ) , search . c_str ( ) ) ; <nl> + strSQL = PrepareSQL ( " SELECT addonID FROM addon WHERE name LIKE ' % % % s % % ' OR summary LIKE ' % % % s % % ' OR description LIKE ' % % % s % % ' " , search . c_str ( ) , search . c_str ( ) , search . c_str ( ) ) ; <nl> CLog : : Log ( LOGDEBUG , " % s query : % s " , __FUNCTION__ , strSQL . c_str ( ) ) ; <nl> <nl> if ( ! m_pDS - > query ( strSQL . c_str ( ) ) ) return false ; <nl> bool CAddonDatabase : : Search ( const CStdString & search , VECADDONS & addons ) <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> AddonPtr addon ; <nl> - GetAddon ( m_pDS - > fv ( 0 ) . get_asInt ( ) , addon ) ; <nl> + GetAddon ( m_pDS - > fv ( 0 ) . get_asString ( ) , addon ) ; <nl> if ( addon - > Type ( ) > = ADDON_UNKNOWN + 1 & & addon - > Type ( ) < ADDON_SCRAPER_LIBRARY ) <nl> addons . push_back ( addon ) ; <nl> m_pDS - > next ( ) ; <nl>
|
[ addondb ] Search ( ) and GetAddons ( ) could return add - ons other than that with highest version
|
xbmc/xbmc
|
57c6c82e5881c1cdbdfd0875728aa72c6d0c768f
|
2014-01-28T07:31:57Z
|
mmm a / lib / SILAnalysis / GlobalARCSequenceDataflow . cpp <nl> ppp b / lib / SILAnalysis / GlobalARCSequenceDataflow . cpp <nl> bool TopDownRefCountState : : merge ( const TopDownRefCountState & Other ) { <nl> } <nl> <nl> / / We should never have an argument path merge with a non - argument path . <nl> - if ( ! Argument . isNull ( ) ) { <nl> - RefCountState < TopDownRefCountState > : : clear ( ) ; <nl> - DEBUG ( <nl> - llvm : : dbgs ( ) < < " Can not merge Argument with Non - Argument " <nl> - " path . . . Bailing ! \ n " ) ; <nl> - return false ; <nl> + if ( Argument . isNull ( ) ! = Other . Argument . isNull ( ) ) { <nl> + RefCountState < TopDownRefCountState > : : clear ( ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Can not merge Argument with " <nl> + " Non - Argument path . . . Bailing ! \ n " ) ; <nl> + return false ; <nl> } <nl> <nl> Increments . insert ( Other . Increments . begin ( ) , Other . Increments . end ( ) ) ; <nl> mmm a / test / SILPasses / globalarcopts . sil <nl> ppp b / test / SILPasses / globalarcopts . sil <nl> bb5 : / / Preds : bb2 bb4 <nl> strong_release % 0 : $ C / / id : % 21 <nl> br bb1 ( undef : $ Builtin . Word ) / / id : % 22 <nl> } <nl> + <nl> + / / CHECK - LABEL : sil @ arg_merge : $ @ thin ( @ owned S ) - > ( ) { <nl> + / / CHECK - NOT : strong_retain <nl> + / / CHECK - NOT : strong_release <nl> + sil @ arg_merge : $ @ thin ( @ owned S ) - > ( ) { <nl> + bb0 ( % 0 : $ S ) : <nl> + % 1 = struct_extract % 0 : $ S , # S . x <nl> + strong_retain % 1 : $ Builtin . NativeObject <nl> + cond_br undef , bb1 , bb2 <nl> + <nl> + bb1 : <nl> + br bb3 <nl> + <nl> + bb2 : <nl> + br bb3 <nl> + <nl> + bb3 : <nl> + strong_release % 1 : $ Builtin . NativeObject <nl> + % 2 = tuple ( ) <nl> + return % 2 : $ ( ) <nl> + } <nl>
|
[ g - arc - opts ] Perform sanity check that we do not merge Argument paths with non - Argument tracking paths correctly .
|
apple/swift
|
aa7f8f46d6465c2a45e8ca2f5a69f25ec3e5d1d5
|
2014-07-15T01:55:19Z
|
mmm a / scene / animation / animation_node_state_machine . cpp <nl> ppp b / scene / animation / animation_node_state_machine . cpp <nl> float AnimationNodeStateMachinePlayback : : process ( AnimationNodeStateMachine * sm , <nl> <nl> bool goto_next = false ; <nl> <nl> - if ( switch_mode = = AnimationNodeStateMachineTransition : : SWITCH_MODE_IMMEDIATE ) { <nl> - goto_next = fading_from = = StringName ( ) ; <nl> - } else { <nl> + if ( switch_mode = = AnimationNodeStateMachineTransition : : SWITCH_MODE_AT_END ) { <nl> goto_next = next_xfade > = ( len_current - pos_current ) | | loops_current > 0 ; <nl> if ( loops_current > 0 ) { <nl> next_xfade = 0 ; <nl> } <nl> + } else { <nl> + goto_next = fading_from = = StringName ( ) ; <nl> } <nl> <nl> if ( goto_next ) { / / loops should be used because fade time may be too small or zero and animation may have looped <nl>
|
StateMachine : Fix sync mode
|
godotengine/godot
|
d35eae166c09ccb43e4f366525ad2ea78aaaf913
|
2019-03-17T13:12:27Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.