diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / include / swift / AST / Attr . def <nl> ppp b / include / swift / AST / Attr . def <nl> <nl> # define SIMPLE_DECL_ATTR ( X , CLASS , OPTIONS , CODE ) DECL_ATTR ( X , CLASS , OPTIONS , CODE ) <nl> # endif <nl> <nl> - # ifndef VIRTUAL_DECL_ATTR <nl> - # define VIRTUAL_DECL_ATTR ( X , CLASS , OPTIONS , CODE ) DECL_ATTR ( X , CLASS , OPTIONS , CODE ) <nl> - # endif <nl> - <nl> # ifndef DECL_ATTR_ALIAS <nl> # define DECL_ATTR_ALIAS ( SPELLING , CLASS ) <nl> # endif <nl> TYPE_ATTR ( opened ) <nl> / / SIMPLE_DECL_ATTR is the same , but the class becomes <nl> / / SimpleDeclAttr < DAK_ # # NAME > . <nl> / / <nl> - / / VIRTUAL_DECL_ATTR is like DECL_ATTR , but it can not be spelled in the source <nl> - / / code as an attribute . It is modelled as an attribute for the convenience of <nl> - / / implementation in the compiler . <nl> <nl> DECL_ATTR ( asmname , Asmname , <nl> OnFunc | OnConstructor | OnDestructor , 0 ) <nl> SIMPLE_DECL_ATTR ( override , Override , <nl> OnFunc | OnVar | OnSubscript | DeclModifier | NotSerialized , <nl> / * Not serialized * / 49 ) <nl> <nl> - VIRTUAL_DECL_ATTR ( accessibility , Accessibility , <nl> - OnFunc | OnExtension | OnTypeAlias | OnStruct | OnEnum | <nl> - OnClass | OnProtocol | OnVar | OnSubscript | OnConstructor | <nl> - DeclModifier | NotSerialized , <nl> - / * Not serialized * / 65535 ) <nl> + DECL_ATTR ( private , Accessibility , <nl> + OnFunc | OnExtension | OnTypeAlias | OnStruct | OnEnum | <nl> + OnClass | OnProtocol | OnVar | OnSubscript | OnConstructor | <nl> + DeclModifier | NotSerialized , <nl> + / * Not serialized * / 44 ) <nl> + DECL_ATTR_ALIAS ( internal , Accessibility ) <nl> + DECL_ATTR_ALIAS ( public , Accessibility ) <nl> + <nl> <nl> - VIRTUAL_DECL_ATTR ( accessibility , SetterAccessibility , <nl> - OnVar | OnSubscript | DeclModifier | NotSerialized , <nl> - / * Not serialized * / 65535 ) <nl> + DECL_ATTR ( __accessibility , SetterAccessibility , <nl> + OnVar | OnSubscript | DeclModifier | NotSerialized , <nl> + / * Not serialized * / 43 ) <nl> <nl> DECL_ATTR ( __raw_doc_comment , RawDocComment , OnAnyDecl | NotSerialized , <nl> / * Not serialized * / 46 ) <nl> AVAILABILITY_PLATFORM ( OSXApplicationExtension ) <nl> # undef AVAILABILITY_PLATFORM <nl> # undef TYPE_ATTR <nl> # undef DECL_ATTR_ALIAS <nl> - # undef VIRTUAL_DECL_ATTR <nl> # undef SIMPLE_DECL_ATTR <nl> # undef DECL_ATTR <nl> - # undef ATTR <nl> mmm a / include / swift / Serialization / DeclTypeRecordNodes . def <nl> ppp b / include / swift / Serialization / DeclTypeRecordNodes . def <nl> DECL ( DESTRUCTOR ) <nl> <nl> # ifndef DECL_ATTR <nl> # define DECL_ATTR ( NAME , CLASS , OPTIONS , CODE ) RECORD_VAL ( CLASS # # _DECL_ATTR , 150 + CODE ) <nl> - # define VIRTUAL_DECL_ATTR ( NAME , CLASS , OPTIONS , CODE ) <nl> # endif <nl> # include " swift / AST / Attr . def " <nl> <nl> mmm a / include / swift / Serialization / ModuleFormat . h <nl> ppp b / include / swift / Serialization / ModuleFormat . h <nl> namespace decls_block { <nl> > ; <nl> <nl> / / Stub layouts , unused . <nl> - using OwnershipDeclAttrLayout = BCRecordLayout < RawDocComment_DECL_ATTR > ; <nl> + using OwnershipDeclAttrLayout = BCRecordLayout < Ownership_DECL_ATTR > ; <nl> using RawDocCommentDeclAttrLayout = BCRecordLayout < RawDocComment_DECL_ATTR > ; <nl> + using AccessibilityDeclAttrLayout = BCRecordLayout < Accessibility_DECL_ATTR > ; <nl> + using SetterAccessibilityDeclAttrLayout = <nl> + BCRecordLayout < SetterAccessibility_DECL_ATTR > ; <nl> <nl> using InlineDeclAttrLayout = BCRecordLayout < <nl> Inline_DECL_ATTR , <nl> mmm a / lib / Serialization / Deserialization . cpp <nl> ppp b / lib / Serialization / Deserialization . cpp <nl> getActualStaticSpellingKind ( uint8_t raw ) { <nl> static bool isDeclAttrRecord ( unsigned ID ) { <nl> using namespace decls_block ; <nl> switch ( ID ) { <nl> - # define DECL_ATTR ( NAME , CLASS , . . . ) \ <nl> - case CLASS # # _DECL_ATTR : return true ; <nl> - # define VIRTUAL_DECL_ATTR ( NAME , CLASS , . . . ) <nl> + # define DECL_ATTR ( NAME , CLASS , . . . ) case CLASS # # _DECL_ATTR : return true ; <nl> # include " swift / Serialization / DeclTypeRecordNodes . def " <nl> default : return false ; <nl> } <nl> mmm a / lib / Serialization / Serialization . cpp <nl> ppp b / lib / Serialization / Serialization . cpp <nl> void Serializer : : writeDeclAttribute ( const DeclAttribute * DA ) { <nl> switch ( DA - > getKind ( ) ) { <nl> case DAK_RawDocComment : <nl> case DAK_Ownership : / / Serialized as part of the type . <nl> + case DAK_Accessibility : <nl> + case DAK_AccessibilitySetter : <nl> case DAK_Count : <nl> llvm_unreachable ( " cannot serialize DAK_Count " ) ; <nl> return ; <nl> <nl> - # define VIRTUAL_DECL_ATTR ( _ , CLASS , . . . ) \ <nl> - case DAK_ # # CLASS : return ; <nl> # define SIMPLE_DECL_ATTR ( _ , CLASS , . . . ) \ <nl> case DAK_ # # CLASS : { \ <nl> auto abbrCode = DeclTypeAbbrCodes [ CLASS # # DeclAttrLayout : : Code ] ; \ <nl> void Serializer : : writeAllDeclsAndTypes ( ) { <nl> <nl> # define DECL_ATTR ( X , NAME , . . . ) \ <nl> registerDeclTypeAbbr < NAME # # DeclAttrLayout > ( ) ; <nl> - # define VIRTUAL_DECL_ATTR ( X , NAME , . . . ) <nl> # include " swift / AST / Attr . def " <nl> } <nl> <nl>
|
eliminate VIRTUAL_DECL_ATTR , switching accessibility ( the last holdout ) over to
|
apple/swift
|
887ff4cefd318dbaaeb56b6ba4d8b25f3cd0c091
|
2014-07-17T05:29:17Z
|
mmm a / src / relooper / testit . sh <nl> ppp b / src / relooper / testit . sh <nl> <nl> <nl> echo " test " <nl> . / test & > test . out <nl> - diff - U 5 test . txt test . out <nl> + diff - w - U 5 test . txt test . out <nl> <nl> echo " test 2 " <nl> . / test2 & > test2 . out <nl> - diff - U 5 test2 . txt test2 . out <nl> + diff - w - U 5 test2 . txt test2 . out <nl> <nl> echo " test 3 " <nl> . / test3 & > test3 . out <nl> - diff - U 5 test3 . txt test3 . out <nl> + diff - w - U 5 test3 . txt test3 . out <nl> <nl> echo " test debug " <nl> . / test_debug & > test_debug . out <nl> - diff - U 5 test_debug . txt test_debug . out <nl> + diff - w - U 5 test_debug . txt test_debug . out <nl> <nl> echo " test dead " <nl> . / test_dead & > test_dead . out <nl> - diff - U 5 test_dead . txt test_dead . out <nl> + diff - w - U 5 test_dead . txt test_dead . out <nl> <nl> echo " test 4 " <nl> . / test4 & > test4 . out <nl> - diff - U 5 test4 . txt test4 . out <nl> + diff - w - U 5 test4 . txt test4 . out <nl> <nl> echo " test 5 " <nl> . / test5 & > test5 . out <nl> - diff - U 5 test5 . txt test5 . out <nl> + diff - w - U 5 test5 . txt test5 . out <nl> <nl> echo " test 6 " <nl> . / test6 & > test6 . out <nl> - diff - U 5 test6 . txt test6 . out <nl> + diff - w - U 5 test6 . txt test6 . out <nl> <nl> echo " test inf " <nl> . / test_inf & > test_inf . out <nl> - diff - U 5 test_inf . txt test_inf . out <nl> + diff - w - U 5 test_inf . txt test_inf . out <nl> <nl> echo " test fuzz1 " <nl> . / test_fuzz1 & > test_fuzz1 . out <nl> - diff - U 5 test_fuzz1 . txt test_fuzz1 . out <nl> + diff - w - U 5 test_fuzz1 . txt test_fuzz1 . out <nl> <nl> echo " test fuzz2 " <nl> . / test_fuzz2 & > test_fuzz2 . out <nl> - diff - U 5 test_fuzz2 . txt test_fuzz2 . out <nl> + diff - w - U 5 test_fuzz2 . txt test_fuzz2 . out <nl> <nl> echo " test fuzz3 " <nl> . / test_fuzz3 & > test_fuzz3 . out <nl> - diff - U 5 test_fuzz3 . txt test_fuzz3 . out <nl> + diff - w - U 5 test_fuzz3 . txt test_fuzz3 . out <nl> <nl> echo " test fuzz4 " <nl> . / test_fuzz4 & > test_fuzz4 . out <nl> - diff - U 5 test_fuzz4 . txt test_fuzz4 . out <nl> + diff - w - U 5 test_fuzz4 . txt test_fuzz4 . out <nl> <nl> echo " test fuzz5 " <nl> . / test_fuzz5 & > test_fuzz5 . out <nl> - diff - U 5 test_fuzz5 . txt test_fuzz5 . out <nl> + diff - w - U 5 test_fuzz5 . txt test_fuzz5 . out <nl> <nl> echo " test fuzz6 " <nl> . / test_fuzz6 & > test_fuzz6 . out <nl> - diff - U 5 test_fuzz6 . txt test_fuzz6 . out <nl> + diff - w - U 5 test_fuzz6 . txt test_fuzz6 . out <nl> <nl>
|
ignore whitespace in relooper reftests
|
emscripten-core/emscripten
|
9f609a10bfe90202d6e9d15216c502d6aa18bbcb
|
2013-12-26T02:16:38Z
|
mmm a / lib / IRGen / GenClass . cpp <nl> ppp b / lib / IRGen / GenClass . cpp <nl> namespace { <nl> / / } ; <nl> <nl> assert ( fields . getNextOffsetFromGlobal ( ) = = size ) ; <nl> - return buildGlobalVariable ( fields , " _CATEGORY_ " ) ; <nl> + return buildGlobalVariable ( fields , " _CATEGORY_ " , / * const * / true ) ; <nl> } <nl> <nl> llvm : : Constant * emitProtocol ( ) { <nl> namespace { <nl> / / } ; <nl> <nl> assert ( fields . getNextOffsetFromGlobal ( ) = = size ) ; <nl> - return buildGlobalVariable ( fields , " _PROTOCOL_ " ) ; <nl> + return buildGlobalVariable ( fields , " _PROTOCOL_ " , / * const * / true ) ; <nl> } <nl> <nl> void emitRODataFields ( ConstantStructBuilder & b , <nl> namespace { <nl> emitRODataFields ( fields , forMeta , hasUpdater ) ; <nl> <nl> auto dataSuffix = forMeta ? " _METACLASS_DATA_ " : " _DATA_ " ; <nl> - return buildGlobalVariable ( fields , dataSuffix ) ; <nl> + return buildGlobalVariable ( fields , dataSuffix , / * const * / true ) ; <nl> } <nl> <nl> private : <nl> namespace { <nl> return null ( ) ; <nl> } <nl> <nl> - return buildGlobalVariable ( array , " _PROTOCOL_METHOD_TYPES_ " ) ; <nl> + return buildGlobalVariable ( array , " _PROTOCOL_METHOD_TYPES_ " , <nl> + / * const * / true ) ; <nl> } <nl> <nl> void buildExtMethodTypes ( ConstantArrayBuilder & array , <nl> namespace { <nl> llvm : : Constant * buildMethodList ( ArrayRef < MethodDescriptor > methods , <nl> StringRef name ) { <nl> return buildOptionalList ( methods , 3 * IGM . getPointerSize ( ) , name , <nl> + / * isConst * / false , <nl> [ & ] ( ConstantArrayBuilder & descriptors , <nl> MethodDescriptor descriptor ) { <nl> buildMethod ( descriptors , descriptor ) ; <nl> namespace { <nl> chooseNamePrefix ( " _PROTOCOLS_ " , <nl> " _CATEGORY_PROTOCOLS_ " , <nl> " _PROTOCOL_PROTOCOLS_ " ) , <nl> + / * isConst * / true , <nl> [ & ] ( ConstantArrayBuilder & descriptors , <nl> ProtocolDecl * protocol ) { <nl> buildProtocol ( descriptors , protocol ) ; <nl> namespace { <nl> llvm : : Constant * buildIvarList ( ) { <nl> Size eltSize = 3 * IGM . getPointerSize ( ) + Size ( 8 ) ; <nl> return buildOptionalList ( Ivars , eltSize , " _IVARS_ " , <nl> + / * constant * / true , <nl> [ & ] ( ConstantArrayBuilder & descriptors , <nl> VarDecl * ivar ) { <nl> buildIvar ( descriptors , ivar ) ; <nl> namespace { <nl> StringRef namePrefix ) { <nl> Size eltSize = 2 * IGM . getPointerSize ( ) ; <nl> return buildOptionalList ( properties , eltSize , namePrefix , <nl> + / * constant * / true , <nl> [ & ] ( ConstantArrayBuilder & descriptors , <nl> VarDecl * property ) { <nl> buildProperty ( descriptors , property ) ; <nl> namespace { <nl> llvm : : Constant * buildOptionalList ( const C & objects , <nl> Size optionalEltSize , <nl> StringRef nameBase , <nl> + bool isConst , <nl> Fn & & buildElement ) { <nl> if ( objects . empty ( ) ) <nl> return null ( ) ; <nl> namespace { <nl> <nl> fields . fillPlaceholderWithInt ( countPosition , countType , count ) ; <nl> <nl> - return buildGlobalVariable ( fields , nameBase ) ; <nl> + return buildGlobalVariable ( fields , nameBase , isConst ) ; <nl> } <nl> <nl> / / / Get the name of the class or protocol to mangle into the ObjC symbol <nl> namespace { <nl> / / / Build a private global variable as a structure containing the <nl> / / / given fields . <nl> template < class B > <nl> - llvm : : Constant * buildGlobalVariable ( B & fields , StringRef nameBase ) { <nl> + llvm : : Constant * buildGlobalVariable ( B & fields , StringRef nameBase , <nl> + bool isConst ) { <nl> llvm : : SmallString < 64 > nameBuffer ; <nl> auto var = <nl> fields . finishAndCreateGlobal ( Twine ( nameBase ) <nl> namespace { <nl> <nl> switch ( IGM . TargetInfo . OutputObjectFormat ) { <nl> case llvm : : Triple : : MachO : <nl> - var - > setSection ( " __DATA , __objc_const " ) ; <nl> + var - > setSection ( isConst ? " __DATA , __objc_const " <nl> + : " __DATA , __objc_data " ) ; <nl> break ; <nl> case llvm : : Triple : : XCOFF : <nl> case llvm : : Triple : : COFF : <nl> mmm a / test / IRGen / class_update_callback_with_fixed_layout . sil <nl> ppp b / test / IRGen / class_update_callback_with_fixed_layout . sil <nl> sil_vtable SubclassOfClassWithResilientField { } <nl> / / - - the update callback <nl> / / CHECK - SAME : @ " $ s39class_update_callback_with_fixed_layout23ClassWithResilientFieldCMU " <nl> <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / Class has static metadata : <nl> / / CHECK - LABEL : @ " $ s39class_update_callback_with_fixed_layout23ClassWithResilientFieldCMf " <nl> mmm a / test / IRGen / class_update_callback_without_fixed_layout . sil <nl> ppp b / test / IRGen / class_update_callback_without_fixed_layout . sil <nl> <nl> / / RUN : % target - swift - frontend - I % t - emit - ir - enable - library - evolution - O % s - target % target - pre - stable - abi - triple <nl> <nl> / / REQUIRES : objc_interop <nl> - / / UNSUPPORTED : OS = iosmac <nl> - / / UNSUPPORTED : CPU = arm64 | | CPU = arm64e <nl> + / / UNSUPPORTED : swift_only_stable_abi <nl> <nl> / / With the old deployment target , these classes use the ' singleton ' metadata <nl> / / initialization pattern . The class is not statically visible to Objective - C , <nl> sil_vtable SubclassOfClassWithResilientField { } <nl> / / - - the update callback <nl> / / CHECK - NEW - SAME : @ " $ s42class_update_callback_without_fixed_layout23ClassWithResilientFieldCMU { { ( \ . ptrauth ) ? } } " <nl> <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " <nl> <nl> / / Class has static metadata : <nl> / / CHECK - LABEL : @ " $ s42class_update_callback_without_fixed_layout23ClassWithResilientFieldCMf " <nl> mmm a / test / IRGen / eager - class - initialization . swift <nl> ppp b / test / IRGen / eager - class - initialization . swift <nl> <nl> / / RUN : % target - swift - frontend ( mock - sdk : % clang - importer - sdk ) % s - emit - ir - target % target - pre - stable - abi - triple | % FileCheck % s - DINT = i % target - ptrsize - - check - prefix = CHECK - - check - prefix = CHECK - OLD <nl> <nl> / / REQUIRES : objc_interop <nl> - / / UNSUPPORTED : OS = iosmac <nl> - / / UNSUPPORTED : CPU = arm64 | | CPU = arm64e <nl> + / / UNSUPPORTED : swift_only_stable_abi <nl> <nl> / / See also eager - class - initialization - stable - abi . swift , for the stable ABI <nl> / / deployment target test . <nl> mmm a / test / IRGen / objc_bridge . swift <nl> ppp b / test / IRGen / objc_bridge . swift <nl> import Foundation <nl> / / CHECK : i8 * bitcast ( void ( [ [ OPAQUE : . * ] ] * , i8 * ) * @ " $ s11objc_bridge3BasCfETo " to i8 * ) <nl> / / CHECK : } <nl> / / CHECK : ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : @ _PROPERTIES__TtC11objc_bridge3Bas = internal constant { i32 , i32 , [ 5 x { i8 * , i8 * } ] } { <nl> <nl> mmm a / test / IRGen / objc_class_export . swift <nl> ppp b / test / IRGen / objc_class_export . swift <nl> <nl> / / CHECK - SAME : i8 * null , <nl> / / CHECK - SAME : i8 * null , <nl> / / CHECK - SAME : i8 * null <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> / / CHECK : @ _DATA__TtC17objc_class_export3Foo = internal constant { { . * \ * } } } { <nl> / / CHECK - SAME : i32 128 , <nl> / / CHECK - SAME : i32 16 , <nl> <nl> / / CHECK - SAME : @ _IVARS__TtC17objc_class_export3Foo , <nl> / / CHECK - SAME : i8 * null , <nl> / / CHECK - SAME : _PROPERTIES__TtC17objc_class_export3Foo <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> / / CHECK : @ " $ s17objc_class_export3FooCMf " = internal global < { { . * } } } > < { <nl> / / CHECK - SAME : void ( [ [ FOO ] ] * ) * @ " $ s17objc_class_export3FooCfD " , <nl> / / CHECK - SAME : i8 * * @ " $ sBOWV " , <nl> mmm a / test / IRGen / objc_extensions . swift <nl> ppp b / test / IRGen / objc_extensions . swift <nl> import objc_extension_base <nl> / / CHECK - SAME : @ " _CATEGORY_CLASS_METHODS_Gizmo_ $ _objc_extensions " , <nl> / / CHECK - SAME : @ " _CATEGORY_PROTOCOLS_Gizmo_ $ _objc_extensions " , <nl> / / CHECK - SAME : i8 * null <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> @ objc protocol NewProtocol { <nl> func brandNewInstanceMethod ( ) <nl> extension Gizmo : NewProtocol { <nl> / / CHECK : { { . * } } @ " _CATEGORY_CLASS_METHODS_Gizmo_ $ _objc_extensions1 " , <nl> / / CHECK : i8 * null , <nl> / / CHECK : i8 * null <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> extension Gizmo { <nl> @ objc func brandSpankingNewInstanceMethod ( ) { <nl> class Hoozit : NSObject { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ STR : @ . * ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * bitcast ( void ( [ [ OPAQUE : % . * ] ] * , i8 * ) * @ " $ s15objc_extensions6HoozitC7blibbleyyFTo " to i8 * ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - LABEL : @ " _CATEGORY_CLASS_METHODS__TtC15objc_extensions6Hoozit_ $ _objc_extensions " = internal constant <nl> / / CHECK : i32 24 , <nl> class Hoozit : NSObject { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ STR ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s15objc_extensions6HoozitC7blobbleyyFZTo " to i8 * ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - LABEL : @ " _CATEGORY__TtC15objc_extensions6Hoozit_ $ _objc_extensions " = internal constant <nl> / / CHECK : i8 * getelementptr inbounds ( [ 16 x i8 ] , [ 16 x i8 ] * [ [ CATEGORY_NAME ] ] , i64 0 , i64 0 ) , <nl> class Hoozit : NSObject { <nl> / / CHECK : { { . * } } @ " _CATEGORY_CLASS_METHODS__TtC15objc_extensions6Hoozit_ $ _objc_extensions " , <nl> / / CHECK : i8 * null , <nl> / / CHECK : i8 * null <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> extension Hoozit { <nl> @ objc func blibble ( ) { } <nl> class SwiftOnly { } <nl> / / CHECK : i8 * getelementptr inbounds ( [ 7 x i8 ] , [ 7 x i8 ] * @ " \ 01L_selector_data ( wibble ) " , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ STR ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s15objc_extensions9SwiftOnlyC6wibbleyyFTo " to i8 * ) <nl> - / / CHECK : } ] } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } ] } , section " __DATA , { { . * } } " , align 8 <nl> extension SwiftOnly { <nl> @ objc func wibble ( ) { } <nl> } <nl> extension NSObject { <nl> / / CHECK - SAME : i8 * getelementptr inbounds ( [ 16 x i8 ] , [ 16 x i8 ] * [ [ CATEGORY_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK - SAME : @ " _CATEGORY_INSTANCE_METHODS__TtCC15objc_extensions5Outer5Inner_ $ _objc_extensions " , <nl> / / CHECK - SAME : i8 * null <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> class Outer : NSObject { <nl> class Inner : NSObject { } <nl> class NSDogcow : NSObject { } <nl> <nl> / / CHECK : [ [ NAME : @ . * ] ] = private unnamed_addr constant [ 5 x i8 ] c " woof \ 00 " <nl> / / CHECK : [ [ ATTR : @ . * ] ] = private unnamed_addr constant [ 7 x i8 ] c " Tq , N , D \ 00 " <nl> - / / CHECK : @ " _CATEGORY_PROPERTIES__TtC15objc_extensions8NSDogcow_ $ _objc_extensions " = internal constant { { . * } } [ [ NAME ] ] , { { . * } } [ [ ATTR ] ] , { { . * } } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : @ " _CATEGORY_PROPERTIES__TtC15objc_extensions8NSDogcow_ $ _objc_extensions " = internal constant { { . * } } [ [ NAME ] ] , { { . * } } [ [ ATTR ] ] , { { . * } } , section " __DATA , { { . * } } " , align 8 <nl> extension NSDogcow { <nl> @ NSManaged var woof : Int <nl> } <nl> mmm a / test / IRGen / objc_methods . swift <nl> ppp b / test / IRGen / objc_methods . swift <nl> class ObjcDestructible : NSObject { <nl> / / CHECK - macosx : i8 * bitcast ( i8 ( i8 * , i8 * , % 4 * * ) * @ " $ s12objc_methods3FooC4failyyKFTo " to i8 * ) <nl> / / CHECK - ios : i8 * bitcast ( i1 ( i8 * , i8 * , % 4 * * ) * @ " $ s12objc_methods3FooC4failyyKFTo " to i8 * ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> / / CHECK : @ _INSTANCE_METHODS__TtC12objc_methods16ObjcDestructible = internal constant { { { . * } } ] } { <nl> / / CHECK : i32 24 , <nl> / / CHECK : i32 2 , <nl> class ObjcDestructible : NSObject { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ NO_ARGS_SIGNATURE ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * bitcast ( void ( % 6 * , i8 * ) * @ " $ s12objc_methods16ObjcDestructibleCfETo " to i8 * ) } ] <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> / / CHECK : [ [ BLOCK_SIGNATURE_EXT_1 : @ . * ] ] = private unnamed_addr constant [ 18 x i8 ] c " v24 @ 0 : 8 @ ? < q @ ? q > 16 \ 00 " <nl> / / CHECK : [ [ BLOCK_SIGNATURE_EXT_2 : @ . * ] ] = private unnamed_addr constant [ 19 x i8 ] c " v24 @ 0 : 8 @ ? < q @ ? qq > 16 \ 00 " <nl> / / CHECK : [ [ STRING_SIGNATURE_EXT : @ . * ] ] = private unnamed_addr constant [ 31 x i8 ] c " @ \ 22NSString \ 2224 @ 0 : 8 @ \ 22NSString \ 2216 \ 00 " <nl> mmm a / test / IRGen / objc_properties . swift <nl> ppp b / test / IRGen / objc_properties . swift <nl> class SomeWrapperTests { <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 11 x i8 ] , [ 11 x i8 ] * [ [ SHARED_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 5 x i8 ] , [ 5 x i8 ] * [ [ SHARED_ATTRS ] ] , i64 0 , i64 0 ) <nl> / / CHECK - NEW : } ] <nl> - / / CHECK - NEW : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - NEW : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : @ _METACLASS_DATA__TtC15objc_properties10SomeObject = internal constant { { { . * } } } { <nl> / / CHECK - SAME : i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , <nl> class SomeWrapperTests { <nl> / / CHECK - SAME : i8 * null , i8 * null , i8 * null , <nl> / / CHECK - NEW - SAME : { { { . + } } } * @ _CLASS_PROPERTIES__TtC15objc_properties10SomeObject <nl> / / CHECK - OLD - SAME : i8 * null <nl> - / / CHECK - SAME : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - SAME : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : [ [ GETTER_SIGNATURE : @ . * ] ] = private unnamed_addr constant [ 8 x i8 ] c " @ 16 @ 0 : 8 \ 00 " <nl> / / CHECK : [ [ SETTER_SIGNATURE : @ . * ] ] = private unnamed_addr constant [ 11 x i8 ] c " v24 @ 0 : 8 @ 16 \ 00 " <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ GETTER_SIGNATURE ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : @ " $ s15objc_properties10SomeObjectCACycfcTo { { ( . ptrauth ) ? } } " <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / This appears earlier because it ' s also used in an ivar description . <nl> / / CHECK : [ [ BAREIVAR_NAME : @ . * ] ] = private unnamed_addr constant [ 9 x i8 ] c " bareIvar \ 00 " <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 7 x i8 ] , [ 7 x i8 ] * [ [ WIBBLE_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * getelementptr inbounds ( [ 50 x i8 ] , [ 50 x i8 ] * [ [ WIBBLE_ATTRS ] ] , i64 0 , i64 0 ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : @ _DATA__TtC15objc_properties10SomeObject = internal constant { { { . + } } } { <nl> / / CHECK : i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , i32 { { [ 0 - 9 ] + } } , <nl> class SomeWrapperTests { <nl> / / CHECK : { { { . + } } } * @ _IVARS__TtC15objc_properties10SomeObject , <nl> / / CHECK : i8 * null , <nl> / / CHECK : { { { . + } } } * @ _PROPERTIES__TtC15objc_properties10SomeObject <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : @ " _CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_ $ _objc_properties " = internal constant { { { . * } } ] } { <nl> / / CHECK : i32 24 , <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 11 x i8 ] , [ 11 x i8 ] * [ [ SETTER_SIGNATURE ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : @ " $ s15objc_properties10SomeObjectC17extensionPropertyACvsTo { { ( . ptrauth ) ? } } " <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : [ [ EXTENSIONPROPERTY_NAME : @ . * ] ] = private unnamed_addr constant [ 18 x i8 ] c " extensionProperty \ 00 " <nl> <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 18 x i8 ] , [ 18 x i8 ] * [ [ EXTENSIONPROPERTY_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * getelementptr inbounds ( [ 42 x i8 ] , [ 42 x i8 ] * [ [ READWRITE_ATTRS ] ] , i64 0 , i64 0 ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - NEW : [ [ EXTENSIONCLASSPROPERTY_NAME : @ . * ] ] = private unnamed_addr constant [ 19 x i8 ] c " extensionClassProp \ 00 " <nl> / / CHECK - NEW : [ [ EXTENSIONCLASSPROPERTY_ATTRS : @ . * ] ] = private unnamed_addr constant [ 7 x i8 ] c " T # , N , R \ 00 " <nl> class SomeWrapperTests { <nl> / / CHECK - NEW : } , { <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 26 x i8 ] , [ 26 x i8 ] * [ [ EXTENSIONSTATICPROPERTY_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 5 x i8 ] , [ 5 x i8 ] * [ [ SHARED_ATTRS ] ] , i64 0 , i64 0 ) } ] <nl> - / / CHECK - NEW : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - NEW : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : @ " _CATEGORY__TtC15objc_properties10SomeObject_ $ _objc_properties " = internal constant { { { . + } } } { <nl> / / CHECK : i8 * getelementptr inbounds ( [ { { . + } } x i8 ] , [ { { . + } } x i8 ] * { { @ . + } } , i64 0 , i64 0 ) , <nl> class SomeWrapperTests { <nl> / / CHECK - NEW : { { { . + } } } * @ " _CATEGORY_CLASS_PROPERTIES__TtC15objc_properties10SomeObject_ $ _objc_properties " , <nl> / / CHECK - OLD : i8 * null , <nl> / / CHECK : i32 60 <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> <nl> / / CHECK : @ _INSTANCE_METHODS__TtC15objc_properties4Tree = <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * null , <nl> / / CHECK - NEW : { { { . + } } } * @ _PROTOCOL_CLASS_PROPERTIES__TtP15objc_properties5Proto_ <nl> / / CHECK - OLD : i8 * null <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> <nl> / / CHECK : [ [ PROTOCOLPROPERTY_NAME : @ . + ] ] = private unnamed_addr constant [ 6 x i8 ] c " value \ 00 " <nl> class SomeWrapperTests { <nl> / / CHECK : i8 * getelementptr inbounds ( [ 6 x i8 ] , [ 6 x i8 ] * [ [ PROTOCOLPROPERTY_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK : i8 * getelementptr inbounds ( [ 7 x i8 ] , [ 7 x i8 ] * [ [ PROTOCOLPROPERTY_ATTRS ] ] , i64 0 , i64 0 ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - NEW : [ [ PROTOCOLCLASSPROPERTY_NAME : @ . + ] ] = private unnamed_addr constant [ 15 x i8 ] c " sharedInstance \ 00 " <nl> / / CHECK - NEW : [ [ PROTOCOLCLASSPROPERTY_ATTRS : @ . + ] ] = private unnamed_addr constant [ 7 x i8 ] c " T @ , N , & \ 00 " <nl> class SomeWrapperTests { <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 15 x i8 ] , [ 15 x i8 ] * [ [ PROTOCOLCLASSPROPERTY_NAME ] ] , i64 0 , i64 0 ) , <nl> / / CHECK - NEW : i8 * getelementptr inbounds ( [ 7 x i8 ] , [ 7 x i8 ] * [ [ PROTOCOLCLASSPROPERTY_ATTRS ] ] , i64 0 , i64 0 ) <nl> / / CHECK - NEW : } ] <nl> - / / CHECK - NEW : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - NEW : } , section " __DATA , { { . * } } " , align 8 <nl> mmm a / test / IRGen / objc_protocols . swift <nl> ppp b / test / IRGen / objc_protocols . swift <nl> class Foo : NSRuncing , NSFunging , Ansible { <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 6 x i8 ] , [ 6 x i8 ] * @ " \ 01L_selector_data ( funge ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3FooC5fungeyyFTo " to i8 * ) } , <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 4 x i8 ] , [ 4 x i8 ] * @ " \ 01L_selector_data ( foo ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3FooC3fooyyFTo " to i8 * ) <nl> / / CHECK : } ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> class Bar { <nl> func bar ( ) { } <nl> extension Bar : NSRuncing , NSFunging { <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 6 x i8 ] , [ 6 x i8 ] * @ " \ 01L_selector_data ( funge ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3BarC5fungeyyFTo " to i8 * ) } , <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 4 x i8 ] , [ 4 x i8 ] * @ " \ 01L_selector_data ( foo ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3BarC3fooyyFTo " to i8 * ) } <nl> / / CHECK : ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / class Bas from objc_protocols_Bas module <nl> extension Bas : NSRuncing { <nl> extension Bas : NSRuncing { <nl> / / CHECK : [ 1 x { i8 * , i8 * , i8 * } ] [ <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 4 x i8 ] , [ 4 x i8 ] * @ " \ 01L_selector_data ( foo ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s18objc_protocols_Bas0C0C0a1_B0E3fooyyFTo " to i8 * ) } <nl> / / CHECK : ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / - - Swift protocol refinement of ObjC protocols . <nl> protocol Frungible : NSRuncing , NSFunging { <nl> class Zim : Frungible { <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 6 x i8 ] , [ 6 x i8 ] * @ " \ 01L_selector_data ( funge ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3ZimC5fungeyyFTo " to i8 * ) } , <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 4 x i8 ] , [ 4 x i8 ] * @ " \ 01L_selector_data ( foo ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s14objc_protocols3ZimC3fooyyFTo " to i8 * ) } <nl> / / CHECK : ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / class Zang from objc_protocols_Bas module <nl> extension Zang : Frungible { <nl> extension Zang : Frungible { <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 6 x i8 ] , [ 6 x i8 ] * @ " \ 01L_selector_data ( runce ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s18objc_protocols_Bas4ZangC0a1_B0E5runceyyFTo " to i8 * ) } , <nl> / / CHECK : { i8 * , i8 * , i8 * } { i8 * getelementptr inbounds ( [ 4 x i8 ] , [ 4 x i8 ] * @ " \ 01L_selector_data ( foo ) " , i64 0 , i64 0 ) , i8 * getelementptr inbounds ( [ 8 x i8 ] , [ 8 x i8 ] * [ [ ENC ] ] , i64 0 , i64 0 ) , i8 * bitcast ( void ( i8 * , i8 * ) * @ " $ s18objc_protocols_Bas4ZangC0a1_B0E3fooyyFTo " to i8 * ) } <nl> / / CHECK : ] <nl> - / / CHECK : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> @ objc protocol BaseProtocol { } <nl> protocol InheritingProtocol : BaseProtocol { } <nl> mmm a / test / IRGen / objc_subclass . swift <nl> ppp b / test / IRGen / objc_subclass . swift <nl> <nl> / / CHECK - 32 : i8 * null , <nl> / / CHECK - 32 : i8 * null , <nl> / / CHECK - 32 : i8 * null <nl> - / / CHECK - 32 : } , section " __DATA , __objc_const " , align 4 <nl> + / / CHECK - 32 : } , section " __DATA , { { . * } } " , align 4 <nl> <nl> / / CHECK - 64 : @ _METACLASS_DATA__TtC13objc_subclass10SwiftGizmo = internal constant { { { . * } } * } { <nl> / / CHECK - 64 : i32 129 , <nl> <nl> / / CHECK - 64 : i8 * null , <nl> / / CHECK - 64 : i8 * null , <nl> / / CHECK - 64 : i8 * null <nl> - / / CHECK - 64 : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - 64 : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - 32 : [ [ METHOD_TYPE_ENCODING1 : @ . * ] ] = private unnamed_addr constant [ 7 x i8 ] c " l8 @ 0 : 4 \ 00 " <nl> / / CHECK - 64 : [ [ METHOD_TYPE_ENCODING1 : @ . * ] ] = private unnamed_addr constant [ 8 x i8 ] c " q16 @ 0 : 8 \ 00 " <nl> <nl> / / CHECK - 32 : i8 * getelementptr inbounds ( [ { { [ 0 - 9 ] + } } x i8 ] , [ { { [ 0 - 9 ] + } } x i8 ] * { { @ [ 0 - 9 ] + } } , i32 0 , i32 0 ) , <nl> / / CHECK - 32 : i8 * bitcast ( { { . * } } * @ " $ s13objc_subclass10SwiftGizmoCfeTo { { ( \ . ptrauth ) ? } } " to i8 * ) <nl> / / CHECK - 32 : } ] <nl> - / / CHECK - 32 : } , section " __DATA , __objc_const " , align 4 <nl> + / / CHECK - 32 : } , section " __DATA , { { . * } } " , align 4 <nl> <nl> / / CHECK - 64 : @ _INSTANCE_METHODS__TtC13objc_subclass10SwiftGizmo = internal constant { { { . * } } ] } { <nl> / / CHECK - 64 : i32 24 , <nl> <nl> / / CHECK - 64 : i8 * getelementptr inbounds ( [ { { [ 0 - 9 ] + } } x i8 ] , [ { { [ 0 - 9 ] + } } x i8 ] * { { @ [ 0 - 9 ] + } } , i64 0 , i64 0 ) , <nl> / / CHECK - 64 : i8 * bitcast ( { { . * } } * @ " $ s13objc_subclass10SwiftGizmoCfeTo { { ( \ . ptrauth ) ? } } " to i8 * ) <nl> / / CHECK - 64 : } ] <nl> - / / CHECK - 64 : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - 64 : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK : [ [ STRING_X : @ . * ] ] = private unnamed_addr constant [ 2 x i8 ] c " x \ 00 " <nl> / / CHECK - 64 : [ [ STRING_EMPTY : @ . * ] ] = private unnamed_addr constant [ 1 x i8 ] zeroinitializer <nl> <nl> / / CHECK - 32 : i8 * getelementptr inbounds ( [ 1 x i8 ] , [ 1 x i8 ] * { { . * } } , i32 0 , i32 0 ) , <nl> / / CHECK - 32 : i32 2 , <nl> / / CHECK - 32 : i32 4 } ] <nl> - / / CHECK - 32 : } , section " __DATA , __objc_const " , align 4 <nl> + / / CHECK - 32 : } , section " __DATA , { { . * } } " , align 4 <nl> <nl> / / CHECK - 64 : @ _IVARS__TtC13objc_subclass10SwiftGizmo = internal constant { { { . * } } ] } { <nl> / / CHECK - 64 : i32 32 , <nl> <nl> / / CHECK - 64 : i8 * getelementptr inbounds ( [ 1 x i8 ] , [ 1 x i8 ] * [ [ STRING_EMPTY ] ] , i64 0 , i64 0 ) , <nl> / / CHECK - 64 : i32 3 , <nl> / / CHECK - 64 : i32 8 } ] <nl> - / / CHECK - 64 : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - 64 : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - 32 : @ _DATA__TtC13objc_subclass10SwiftGizmo = internal constant { { { . * } } * } { <nl> / / CHECK - 32 : i32 132 , <nl> <nl> / / CHECK - 32 : @ _IVARS__TtC13objc_subclass10SwiftGizmo , <nl> / / CHECK - 32 : i8 * null , <nl> / / CHECK - 32 : @ _PROPERTIES__TtC13objc_subclass10SwiftGizmo <nl> - / / CHECK - 32 : } , section " __DATA , __objc_const " , align 4 <nl> + / / CHECK - 32 : } , section " __DATA , { { . * } } " , align 4 <nl> <nl> / / CHECK - 64 : @ _DATA__TtC13objc_subclass10SwiftGizmo = internal constant { { { . * } } * } { <nl> / / CHECK - 64 : i32 132 , <nl> <nl> / / CHECK - 64 : @ _IVARS__TtC13objc_subclass10SwiftGizmo , <nl> / / CHECK - 64 : i8 * null , <nl> / / CHECK - 64 : @ _PROPERTIES__TtC13objc_subclass10SwiftGizmo <nl> - / / CHECK - 64 : } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - 64 : } , section " __DATA , { { . * } } " , align 8 <nl> <nl> / / CHECK - NOT : @ _TMCSo13SwiftGizmo = { { . * NSObject } } <nl> <nl> <nl> / / CHECK - 32 : i8 * bitcast ( { { . * } } * @ " $ s13objc_subclass11SwiftGizmo2CfETo { { ( \ . ptrauth ) ? } } " to i8 * ) <nl> / / CHECK - 32 : } <nl> / / CHECK - 32 : ] <nl> - / / CHECK - 32 : } , section " __DATA , __objc_const " , align 4 <nl> + / / CHECK - 32 : } , section " __DATA , { { . * } } " , align 4 <nl> <nl> / / CHECK - 64 : @ _INSTANCE_METHODS__TtC13objc_subclass11SwiftGizmo2 = internal constant { i32 , { { . * } } ] } { <nl> / / CHECK - 64 : i32 24 , <nl> mmm a / test / IRGen / objc_type_encoding . swift <nl> ppp b / test / IRGen / objc_type_encoding . swift <nl> class C : P { <nl> } <nl> <nl> / / CHECK - macosx : [ [ ENC5 : @ . * ] ] = private unnamed_addr constant [ 9 x i8 ] c " Vv16 @ 0 : 8 \ 00 " <nl> - / / CHECK - macosx : @ _PROTOCOL_INSTANCE_METHODS_P = { { . * } } @ " \ 01L_selector_data ( stuff ) " { { . * } } [ [ ENC5 ] ] { { . * } } , section " __DATA , __objc_const " , align 8 <nl> + / / CHECK - macosx : @ _PROTOCOL_INSTANCE_METHODS_P = { { . * } } @ " \ 01L_selector_data ( stuff ) " { { . * } } [ [ ENC5 ] ] { { . * } } <nl> mmm a / test / decl / protocol / conforms / nscoding . swift <nl> ppp b / test / decl / protocol / conforms / nscoding . swift <nl> <nl> / / RUN : % FileCheck - - check - prefix = NEGATIVE % s < % t / old . ast <nl> <nl> / / REQUIRES : objc_interop <nl> - / / UNSUPPORTED : CPU = arm64e <nl> + / / UNSUPPORTED : swift_only_stable_abi <nl> <nl> / / See also nscoding_stable_abi . swift , for the stable ABI deployment <nl> / / target test . <nl>
|
Merge remote - tracking branch ' origin / master ' into master - rebranch
|
apple/swift
|
3acd7bf7c0e810ddfe411efc7cc9ff6d25367631
|
2020-08-07T19:43:53Z
|
mmm a / test / cctest / test - simulator - arm . cc <nl> ppp b / test / cctest / test - simulator - arm . cc <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + # if defined ( USE_SIMULATOR ) <nl> + <nl> # ifndef V8_TARGET_LITTLE_ENDIAN <nl> # error Expected ARM to be little - endian <nl> # endif <nl> <nl> / / Define these function prototypes to match JSEntryFunction in execution . cc . <nl> - typedef Object * ( * F_iiiii ) ( int p0 , int p1 , int p2 , int p3 , int p4 ) ; <nl> - typedef Object * ( * F_piiii ) ( void * p0 , int p1 , int p2 , int p3 , int p4 ) ; <nl> + typedef Object * ( * F1 ) ( int x , int p1 , int p2 , int p3 , int p4 ) ; <nl> + typedef Object * ( * F3 ) ( void * p0 , int p1 , int p2 , int p3 , int p4 ) ; <nl> <nl> # define __ assm . <nl> <nl> void AssembleMemoryAccess ( Assembler * assembler , MemoryAccess access , <nl> } <nl> } <nl> <nl> - Address AssembleCode ( std : : function < void ( Assembler & ) > assemble ) { <nl> - Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> - Assembler assm ( isolate , nullptr , 0 ) ; <nl> - <nl> - assemble ( assm ) ; <nl> - <nl> - __ bx ( lr ) ; <nl> - <nl> - CodeDesc desc ; <nl> - assm . GetCode ( isolate , & desc ) ; <nl> - Handle < Code > code = <nl> - isolate - > factory ( ) - > NewCode ( desc , Code : : STUB , Handle < Code > ( ) ) ; <nl> - return code - > entry ( ) ; <nl> - } <nl> - <nl> - # if defined ( USE_SIMULATOR ) <nl> void AssembleLoadExcl ( Assembler * assembler , MemoryAccess access , <nl> Register value_reg , Register addr_reg ) { <nl> DCHECK ( access . kind = = MemoryAccess : : Kind : : LoadExcl ) ; <nl> void AssembleStoreExcl ( Assembler * assembler , MemoryAccess access , <nl> AssembleMemoryAccess ( assembler , access , dest_reg , value_reg , addr_reg ) ; <nl> } <nl> <nl> + F3 AssembleCode ( std : : function < void ( Assembler & ) > assemble ) { <nl> + Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> + Assembler assm ( isolate , nullptr , 0 ) ; <nl> + <nl> + assemble ( assm ) ; <nl> + <nl> + __ bx ( lr ) ; <nl> + <nl> + CodeDesc desc ; <nl> + assm . GetCode ( isolate , & desc ) ; <nl> + Handle < Code > code = <nl> + isolate - > factory ( ) - > NewCode ( desc , Code : : STUB , Handle < Code > ( ) ) ; <nl> + F3 f = FUNCTION_CAST < F3 > ( code - > entry ( ) ) ; <nl> + return f ; <nl> + } <nl> + <nl> void TestInvalidateExclusiveAccess ( TestData initial_data , MemoryAccess access1 , <nl> MemoryAccess access2 , MemoryAccess access3 , <nl> int expected_res , TestData expected_data ) { <nl> Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> HandleScope scope ( isolate ) ; <nl> <nl> - F_piiii f = FUNCTION_CAST < F_piiii > ( AssembleCode ( [ & ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ & ] ( Assembler & assm ) { <nl> AssembleLoadExcl ( & assm , access1 , r1 , r1 ) ; <nl> AssembleMemoryAccess ( & assm , access2 , r3 , r2 , r1 ) ; <nl> AssembleStoreExcl ( & assm , access3 , r0 , r3 , r1 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> TestData t = initial_data ; <nl> <nl> void TestInvalidateExclusiveAccess ( TestData initial_data , MemoryAccess access1 , <nl> break ; <nl> } <nl> } <nl> - # endif <nl> <nl> std : : vector < Float32 > Float32Inputs ( ) { <nl> std : : vector < Float32 > inputs ; <nl> std : : vector < Float64 > Float64Inputs ( ) { <nl> <nl> } / / namespace <nl> <nl> - / / TODO ( rodolph . perfetta @ arm . com ) : Enable this test for native hardware , see <nl> - / / http : / / crbug . com / v8 / 6963 . <nl> - # if defined ( USE_SIMULATOR ) <nl> - <nl> TEST ( simulator_invalidate_exclusive_access ) { <nl> using Kind = MemoryAccess : : Kind ; <nl> using Size = MemoryAccess : : Size ; <nl> TEST ( simulator_invalidate_exclusive_access ) { <nl> 0 , TestData ( 7 ) ) ; <nl> } <nl> <nl> - # endif / / USE_SIMULATOR <nl> - <nl> static int ExecuteMemoryAccess ( Isolate * isolate , TestData * test_data , <nl> MemoryAccess access ) { <nl> HandleScope scope ( isolate ) ; <nl> - F_piiii f = FUNCTION_CAST < F_piiii > ( AssembleCode ( [ & ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ & ] ( Assembler & assm ) { <nl> AssembleMemoryAccess ( & assm , access , r0 , r2 , r1 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> return reinterpret_cast < int > ( <nl> CALL_GENERATED_CODE ( isolate , f , test_data , 0 , 0 , 0 , 0 ) ) ; <nl> TEST ( simulator_vabs_32 ) { <nl> Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> HandleScope scope ( isolate ) ; <nl> <nl> - F_iiiii f = FUNCTION_CAST < F_iiiii > ( AssembleCode ( [ ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ ] ( Assembler & assm ) { <nl> __ vmov ( s0 , r0 ) ; <nl> __ vabs ( s0 , s0 ) ; <nl> __ vmov ( r0 , s0 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> for ( Float32 f32 : Float32Inputs ( ) ) { <nl> Float32 res = Float32 : : FromBits ( reinterpret_cast < uint32_t > ( <nl> TEST ( simulator_vabs_64 ) { <nl> Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> HandleScope scope ( isolate ) ; <nl> <nl> - F_iiiii f = FUNCTION_CAST < F_iiiii > ( AssembleCode ( [ ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ ] ( Assembler & assm ) { <nl> __ vmov ( d0 , r0 , r1 ) ; <nl> __ vabs ( d0 , d0 ) ; <nl> __ vmov ( r1 , r0 , d0 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> for ( Float64 f64 : Float64Inputs ( ) ) { <nl> uint32_t p0 = static_cast < uint32_t > ( f64 . get_bits ( ) ) ; <nl> TEST ( simulator_vneg_32 ) { <nl> Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> HandleScope scope ( isolate ) ; <nl> <nl> - F_iiiii f = FUNCTION_CAST < F_iiiii > ( AssembleCode ( [ ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ ] ( Assembler & assm ) { <nl> __ vmov ( s0 , r0 ) ; <nl> __ vneg ( s0 , s0 ) ; <nl> __ vmov ( r0 , s0 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> for ( Float32 f32 : Float32Inputs ( ) ) { <nl> Float32 res = Float32 : : FromBits ( reinterpret_cast < uint32_t > ( <nl> TEST ( simulator_vneg_64 ) { <nl> Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> HandleScope scope ( isolate ) ; <nl> <nl> - F_iiiii f = FUNCTION_CAST < F_iiiii > ( AssembleCode ( [ ] ( Assembler & assm ) { <nl> + F3 f = AssembleCode ( [ ] ( Assembler & assm ) { <nl> __ vmov ( d0 , r0 , r1 ) ; <nl> __ vneg ( d0 , d0 ) ; <nl> __ vmov ( r1 , r0 , d0 ) ; <nl> - } ) ) ; <nl> + } ) ; <nl> <nl> for ( Float64 f64 : Float64Inputs ( ) ) { <nl> uint32_t p0 = static_cast < uint32_t > ( f64 . get_bits ( ) ) ; <nl> TEST ( simulator_vneg_64 ) { <nl> <nl> # undef __ <nl> <nl> + # endif / / USE_SIMULATOR <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl>
|
Revert " Reland " [ arm ] [ simulator ] Do also execute tests on real hardware " "
|
v8/v8
|
e291c6913e64a31eb5d72bf9481c48962ec831a2
|
2017-10-19T12:09:33Z
|
mmm a / tensorflow / contrib / cmake / CMakeLists . txt <nl> ppp b / tensorflow / contrib / cmake / CMakeLists . txt <nl> if ( WIN32 ) <nl> set ( CMAKE_MODULE_LINKER_FLAGS " $ { CMAKE_MODULE_LINKER_FLAGS } / ignore : 4049 / ignore : 4197 / ignore : 4217 / ignore : 4221 " ) <nl> set ( CMAKE_EXE_LINKER_FLAGS " $ { CMAKE_EXE_LINKER_FLAGS } / ignore : 4049 / ignore : 4197 / ignore : 4217 / ignore : 4221 " ) <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } / MP " ) <nl> - set ( CMAKE_CXX_FLAGS_DEBUG " / D_DEBUG / MDd / Ob0 " ) <nl> + set ( CMAKE_CXX_FLAGS_DEBUG " / D_DEBUG / MDd / Ob2 " ) <nl> set ( CMAKE_CXX_FLAGS_RELEASE " $ { CMAKE_CXX_FLAGS_RELEASE } / D_ITERATOR_DEBUG_LEVEL = 0 " ) <nl> set ( CMAKE_CXX_FLAGS_MINSIZEREL " $ { CMAKE_CXX_FLAGS_MINSIZEREL } / D_ITERATOR_DEBUG_LEVEL = 0 " ) <nl> set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO " $ { CMAKE_CXX_FLAGS_RELWITHDEBINFO } / D_ITERATOR_DEBUG_LEVEL = 0 " ) <nl>
|
Merge pull request from guschmue / win - fix - dbg - build
|
tensorflow/tensorflow
|
1076c0caec7f1fd136b4b7ac407109af7bc0e387
|
2017-06-22T18:21:36Z
|
mmm a / docs / api / menu - item . md <nl> ppp b / docs / api / menu - item . md <nl> See [ ` Menu ` ] ( menu . md ) for examples . <nl> * ` browserWindow ` BrowserWindow <nl> * ` event ` Event <nl> * ` role ` String ( optional ) - Define the action of the menu item , when specified the <nl> - ` click ` property will be ignored . <nl> + ` click ` property will be ignored . See [ roles ] ( # roles ) . <nl> * ` type ` String ( optional ) - Can be ` normal ` , ` separator ` , ` submenu ` , ` checkbox ` or <nl> ` radio ` . <nl> * ` label ` String - ( optional ) <nl> See [ ` Menu ` ] ( menu . md ) for examples . <nl> * ` position ` String ( optional ) - This field allows fine - grained definition of the <nl> specific location within a given menu . <nl> <nl> + # # # Roles <nl> + <nl> + Roles allow menu items to have predefined behaviors . <nl> + <nl> It is best to specify ` role ` for any menu item that matches a standard role , <nl> rather than trying to manually implement the behavior in a ` click ` function . <nl> The built - in ` role ` behavior will give the best native experience . <nl> <nl> - The ` label ` and ` accelerator ` are optional when using a ` role ` and will default <nl> - to appropriate values for each platform . <nl> + The ` label ` and ` accelerator ` values are optional when using a ` role ` and will <nl> + default to appropriate values for each platform . <nl> <nl> The ` role ` property can have following values : <nl> <nl> The ` role ` property can have following values : <nl> * ` resetzoom ` - Reset the focused page ' s zoom level to the original size <nl> * ` zoomin ` - Zoom in the focused page by 10 % <nl> * ` zoomout ` - Zoom out the focused page by 10 % <nl> - <nl> * ` editMenu ` - Whole default " Edit " menu ( Undo , Copy , etc . ) <nl> * ` windowMenu ` - Whole default " Window " menu ( Minimize , Close , etc . ) <nl> <nl> - On macOS ` role ` can also have following additional values : <nl> + The following additional roles are avaiable on macOS : <nl> <nl> * ` about ` - Map to the ` orderFrontStandardAboutPanel ` action <nl> * ` hide ` - Map to the ` hide ` action <nl> On macOS ` role ` can also have following additional values : <nl> * ` help ` - The submenu is a " Help " menu <nl> * ` services ` - The submenu is a " Services " menu <nl> <nl> - When specifying ` role ` on macOS , ` label ` and ` accelerator ` are the only options <nl> - that will affect the MenuItem . All other options will be ignored . <nl> + When specifying a ` role ` on macOS , ` label ` and ` accelerator ` are the only <nl> + options that will affect the menu item . All other options will be ignored . <nl> <nl> # # # Instance Properties <nl> <nl>
|
create a linkable heading for MenuItem roles
|
electron/electron
|
d779ecf6745a6cf08ad6fa4c765dfae2474bb1a7
|
2017-03-30T18:07:25Z
|
mmm a / tensorflow / python / framework / dtypes . py <nl> ppp b / tensorflow / python / framework / dtypes . py <nl> def size ( self ) : <nl> # quantized types . <nl> # TODO ( mrry , keveman ) : Investigate Numpy type registration to replace this <nl> # hard - coding of names . <nl> - _np_qint8 = np . dtype ( [ ( " qint8 " , np . int8 , 1 ) ] ) <nl> - _np_quint8 = np . dtype ( [ ( " quint8 " , np . uint8 , 1 ) ] ) <nl> - _np_qint16 = np . dtype ( [ ( " qint16 " , np . int16 , 1 ) ] ) <nl> - _np_quint16 = np . dtype ( [ ( " quint16 " , np . uint16 , 1 ) ] ) <nl> - _np_qint32 = np . dtype ( [ ( " qint32 " , np . int32 , 1 ) ] ) <nl> + _np_qint8 = np . dtype ( [ ( " qint8 " , np . int8 ) ] ) <nl> + _np_quint8 = np . dtype ( [ ( " quint8 " , np . uint8 ) ] ) <nl> + _np_qint16 = np . dtype ( [ ( " qint16 " , np . int16 ) ] ) <nl> + _np_quint16 = np . dtype ( [ ( " quint16 " , np . uint16 ) ] ) <nl> + _np_qint32 = np . dtype ( [ ( " qint32 " , np . int32 ) ] ) <nl> <nl> # _np_bfloat16 is defined by a module import . <nl> <nl> # Custom struct dtype for directly - fed ResourceHandles of supported type ( s ) . <nl> - np_resource = np . dtype ( [ ( " resource " , np . ubyte , 1 ) ] ) <nl> + np_resource = np . dtype ( [ ( " resource " , np . ubyte ) ] ) <nl> <nl> # Standard mappings between types_pb2 . DataType values and numpy . dtypes . <nl> _NP_TO_TF = { <nl>
|
Fix numpy warning with numpy 1 . 17 . 0 +
|
tensorflow/tensorflow
|
3402d7118460857cf484f57338d14d9113597d15
|
2019-07-10T12:36:56Z
|
mmm a / aten / src / ATen / core / Generator . h <nl> ppp b / aten / src / ATen / core / Generator . h <nl> <nl> * <nl> * By default , there is one generator per device , and a device ' s generator is <nl> * lazily created . A user can use the torch . Generator ( ) api to create their own generator . <nl> - * Currently torch . Generator ( ) can only create a CPUGeneratorImpl . <nl> * / <nl> <nl> / * * <nl> <nl> * Please use the public mutex_ when using any methods from these classes , except for the <nl> * read - only methods . You can learn about the usage by looking into the unittests <nl> * ( aten / src / ATen / cpu_generator_test . cpp ) and other places where we have used lock_guard . <nl> - * <nl> + * <nl> * TODO : Look into changing the threading semantics of Generators in ATen ( e . g . , making <nl> * them non - thread safe and instead making the generator state splittable , to accommodate <nl> * forks into other threads ) . <nl> Generator make_generator ( Args & & . . . args ) { <nl> } <nl> <nl> } / / namespace at <nl> - <nl> mmm a / aten / src / ATen / native / TensorFactories . cpp <nl> ppp b / aten / src / ATen / native / TensorFactories . cpp <nl> Tensor & randperm_out ( Tensor & result , int64_t n ) { <nl> <nl> Tensor & randperm_out_cpu ( Tensor & result , int64_t n , c10 : : optional < Generator > generator ) { <nl> TORCH_CHECK ( n > = 0 , " n must be non - negative , got " , n ) ; <nl> + TORCH_CHECK ( ! generator . has_value ( ) | | ( generator . has_value ( ) & & result . device ( ) = = generator - > device ( ) ) , " Expected a ' " , result . device ( ) , " ' generator device but found ' " , generator - > device ( ) , " ' " ) ; <nl> check_supported_max_int_with_precision ( n , result ) ; <nl> result . resize_ ( { n } ) ; <nl> auto gen = get_generator_or_default < CPUGeneratorImpl > ( generator , detail : : getDefaultCPUGenerator ( ) ) ; <nl> mmm a / aten / src / ATen / native / cuda / TensorFactories . cu <nl> ppp b / aten / src / ATen / native / cuda / TensorFactories . cu <nl> Tensor empty_strided_cuda ( IntArrayRef size , IntArrayRef stride , const TensorOpti <nl> <nl> Tensor & randperm_out_cuda ( Tensor & result , int64_t n , c10 : : optional < Generator > generator ) { <nl> TORCH_CHECK ( n > = 0 , " n must be non - negative , got " , n ) ; <nl> + TORCH_CHECK ( ! generator . has_value ( ) | | ( generator . has_value ( ) & & result . device ( ) = = generator - > device ( ) ) , " Expected a ' " , result . device ( ) , " ' generator device but found ' " , generator - > device ( ) , " ' " ) ; <nl> check_supported_max_int_with_precision ( n , result ) ; <nl> <nl> result . resize_ ( { n } ) ; <nl> mmm a / test / test_tensor_creation_ops . py <nl> ppp b / test / test_tensor_creation_ops . py <nl> def test_logspace_special_steps ( self , device , dtype ) : <nl> self . _test_logspace_base2 ( device , dtype , steps = steps ) <nl> <nl> @ dtypes ( * torch . testing . get_all_dtypes ( include_bool = False , include_half = False , include_complex = False ) ) <nl> - @ dtypesIfCUDA ( * ( ( torch . testing . get_all_int_dtypes ( ) + [ torch . float32 , torch . float16 , torch . bfloat16 ] ) <nl> - if TEST_WITH_ROCM <nl> + @ dtypesIfCUDA ( * ( ( torch . testing . get_all_int_dtypes ( ) + [ torch . float32 , torch . float16 , torch . bfloat16 ] ) <nl> + if TEST_WITH_ROCM <nl> else torch . testing . get_all_dtypes ( include_bool = False , include_half = True , include_complex = False ) ) ) <nl> def test_logspace ( self , device , dtype ) : <nl> _from = random . random ( ) <nl> def test_randperm ( self , device ) : <nl> torch . randperm ( n , out = non_contiguous_tensor ) <nl> self . assertEqual ( non_contiguous_tensor , res ) <nl> <nl> + # Test exceptions when device and generator types are incompatible <nl> + @ onlyCUDA <nl> + def test_randperm_device_compatibility ( self , device ) : <nl> + cuda_gen = torch . Generator ( device = ' cuda ' ) <nl> + cpu_gen = torch . Generator ( device = ' cpu ' ) <nl> + for n in ( 0 , 3 , 100 , 30000 ) : <nl> + regex = ' Expected a . * generator device but found . * ' <nl> + cuda_t = torch . tensor ( n , device = ' cuda ' ) <nl> + self . assertRaisesRegex ( RuntimeError , regex , lambda : torch . randperm ( n , device = ' cuda ' , generator = cpu_gen ) ) <nl> + self . assertRaisesRegex ( RuntimeError , regex , lambda : torch . randperm ( n , device = ' cuda ' , generator = cpu_gen , out = cuda_t ) ) <nl> + cpu_t = torch . tensor ( n , device = ' cpu ' ) <nl> + self . assertRaisesRegex ( RuntimeError , regex , lambda : torch . randperm ( n , device = ' cpu ' , generator = cuda_gen ) ) <nl> + self . assertRaisesRegex ( RuntimeError , regex , lambda : torch . randperm ( n , device = ' cpu ' , generator = cuda_gen , out = cpu_t ) ) <nl> + self . assertRaisesRegex ( RuntimeError , regex , lambda : torch . randperm ( n , generator = cuda_gen ) ) # implicitly on CPU <nl> <nl> # Class for testing * like ops , like torch . ones_like <nl> class TestLikeTensorCreation ( TestCase ) : <nl>
|
randperm : add torch check to ensure generator device = tensor device ( )
|
pytorch/pytorch
|
e4bc785dd57b15ae091eb8e8ca71a604da9b3fb2
|
2020-11-04T16:29:31Z
|
mmm a / dbms / src / Interpreters / InterpreterInsertQuery . cpp <nl> ppp b / dbms / src / Interpreters / InterpreterInsertQuery . cpp <nl> void InterpreterInsertQuery : : execute ( ReadBuffer * remaining_data_istr ) <nl> if ( format . empty ( ) ) <nl> format = " Values " ; <nl> <nl> - / / / Данные могут содержаться в распарсенной и ещё не распарсенной части запроса . <nl> + / / / Данные могут содержаться в распарсенной ( query . data ) и ещё не распарсенной ( remaining_data_istr ) части запроса . <nl> + <nl> + / / / Если данных нет . <nl> + bool has_remaining_data = remaining_data_istr & & ! remaining_data_istr - > eof ( ) ; <nl> + <nl> + if ( ! query . data & & ! has_remaining_data ) <nl> + throw Exception ( " No data to insert " , ErrorCodes : : NO_DATA_TO_INSERT ) ; <nl> + <nl> ConcatReadBuffer : : ReadBuffers buffers ; <nl> - ReadBuffer buf1 ( const_cast < char * > ( query . data ) , query . end - query . data , 0 ) ; <nl> + ReadBuffer buf1 ( const_cast < char * > ( query . data ) , query . data ? query . end - query . data : 0 , 0 ) ; <nl> <nl> - buffers . push_back ( & buf1 ) ; <nl> - if ( remaining_data_istr ) <nl> + if ( query . data ) <nl> + buffers . push_back ( & buf1 ) ; <nl> + if ( has_remaining_data ) <nl> buffers . push_back ( remaining_data_istr ) ; <nl> <nl> ConcatReadBuffer istr ( buffers ) ; <nl>
|
dbms : fixed error when inserting empty data ( using HTTP protocol ) [ # CONV - 2944 ] .
|
ClickHouse/ClickHouse
|
77026f581ff9c7e0093d12a4fd0b0d2604e18f6a
|
2013-02-20T23:24:17Z
|
mmm a / src / ccstruct / imagedata . cpp <nl> ppp b / src / ccstruct / imagedata . cpp <nl> bool WordFeature : : Serialize ( FILE * fp ) const { <nl> } <nl> <nl> / / Reads from the given file . Returns false in case of error . <nl> + / / If swap is true , assumes a big / little - endian swap is needed . <nl> bool WordFeature : : DeSerialize ( bool swap , FILE * fp ) { <nl> if ( ! tesseract : : DeSerialize ( fp , & x_ ) ) return false ; <nl> if ( swap ) ReverseN ( & x_ , sizeof ( x_ ) ) ; <nl> bool ImageData : : Serialize ( TFile * fp ) const { <nl> } <nl> <nl> / / Reads from the given file . Returns false in case of error . <nl> - / / If swap is true , assumes a big / little - endian swap is needed . <nl> bool ImageData : : DeSerialize ( TFile * fp ) { <nl> if ( ! imagefilename_ . DeSerialize ( fp ) ) return false ; <nl> if ( ! fp - > DeSerialize ( & page_number_ ) ) return false ; <nl>
|
Move comment about swap meaning for DeSerialize to correct function
|
tesseract-ocr/tesseract
|
e7e6999d3b18f9c50c2ccc3e82247f50e9f35e76
|
2020-05-13T06:02:59Z
|
mmm a / Makefile <nl> ppp b / Makefile <nl> ifdef ASSERT_STATUS_CHECKED <nl> crc32c_test \ <nl> dbformat_test \ <nl> db_basic_test \ <nl> + db_with_timestamp_basic_test \ <nl> + db_with_timestamp_compaction_test \ <nl> db_options_test \ <nl> options_file_test \ <nl> defer_test \ <nl> mmm a / db / db_impl / db_impl_compaction_flush . cc <nl> ppp b / db / db_impl / db_impl_compaction_flush . cc <nl> Status DBImpl : : CompactFilesImpl ( <nl> <nl> Status status = compaction_job . Install ( * c - > mutable_cf_options ( ) ) ; <nl> if ( status . ok ( ) ) { <nl> + assert ( compaction_job . io_status ( ) . ok ( ) ) ; <nl> InstallSuperVersionAndScheduleWork ( c - > column_family_data ( ) , <nl> & job_context - > superversion_contexts [ 0 ] , <nl> * c - > mutable_cf_options ( ) ) ; <nl> mmm a / db / db_with_timestamp_basic_test . cc <nl> ppp b / db / db_with_timestamp_basic_test . cc <nl> TEST_F ( DBBasicTestWithTimestamp , ReseekToNextUserKey ) { <nl> { <nl> std : : string ts_str = Timestamp ( static_cast < uint64_t > ( kNumKeys + 1 ) , 0 ) ; <nl> WriteBatch batch ( 0 , 0 , kTimestampSize ) ; <nl> - batch . Put ( " a " , " new_value " ) ; <nl> - batch . Put ( " b " , " new_value " ) ; <nl> + ASSERT_OK ( batch . Put ( " a " , " new_value " ) ) ; <nl> + ASSERT_OK ( batch . Put ( " b " , " new_value " ) ) ; <nl> s = batch . AssignTimestamp ( ts_str ) ; <nl> ASSERT_OK ( s ) ; <nl> s = db_ - > Write ( write_opts , & batch ) ; <nl> TEST_P ( DBBasicTestWithTimestampCompressionSettings , PutAndGetWithCompaction ) { <nl> / / at higher levels . <nl> CompactionOptions compact_opt ; <nl> compact_opt . compression = kNoCompression ; <nl> - db_ - > CompactFiles ( compact_opt , handles_ [ cf ] , <nl> - collector - > GetFlushedFiles ( ) , <nl> - static_cast < int > ( kNumTimestamps - i ) ) ; <nl> + ASSERT_OK ( db_ - > CompactFiles ( compact_opt , handles_ [ cf ] , <nl> + collector - > GetFlushedFiles ( ) , <nl> + static_cast < int > ( kNumTimestamps - i ) ) ) ; <nl> collector - > ClearFlushedFiles ( ) ; <nl> } <nl> } <nl> TEST_F ( DBBasicTestWithTimestamp , BatchWriteAndMultiGet ) { <nl> batch . Put ( handles_ [ cf ] , Key1 ( j ) , <nl> " value_ " + std : : to_string ( j ) + " _ " + std : : to_string ( i ) ) ) ; <nl> } <nl> - batch . AssignTimestamp ( write_ts ) ; <nl> + ASSERT_OK ( batch . AssignTimestamp ( write_ts ) ) ; <nl> ASSERT_OK ( db_ - > Write ( wopts , & batch ) ) ; <nl> <nl> verify_records_func ( i , handles_ [ cf ] ) ; <nl> mmm a / db / error_handler . cc <nl> ppp b / db / error_handler . cc <nl> Status ErrorHandler : : SetBGError ( const IOStatus & bg_io_err , <nl> Status s ; <nl> DBRecoverContext context ; <nl> if ( bg_io_err . GetDataLoss ( ) ) { <nl> - / / FIrst , data loss is treated as unrecoverable error . So it can directly <nl> + / / First , data loss is treated as unrecoverable error . So it can directly <nl> / / overwrite any existing bg_error_ . <nl> bool auto_recovery = false ; <nl> Status bg_err ( new_bg_io_err , Status : : Severity : : kUnrecoverableError ) ; <nl> mmm a / table / block_based / block_based_table_builder . cc <nl> ppp b / table / block_based / block_based_table_builder . cc <nl> void BlockBasedTableBuilder : : Add ( const Slice & key , const Slice & value ) { <nl> if ( r - > props . num_entries > r - > props . num_range_deletions ) { <nl> assert ( r - > internal_comparator . Compare ( key , Slice ( r - > last_key ) ) > 0 ) ; <nl> } <nl> - # endif / / NDEBUG <nl> + # endif / / ! NDEBUG <nl> <nl> auto should_flush = r - > flush_block_policy - > Update ( key , value ) ; <nl> if ( should_flush ) { <nl> Status BlockBasedTableBuilder : : Finish ( ) { <nl> r - > pc_rep - > write_queue . finish ( ) ; <nl> r - > pc_rep - > write_thread - > join ( ) ; <nl> r - > pc_rep - > finished = true ; <nl> + # ifndef NDEBUG <nl> + for ( const auto & br : r - > pc_rep - > block_rep_buf ) { <nl> + assert ( br . status . ok ( ) ) ; <nl> + } <nl> + # endif / / ! NDEBUG <nl> } else { <nl> / / To make sure properties block is able to keep the accurate size of index <nl> / / block , we will finish writing all index entries first . <nl> mmm a / table / block_based / block_based_table_reader . cc <nl> ppp b / table / block_based / block_based_table_reader . cc <nl> bool BlockBasedTable : : PrefixMayMatch ( <nl> } <nl> <nl> bool may_match = true ; <nl> - Status s ; <nl> <nl> / / First , try check with full filter <nl> FilterBlockReader * const filter = rep_ - > filter . get ( ) ; <nl> void BlockBasedTable : : MultiGet ( const ReadOptions & read_options , <nl> read_options , results [ idx_in_batch ] , & first_biter , <nl> statuses [ idx_in_batch ] ) ; <nl> reusing_block = false ; <nl> + } else { <nl> + / / If handler is null and result is empty , then the status is never <nl> + / / set , which should be the initial value : ok ( ) . <nl> + assert ( statuses [ idx_in_batch ] . ok ( ) ) ; <nl> } <nl> biter = & first_biter ; <nl> idx_in_batch + + ; <nl> mmm a / table / multiget_context . h <nl> ppp b / table / multiget_context . h <nl> struct KeyContext { <nl> class MultiGetContext { <nl> public : <nl> / / Limit the number of keys in a batch to this number . Benchmarks show that <nl> - / / there is negligible benefit for batches exceeding this . Keeping this < 64 <nl> + / / there is negligible benefit for batches exceeding this . Keeping this < 32 <nl> / / simplifies iteration , as well as reduces the amount of stack allocations <nl> - / / htat need to be performed <nl> + / / that need to be performed <nl> static const int MAX_BATCH_SIZE = 32 ; <nl> <nl> MultiGetContext ( autovector < KeyContext * , MAX_BATCH_SIZE > * sorted_keys , <nl>
|
Status check enforcement for timestamp_basic_test ( )
|
facebook/rocksdb
|
1bdaef7a06ee2fc147f1188cec6781905849c71b
|
2020-09-30T01:23:27Z
|
mmm a / Marlin / language_cz . h <nl> ppp b / Marlin / language_cz . h <nl> <nl> # define MSG_AUTOSTART " Autostart " <nl> # define MSG_DISABLE_STEPPERS " Uvolnit motory " <nl> # define MSG_AUTO_HOME " Domovska pozice " <nl> - # define MSG_LEVEL_BED_HOMING " Homing " <nl> + # define MSG_LEVEL_BED_HOMING " Mereni podlozky " <nl> # define MSG_SET_HOME_OFFSETS " Nastavit ofsety " <nl> # define MSG_SET_ORIGIN " Nastavit pocatek " <nl> # define MSG_PREHEAT_PLA " Zahrat PLA " <nl>
|
Update language_cz . h
|
MarlinFirmware/Marlin
|
daa52124b0985d7084c3dec4fb7cc48c027d1f83
|
2016-03-19T19:43:28Z
|
mmm a / tensorflow / go / op / wrappers . go <nl> ppp b / tensorflow / go / op / wrappers . go <nl> func DepthwiseConv2dNativeBackpropFilter ( scope * Scope , input tf . Output , filter_s <nl> return op . Output ( 0 ) <nl> } <nl> <nl> + / / Returns immutable tensor from memory region . <nl> + / / <nl> + / / The current implementation memmaps the tensor from a file . <nl> + / / <nl> + / / Arguments : <nl> + / / dtype : Type of the returned tensor . <nl> + / / shape : Shape of the returned tensor . <nl> + / / memory_region_name : Name of readonly memory region used by the tensor , see <nl> + / / NewReadOnlyMemoryRegionFromFile in tensorflow : : Env . <nl> + func ImmutableConst ( scope * Scope , dtype tf . DataType , shape tf . Shape , memory_region_name string ) ( tensor tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { " dtype " : dtype , " shape " : shape , " memory_region_name " : memory_region_name } <nl> + opspec : = tf . OpSpec { <nl> + Type : " ImmutableConst " , <nl> + <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / StringJoinAttr is an optional argument to StringJoin . <nl> + type StringJoinAttr func ( optionalAttr ) <nl> + <nl> + / / StringJoinSeparator sets the optional separator attribute to value . <nl> + / / <nl> + / / value : string , an optional join separator . <nl> + / / If not specified , defaults to " " <nl> + func StringJoinSeparator ( value string ) StringJoinAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " separator " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Joins the strings in the given list of string tensors into one tensor ; <nl> + / / <nl> + / / with the given separator ( default is an empty separator ) . <nl> + / / <nl> + / / Arguments : <nl> + / / inputs : A list of string tensors . The tensors must all have the same shape , <nl> + / / or be scalars . Scalars may be mixed in ; these will be broadcast to the shape <nl> + / / of non - scalar inputs . <nl> + func StringJoin ( scope * Scope , inputs [ ] tf . Output , optional . . . StringJoinAttr ) ( output tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " StringJoin " , <nl> + Input : [ ] tf . Input { <nl> + tf . OutputList ( inputs ) , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> / / LRNGradAttr is an optional argument to LRNGrad . <nl> type LRNGradAttr func ( optionalAttr ) <nl> <nl> func DeserializeManySparse ( scope * Scope , serialized_sparse tf . Output , dtype tf . D <nl> return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) <nl> } <nl> <nl> - / / StringJoinAttr is an optional argument to StringJoin . <nl> - type StringJoinAttr func ( optionalAttr ) <nl> - <nl> - / / StringJoinSeparator sets the optional separator attribute to value . <nl> - / / <nl> - / / value : string , an optional join separator . <nl> - / / If not specified , defaults to " " <nl> - func StringJoinSeparator ( value string ) StringJoinAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " separator " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Joins the strings in the given list of string tensors into one tensor ; <nl> - / / <nl> - / / with the given separator ( default is an empty separator ) . <nl> - / / <nl> - / / Arguments : <nl> - / / inputs : A list of string tensors . The tensors must all have the same shape , <nl> - / / or be scalars . Scalars may be mixed in ; these will be broadcast to the shape <nl> - / / of non - scalar inputs . <nl> - func StringJoin ( scope * Scope , inputs [ ] tf . Output , optional . . . StringJoinAttr ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " StringJoin " , <nl> - Input : [ ] tf . Input { <nl> - tf . OutputList ( inputs ) , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / Returns immutable tensor from memory region . <nl> - / / <nl> - / / The current implementation memmaps the tensor from a file . <nl> - / / <nl> - / / Arguments : <nl> - / / dtype : Type of the returned tensor . <nl> - / / shape : Shape of the returned tensor . <nl> - / / memory_region_name : Name of readonly memory region used by the tensor , see <nl> - / / NewReadOnlyMemoryRegionFromFile in tensorflow : : Env . <nl> - func ImmutableConst ( scope * Scope , dtype tf . DataType , shape tf . Shape , memory_region_name string ) ( tensor tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { " dtype " : dtype , " shape " : shape , " memory_region_name " : memory_region_name } <nl> - opspec : = tf . OpSpec { <nl> - Type : " ImmutableConst " , <nl> - <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Inverse real - valued fast Fourier transform . <nl> / / <nl> / / Computes the inverse 1 - dimensional discrete Fourier transform of a real - valued <nl> func LatencyStatsDataset ( scope * Scope , input_dataset tf . Output , tag tf . Output , o <nl> return op . Output ( 0 ) <nl> } <nl> <nl> + / / Runs multiple additive regression ensemble predictors on input instances and <nl> + / / <nl> + / / computes the update to cached logits . It is designed to be used during training . <nl> + / / It traverses the trees starting from cached tree id and cached node id and <nl> + / / calculates the updates to be pushed to the cache . <nl> + / / <nl> + / / Arguments : <nl> + / / <nl> + / / cached_tree_ids : Rank 1 Tensor containing cached tree ids which is the starting <nl> + / / tree of prediction . <nl> + / / cached_node_ids : Rank 1 Tensor containing cached node id which is the starting <nl> + / / node of prediction . <nl> + / / bucketized_features : A list of rank 1 Tensors containing bucket id for each <nl> + / / feature . <nl> + / / logits_dimension : scalar , dimension of the logits , to be used for partial logits <nl> + / / shape . <nl> + / / <nl> + / / Returns Rank 2 Tensor containing logits update ( with respect to cached <nl> + / / values stored ) for each example . Rank 1 Tensor containing new tree ids for each example . Rank 1 Tensor containing new node ids in the new tree_ids . <nl> + func BoostedTreesTrainingPredict ( scope * Scope , tree_ensemble_handle tf . Output , cached_tree_ids tf . Output , cached_node_ids tf . Output , bucketized_features [ ] tf . Output , logits_dimension int64 ) ( partial_logits tf . Output , tree_ids tf . Output , node_ids tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { " logits_dimension " : logits_dimension } <nl> + opspec : = tf . OpSpec { <nl> + Type : " BoostedTreesTrainingPredict " , <nl> + Input : [ ] tf . Input { <nl> + tree_ensemble_handle , cached_tree_ids , cached_node_ids , tf . OutputList ( bucketized_features ) , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) <nl> + } <nl> + <nl> / / MapSizeAttr is an optional argument to MapSize . <nl> type MapSizeAttr func ( optionalAttr ) <nl> <nl> func BoostedTreesDeserializeEnsemble ( scope * Scope , tree_ensemble_handle tf . Outpu <nl> return scope . AddOperation ( opspec ) <nl> } <nl> <nl> - / / Runs multiple additive regression ensemble predictors on input instances and <nl> - / / <nl> - / / computes the update to cached logits . It is designed to be used during training . <nl> - / / It traverses the trees starting from cached tree id and cached node id and <nl> - / / calculates the updates to be pushed to the cache . <nl> - / / <nl> - / / Arguments : <nl> - / / <nl> - / / cached_tree_ids : Rank 1 Tensor containing cached tree ids which is the starting <nl> - / / tree of prediction . <nl> - / / cached_node_ids : Rank 1 Tensor containing cached node id which is the starting <nl> - / / node of prediction . <nl> - / / bucketized_features : A list of rank 1 Tensors containing bucket id for each <nl> - / / feature . <nl> - / / logits_dimension : scalar , dimension of the logits , to be used for partial logits <nl> - / / shape . <nl> - / / <nl> - / / Returns Rank 2 Tensor containing logits update ( with respect to cached <nl> - / / values stored ) for each example . Rank 1 Tensor containing new tree ids for each example . Rank 1 Tensor containing new node ids in the new tree_ids . <nl> - func BoostedTreesTrainingPredict ( scope * Scope , tree_ensemble_handle tf . Output , cached_tree_ids tf . Output , cached_node_ids tf . Output , bucketized_features [ ] tf . Output , logits_dimension int64 ) ( partial_logits tf . Output , tree_ids tf . Output , node_ids tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { " logits_dimension " : logits_dimension } <nl> - opspec : = tf . OpSpec { <nl> - Type : " BoostedTreesTrainingPredict " , <nl> - Input : [ ] tf . Input { <nl> - tree_ensemble_handle , cached_tree_ids , cached_node_ids , tf . OutputList ( bucketized_features ) , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) <nl> - } <nl> - <nl> / / Elementwise computes the bitwise AND of ` x ` and ` y ` . <nl> / / <nl> / / The result will have those bits set , that are set in both ` x ` and ` y ` . The <nl>
|
Go : Update generated wrapper functions for TensorFlow ops .
|
tensorflow/tensorflow
|
fba60ec27f4d415dafdf2ee916e2aa2004fa9635
|
2018-06-08T00:55:30Z
|
mmm a / examples / directx11_example / imgui_impl_dx11 . cpp <nl> ppp b / examples / directx11_example / imgui_impl_dx11 . cpp <nl> bool ImGui_ImplDX11_CreateDeviceObjects ( ) <nl> return output ; \ <nl> } " ; <nl> <nl> - D3DCompile ( vertexShader , strlen ( vertexShader ) , NULL , NULL , NULL , " main " , " vs_5_0 " , 0 , 0 , & g_pVertexShaderBlob , NULL ) ; <nl> + D3DCompile ( vertexShader , strlen ( vertexShader ) , NULL , NULL , NULL , " main " , " vs_4_0 " , 0 , 0 , & g_pVertexShaderBlob , NULL ) ; <nl> if ( g_pVertexShaderBlob = = NULL ) / / NB : Pass ID3D10Blob * pErrorBlob to D3DCompile ( ) to get error showing in ( const char * ) pErrorBlob - > GetBufferPointer ( ) . Make sure to Release ( ) the blob ! <nl> return false ; <nl> if ( g_pd3dDevice - > CreateVertexShader ( ( DWORD * ) g_pVertexShaderBlob - > GetBufferPointer ( ) , g_pVertexShaderBlob - > GetBufferSize ( ) , NULL , & g_pVertexShader ) ! = S_OK ) <nl> bool ImGui_ImplDX11_CreateDeviceObjects ( ) <nl> return out_col ; \ <nl> } " ; <nl> <nl> - D3DCompile ( pixelShader , strlen ( pixelShader ) , NULL , NULL , NULL , " main " , " ps_5_0 " , 0 , 0 , & g_pPixelShaderBlob , NULL ) ; <nl> + D3DCompile ( pixelShader , strlen ( pixelShader ) , NULL , NULL , NULL , " main " , " ps_4_0 " , 0 , 0 , & g_pPixelShaderBlob , NULL ) ; <nl> if ( g_pPixelShaderBlob = = NULL ) / / NB : Pass ID3D10Blob * pErrorBlob to D3DCompile ( ) to get error showing in ( const char * ) pErrorBlob - > GetBufferPointer ( ) . Make sure to Release ( ) the blob ! <nl> return false ; <nl> if ( g_pd3dDevice - > CreatePixelShader ( ( DWORD * ) g_pPixelShaderBlob - > GetBufferPointer ( ) , g_pPixelShaderBlob - > GetBufferSize ( ) , NULL , & g_pPixelShader ) ! = S_OK ) <nl>
|
Merge pull request from RaptorFactor / master
|
ocornut/imgui
|
fe2972e8b2bd4ff158307322825039c4a9ea135d
|
2015-11-30T19:36:06Z
|
mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> void Genesis : : InitializeGlobal ( Handle < JSGlobalObject > global_object , <nl> Handle < JSObject > json_object = factory - > NewJSObject ( cons , TENURED ) ; <nl> DCHECK ( json_object - > IsJSObject ( ) ) ; <nl> JSObject : : AddProperty ( global , name , json_object , DONT_ENUM ) ; <nl> - SimpleInstallFunction ( json_object , " parse " , Builtins : : kJsonParse , 2 , true ) ; <nl> + SimpleInstallFunction ( json_object , " parse " , Builtins : : kJsonParse , 2 , false ) ; <nl> SimpleInstallFunction ( json_object , " stringify " , Builtins : : kJsonStringify , 3 , <nl> true ) ; <nl> JSObject : : AddProperty ( <nl> mmm a / src / builtins . cc <nl> ppp b / src / builtins . cc <nl> BUILTIN ( JsonParse ) { <nl> Handle < String > string ; <nl> ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , string , <nl> Object : : ToString ( isolate , source ) ) ; <nl> + string = String : : Flatten ( string ) ; <nl> RETURN_RESULT_OR_FAILURE ( <nl> isolate , string - > IsSeqOneByteString ( ) <nl> ? JsonParser < true > : : Parse ( isolate , string , reviver ) <nl>
|
[ json ] Repair JSON . parse regression with non - sequential strings .
|
v8/v8
|
e3c3be36eee9aa413fa309d5df88a2f18f24d2a1
|
2016-06-03T18:42:29Z
|
mmm a / java / carrier / pom . xml <nl> ppp b / java / carrier / pom . xml <nl> <nl> < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > carrier < / artifactId > <nl> - < version > 1 . 25 < / version > <nl> + < version > 1 . 26 - SNAPSHOT < / version > <nl> < packaging > jar < / packaging > <nl> < url > https : / / github . com / googlei18n / libphonenumber / < / url > <nl> <nl> < parent > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / parent > <nl> <nl> < build > <nl> <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / dependency > <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > prefixmapper < / artifactId > <nl> - < version > 2 . 35 < / version > <nl> + < version > 2 . 36 - SNAPSHOT < / version > <nl> < / dependency > <nl> < / dependencies > <nl> <nl> mmm a / java / demo / pom . xml <nl> ppp b / java / demo / pom . xml <nl> <nl> < parent > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / parent > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > demo < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> <nl> < properties > <nl> < gae . version > 1 . 9 . 32 < / gae . version > <nl> <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / dependency > <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > geocoder < / artifactId > <nl> - < version > 2 . 35 < / version > <nl> + < version > 2 . 36 - SNAPSHOT < / version > <nl> < / dependency > <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > carrier < / artifactId > <nl> - < version > 1 . 25 < / version > <nl> + < version > 1 . 26 - SNAPSHOT < / version > <nl> < / dependency > <nl> < / dependencies > <nl> <nl> mmm a / java / geocoder / pom . xml <nl> ppp b / java / geocoder / pom . xml <nl> <nl> < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > geocoder < / artifactId > <nl> - < version > 2 . 35 < / version > <nl> + < version > 2 . 36 - SNAPSHOT < / version > <nl> < packaging > jar < / packaging > <nl> < url > https : / / github . com / googlei18n / libphonenumber / < / url > <nl> <nl> < parent > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / parent > <nl> <nl> < build > <nl> <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / dependency > <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > prefixmapper < / artifactId > <nl> - < version > 2 . 35 < / version > <nl> + < version > 2 . 36 - SNAPSHOT < / version > <nl> < / dependency > <nl> < / dependencies > <nl> <nl> mmm a / java / internal / prefixmapper / pom . xml <nl> ppp b / java / internal / prefixmapper / pom . xml <nl> <nl> < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > prefixmapper < / artifactId > <nl> - < version > 2 . 35 < / version > <nl> + < version > 2 . 36 - SNAPSHOT < / version > <nl> < packaging > jar < / packaging > <nl> < url > https : / / github . com / googlei18n / libphonenumber / < / url > <nl> <nl> < parent > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < relativePath > . . / . . / pom . xml < / relativePath > <nl> < / parent > <nl> <nl> <nl> < dependency > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / dependency > <nl> < / dependencies > <nl> <nl> mmm a / java / libphonenumber / pom . xml <nl> ppp b / java / libphonenumber / pom . xml <nl> <nl> < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < packaging > jar < / packaging > <nl> < url > https : / / github . com / googlei18n / libphonenumber / < / url > <nl> <nl> < parent > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < / parent > <nl> <nl> < build > <nl> mmm a / java / pom . xml <nl> ppp b / java / pom . xml <nl> <nl> < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> < groupId > com . googlecode . libphonenumber < / groupId > <nl> < artifactId > libphonenumber - parent < / artifactId > <nl> - < version > 7 . 2 . 5 < / version > <nl> + < version > 7 . 2 . 6 - SNAPSHOT < / version > <nl> < packaging > pom < / packaging > <nl> < url > https : / / github . com / googlei18n / libphonenumber / < / url > <nl> <nl>
|
[ maven - release - plugin ] prepare for next development iteration
|
google/libphonenumber
|
07b59cb032a44b080e8d9624d7b8acddddc4feb7
|
2016-02-11T09:51:39Z
|
mmm a / Marlin / src / feature / mixing . cpp <nl> ppp b / Marlin / src / feature / mixing . cpp <nl> float mixing_factor [ MIXING_STEPPERS ] ; / / Reciprocal of mix proportion . 0 . 0 = off <nl> float mixing_virtual_tool_mix [ MIXING_VIRTUAL_TOOLS ] [ MIXING_STEPPERS ] ; <nl> <nl> void mixing_tools_init ( ) { <nl> - / / Initialize mixing to 100 % color 1 <nl> - for ( uint8_t i = 0 ; i < MIXING_STEPPERS ; i + + ) <nl> - mixing_factor [ i ] = ( i = = 0 ) ? 1 . 0 : 0 . 0 ; <nl> - for ( uint8_t t = 0 ; t < MIXING_VIRTUAL_TOOLS ; t + + ) <nl> + / / Virtual Tools 0 , 1 , 2 , 3 = Filament 1 , 2 , 3 , 4 , etc . <nl> + for ( uint8_t t = 0 ; t < MIXING_VIRTUAL_TOOLS & & t < MIXING_STEPPERS ; t + + ) <nl> for ( uint8_t i = 0 ; i < MIXING_STEPPERS ; i + + ) <nl> - mixing_virtual_tool_mix [ t ] [ i ] = mixing_factor [ i ] ; <nl> + mixing_virtual_tool_mix [ t ] [ i ] = ( t = = i ) ? 1 . 0 : 0 . 0 ; <nl> + <nl> + / / Remaining virtual tools are 100 % filament 1 <nl> + # if MIXING_STEPPERS < MIXING_VIRTUAL_TOOLS <nl> + for ( uint8_t t = MIXING_STEPPERS ; t < MIXING_VIRTUAL_TOOLS ; t + + ) <nl> + for ( uint8_t i = 0 ; i < MIXING_STEPPERS ; i + + ) <nl> + mixing_virtual_tool_mix [ t ] [ i ] = ( i = = 0 ) ? 1 . 0 : 0 . 0 ; <nl> + # endif <nl> + <nl> + / / Initialize mixing to tool 0 color <nl> + for ( uint8_t i = 0 ; i < MIXING_STEPPERS ; i + + ) <nl> + mixing_factor [ i ] = mixing_virtual_tool_mix [ 0 ] [ i ] ; <nl> } <nl> <nl> # endif / / MIXING_VIRTUAL_TOOLS > 1 <nl>
|
Init MIXING virtual tools as switching
|
MarlinFirmware/Marlin
|
e34c6827ead09b79cb1ae84664bf0aa5b480373c
|
2017-11-25T00:02:09Z
|
mmm a / utils / build - script <nl> ppp b / utils / build - script <nl> import shutil <nl> import sys <nl> import textwrap <nl> <nl> + # FIXME : Instead of modifying the system path in order to enable imports from <nl> + # other directories , all Python modules related to the build script <nl> + # should be moved to the ` swift_build_support ` module . <nl> + # For additional information , see : https : / / bugs . swift . org / browse / SR - 237 . <nl> sys . path . append ( os . path . dirname ( __file__ ) ) <nl> - <nl> from SwiftBuildSupport import ( <nl> HOME , <nl> SWIFT_BUILD_ROOT , <nl> from SwiftBuildSupport import ( <nl> quote_shell_command , <nl> ) <nl> <nl> + sys . path . append ( os . path . join ( os . path . dirname ( __file__ ) , ' swift_build_support ' ) ) <nl> + import swift_build_support . clang <nl> + from swift_build_support . migration import migrate_impl_args <nl> + <nl> + <nl> # Main entry point for the preset mode . <nl> def main_preset ( ) : <nl> parser = argparse . ArgumentParser ( <nl> the number of parallel build jobs to use " " " , <nl> dest = " build_jobs " , <nl> default = multiprocessing . cpu_count ( ) ) <nl> <nl> + parser . add_argument ( " - - darwin - xcrun - toolchain " , <nl> + help = " the name of the toolchain to use on Darwin " , <nl> + default = " default " ) <nl> + <nl> parser . add_argument ( " - - extra - swift - args " , help = textwrap . dedent ( " " " <nl> Pass through extra flags to swift in the form of a cmake list ' module_regexp ; flag ' . Can <nl> be called multiple times to add multiple such module_regexp flag pairs . All semicolons <nl> the number of parallel build jobs to use " " " , <nl> help = " " , <nl> nargs = " * " ) <nl> <nl> - args = parser . parse_args ( ) <nl> + args = parser . parse_args ( migrate_impl_args ( sys . argv [ 1 : ] , [ <nl> + ' - - darwin - xcrun - toolchain ' ] ) ) <nl> <nl> # Build cmark if any cmark - related options were specified . <nl> if ( args . cmark_build_variant is not None ) : <nl> the number of parallel build jobs to use " " " , <nl> if args . clean : <nl> shutil . rmtree ( build_dir ) <nl> <nl> + host_clang = swift_build_support . clang . host_clang ( <nl> + xcrun_toolchain = args . darwin_xcrun_toolchain ) <nl> + if not host_clang : <nl> + print_with_argv0 ( <nl> + " Can ' t find clang . Please install clang - 3 . 5 or a later version . " ) <nl> + return 1 <nl> build_script_impl_args = [ <nl> os . path . join ( SWIFT_SOURCE_ROOT , " swift " , " utils " , " build - script - impl " ) , <nl> " - - build - dir " , build_dir , <nl> + " - - host - cc " , host_clang . cc , <nl> + " - - host - cxx " , host_clang . cxx , <nl> + " - - darwin - xcrun - toolchain " , args . darwin_xcrun_toolchain , <nl> " - - cmark - build - type " , args . cmark_build_variant , <nl> " - - llvm - build - type " , args . llvm_build_variant , <nl> " - - swift - build - type " , args . swift_build_variant , <nl> mmm a / utils / build - script - impl <nl> ppp b / utils / build - script - impl <nl> KNOWN_SETTINGS = ( <nl> # name default description <nl> build - args " " " arguments to the build tool ; defaults to - j8 when CMake generator is \ " Unix Makefiles \ " " <nl> build - dir " " " out - of - tree build directory ; default is in - tree . * * This argument is required * * " <nl> + host - cc " " " the path to CC , the ' clang ' compiler for the host platform . * * This argument is requied * * " <nl> + host - cxx " " " the path to CXX , the ' clang + + ' compiler for the host platform . * * This argument is requied * * " <nl> darwin - xcrun - toolchain " default " " the name of the toolchain to use on Darwin " <nl> build - ninja " " " build the Ninja tool " <nl> cmark - build - type " Debug " " the CMake build variant for CommonMark ( Debug , RelWithDebInfo , Release , MinSizeRel ) . Defaults to Debug . " <nl> if [ [ " $ { EXPORT_COMPILE_COMMANDS } " ] ] ; then <nl> ) <nl> fi <nl> <nl> - if [ - z " $ { HOST_CC } " ] ; then <nl> - if [ " $ ( uname - s ) " = = " Darwin " ] ; then <nl> - HOST_CC = " $ ( xcrun_find_tool clang ) " <nl> - HOST_CXX = " $ ( xcrun_find_tool clang + + ) " <nl> - elif [ " $ ( uname - s ) " = = " FreeBSD " ] ; then <nl> - if [ $ ( sysctl - n kern . osreldate ) - ge 1100000 ] ; then <nl> - HOST_CC = " clang " <nl> - HOST_CXX = " clang + + " <nl> - else <nl> - for clang_candidate_suffix in " 38 " " 37 " " 36 " " 35 " ; do <nl> - if which " clang $ { clang_candidate_suffix } " > / dev / null ; then <nl> - HOST_CC = " clang $ { clang_candidate_suffix } " <nl> - HOST_CXX = " clang + + $ { clang_candidate_suffix } " <nl> - break <nl> - fi <nl> - done <nl> - fi <nl> - else <nl> - for clang_candidate_suffix in " " " - 3 . 8 " " - 3 . 7 " " - 3 . 6 " " - 3 . 5 " ; do <nl> - if which " clang $ { clang_candidate_suffix } " > / dev / null ; then <nl> - HOST_CC = " clang $ { clang_candidate_suffix } " <nl> - HOST_CXX = " clang + + $ { clang_candidate_suffix } " <nl> - break <nl> - fi <nl> - done <nl> - fi <nl> - fi <nl> + # FIXME : HOST_CC is set and its presence is validated by utils / build - script . <nl> + # This check is redundant , but must remain until build - script - impl <nl> + # is merged completely with utils / build - script . <nl> + # For additional information , see : https : / / bugs . swift . org / browse / SR - 237 <nl> if [ - z " $ { HOST_CC } " ] ; then <nl> echo " Can ' t find clang . Please install clang - 3 . 5 or a later version . " <nl> exit 1 <nl> new file mode 100644 <nl> index 000000000000 . . 5746cb0174ce <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / README . md <nl> <nl> + # swift_build_support <nl> + <nl> + ` swift_build_support ` is a Python module containing functions and data <nl> + structures used by the Swift build script . <nl> + <nl> + You may run unit tests for ` swift_build_support ` from the command line : <nl> + <nl> + ` ` ` sh <nl> + apple / swift $ python - m unittest discover - s utils / swift_build_support <nl> + ` ` ` <nl> new file mode 100644 <nl> index 000000000000 . . b90cf8b9b2bb <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / swift_build_support / __init__ . py <nl> <nl> + # swift_build_support / __init__ . py - Helpers for building Swift - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # This file needs to be here in order for Python to treat the <nl> + # utils / swift_build_support / directory as a module . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> new file mode 100644 <nl> index 000000000000 . . c2a39acb0835 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / swift_build_support / clang . py <nl> <nl> + # swift_build_support / clang . py - Detect host machine ' s Clang - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # Find the path to a Clang executable on the host machine that is most <nl> + # suitable for building Swift . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + from __future__ import absolute_import <nl> + <nl> + import collections <nl> + import platform <nl> + import subprocess <nl> + <nl> + from . import xcrun <nl> + from . which import which <nl> + <nl> + <nl> + # A named tuple consisting of two paths : <nl> + # 1 . ' cc ' is the path to a program used for compiling C . <nl> + # 2 . ' cxx ' is the path to a program used for compiling C + + . <nl> + CompilerExecutable = collections . namedtuple ( ' CompilerExecutable ' , ' cc cxx ' ) <nl> + <nl> + <nl> + def _freebsd_release_date ( ) : <nl> + " " " <nl> + Return the release date for FreeBSD operating system on this host . <nl> + If the release date cannot be ascertained , return None . <nl> + " " " <nl> + try : <nl> + # For details on ` sysctl ` , see : <nl> + # http : / / www . freebsd . org / cgi / man . cgi ? sysctl ( 8 ) <nl> + return int ( subprocess . check_output ( <nl> + [ ' sysctl ' , ' - n ' , ' kern . osreldate ' ] ) . rstrip ( ) ) <nl> + except subprocess . CalledProcessError : <nl> + return None <nl> + <nl> + <nl> + def _first_clang ( suffixes ) : <nl> + " " " <nl> + Return a CompilerExecutable with the first available versions of clang <nl> + and clang + + , searching in the order of the given suffixes . <nl> + <nl> + If no Clang executables are found , return None . <nl> + " " " <nl> + for suffix in suffixes : <nl> + cc_path = which ( ' clang { } ' . format ( suffix ) ) <nl> + cxx_path = which ( ' clang + + { } ' . format ( suffix ) ) <nl> + if cc_path and cxx_path : <nl> + return CompilerExecutable ( cc = cc_path , cxx = cxx_path ) <nl> + <nl> + return None <nl> + <nl> + <nl> + def host_clang ( xcrun_toolchain ) : <nl> + " " " <nl> + Return a CompilerExecutable for the host platform . <nl> + If no appropriate compilers can be found , return None . <nl> + " " " <nl> + if platform . system ( ) = = ' Darwin ' : <nl> + cc = xcrun . find ( xcrun_toolchain , ' clang ' ) <nl> + cxx = xcrun . find ( xcrun_toolchain , ' clang + + ' ) <nl> + if cc and cxx : <nl> + return CompilerExecutable ( cc = cc , cxx = cxx ) <nl> + else : <nl> + return None <nl> + elif platform . system ( ) = = ' FreeBSD ' : <nl> + # See : https : / / github . com / apple / swift / pull / 169 <nl> + # Building Swift from source requires a recent version of the Clang <nl> + # compiler with C + + 14 support . <nl> + freebsd_release_date = _freebsd_release_date ( ) <nl> + if freebsd_release_date and freebsd_release_date > = 1100000 : <nl> + # On newer releases of FreeBSD , the default Clang is sufficient . <nl> + return CompilerExecutable ( cc = ' clang ' , cxx = ' clang + + ' ) <nl> + else : <nl> + # On older releases , or on releases for which we cannot determine <nl> + # the release date , we search for the most modern version <nl> + # available . <nl> + return _first_clang ( [ ' 38 ' , ' 37 ' , ' 36 ' , ' 35 ' ] ) <nl> + else : <nl> + return _first_clang ( [ ' ' , ' - 3 . 8 ' , ' - 3 . 7 ' , ' - 3 . 6 ' , ' - 3 . 5 ' ] ) <nl> new file mode 100644 <nl> index 000000000000 . . 72a183e4f9e8 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / swift_build_support / migration . py <nl> <nl> + # swift_build_support / migration . py - Migrating build - script - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # utils / build - script takes arguments for its argument parser , as well as <nl> + # arguments that are meant to be passed directly to utils / build - script - impl . <nl> + # In order to gradually migrate away from build - script - impl , this module <nl> + # provides tools to handle parsing of these args . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + <nl> + def migrate_impl_args ( argv , migrate_args ) : <nl> + " " " <nl> + Given a list of arguments of the form : <nl> + <nl> + - - foo - - bar = baz - - - - flim = flam <nl> + <nl> + And a list of arguments to migrate , return a list in which the arguments <nl> + to migrate come before the ' - - ' separator . For example , were we to migrate <nl> + ' - - flim ' , we would return : <nl> + <nl> + - - foo - - bar = baz - - flim = flam - - <nl> + <nl> + Note that we do not attempt to remove the ' - - ' separator if it is no longer <nl> + necessary , nor do we replace ' - - flim ' if it already appears before the <nl> + separator . In these cases , argparse " does the right thing " : it can handle <nl> + a trailing separator , and when options that are specified twice argparse <nl> + uses the second value . <nl> + " " " <nl> + try : <nl> + split_index = argv . index ( ' - - ' ) <nl> + except ValueError : <nl> + # If there is no separator , then we have nothing to migrate . <nl> + return argv <nl> + <nl> + args = argv [ : split_index ] <nl> + impl_args = argv [ split_index : ] <nl> + impl_args_to_remove = [ ] <nl> + for index , impl_arg in enumerate ( impl_args ) : <nl> + if impl_arg . split ( ' = ' ) [ 0 ] in migrate_args : <nl> + args . append ( impl_arg ) <nl> + impl_args_to_remove . append ( impl_arg ) <nl> + <nl> + for impl_arg_to_remove in impl_args_to_remove : <nl> + impl_args . remove ( impl_arg_to_remove ) <nl> + <nl> + return args + impl_args <nl> new file mode 100644 <nl> index 000000000000 . . 7b6a5b212869 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / swift_build_support / which . py <nl> <nl> + # swift_build_support / which . py - shutil . which ( ) for Python 2 . 7 - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # A naive reimplementation of shutil . which ( ) for Python 2 . 7 . This can be <nl> + # removed if shutil . which ( ) is backported , or if the Swift build toolchain <nl> + # migrates completely to Python 3 . 3 + . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + import subprocess <nl> + <nl> + <nl> + def which ( cmd ) : <nl> + " " " <nl> + Return the path to an executable which would be run if <nl> + the given cmd was called . If no cmd would be called , return None . <nl> + <nl> + Python 3 . 3 + provides this behavior via the shutil . which ( ) function ; <nl> + see : https : / / docs . python . org / 3 . 3 / library / shutil . html # shutil . which <nl> + <nl> + We provide our own implementation because shutil . which ( ) has not <nl> + been backported to Python 2 . 7 , which we support . <nl> + " " " <nl> + try : <nl> + return subprocess . check_output ( [ ' which ' , cmd ] ) . rstrip ( ) <nl> + except subprocess . CalledProcessError : <nl> + return None <nl> new file mode 100644 <nl> index 000000000000 . . 0bb387553df8 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / swift_build_support / xcrun . py <nl> <nl> + # swift_build_support / xcrun . py - Invoke xcrun from Python - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # Python wrappers for invoking ` xcrun ` on the command - line . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> + import subprocess <nl> + <nl> + <nl> + def find ( toolchain , tool ) : <nl> + " " " <nl> + Return the path for the given tool , according to ` xcrun - - find ` , using <nl> + the given toolchain . If ` xcrun - - find ` cannot find the tool , return None . <nl> + " " " <nl> + try : <nl> + # ` xcrun - - find ` prints to stderr when it fails to find the <nl> + # given tool . We swallow that output with a pipe . <nl> + out = subprocess . check_output ( [ ' xcrun ' , ' - - sdk ' , ' macosx ' , <nl> + ' - - toolchain ' , toolchain , <nl> + ' - - find ' , tool ] , <nl> + stderr = subprocess . PIPE ) <nl> + return out . rstrip ( ) <nl> + except subprocess . CalledProcessError : <nl> + return None <nl> new file mode 100644 <nl> index 000000000000 . . c732b7348f69 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / tests / __init__ . py <nl> <nl> + # swift_build_support / tests / __init__ . py - Test module - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # <nl> + # This file needs to be here in order for Python to treat the <nl> + # utils / swift_build_support / tests / directory as a module . <nl> + # <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> new file mode 100644 <nl> index 000000000000 . . 43743c32b385 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / tests / test_clang . py <nl> <nl> + # test_clang . py - Unit tests for swift_build_support . clang - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + import os <nl> + import unittest <nl> + <nl> + from swift_build_support . clang import host_clang <nl> + <nl> + <nl> + class HostClangTestCase ( unittest . TestCase ) : <nl> + def test_clang_available_on_this_platform ( self ) : <nl> + # Test that Clang is installed on this platform , as a means of <nl> + # testing host_clang ( ) . <nl> + clang = host_clang ( xcrun_toolchain = ' default ' ) <nl> + <nl> + # The CC and CXX from host_clang ( ) should be of the form <nl> + # ' path / to / clang ' , where ' clang ' may have a trailing version <nl> + # number . <nl> + self . assertTrue ( os . path . split ( clang . cc ) [ - 1 ] . startswith ( ' clang ' ) ) <nl> + self . assertTrue ( os . path . split ( clang . cxx ) [ - 1 ] . startswith ( ' clang + + ' ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> new file mode 100644 <nl> index 000000000000 . . 1cadb1a1afed <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / tests / test_migration . py <nl> <nl> + # test_migration . py - Tests for swift_build_support . migration - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + import unittest <nl> + <nl> + from swift_build_support . migration import migrate_impl_args <nl> + <nl> + <nl> + class MigrateImplArgsTestCase ( unittest . TestCase ) : <nl> + def test_args_moved_before_separator ( self ) : <nl> + # Tests that ' - RT - - foo = bar - - - - foo = baz - - flim ' is parsed as <nl> + # ' - RT - - foo = bar - - foo = baz - - - - flim ' <nl> + args = migrate_impl_args ( <nl> + [ ' - RT ' , ' - - darwin - xcrun - toolchain = foo ' , ' - - ' , <nl> + ' - - darwin - xcrun - toolchain = bar ' , ' - - other ' ] , <nl> + [ ' - - darwin - xcrun - toolchain ' ] ) <nl> + <nl> + self . assertEqual ( <nl> + args , <nl> + [ ' - RT ' , ' - - darwin - xcrun - toolchain = foo ' , <nl> + ' - - darwin - xcrun - toolchain = bar ' , ' - - ' , ' - - other ' ] ) <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> new file mode 100644 <nl> index 000000000000 . . ed886a1b6bf8 <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / tests / test_which . py <nl> <nl> + # test_which . py - Unit tests for swift_build_support . which - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + import os <nl> + import unittest <nl> + <nl> + from swift_build_support . which import which <nl> + <nl> + <nl> + class WhichTestCase ( unittest . TestCase ) : <nl> + def test_when_cmd_not_found_returns_none ( self ) : <nl> + self . assertIsNone ( which ( ' a - tool - that - doesnt - exist ' ) ) <nl> + <nl> + def test_when_cmd_found_returns_path ( self ) : <nl> + self . assertEquals ( os . path . split ( which ( ' ls ' ) ) [ - 1 ] , ' ls ' ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> new file mode 100644 <nl> index 000000000000 . . 5a54b68473af <nl> mmm / dev / null <nl> ppp b / utils / swift_build_support / tests / test_xcrun . py <nl> <nl> + # test_xcrun . py - Unit tests for swift_build_support . xcrun - * - python - * - <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See http : / / swift . org / LICENSE . txt for license information <nl> + # See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + import platform <nl> + import unittest <nl> + <nl> + from swift_build_support import xcrun <nl> + <nl> + <nl> + class FindTestCase ( unittest . TestCase ) : <nl> + def setUp ( self ) : <nl> + if platform . system ( ) ! = ' Darwin ' : <nl> + self . skipTest ( ' XCRun tests should only be run on OS X ' ) <nl> + <nl> + def test_when_tool_not_found_returns_none ( self ) : <nl> + self . assertIsNone ( xcrun . find ( <nl> + toolchain = ' default ' , tool = ' a - tool - that - isnt - on - osx ' ) ) <nl> + <nl> + def test_when_tool_found_returns_path ( self ) : <nl> + self . assertTrue ( xcrun . find ( <nl> + toolchain = ' default ' , tool = ' clang ' ) . endswith ( ' / clang ' ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl> new file mode 100644 <nl> index 000000000000 . . abdee4bef4be <nl> mmm / dev / null <nl> ppp b / validation - test / Python / swift_build_support . swift <nl> @ @ - 0 , 0 + 1 @ @ <nl> + / / RUN : % { python } - m unittest discover - s % S / . . / . . / utils / swift_build_support <nl>
|
Merge pull request from modocache / sr - 237 - build - script - impl - merge - host - cc
|
apple/swift
|
afde6d373776660215e071c58656f7a15ba7887f
|
2015-12-27T16:47:38Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> <nl> cmake_minimum_required ( VERSION 3 . 5 . 1 ) <nl> <nl> set ( PACKAGE_NAME " grpc " ) <nl> - set ( PACKAGE_VERSION " 1 . 33 . 0 - dev " ) <nl> - set ( gRPC_CORE_VERSION " 12 . 0 . 0 " ) <nl> - set ( gRPC_CORE_SOVERSION " 12 " ) <nl> - set ( gRPC_CPP_VERSION " 1 . 33 . 0 - dev " ) <nl> + set ( PACKAGE_VERSION " 1 . 33 . 0 - pre1 " ) <nl> + set ( gRPC_CORE_VERSION " 13 . 0 . 0 " ) <nl> + set ( gRPC_CORE_SOVERSION " 13 " ) <nl> + set ( gRPC_CPP_VERSION " 1 . 33 . 0 - pre1 " ) <nl> set ( gRPC_CPP_SOVERSION " 1 " ) <nl> - set ( gRPC_CSHARP_VERSION " 2 . 33 . 0 - dev " ) <nl> + set ( gRPC_CSHARP_VERSION " 2 . 33 . 0 - pre1 " ) <nl> set ( gRPC_CSHARP_SOVERSION " 2 " ) <nl> set ( PACKAGE_STRING " $ { PACKAGE_NAME } $ { PACKAGE_VERSION } " ) <nl> set ( PACKAGE_TARNAME " $ { PACKAGE_NAME } - $ { PACKAGE_VERSION } " ) <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> E = @ echo <nl> Q = @ <nl> endif <nl> <nl> - CORE_VERSION = 12 . 0 . 0 <nl> - CPP_VERSION = 1 . 33 . 0 - dev <nl> - CSHARP_VERSION = 2 . 33 . 0 - dev <nl> + CORE_VERSION = 13 . 0 . 0 <nl> + CPP_VERSION = 1 . 33 . 0 - pre1 <nl> + CSHARP_VERSION = 2 . 33 . 0 - pre1 <nl> <nl> CPPFLAGS_NO_ARCH + = $ ( addprefix - I , $ ( INCLUDES ) ) $ ( addprefix - D , $ ( DEFINES ) ) <nl> CPPFLAGS + = $ ( CPPFLAGS_NO_ARCH ) $ ( ARCH_FLAGS ) <nl> SHARED_EXT_CORE = dll <nl> SHARED_EXT_CPP = dll <nl> SHARED_EXT_CSHARP = dll <nl> SHARED_PREFIX = <nl> - SHARED_VERSION_CORE = - 12 <nl> + SHARED_VERSION_CORE = - 13 <nl> SHARED_VERSION_CPP = - 1 <nl> SHARED_VERSION_CSHARP = - 2 <nl> else ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) address_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBADDRESS_SORTING_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libaddress_sorting . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBADDRESS_SORTING_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) address_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libaddress_sorting . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBADDRESS_SORTING_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) address_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) address_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : $ ( LIBGPR_OB <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) gpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGPR_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgpr . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGPR_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) gpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgpr . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGPR_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) gpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) gpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : $ ( LIBGRPC_ <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) grpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( OPENSSL_MERGE_LIBS ) $ ( LDLIBS_SECURE ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( OPENSSL_MERGE_LIBS ) $ ( LDLIBS_SECURE ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( OPENSSL_MERGE_LIBS ) $ ( LDLIBS_SECURE ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) grpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_CSHARP_EXT_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc_csharp_ext . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_CSHARP_EXT_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc_csharp_ext . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_CSHARP_EXT_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_csharp_ext $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : $ <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) grpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_UNSECURE_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc_unsecure . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_UNSECURE_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc_unsecure . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBGRPC_UNSECURE_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) : $ ( LIBUPB_OB <nl> ifeq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) upb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBUPB_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> else <nl> - $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libupb . so . 12 - o $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBUPB_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> - $ ( Q ) ln - sf $ ( SHARED_PREFIX ) upb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . so . 12 <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libupb . so . 13 - o $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBUPB_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( RE2_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( GRPC_ABSEIL_MERGE_LIBS ) $ ( LDLIBS ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) upb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . so . 13 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) upb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / libupb $ ( SHARED_VERSION_CORE ) . so <nl> endif <nl> endif <nl> mmm a / build_config . rb <nl> ppp b / build_config . rb <nl> <nl> # limitations under the License . <nl> <nl> module GrpcBuildConfig <nl> - CORE_WINDOWS_DLL = ' / tmp / libs / opt / grpc - 12 . dll ' <nl> + CORE_WINDOWS_DLL = ' / tmp / libs / opt / grpc - 13 . dll ' <nl> end <nl> mmm a / gRPC - C + + . podspec <nl> ppp b / gRPC - C + + . podspec <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - C + + ' <nl> # TODO ( mxyan ) : use version that match gRPC version when pod is stabilized <nl> - version = ' 1 . 33 . 0 - dev ' <nl> + version = ' 1 . 33 . 0 - pre1 ' <nl> s . version = version <nl> s . summary = ' gRPC C + + library ' <nl> s . homepage = ' https : / / grpc . io ' <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - Core ' <nl> - version = ' 1 . 33 . 0 - dev ' <nl> + version = ' 1 . 33 . 0 - pre1 ' <nl> s . version = version <nl> s . summary = ' Core cross - platform gRPC library , written in C ' <nl> s . homepage = ' https : / / grpc . io ' <nl> mmm a / gRPC - ProtoRPC . podspec <nl> ppp b / gRPC - ProtoRPC . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - ProtoRPC ' <nl> - version = ' 1 . 33 . 0 - dev ' <nl> + version = ' 1 . 33 . 0 - pre1 ' <nl> s . version = version <nl> s . summary = ' RPC library for Protocol Buffers , based on gRPC ' <nl> s . homepage = ' https : / / grpc . io ' <nl> mmm a / gRPC - RxLibrary . podspec <nl> ppp b / gRPC - RxLibrary . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC - RxLibrary ' <nl> - version = ' 1 . 33 . 0 - dev ' <nl> + version = ' 1 . 33 . 0 - pre1 ' <nl> s . version = version <nl> s . summary = ' Reactive Extensions library for iOS / OSX . ' <nl> s . homepage = ' https : / / grpc . io ' <nl> mmm a / gRPC . podspec <nl> ppp b / gRPC . podspec <nl> <nl> <nl> Pod : : Spec . new do | s | <nl> s . name = ' gRPC ' <nl> - version = ' 1 . 33 . 0 - dev ' <nl> + version = ' 1 . 33 . 0 - pre1 ' <nl> s . version = version <nl> s . summary = ' gRPC client library for iOS / OSX ' <nl> s . homepage = ' https : / / grpc . io ' <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < date > 2019 - 09 - 24 < / date > <nl> < time > 16 : 06 : 07 < / time > <nl> < version > <nl> - < release > 1 . 33 . 0dev < / release > <nl> - < api > 1 . 33 . 0dev < / api > <nl> + < release > 1 . 33 . 0RC1 < / release > <nl> + < api > 1 . 33 . 0RC1 < / api > <nl> < / version > <nl> < stability > <nl> < release > beta < / release > <nl> mmm a / src / core / lib / surface / version . cc <nl> ppp b / src / core / lib / surface / version . cc <nl> <nl> <nl> # include < grpc / grpc . h > <nl> <nl> - const char * grpc_version_string ( void ) { return " 12 . 0 . 0 " ; } <nl> + const char * grpc_version_string ( void ) { return " 13 . 0 . 0 " ; } <nl> <nl> const char * grpc_g_stands_for ( void ) { return " geeky " ; } <nl> mmm a / src / cpp / common / version_cc . cc <nl> ppp b / src / cpp / common / version_cc . cc <nl> <nl> # include < grpcpp / grpcpp . h > <nl> <nl> namespace grpc { <nl> - std : : string Version ( ) { return " 1 . 33 . 0 - dev " ; } <nl> + std : : string Version ( ) { return " 1 . 33 . 0 - pre1 " ; } <nl> } / / namespace grpc <nl> mmm a / src / csharp / Grpc . Core . Api / VersionInfo . cs <nl> ppp b / src / csharp / Grpc . Core . Api / VersionInfo . cs <nl> public static class VersionInfo <nl> / / / < summary > <nl> / / / Current version of gRPC C # <nl> / / / < / summary > <nl> - public const string CurrentVersion = " 2 . 33 . 0 - dev " ; <nl> + public const string CurrentVersion = " 2 . 33 . 0 - pre1 " ; <nl> } <nl> } <nl> mmm a / src / csharp / build / dependencies . props <nl> ppp b / src / csharp / build / dependencies . props <nl> <nl> < ! - - This file is generated - - > <nl> < Project > <nl> < PropertyGroup > <nl> - < GrpcCsharpVersion > 2 . 33 . 0 - dev < / GrpcCsharpVersion > <nl> + < GrpcCsharpVersion > 2 . 33 . 0 - pre1 < / GrpcCsharpVersion > <nl> < GoogleProtobufVersion > 3 . 13 . 0 < / GoogleProtobufVersion > <nl> < / PropertyGroup > <nl> < / Project > <nl> mmm a / src / csharp / build_unitypackage . bat <nl> ppp b / src / csharp / build_unitypackage . bat <nl> <nl> @ rem limitations under the License . <nl> <nl> @ rem Current package versions <nl> - set VERSION = 2 . 33 . 0 - dev <nl> + set VERSION = 2 . 33 . 0 - pre1 <nl> <nl> @ rem Adjust the location of nuget . exe <nl> set NUGET = nuget <nl> mmm a / src / objective - c / ! ProtoCompiler - gRPCCppPlugin . podspec <nl> ppp b / src / objective - c / ! ProtoCompiler - gRPCCppPlugin . podspec <nl> Pod : : Spec . new do | s | <nl> # exclamation mark ensures that other " regular " pods will be able to find it as it ' ll be installed <nl> # before them . <nl> s . name = ' ! ProtoCompiler - gRPCCppPlugin ' <nl> - v = ' 1 . 33 . 0 - dev ' <nl> + v = ' 1 . 33 . 0 - pre1 ' <nl> s . version = v <nl> s . summary = ' The gRPC ProtoC plugin generates C + + files from . proto services . ' <nl> s . description = < < - DESC <nl> mmm a / src / objective - c / ! ProtoCompiler - gRPCPlugin . podspec <nl> ppp b / src / objective - c / ! ProtoCompiler - gRPCPlugin . podspec <nl> Pod : : Spec . new do | s | <nl> # exclamation mark ensures that other " regular " pods will be able to find it as it ' ll be installed <nl> # before them . <nl> s . name = ' ! ProtoCompiler - gRPCPlugin ' <nl> - v = ' 1 . 33 . 0 - dev ' <nl> + v = ' 1 . 33 . 0 - pre1 ' <nl> s . version = v <nl> s . summary = ' The gRPC ProtoC plugin generates Objective - C files from . proto services . ' <nl> s . description = < < - DESC <nl> mmm a / src / objective - c / GRPCClient / version . h <nl> ppp b / src / objective - c / GRPCClient / version . h <nl> <nl> / / instead . This file can be regenerated from the template by running <nl> / / ` tools / buildgen / generate_projects . sh ` . <nl> <nl> - # define GRPC_OBJC_VERSION_STRING @ " 1 . 33 . 0 - dev " <nl> + # define GRPC_OBJC_VERSION_STRING @ " 1 . 33 . 0 - pre1 " <nl> mmm a / src / objective - c / tests / version . h <nl> ppp b / src / objective - c / tests / version . h <nl> <nl> / / instead . This file can be regenerated from the template by running <nl> / / ` tools / buildgen / generate_projects . sh ` . <nl> <nl> - # define GRPC_OBJC_VERSION_STRING @ " 1 . 33 . 0 - dev " <nl> - # define GRPC_C_VERSION_STRING @ " 12 . 0 . 0 " <nl> + # define GRPC_OBJC_VERSION_STRING @ " 1 . 33 . 0 - pre1 " <nl> + # define GRPC_C_VERSION_STRING @ " 13 . 0 . 0 " <nl> mmm a / src / php / ext / grpc / version . h <nl> ppp b / src / php / ext / grpc / version . h <nl> <nl> # ifndef VERSION_H <nl> # define VERSION_H <nl> <nl> - # define PHP_GRPC_VERSION " 1 . 33 . 0dev " <nl> + # define PHP_GRPC_VERSION " 1 . 33 . 0RC1 " <nl> <nl> # endif / * VERSION_H * / <nl> mmm a / src / python / grpcio / grpc / _grpcio_metadata . py <nl> ppp b / src / python / grpcio / grpc / _grpcio_metadata . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio / grpc / _grpcio_metadata . py . template ` ! ! ! <nl> <nl> - __version__ = " " " 1 . 33 . 0 . dev0 " " " <nl> + __version__ = " " " 1 . 33 . 0rc1 " " " <nl> mmm a / src / python / grpcio / grpc_version . py <nl> ppp b / src / python / grpcio / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_channelz / grpc_version . py <nl> ppp b / src / python / grpcio_channelz / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_channelz / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_health_checking / grpc_version . py <nl> ppp b / src / python / grpcio_health_checking / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_health_checking / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_reflection / grpc_version . py <nl> ppp b / src / python / grpcio_reflection / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_reflection / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_status / grpc_version . py <nl> ppp b / src / python / grpcio_status / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_status / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_testing / grpc_version . py <nl> ppp b / src / python / grpcio_testing / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_testing / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / python / grpcio_tests / grpc_version . py <nl> ppp b / src / python / grpcio_tests / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / src / python / grpcio_tests / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / src / ruby / lib / grpc / version . rb <nl> ppp b / src / ruby / lib / grpc / version . rb <nl> <nl> <nl> # GRPC contains the General RPC module . <nl> module GRPC <nl> - VERSION = ' 1 . 33 . 0 . dev ' <nl> + VERSION = ' 1 . 33 . 0 . pre1 ' <nl> end <nl> mmm a / src / ruby / tools / version . rb <nl> ppp b / src / ruby / tools / version . rb <nl> <nl> <nl> module GRPC <nl> module Tools <nl> - VERSION = ' 1 . 33 . 0 . dev ' <nl> + VERSION = ' 1 . 33 . 0 . pre1 ' <nl> end <nl> end <nl> mmm a / tools / distrib / python / grpc_version . py <nl> ppp b / tools / distrib / python / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / tools / distrib / python / grpcio_tools / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / tools / distrib / python / grpcio_tools / grpc_version . py <nl> ppp b / tools / distrib / python / grpcio_tools / grpc_version . py <nl> <nl> <nl> # AUTO - GENERATED FROM ` $ REPO_ROOT / templates / tools / distrib / python / grpcio_tools / grpc_version . py . template ` ! ! ! <nl> <nl> - VERSION = ' 1 . 33 . 0 . dev0 ' <nl> + VERSION = ' 1 . 33 . 0rc1 ' <nl> mmm a / tools / doxygen / Doxyfile . c + + <nl> ppp b / tools / doxygen / Doxyfile . c + + <nl> PROJECT_NAME = " GRPC C + + " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 33 . 0 - dev <nl> + PROJECT_NUMBER = 1 . 33 . 0 - pre1 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . c + + . internal <nl> ppp b / tools / doxygen / Doxyfile . c + + . internal <nl> PROJECT_NAME = " GRPC C + + " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 33 . 0 - dev <nl> + PROJECT_NUMBER = 1 . 33 . 0 - pre1 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . core <nl> ppp b / tools / doxygen / Doxyfile . core <nl> PROJECT_NAME = " GRPC Core " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 12 . 0 . 0 <nl> + PROJECT_NUMBER = 13 . 0 . 0 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> PROJECT_NAME = " GRPC Core " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 12 . 0 . 0 <nl> + PROJECT_NUMBER = 13 . 0 . 0 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . objc <nl> ppp b / tools / doxygen / Doxyfile . objc <nl> PROJECT_NAME = " GRPC Objective - C " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 33 . 0 - dev <nl> + PROJECT_NUMBER = 1 . 33 . 0 - pre1 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . objc . internal <nl> ppp b / tools / doxygen / Doxyfile . objc . internal <nl> PROJECT_NAME = " GRPC Objective - C " <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 33 . 0 - dev <nl> + PROJECT_NUMBER = 1 . 33 . 0 - pre1 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl> mmm a / tools / doxygen / Doxyfile . php <nl> ppp b / tools / doxygen / Doxyfile . php <nl> <nl> # could be handy for archiving the generated documentation or if some version <nl> # control system is used . <nl> <nl> - PROJECT_NUMBER = 1 . 33 . 0 - dev <nl> + PROJECT_NUMBER = 1 . 33 . 0 - pre1 <nl> <nl> # Using the PROJECT_BRIEF tag one can provide an optional one line description <nl> # for a project that appears at the top of each page and should give viewer a <nl>
|
Bump version to v1 . 33 . x - pre1 : regenerate projects
|
grpc/grpc
|
aa7b10f659a1257f890e9c2fc6ffe93e23135730
|
2020-10-07T20:38:47Z
|
mmm a / tools / run_tests / jobset . py <nl> ppp b / tools / run_tests / jobset . py <nl> <nl> def sanitized_environment ( env ) : <nl> sanitized = { } <nl> for key , value in env . items ( ) : <nl> - sanitized [ str ( key ) . encode ( ) ] = str ( value ) . encode ( ) <nl> + sanitized [ key . encode ( errors = ' ignore ' ) ] = value . encode ( errors = ' ignore ' ) <nl> return sanitized <nl> <nl> def platform_string ( ) : <nl>
|
Attempt to deal with unicode strings in jenkins environment .
|
grpc/grpc
|
efd7795335aa1aef178155be421e353539f2846a
|
2016-12-01T20:48:46Z
|
mmm a / tensorflow / tools / docs / generate_lib . py <nl> ppp b / tensorflow / tools / docs / generate_lib . py <nl> def write_docs ( output_dir , parser_config , yaml_toc , root_title = ' TensorFlow ' ) : <nl> # Generate header <nl> f . write ( ' # Automatically generated file ; please do not edit \ ntoc : \ n ' ) <nl> for module in modules : <nl> - f . write ( ' - title : ' + module + ' \ n ' <nl> - ' section : \ n ' + ' - title : Overview \ n ' + <nl> - ' path : / TARGET_DOC_ROOT / VERSION / ' + symbol_to_file [ module ] <nl> - + ' \ n ' ) <nl> + indent_num = module . count ( ' . ' ) <nl> + # Don ' t list ` tf . submodule ` inside ` tf ` <nl> + indent_num = max ( indent_num , 1 ) <nl> + indent = ' ' * indent_num <nl> + <nl> + if indent_num > 1 : <nl> + # tf . contrib . baysflow . entropy will be under <nl> + # tf . contrib - > baysflow - > entropy <nl> + title = module . split ( ' . ' ) [ - 1 ] <nl> + else : <nl> + title = module <nl> + <nl> + header = [ <nl> + ' - title : ' + title , <nl> + ' section : ' , <nl> + ' - title : Overview ' , <nl> + ' path : / TARGET_DOC_ROOT / VERSION / ' + symbol_to_file [ module ] ] <nl> + header = ' ' . join ( [ indent + line + ' \ n ' for line in header ] ) <nl> + f . write ( header ) <nl> <nl> symbols_in_module = module_children . get ( module , [ ] ) <nl> # Sort case - insensitive , if equal sort case sensitive ( upper first ) <nl> symbols_in_module . sort ( key = lambda a : ( a . upper ( ) , a ) ) <nl> <nl> for full_name in symbols_in_module : <nl> - f . write ( ' - title : ' + full_name [ len ( module ) + 1 : ] + ' \ n ' <nl> - ' path : / TARGET_DOC_ROOT / VERSION / ' + <nl> - symbol_to_file [ full_name ] + ' \ n ' ) <nl> + item = [ <nl> + ' - title : ' + full_name [ len ( module ) + 1 : ] , <nl> + ' path : / TARGET_DOC_ROOT / VERSION / ' + symbol_to_file [ full_name ] ] <nl> + item = ' ' . join ( [ indent + line + ' \ n ' for line in item ] ) <nl> + f . write ( item ) <nl> <nl> # Write a global index containing all full names with links . <nl> with open ( os . path . join ( output_dir , ' index . md ' ) , ' w ' ) as f : <nl>
|
Use nesting to reduce the number of modules listed in the API TOC .
|
tensorflow/tensorflow
|
d71abc570b15451232bf7582c9173c56651aed1b
|
2017-11-07T14:35:20Z
|
mmm a / Kodi . xcodeproj / project . pbxproj <nl> ppp b / Kodi . xcodeproj / project . pbxproj <nl> <nl> DFEF0BC1180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = DFEF0BBF180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp * / ; } ; <nl> DFEF0BC2180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = DFEF0BBF180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp * / ; } ; <nl> DFEF0BC3180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = DFEF0BBF180ADEDA00AEAED1 / * SmartPlaylistFileItemListModifier . cpp * / ; } ; <nl> - DFF0EB54175280D1002DA3A4 / * libz . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CE6131F5DC6000AD0F6 / * libz . dylib * / ; } ; <nl> - DFF0EB55175280E5002DA3A4 / * libiconv . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CF2131F5DFD000AD0F6 / * libiconv . dylib * / ; } ; <nl> DFF0EBB3175281CE002DA3A4 / * AudioToolbox . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910EC174E54D200741B6D / * AudioToolbox . framework * / ; } ; <nl> DFF0EBB4175281D6002DA3A4 / * CFNetwork . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910F0174E54EC00741B6D / * CFNetwork . framework * / ; } ; <nl> DFF0EBB6175281E0002DA3A4 / * CoreAudio . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910EA174E54C900741B6D / * CoreAudio . framework * / ; } ; <nl> <nl> E49910F1174E54ED00741B6D / * CFNetwork . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910F0174E54EC00741B6D / * CFNetwork . framework * / ; } ; <nl> E49910F3174E54FB00741B6D / * AVFoundation . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910F2174E54FB00741B6D / * AVFoundation . framework * / ; } ; <nl> E49910F5174E550200741B6D / * MediaPlayer . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = E49910F4174E550200741B6D / * MediaPlayer . framework * / ; } ; <nl> - E49910F8174E561500741B6D / * libz . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CE6131F5DC6000AD0F6 / * libz . dylib * / ; } ; <nl> - E49910F9174E561D00741B6D / * libiconv . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CF2131F5DFD000AD0F6 / * libiconv . dylib * / ; } ; <nl> E499114F174E5CC300741B6D / * archive . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = E38E1CE60D25F9FC00618676 / * archive . cpp * / ; settings = { COMPILER_FLAGS = " - DSILENT " ; } ; } ; <nl> E4991150174E5CC300741B6D / * arcread . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = E38E1CE80D25F9FC00618676 / * arcread . cpp * / ; settings = { COMPILER_FLAGS = " - DSILENT " ; } ; } ; <nl> E4991151174E5CC300741B6D / * cmddata . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = E38E1CEA0D25F9FC00618676 / * cmddata . cpp * / ; settings = { COMPILER_FLAGS = " - DSILENT " ; } ; } ; <nl> <nl> F52CC5F01713AAA200113454 / * DirectoryNodeGrouped . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F52CC5EE1713AAA200113454 / * DirectoryNodeGrouped . cpp * / ; } ; <nl> F52CC6AA1713BD2B00113454 / * DirectoryNodeGrouped . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F52CC6A81713BD2B00113454 / * DirectoryNodeGrouped . cpp * / ; } ; <nl> F5364D34155B3B270016D00B / * CoreVideo . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = F5364D33155B3B270016D00B / * CoreVideo . framework * / ; } ; <nl> - F5364D55155B3C7B0016D00B / * libm . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F5364D54155B3C7B0016D00B / * libm . dylib * / ; } ; <nl> F5364E05155B3CAF0016D00B / * IOSurface . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = F5364E04155B3CAF0016D00B / * IOSurface . framework * / ; } ; <nl> F548786D0FE060FF00E506FD / * DVDSubtitleParserMPL2 . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F548786C0FE060FF00E506FD / * DVDSubtitleParserMPL2 . cpp * / ; } ; <nl> F5487B4C0FE6F02700E506FD / * StreamDetails . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F5487B4B0FE6F02700E506FD / * StreamDetails . cpp * / ; } ; <nl> <nl> F56353BF16E9BB3500D21BAD / * BitstreamConverter . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F56353BD16E9BB3500D21BAD / * BitstreamConverter . cpp * / ; } ; <nl> F56579AF13060D1E0085ED7F / * RenderCapture . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F56579AD13060D1E0085ED7F / * RenderCapture . cpp * / ; } ; <nl> F56A084B0F4A18FB003F9F87 / * karaokewindowbackground . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F56A084A0F4A18FB003F9F87 / * karaokewindowbackground . cpp * / ; } ; <nl> - F56C8CE7131F5DC6000AD0F6 / * libz . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CE6131F5DC6000AD0F6 / * libz . dylib * / ; } ; <nl> - F56C8CF3131F5DFD000AD0F6 / * libiconv . dylib in Frameworks * / = { isa = PBXBuildFile ; fileRef = F56C8CF2131F5DFD000AD0F6 / * libiconv . dylib * / ; } ; <nl> F57A1D1E1329B15300498CC7 / * AutoPool . mm in Sources * / = { isa = PBXBuildFile ; fileRef = F57A1D1D1329B15300498CC7 / * AutoPool . mm * / ; } ; <nl> F57B6F801071B8B500079ACB / * JobManager . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F57B6F7E1071B8B500079ACB / * JobManager . cpp * / ; } ; <nl> F584E12E0F257C5100DB26A5 / * HTTPDirectory . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = F584E12D0F257C5100DB26A5 / * HTTPDirectory . cpp * / ; } ; <nl> <nl> F52CC6A81713BD2B00113454 / * DirectoryNodeGrouped . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = DirectoryNodeGrouped . cpp ; sourceTree = " < group > " ; } ; <nl> F52CC6A91713BD2B00113454 / * DirectoryNodeGrouped . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = DirectoryNodeGrouped . h ; sourceTree = " < group > " ; } ; <nl> F5364D33155B3B270016D00B / * CoreVideo . framework * / = { isa = PBXFileReference ; lastKnownFileType = wrapper . framework ; name = CoreVideo . framework ; path = / System / Library / Frameworks / CoreVideo . framework ; sourceTree = " < absolute > " ; } ; <nl> - F5364D54155B3C7B0016D00B / * libm . dylib * / = { isa = PBXFileReference ; lastKnownFileType = " compiled . mach - o . dylib " ; name = libm . dylib ; path = / usr / lib / libm . dylib ; sourceTree = " < absolute > " ; } ; <nl> F5364E04155B3CAF0016D00B / * IOSurface . framework * / = { isa = PBXFileReference ; lastKnownFileType = wrapper . framework ; name = IOSurface . framework ; path = / System / Library / Frameworks / IOSurface . framework ; sourceTree = " < absolute > " ; } ; <nl> F548786B0FE060FF00E506FD / * DVDSubtitleParserMPL2 . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = DVDSubtitleParserMPL2 . h ; sourceTree = " < group > " ; } ; <nl> F548786C0FE060FF00E506FD / * DVDSubtitleParserMPL2 . cpp * / = { isa = PBXFileReference ; explicitFileType = sourcecode . cpp . cpp ; fileEncoding = 4 ; path = DVDSubtitleParserMPL2 . cpp ; sourceTree = " < group > " ; } ; <nl> <nl> F56579AE13060D1E0085ED7F / * RenderCapture . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = RenderCapture . h ; sourceTree = " < group > " ; } ; <nl> F56A08490F4A18FB003F9F87 / * karaokewindowbackground . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = karaokewindowbackground . h ; sourceTree = " < group > " ; } ; <nl> F56A084A0F4A18FB003F9F87 / * karaokewindowbackground . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = karaokewindowbackground . cpp ; sourceTree = " < group > " ; } ; <nl> - F56C8CE6131F5DC6000AD0F6 / * libz . dylib * / = { isa = PBXFileReference ; lastKnownFileType = " compiled . mach - o . dylib " ; name = libz . dylib ; path = usr / lib / libz . dylib ; sourceTree = SDKROOT ; } ; <nl> - F56C8CF2131F5DFD000AD0F6 / * libiconv . dylib * / = { isa = PBXFileReference ; lastKnownFileType = " compiled . mach - o . dylib " ; name = libiconv . dylib ; path = usr / lib / libiconv . dylib ; sourceTree = SDKROOT ; } ; <nl> F57A1D1C1329B15300498CC7 / * AutoPool . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = AutoPool . h ; sourceTree = " < group > " ; } ; <nl> F57A1D1D1329B15300498CC7 / * AutoPool . mm * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . objcpp ; path = AutoPool . mm ; sourceTree = " < group > " ; } ; <nl> F57B6F7E1071B8B500079ACB / * JobManager . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = JobManager . cpp ; sourceTree = " < group > " ; } ; <nl> <nl> isa = PBXFrameworksBuildPhase ; <nl> buildActionMask = 2147483647 ; <nl> files = ( <nl> - F56C8CE7131F5DC6000AD0F6 / * libz . dylib in Frameworks * / , <nl> - F5364D55155B3C7B0016D00B / * libm . dylib in Frameworks * / , <nl> - F56C8CF3131F5DFD000AD0F6 / * libiconv . dylib in Frameworks * / , <nl> F5ED9BFB155EC77400842059 / * ApplicationServices . framework in Frameworks * / , <nl> E38E23930D2626E600618676 / * AudioUnit . framework in Frameworks * / , <nl> E38E23920D2626E600618676 / * AudioToolbox . framework in Frameworks * / , <nl> <nl> isa = PBXFrameworksBuildPhase ; <nl> buildActionMask = 2147483647 ; <nl> files = ( <nl> - DFF0EB54175280D1002DA3A4 / * libz . dylib in Frameworks * / , <nl> - DFF0EB55175280E5002DA3A4 / * libiconv . dylib in Frameworks * / , <nl> DFF0EBB3175281CE002DA3A4 / * AudioToolbox . framework in Frameworks * / , <nl> DFF0EBB4175281D6002DA3A4 / * CFNetwork . framework in Frameworks * / , <nl> DFF0EBB6175281E0002DA3A4 / * CoreAudio . framework in Frameworks * / , <nl> <nl> E499108C174D0D2600741B6D / * UIKit . framework in Frameworks * / , <nl> E499108E174D0D2600741B6D / * Foundation . framework in Frameworks * / , <nl> E4991090174D0D2600741B6D / * CoreGraphics . framework in Frameworks * / , <nl> - E49910F8174E561500741B6D / * libz . dylib in Frameworks * / , <nl> - E49910F9174E561D00741B6D / * libiconv . dylib in Frameworks * / , <nl> DFF0EBB7175281E1002DA3A4 / * CoreAudio . framework in Frameworks * / , <nl> DFF0EC8C17528283002DA3A4 / * VideoToolbox . framework in Frameworks * / , <nl> ) ; <nl> <nl> 08FB779DFE84155DC02AAC07 / * System Libs and Frameworks * / , <nl> E49910C2174E2CDE00741B6D / * Configurations * / , <nl> E47252BE175115F9001C1AAA / * Support * / , <nl> - E499108A174D0D2600741B6D / * Frameworks * / , <nl> 19C28FBDFE9D53C911CA2CBB / * Products * / , <nl> ) ; <nl> indentWidth = 2 ; <nl> <nl> DFF0EB7E17528112002DA3A4 / * ATV2 * / , <nl> E49910F6174E55D400741B6D / * iOS * / , <nl> E49910F7174E55E100741B6D / * OSX * / , <nl> - F56C8CE6131F5DC6000AD0F6 / * libz . dylib * / , <nl> - F5364D54155B3C7B0016D00B / * libm . dylib * / , <nl> - F56C8CF2131F5DFD000AD0F6 / * libiconv . dylib * / , <nl> ) ; <nl> name = " System Libs and Frameworks " ; <nl> sourceTree = " < group > " ; <nl> <nl> path = tools / darwin / Support ; <nl> sourceTree = " < group > " ; <nl> } ; <nl> - E499108A174D0D2600741B6D / * Frameworks * / = { <nl> - isa = PBXGroup ; <nl> - children = ( <nl> - E499108B174D0D2600741B6D / * UIKit . framework * / , <nl> - E499108D174D0D2600741B6D / * Foundation . framework * / , <nl> - E499108F174D0D2600741B6D / * CoreGraphics . framework * / , <nl> - ) ; <nl> - name = Frameworks ; <nl> - sourceTree = " < group > " ; <nl> - } ; <nl> E49910A6174D0E2A00741B6D / * iOS * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> <nl> E49910EE174E54E400741B6D / * ImageIO . framework * / , <nl> E49910F4174E550200741B6D / * MediaPlayer . framework * / , <nl> E49910E4174E54A100741B6D / * OpenGLES . framework * / , <nl> + E499108B174D0D2600741B6D / * UIKit . framework * / , <nl> + E499108D174D0D2600741B6D / * Foundation . framework * / , <nl> + E499108F174D0D2600741B6D / * CoreGraphics . framework * / , <nl> E49910E2174E549400741B6D / * QuartzCore . framework * / , <nl> ) ; <nl> name = iOS ; <nl> <nl> 08FB7793FE84155DC02AAC07 / * Project object * / = { <nl> isa = PBXProject ; <nl> attributes = { <nl> - LastUpgradeCheck = 0430 ; <nl> } ; <nl> buildConfigurationList = 1DEB924B08733DCA0010E9CD / * Build configuration list for PBXProject " Kodi " * / ; <nl> compatibilityVersion = " Xcode 3 . 2 " ; <nl> mmm a / tools / darwin / Configurations / App . xcconfig . in <nl> ppp b / tools / darwin / Configurations / App . xcconfig . in <nl> HEADER_SEARCH_PATHS = $ ( inherited ) $ SRCROOT xbmc xbmc / linux xbmc / osx xbmc / cores / <nl> LIBRARY_SEARCH_PATHS = $ ( inherited ) $ ( SRCROOT ) $ ( SRCROOT ) / xbmc / interfaces / json - rpc " $ ( SRCROOT ) / xbmc / interfaces / python " " $ ( SRCROOT ) / xbmc / interfaces / legacy " <nl> FRAMEWORK_SEARCH_PATHS = $ ( inherited ) " $ ( SDKROOT ) / System / Library / PrivateFrameworks / " " $ ( SDKROOT ) / System / Library / Frameworks / " <nl> <nl> - XBMC_OTHER_LDFLAGS_COMMON = $ ( inherited ) - Wl , - headerpad_max_install_names - Wl , - all_load - L $ XBMC_DEPENDS / lib - lbz2 - lintl - lexpat - lssl - lgpg - error - lresolv - lffi - lssh - llzo2 - lpcre - lpcrecpp - lfribidi - lfreetype - lfontconfig - lsqlite3 - ltinyxml - lmicrohttpd - lsmbclient - lpython2 . 6 - lyajl - ljpeg - lcrypto - lgcrypt - lavdevice - lavfilter - lavcodec - lavformat - lpostproc - lavutil - ldcadec - lswresample - lswscale - ltag - L $ XBMC_DEPENDS / lib / mysql - lmysqlclient - lxml2 - lxslt - lnettle - lgmp - lhogweed - lgnutls - lsquish - lcrossguid <nl> + XBMC_OTHER_LDFLAGS_COMMON = $ ( inherited ) - Wl , - headerpad_max_install_names - Wl , - all_load - L $ XBMC_DEPENDS / lib - lbz2 - lintl - lexpat - lssl - lgpg - error - lresolv - lffi - lssh - llzo2 - lpcre - lpcrecpp - lfribidi - lfreetype - lfontconfig - lsqlite3 - ltinyxml - lmicrohttpd - lsmbclient - lpython2 . 6 - lyajl - ljpeg - lcrypto - lgcrypt - lavdevice - lavfilter - lavcodec - lavformat - lpostproc - lavutil - ldcadec - lswresample - lswscale - ltag - L $ XBMC_DEPENDS / lib / mysql - lmysqlclient - lxml2 - lxslt - lnettle - lgmp - lhogweed - lgnutls - lsquish - lcrossguid - lz - lm - liconv <nl> <nl> CLANG_CXX_LANGUAGE_STANDARD = c + + 0x <nl> CLANG_CXX_LIBRARY = libc + + <nl>
|
[ ios / osx ] - move those explicit dylib references from the xcode project to the xcconfig files ( this leaves out the extension and fixes linking so that it now also finds tbd files )
|
xbmc/xbmc
|
24324640029873f18d5c411eeb327b3d822abda6
|
2015-09-15T09:49:57Z
|
mmm a / documentation / sphinx / source / administration . rst <nl> ppp b / documentation / sphinx / source / administration . rst <nl> To upgrade a FoundationDB cluster , you must install the updated version of Found <nl> <nl> . . warning : : | development - use - only - warning | <nl> <nl> + . . note : : For information about upgrading client application code to newer API versions , see the : doc : ` api - version - upgrade - guide ` . <nl> + <nl> Install updated client binaries <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> mmm a / documentation / sphinx / source / api - general . rst <nl> ppp b / documentation / sphinx / source / api - general . rst <nl> Versioning <nl> <nl> FoundationDB supports a robust versioning system for both its API and binaries . This system allows clusters to be upgraded with minimal changes to both application code and FoundationDB binaries . The API and the FoundationDB binaries are each released in numbered versions . Each version of the binaries has a corresponding API version . <nl> <nl> + . . _api - versions : <nl> + <nl> API versions <nl> mmmmmmmmmmmm <nl> <nl> mmm a / documentation / sphinx / source / api - python . rst <nl> ppp b / documentation / sphinx / source / api - python . rst <nl> When you import the ` ` fdb ` ` module , it exposes only one useful symbol : <nl> <nl> . . warning : : | api - version - multi - version - warning | <nl> <nl> - For API changes between version 13 and | api - version | ( for the purpose of porting older programs ) , see : doc : ` release - notes ` . <nl> + For API changes between version 13 and | api - version | ( for the purpose of porting older programs ) , see : doc : ` release - notes ` and : doc : ` api - version - upgrade - guide ` . <nl> <nl> Opening a database <nl> = = = = = = = = = = = = = = = = = = <nl> mmm a / documentation / sphinx / source / api - ruby . rst <nl> ppp b / documentation / sphinx / source / api - ruby . rst <nl> When you require the ` ` FDB ` ` gem , it exposes only one useful method : <nl> <nl> . . warning : : | api - version - multi - version - warning | <nl> <nl> - For API changes between version 14 and | api - version | ( for the purpose of porting older programs ) , see : doc : ` release - notes ` . <nl> + For API changes between version 14 and | api - version | ( for the purpose of porting older programs ) , see : doc : ` release - notes ` and : doc : ` api - version - upgrade - guide ` . <nl> <nl> Opening a database <nl> = = = = = = = = = = = = = = = = = = <nl> new file mode 100644 <nl> index 0000000000 . . eab7f8b6a2 <nl> mmm / dev / null <nl> ppp b / documentation / sphinx / source / api - version - upgrade - guide . rst <nl> <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + API Version Upgrade Guide <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + Overview <nl> + = = = = = = = = <nl> + <nl> + This document provides an overview of changes that an application developer may need to make or effects that they should consider when upgrading the API version in their code . For each version , a list is provided that details the relevant changes when upgrading to that version from a prior version . To upgrade across multiple versions , make sure you apply changes from each version starting after your start version up to and including your target version . <nl> + <nl> + For more details about API versions , see : ref : ` api - versions ` . <nl> + <nl> + . . _api - version - upgrade - guide - 620 : <nl> + <nl> + API version 620 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + C bindings <nl> + mmmmmmmmm - <nl> + <nl> + * ` ` fdb_future_get_version ` ` has been renamed to ` ` fdb_future_get_int64 ` ` . <nl> + <nl> + . . _api - version - upgrade - guide - 610 : <nl> + <nl> + API version 610 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * The concept of opening a cluster has been removed from the API . Instead , databases are opened directly . See binding specific notes for the details as they apply to your language binding . <nl> + * The ` ` TIMEOUT ` ` , ` ` MAX_RETRY_DELAY ` ` , and ` ` RETRY_LIMIT ` ` transaction options are no longer reset by calls to ` ` onError ` ` . <nl> + * Calling ` ` onError ` ` with a non - retryable error will now put a transaction into an error state . Previously , this would partially reset the transaction . <nl> + * The ` ` TRANSACTION_LOGGING_ENABLE ` ` option has been deprecated . Its behavior can be replicated by setting the ` ` DEBUG_TRANSACTION_IDENTIFIER ` ` and ` ` LOG_TRANSACTION ` ` options . <nl> + <nl> + C bindings <nl> + mmmmmmmmm - <nl> + <nl> + * Creating a database is now done by calling ` ` fdb_create_database ` ` , which is a synchronous operation . <nl> + * The ` ` FDBCluster ` ` type has been eliminated and the following functions have been removed : ` ` fdb_create_cluster ` ` , ` ` fdb_cluster_create_database ` ` , ` ` fdb_cluster_set_option ` ` , ` ` fdb_cluster_destroy ` ` , ` ` fdb_future_get_cluster ` ` , and ` ` fdb_future_get_database ` ` . <nl> + <nl> + Python bindings <nl> + mmmmmmmmmmmmmmm <nl> + <nl> + * ` ` fdb . open ` ` no longer accepts a ` ` database_name ` ` parameter . <nl> + * Removed ` ` fdb . init ` ` , ` ` fdb . create_cluster ` ` , and ` ` fdb . Cluster ` ` . ` ` fdb . open ` ` should be used instead . <nl> + <nl> + Java bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * ` ` FDB . createCluster ` ` and the ` ` Cluster ` ` class have been deprecated . ` ` FDB . open ` ` should be used instead . <nl> + <nl> + Ruby bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * ` ` FDB . open ` ` no longer accepts a ` ` database_name ` ` parameter . <nl> + * Removed ` ` FDB . init ` ` , ` ` FDB . create_cluster ` ` , and ` ` FDB . Cluster ` ` . ` ` FDB . open ` ` should be used instead . <nl> + <nl> + Go bindings <nl> + mmmmmmmmm - - <nl> + <nl> + * Added ` ` fdb . OpenDatabase ` ` and ` ` fdb . MustOpenDatabase ` ` to open a connection to the database by specifying a cluster file . <nl> + * Deprecated ` ` fdb . StartNetwork ` ` , ` ` fdb . Open ` ` , ` ` fdb . MustOpen ` ` , and ` ` fdb . CreateCluster ` ` . ` ` fdb . OpenDatabase ` ` or ` ` fdb . OpenDefault ` ` should be used instead . <nl> + <nl> + . . _api - version - upgrade - guide - 600 : <nl> + <nl> + API version 600 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * The ` ` TLS_PLUGIN ` ` option is now a no - op and has been deprecated . TLS support is now included in the published binaries . <nl> + <nl> + . . _api - version - upgrade - guide - 520 : <nl> + <nl> + API version 520 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * The ` ` SET_VERSIONSTAMPED_KEY ` ` atomic operation now uses four bytes instead of two to specify the versionstamp offset . <nl> + * The ` ` SET_VERSIONSTAMPED_VALUE ` ` atomic operation now requires a four byte versionstamp offset to be specified at the end of the value , similar to the behavior with ` ` SET_VERSIONSTAMPED_KEY ` ` . <nl> + * The ` ` READ_AHEAD_DISABLE ` ` option has been deprecated . <nl> + <nl> + Java and Python bindings <nl> + mmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + * Tuples packed with versionstamps will be encoded with four byte offsets instead of two . <nl> + <nl> + . . _api - version - upgrade - guide - 510 : <nl> + <nl> + API version 510 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * The atomic operations ` ` AND ` ` and ` ` MIN ` ` have changed behavior when used on a key that isn ' t present in the database . Previously , these operations would set an unset key to a value of equal length with the specified value but containing all null bytes ( 0x00 ) . Now , an unset key will be set with the value passed to the operation ( equivalent to a set ) . <nl> + <nl> + Java bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * Note : the Java bindings as of 5 . 1 no longer support API versions older that 510 . <nl> + * The Java bindings have moved packages from ` ` com . apple . cie . foundationdb ` ` to ` ` com . apple . foundationdb ` ` . <nl> + * The version of the Java bindings using our custom futures library has been deprecated and is no longer being maintained . The Java bindings using ` ` CompletableFuture ` ` are the only ones that remain . <nl> + * Finalizers now log a warning to ` ` stderr ` ` if an object with native resources is not closed . This can be disabled by calling ` ` FDB . setUnclosedWarning ( ) ` ` . <nl> + * Implementers of the ` ` Disposable ` ` interface now implement ` ` AutoCloseable ` ` instead , with ` ` close ( ) ` ` replacing ` ` dispose ( ) ` ` . <nl> + * ` ` AutoCloseable ` ` objects will continue to be closed in object finalizers , but this behavior is being deprecated . All ` ` AutoCloseable ` ` objects should be explicitly closed . <nl> + * ` ` AsyncIterator ` ` is no longer closeable . <nl> + * ` ` getBoundaryKeys ( ) ` ` now returns a ` ` CloseableAsyncIterable ` ` rather than an ` ` AsyncIterator ` ` . <nl> + <nl> + . . _api - version - upgrade - guide - 500 : <nl> + <nl> + API version 500 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + Java bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * Note : the Java bindings as of 5 . 0 no longer support API versions older than 500 . <nl> + * ` ` FDB . open ` ` and ` ` Cluster . openDatabase ` ` no longer take a DB name parameter . <nl> + * ` ` Transaction . onError ` ` invalidates its transaction and asynchronously return a new replacement ` ` Transaction ` ` . <nl> + * ` ` Transaction . reset ` ` has been removed . <nl> + <nl> + . . _api - version - upgrade - guide - 460 : <nl> + <nl> + API version 460 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + There are no behavior changes in this API version . <nl> + <nl> + . . _api - version - upgrade - guide - 450 : <nl> + <nl> + API version 450 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + There are no behavior changes in this API version . <nl> + <nl> + . . _api - version - upgrade - guide - 440 : <nl> + <nl> + API version 440 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + There are no behavior changes in this API version . <nl> + <nl> + . . _api - version - upgrade - guide - 430 : <nl> + <nl> + API version 430 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + There are no behavior changes in this API version . <nl> + <nl> + . . _api - version - upgrade - guide - 420 : <nl> + <nl> + API version 420 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + There are no behavior changes in this API version . <nl> + <nl> + . . _api - version - upgrade - guide - 410 : <nl> + <nl> + API version 410 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * Transactions no longer reset after a successful commit . <nl> + <nl> + . . _api - version - upgrade - guide - 400 : <nl> + <nl> + API version 400 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + Java bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * The Java bindings have moved packages from ` ` com . foundationdb ` ` to ` ` com . apple . cie . foundationdb ` ` . <nl> + <nl> + . . _api - version - upgrade - guide - 300 : <nl> + <nl> + API version 300 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * Snapshot reads now see the effects of prior writes within the same transaction . The previous behavior can be achieved using the ` ` SNAPSHOT_RYW_DISABLE ` ` transaction option . <nl> + * The transaction size limit now includes the size of conflict ranges in its calculation . The size of a conflict range is the sum of the lengths of its begin and end keys . <nl> + * Adding conflict ranges or watches in the system keyspace ( beginning with ` ` \ xFF ` ` ) now requires setting the ` ` READ_SYSTEM_KEYS ` ` or ` ` ACCESS_SYSTEM_KEYS ` ` option . <nl> + <nl> + . . _api - version - upgrade - guide - 200 : <nl> + <nl> + API version 200 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + General <nl> + mmmmmm - <nl> + <nl> + * Read version requests will now fail when the transaction is reset or has experienced another error . <nl> + <nl> + . . _api - version - upgrade - guide - 100 : <nl> + <nl> + API version 100 <nl> + = = = = = = = = = = = = = = = <nl> + <nl> + Java bindings <nl> + mmmmmmmmmmmm - <nl> + <nl> + * ` ` Transaction . clearRangeStartsWith ` ` has been deprecated . ` ` Transaction . clear ( Range ) ` ` should be used instead . <nl> + <nl> + Older API versions <nl> + = = = = = = = = = = = = = = = = = = <nl> + <nl> + API versions from the beta and alpha releases of Foundationdb ( pre - 100 ) are not documented here . See : doc : ` old - release - notes / release - notes - 023 ` for details about changes in those releases . <nl> mmm a / documentation / sphinx / source / client - design . rst <nl> ppp b / documentation / sphinx / source / client - design . rst <nl> FoundationDB supports language bindings for application development using the or <nl> <nl> * : doc : ` api - general ` contains information on FoundationDB clients applicable across all language bindings . <nl> <nl> + * : doc : ` api - version - upgrade - guide ` contains information about upgrading client code to a new API version . <nl> + <nl> * : doc : ` known - limitations ` describes both long - term design limitations of FoundationDB and short - term limitations applicable to the current version . <nl> <nl> . . toctree : : <nl> FoundationDB supports language bindings for application development using the or <nl> client - testing <nl> api - general <nl> known - limitations <nl> + api - version - upgrade - guide <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 014 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 014 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( Alpha 5 ) <nl> - # # # # # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> FoundationDB Alpha 5 <nl> = = = = = = = = = = = = = = = = = = = = <nl> <nl> Language support <nl> mmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + mmmmmmmmmmmmmmm - <nl> <nl> * FoundationDB now supports : doc : ` Ruby < / api - ruby > ` <nl> <nl> Language support <nl> . . _alpha - 5 - rel - notes - features : <nl> <nl> Features <nl> mmmmmmmmmmmm - <nl> + mmmmmm - - <nl> + <nl> * A new : doc : ` backup < / backups > ` system allows scheduled backups of a snapshot of the FoundationDB database to an external filesystem . <nl> <nl> * : doc : ` Integrated HTML documentation < / index > ` <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 016 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 016 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( Alpha 6 ) <nl> - # # # # # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> FoundationDB Alpha 6 <nl> = = = = = = = = = = = = = = = = = = = = <nl> <nl> Platform support <nl> mmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + mmmmmmmmmmmmmmm - <nl> <nl> * FoundationDB now supports both clients and development servers on : doc : ` Mac OS X < / getting - started - mac > ` . <nl> <nl> Platform support <nl> * All language APIs are supported on Linux , Mac , and Windows ( except for Ruby on Windows , because there is not a 64 - bit Ruby for Windows . ) <nl> <nl> Features <nl> mmmmmmmmmmmm - <nl> + mmmmmm - - <nl> <nl> * The set of coordination servers can be safely : ref : ` changed < configuration - changing - coordination - servers > ` on - the - fly via the CLI . <nl> <nl> Features <nl> * The database size estimate shown in the CLI status is much more accurate . <nl> <nl> Performance <nl> mmmmmmmmmmmmmmm <nl> + mmmmmmmmm - - <nl> <nl> * Improved latency performance for intense workloads with range - read operations . <nl> <nl> * Improved performance and decreased memory usage for certain intense write workloads targeting a small set of keys ( such as sequential insert ) . <nl> <nl> Fixes <nl> mmmmmmmmm <nl> + mmm - - <nl> <nl> * An incorrect result could be returned by a range read when : ( 1 ) The range start was specified using a non - default " less than " type key selector ; and ( 2 ) the range read started at the beginning of the database ; and ( 3 ) the transaction also included a prior write to a key less than the key of the begin key selector . <nl> <nl> Changes to all APIs <nl> * Three new transaction options ( : py : meth : ` READ_AHEAD_DISABLE < fdb . Transaction . options . set_read_ahead_disable > ` , : py : meth : ` READ_YOUR_WRITES_DISABLE < fdb . Transaction . options . set_read_your_writes_disable > ` , and : py : meth : ` ACCESS_SYSTEM_KEYS < fdb . Transaction . options . set_access_system_keys > ` ) enable more control for advanced applications . <nl> <nl> Changes to the Java API <nl> mmmmmmmmmmmmmmmmmmmmmmmm - <nl> + mmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> * A new construct ` AsyncUtil . whileTrue ( ) < . . / javadoc / com / apple / cie / foundationdb / async / AsyncUtil . html # whileTrue - com . apple . foundationdb . async . Function - > ` _ simplifies writing loops using the asynchronous version of the Java FDB client . <nl> <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 021 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 021 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( Beta 1 ) <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> Beta 1 <nl> = = = = = = <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 022 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 022 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( Beta 2 ) <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> Beta 2 <nl> = = = = = = <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 023 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 023 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( Beta 3 ) <nl> - # # # # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> Beta 3 <nl> = = = = = = <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 100 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 100 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 1 . 0 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 1 . 0 . 1 <nl> = = = = = <nl> There are only minor technical differences between this release and the 0 . 3 . 0 re <nl> <nl> Java <nl> mmm - <nl> + <nl> * ` ` clear ( Range ) ` ` replaces the now deprecated ` ` clearRangeStartsWith ( ) ` ` . <nl> <nl> Python <nl> mmmmmm <nl> + <nl> * Windows installer supports Python 3 . <nl> <nl> Node and Ruby <nl> mmmmmmmmmmmm - <nl> + <nl> * String option parameters are converted to UTF - 8 . <nl> <nl> All <nl> mmm <nl> - * API version changed to 100 . Programs with lower versions continue to work . <nl> + <nl> + * API version updated to 100 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 100 > ` for upgrade details . <nl> * Runs on Mac OS X 10 . 7 . <nl> * Improvements to installation packages , including package paths and directory modes . <nl> * Eliminated cases of excessive resource usage in the locality API . <nl> All <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * A few Python API entry points failed to respect the ` ` as_foundationdb_key ( ) ` ` convenience interface . <nl> * ` ` fdbcli ` ` could print commit version numbers incorrectly in Windows . <nl> * Multiple watches set on the same key were not correctly triggered by a subsequent write in the same transaction . <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 200 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 200 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 2 . 0 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 2 . 0 . 10 <nl> = = = = = = <nl> Fixes <nl> <nl> PHP <nl> mmm <nl> + <nl> * Package updated to support PHP 5 . 4 + ( instead of 5 . 3 + ) . <nl> * Fix : ` ` get_boundary_keys ( ) ` ` could fail to complete successfully if certain retryable errors were encountered . <nl> * Fix : Bindings set error reporting level , which could interfere with clients that used alternate settings . <nl> <nl> Java <nl> mmm - <nl> + <nl> * Fix : Calling ` ` getRange ` ` on a ` ` Transaction ` ` could leak memory . <nl> <nl> 2 . 0 . 7 <nl> Release 2 . 0 . 5 is protocol - compatible with 2 . 0 . 0 , 2 . 0 . 1 , 2 . 0 . 2 , 2 . 0 . 3 , and 2 . 0 . 4 . <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Clients and servers that specified a cluster file as a filename only ( without path ) could crash when the coordinators were changed . <nl> <nl> PHP <nl> mmm <nl> + <nl> * Directory layer partitions created with the PHP bindings were incompatible with other language bindings . Contact us if you have data stored in a directory partition created by PHP that can ' t easily be restored and needs to be migrated . <nl> <nl> 2 . 0 . 4 <nl> Release 2 . 0 . 4 is protocol - compatible with 2 . 0 . 0 , 2 . 0 . 1 , 2 . 0 . 2 , and 2 . 0 . 3 . Users <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Clearing a key larger than the legal limit of 10 kB caused the database to crash and become unreadable . <nl> * Explicitly added write conflict ranges were ignored when read - your - writes was disabled . <nl> <nl> Java <nl> mmm - <nl> + <nl> * ` ` ByteArrayUtil . compareUnsigned ( ) ` ` failed to return in some circumstances . <nl> <nl> 2 . 0 . 3 <nl> Release 2 . 0 . 3 is protocol - compatible with 2 . 0 . 0 , 2 . 0 . 1 , and 2 . 0 . 2 . There are no <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Updated FDBGnuTLS plugin with GnuTLS 3 . 2 . 12 , incorporating fixes for ` GNUTLS - SA - 2014 - 1 < http : / / gnutls . org / security . html # GNUTLS - SA - 2014 - 1 > ` _ and ` GNUTLS - SA - 2014 - 2 < http : / / gnutls . org / security . html # GNUTLS - SA - 2014 - 2 > ` _ . <nl> * When inserting a large number of keys close to the key size limit , server logs were unexpectedly verbose . <nl> <nl> Release 2 . 0 . 2 is protocol - compatible with 2 . 0 . 0 and 2 . 0 . 1 . There are no updates <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Windows : Possible database corruption when the FoundationDB service is stopped but unable to kill its child processes . <nl> <nl> 2 . 0 . 1 <nl> Release 2 . 0 . 1 is protocol - compatible with 2 . 0 . 0 . There are no updates to the lan <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * In some cases , a server reincluded after previous exclusion would not participate in data distribution . <nl> * Clients could not reliably connect to multiple clusters . <nl> * The calculation of usable disk space on Linux and Mac OS X improperly included space reserved for superuser . <nl> Fixes <nl> <nl> New language support <nl> mmmmmmmmmmmmmmmmmm - - <nl> + <nl> * ` Go < . . / godoc / fdb . html > ` _ <nl> * PHP <nl> <nl> New layers available in all languages <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> * The : ref : ` Subspace < developer - guide - sub - keyspaces > ` layer provides a recommended way to define subspaces of keys by managing key prefixes . <nl> * The : ref : ` Directory < developer - guide - directories > ` layer provides a tool to manage related subspaces as virtual directories . Recommended as a convenient and high - performance way to organize and layout different kinds of data within a single FoundationDB database . <nl> <nl> Security <nl> mmmmmm - - <nl> + <nl> * Added certificate - based : doc : ` Transport Layer Security < / tls > ` to encrypt network traffic . <nl> <nl> Monitoring <nl> mmmmmmmmm - <nl> + <nl> * The ` ` fdbcli ` ` command - line interface reports information and warnings about available memory . <nl> <nl> Performance <nl> mmmmmmmmm - - <nl> + <nl> * Improved client CPU performance overall . <nl> * Greatly improved client CPU performance for range - read operations . <nl> * Greatly improved concurrency when issuing writes between reads . <nl> Performance <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * In rare cases when many keys very close to the maximum key size are inserted , the database could become unavailable . <nl> * ` ` GetReadVersion ` ` did not properly throw ` ` transaction_cancelled ` ` when called on a transaction that had been cancelled . <nl> * When using the ` ` access_system_keys ` ` option , a ` ` get_range_startswith ( \ xff ) ` ` would incorrectly return no results . <nl> Fixes <nl> <nl> Other changes <nl> mmmmmmmmmmmm - <nl> + <nl> * To avoid confusing situations , any use of a transaction that is currently committing will cause both the commit and the use to throw a ` ` used_during_commit ` ` error . <nl> * The ` ` FDB_CLUSTER_FILE ` ` environment variable can point to a cluster file that takes precedence over both the current working directory and ( e . g . , in Linux ) ` ` / etc / foundationdb / fdb . cluster ` ` . <nl> * Disabled unloading the ` ` fdb_c ` ` library to prevent consequent unavoidable race conditions . <nl> * Discontinued testing and support for Ubuntu 11 . 04 . We continue to support Ubuntu 11 . 10 and later . <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 200 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 200 > ` for upgrade details . <nl> + <nl> Java <nl> mmm - <nl> - * Support for API version 200 and backwards compatibility with previous API versions . <nl> + <nl> * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> * In most cases , exceptions thrown in synchronous - style Java programs will have the original calling line of code in the backtrace . <nl> * Native resources are handled in a safer and more efficient manner . <nl> Java <nl> <nl> Node <nl> mmm - <nl> - * Support for API version 200 and backwards compatibility with previous API versions . <nl> + <nl> * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> * Support for the Promise / A + specification with supporting utilities . <nl> * Futures can take multiple callbacks . Callbacks can be added if the original function was called with a callback . The Future type is exposed in our binding . <nl> Node <nl> <nl> Ruby <nl> mmm - <nl> - * Support for API version 200 and backwards compatibility with previous API versions . <nl> + <nl> * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> * Tuple and subspace range assume the empty tuple if none is passed . <nl> * Added ` ` as_foundationdb_key ` ` and ` ` as_foundationdb_value ` ` support . <nl> Ruby <nl> <nl> Python <nl> mmmmmm <nl> - * Support for API version 200 and backwards compatibility with previous API versions . <nl> + <nl> * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> * Snapshot transactions can be used in retry loops . <nl> * Support for gevent 1 . 0 . <nl> Python <nl> <nl> C <nl> - <nl> + <nl> * Support for API version 200 and backwards compatibility with previous API versions . <nl> <nl> . NET <nl> mmm - <nl> - * Support for API version 200 and backwards compatibility with previous API versions . <nl> - * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> - <nl> <nl> + * New APIs for allocating and managing keyspace ( : ref : ` Directory < developer - guide - directories > ` ) . <nl> <nl> Earlier release notes <nl> mmmmmmmmmmmmmmmmmmmmm <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 300 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 300 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 3 . 0 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 3 . 0 . 8 <nl> = = = = = <nl> Release 3 . 0 . 8 is protocol - compatible with all prior 3 . 0 . x releases . All users sh <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Backup : the backup agent could crash in some circumstances , preventing a backup from completing . <nl> * Linux : On some systems , disk space usage tracking could be inaccurate . <nl> * In rare cases , range reading could get stuck in an infinite past_version loop . <nl> Fixes <nl> <nl> Java <nl> mmm - <nl> + <nl> * Fix : getBoundaryKeys could throw a NullPointerException . <nl> <nl> 3 . 0 . 7 <nl> Release 3 . 0 . 7 is protocol - compatible with all prior 3 . 0 . x releases . All users sh <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * ` ` fdbcli ` ` would segmentation fault if there was a semicolon after a quoted string . <nl> * : ref : ` Atomic operations < api - python - transaction - atomic - operations > ` performed on keys that had been : ref : ` snapshot read < api - python - snapshot - reads > ` would be converted into a set operation . <nl> * Reading a key to which an atomic operation had already been applied would cause the read to behave as a snapshot read . <nl> Fixes <nl> <nl> Ruby <nl> mmm - <nl> + <nl> * Fix : ` ` FDB ` ` objects could not be garbage collected . <nl> <nl> 3 . 0 . 6 <nl> Release 3 . 0 . 6 is protocol - compatible with all prior 3 . 0 . x releases . All users sh <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Read - latency probes for status incorrectly returned zero . <nl> * Commit - latency probe for status included the time to acquire its read version . <nl> * Client and server could crash when experiencing problems with network connections . <nl> <nl> Node . js <nl> mmmmmm - <nl> + <nl> * Fix : npm source package did not compile on Mac OS X 10 . 9 or newer . <nl> <nl> Windows <nl> mmmmmm - <nl> + <nl> * Added registry key during installation . <nl> <nl> 3 . 0 . 5 <nl> Release 3 . 0 . 5 is protocol - compatible with all prior 3 . 0 . x releases . This release <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Windows : fix Visual Studio 2013 code generation bug on older processors or versions of Windows that don ' t support the AVX instruction set ( see https : / / connect . microsoft . com / VisualStudio / feedback / details / 811093 ) . <nl> <nl> 3 . 0 . 4 <nl> Release 3 . 0 . 4 is protocol - compatible with all prior 3 . 0 . x releases . Users should <nl> <nl> Fixes <nl> mmm - - <nl> + <nl> * Mac OS X : backup agent used 100 % CPU even when idle . <nl> * Backups were inoperative on databases with greater than 32 - bit versions . <nl> * Backup agents were not started on Windows . <nl> Fixes <nl> <nl> Node . js <nl> mmmmmm - <nl> + <nl> * Fixed a compilation problem on Linux and Mac OS X as distributed on ` ` npm ` ` . ( Note : The corrected binding is distributed as version 3 . 0 . 3 . ) <nl> <nl> 3 . 0 . 2 <nl> Fixes <nl> Client <nl> mmmmmm <nl> <nl> - * Support for API version 300 and backwards compatible with previous API versions . <nl> + * API version updated to 300 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 300 > ` for upgrade details . <nl> * By default , : ref : ` snapshot reads < snapshot isolation > ` see writes within the same transaction . The previous behavior can be achieved using transaction options . <nl> * The : ref : ` transaction size limit < large - transactions > ` includes conflict ranges . <nl> * Explicitly added read or write : ref : ` conflict ranges < api - python - conflict - ranges > ` and : ref : ` watches < api - python - watches > ` for keys that begin with ` ` \ xFF ` ` require one of the transaction options ` ` access_system_keys ` ` or ` ` read_system_keys ` ` to be set . <nl> Java <nl> <nl> Node . js <nl> mmmmmm - <nl> + <nl> * Fix : ` ` fdb . open ` ` , ` ` fdb . createCluster ` ` , and ` ` cluster . openDatabase ` ` didn ' t use the callback in API versions 22 or lower . <nl> * Tuple performance is improved . <nl> <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 400 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 400 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 0 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 0 . 2 <nl> = = = = = <nl> Fixes <nl> <nl> * It was not safe to allocate multiple directories concurrently in the same transaction in the directory layer . <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 400 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 400 > ` for upgrade details . <nl> + <nl> Java <nl> mmm - <nl> <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 410 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 410 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 1 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 1 . 1 <nl> = = = = = <nl> Fixes <nl> * A rare scenario could cause a crash when a master is recovering metadata from the previous generation of logs . <nl> * Streaming mode ` ` EXACT ` ` was ignoring the ` ` target_bytes ` ` parameter . <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 410 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 410 > ` for upgrade details . <nl> + <nl> Earlier release notes <nl> mmmmmmmmmmmmmmmmmmmmm <nl> * : doc : ` 4 . 0 ( API Version 400 ) < release - notes - 400 > ` <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 420 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 420 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 2 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 2 . 1 <nl> = = = = = <nl> Features <nl> * Information on the versions of connected clients has been added to : doc : ` Machine - Readable Status < / mr - status > ` . <nl> * Information on the status of running backups has been added to : doc : ` Machine - Readable Status < / mr - status > ` . <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 420 . There are no behavior changes in this API version . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 420 > ` for upgrade details . <nl> + <nl> Earlier release notes <nl> mmmmmmmmmmmmmmmmmmmmm <nl> * : doc : ` 4 . 1 ( API Version 410 ) < release - notes - 410 > ` <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 430 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 430 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 3 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 3 . 0 <nl> = = = = = <nl> Fixes <nl> * Changed the blob restore read pattern to work around blob store issues . <nl> * External clients do not load environment variable options . <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 430 . There are no behavior changes in this API version . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 430 > ` for upgrade details . <nl> + <nl> Earlier release notes <nl> mmmmmmmmmmmmmmmmmmmmm <nl> * : doc : ` 4 . 2 ( API Version 420 ) < release - notes - 420 > ` <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 440 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 440 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 4 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 4 . 2 <nl> = = = = = <nl> Fixes <nl> * DR errors were not being reported properly in DR status . <nl> * Backup and DR layer status expiration and cleanup now use database read version instead of time . < rdar : / / problem / 24805824 > <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 440 . There are no behavior changes in this API version . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 440 > ` for upgrade details . <nl> + <nl> Java <nl> mmm - <nl> <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 450 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 450 . rst <nl> <nl> - # # # # # # # # # # # # # # # # # # # <nl> - Release Notes ( 4 . 5 ) <nl> - # # # # # # # # # # # # # # # # # # # <nl> + # # # # # # # # # # # # # <nl> + Release Notes <nl> + # # # # # # # # # # # # # <nl> <nl> 4 . 5 . 6 <nl> = = = = = <nl> Backup <nl> Bindings <nl> mmmmmm - - <nl> <nl> + * API version updated to 450 . There are no behavior changes in this API version . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 450 > ` for upgrade details . <nl> * Add error predicate testing to client bindings . This new functionality should help complex use cases write correct transaction retry loops where dispatching on error classes is needed . < rdar : / / problem / 24492860 > <nl> <nl> Other Changes <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 460 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 460 . rst <nl> Fixes <nl> * Java : fix race condition when removing an empty directory which could lead to a NoSuchElementException < rdar : / / problem / 28858833 > <nl> * Fixed a source of potential crashes in fdbcli < rdar : / / problem / 27063940 > <nl> <nl> + Bindings <nl> + mmmmmm - - <nl> + <nl> + * API version updated to 460 . There are no behavior changes in this API version . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 460 > ` for upgrade details . <nl> + <nl> Status <nl> mmmmmm <nl> <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 500 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 500 . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> - * API version updated to 500 . <nl> + * API version updated to 500 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 500 > ` for upgrade details . <nl> * Tuples now support single - and double - precision floating point numbers , UUIDs , booleans , and nested tuples . < rdar : / / problem / 30053926 > <nl> * Add ` ` TRANSACTION_LOGGING_ENABLE ` ` transaction option that causes the details of a transaction ' s operations to be logged to the client trace logs . < rdar : / / problem / 32074484 > <nl> * Add ` ` USED_DURING_COMMIT_PROTECTION_DISABLE ` ` transaction option that prevents operations performed during that transaction ' s commit from causing the commit to fail . < rdar : / / problem / 30378251 > <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 510 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 510 . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> - * API version updated to 510 . <nl> + * API version updated to 510 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 510 > ` for upgrade details . <nl> * Add versionstamp support to the Tuple layer in Java and Python . < rdar : / / problem / 25560444 > <nl> <nl> Java <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 520 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 520 . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> - * API version updated to 520 . <nl> + * API version updated to 520 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 520 > ` for upgrade details . <nl> * Java and Python : Versionstamp packing methods within tuple class now add four bytes for the offset instead of two if the API version is set to 520 or higher . ` ( Issue # 148 ) < https : / / github . com / apple / foundationdb / issues / 148 > ` _ <nl> * Added convenience methods to determine if an API version has been set . ` ( PR # 72 ) < https : / / github . com / apple / foundationdb / pull / 72 > ` _ <nl> * Go : Reduce memory allocations when packing tuples . ` ( PR # 278 ) < https : / / github . com / apple / foundationdb / pull / 278 > ` _ <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 600 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 600 . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> - * API version updated to 600 . There are no changes since API version 520 . <nl> + * API version updated to 600 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 600 > ` for upgrade details . <nl> * Several cases where functions in go might previously cause a panic now return a non - ` ` nil ` ` error . ` ( PR # 532 ) < https : / / github . com / apple / foundationdb / pull / 532 > ` _ <nl> * C API calls made on the network thread could be reordered with calls made from other threads . [ 6 . 0 . 2 ] ` ( Issue # 518 ) < https : / / github . com / apple / foundationdb / issues / 518 > ` _ <nl> * The TLS_PLUGIN option is now a no - op and has been deprecated . [ 6 . 0 . 10 ] ` ( PR # 710 ) < https : / / github . com / apple / foundationdb / pull / 710 > ` _ <nl> mmm a / documentation / sphinx / source / old - release - notes / release - notes - 610 . rst <nl> ppp b / documentation / sphinx / source / old - release - notes / release - notes - 610 . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> - * API version updated to 610 . <nl> + * API version updated to 610 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 610 > ` for upgrade details . <nl> * The API to create a database has been simplified across the bindings . All changes are backward compatible with previous API versions , with one exception in Java noted below . ` ( PR # 942 ) < https : / / github . com / apple / foundationdb / pull / 942 > ` _ <nl> * C : ` ` FDBCluster ` ` objects and related methods ( ` ` fdb_create_cluster ` ` , ` ` fdb_cluster_create_database ` ` , ` ` fdb_cluster_set_option ` ` , ` ` fdb_cluster_destroy ` ` , ` ` fdb_future_get_cluster ` ` ) have been removed . ` ( PR # 942 ) < https : / / github . com / apple / foundationdb / pull / 942 > ` _ <nl> * C : Added ` ` fdb_create_database ` ` that creates a new ` ` FDBDatabase ` ` object synchronously and removed ` ` fdb_future_get_database ` ` . ` ( PR # 942 ) < https : / / github . com / apple / foundationdb / pull / 942 > ` _ <nl> mmm a / documentation / sphinx / source / release - notes . rst <nl> ppp b / documentation / sphinx / source / release - notes . rst <nl> Status <nl> Bindings <nl> mmmmmm - - <nl> <nl> + * API version updated to 620 . See the : ref : ` API version upgrade guide < api - version - upgrade - guide - 620 > ` for upgrade details . <nl> * Add a transaction size limit as both a database option and a transaction option . ` ( PR # 1725 ) < https : / / github . com / apple / foundationdb / pull / 1725 > ` _ . <nl> * Added a new API to get the approximated transaction size before commit , e . g . , ` ` fdb_transaction_get_approximate_size ` ` in the C binding . ` ( PR # 1756 ) < https : / / github . com / apple / foundationdb / pull / 1756 > ` _ . <nl> * C : ` ` fdb_future_get_version ` ` has been renamed to ` ` fdb_future_get_int64 ` ` . ` ( PR # 1756 ) < https : / / github . com / apple / foundationdb / pull / 1756 > ` _ . <nl>
|
Merge pull request from ajbeamon / document - api - version - upgrade - guide
|
apple/foundationdb
|
8972027f433ea971fa3ac43d535b8a0522848738
|
2020-01-25T02:30:53Z
|
old mode 100644 <nl> new mode 100755 <nl> mmm a / src / ruby / tools / grpc - tools . gemspec <nl> ppp b / src / ruby / tools / grpc - tools . gemspec <nl> require_relative ' version . rb ' <nl> Gem : : Specification . new do | s | <nl> s . name = ' grpc - tools ' <nl> s . version = GRPC : : Tools : : VERSION <nl> + s . authors = [ ' grpc Authors ' ] <nl> + s . email = ' grpc - io @ googlegroups . com ' <nl> s . homepage = ' https : / / github . com / google / grpc / tree / master / src / ruby / tools ' <nl> s . summary = ' Development tools for Ruby gRPC ' <nl> s . description = ' protoc and the Ruby gRPC protoc plugin ' <nl>
|
Fixed grpc - tools . gemspec
|
grpc/grpc
|
faf3bfca82c88b1bf08995fdfb26a152c90bf0a5
|
2016-04-29T19:39:05Z
|
mmm a / ios / sdk / WeexSDK / Sources / Module / WXDomModule . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Module / WXDomModule . m <nl> - ( void ) addRule : ( NSString * ) type rule : ( NSDictionary * ) rule { <nl> } <nl> <nl> - ( void ) getComponentRect : ( NSString * ) ref callback : ( WXModuleKeepAliveCallback ) callback { <nl> - [ self performBlockOnComponentMananger : ^ ( WXComponentManager * manager ) { <nl> + [ self performBlockOnComponentManager : ^ ( WXComponentManager * manager ) { <nl> UIView * rootView = manager . weexInstance . rootView ; <nl> CGRect rootRect = [ rootView . superview convertRect : rootView . frame toView : rootView ] ; <nl> if ( [ ref isEqualToString : @ " viewport " ] ) { <nl>
|
* [ ios ] fix spell
|
apache/incubator-weex
|
4a5bc5aa021e09fc74aed3505c85f1ec165405c0
|
2017-02-06T07:38:59Z
|
mmm a / . bazelrc <nl> ppp b / . bazelrc <nl> <nl> # Android options : <nl> # android : <nl> # android_arm : <nl> + # android_arm64 : <nl> # android_x86 : <nl> # android_x86_64 : <nl> # <nl> mmm a / tensorflow / lite / examples / minimal / minimal . cc <nl> ppp b / tensorflow / lite / examples / minimal / minimal . cc <nl> limitations under the License . <nl> / / <nl> / / Usage : minimal < tflite model > <nl> <nl> - using namespace tflite ; <nl> - <nl> # define TFLITE_MINIMAL_CHECK ( x ) \ <nl> if ( ! ( x ) ) { \ <nl> fprintf ( stderr , " Error at % s : % d \ n " , __FILE__ , __LINE__ ) ; \ <nl> int main ( int argc , char * argv [ ] ) { <nl> / / which allocates memory for the Intrepter and does various set up <nl> / / tasks so that the Interpreter can read the provided model . <nl> tflite : : ops : : builtin : : BuiltinOpResolver resolver ; <nl> - InterpreterBuilder builder ( * model , resolver ) ; <nl> - std : : unique_ptr < Interpreter > interpreter ; <nl> + tflite : : InterpreterBuilder builder ( * model , resolver ) ; <nl> + std : : unique_ptr < tflite : : Interpreter > interpreter ; <nl> builder ( & interpreter ) ; <nl> TFLITE_MINIMAL_CHECK ( interpreter ! = nullptr ) ; <nl> <nl> int main ( int argc , char * argv [ ] ) { <nl> tflite : : PrintInterpreterState ( interpreter . get ( ) ) ; <nl> <nl> / / Fill input buffers <nl> - / / TODO ( user ) : Insert code to fill input tensors <nl> + / / TODO ( user ) : Insert code to fill input tensors . <nl> + / / Note : The buffer of the input tensor with index ` i ` of type T can <nl> + / / be accessed with ` T * input = interpreter - > typed_input_tensor < T > ( i ) ; ` <nl> <nl> / / Run inference <nl> TFLITE_MINIMAL_CHECK ( interpreter - > Invoke ( ) = = kTfLiteOk ) ; <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> / / Read output buffers <nl> / / TODO ( user ) : Insert getting data out code . <nl> + / / Note : The buffer of the output tensor with index ` i ` of type T can <nl> + / / be accessed with ` T * output = interpreter - > typed_output_tensor < T > ( i ) ; ` <nl> <nl> return 0 ; <nl> } <nl>
|
Merge pull request from nordstroem : update - tf - lite - examples
|
tensorflow/tensorflow
|
b0c3b5bdd768a1410a498642aec6de842692d857
|
2020-09-17T14:45:11Z
|
mmm a / src / core / console_user_server / CMakeLists . txt <nl> ppp b / src / core / console_user_server / CMakeLists . txt <nl> include_directories ( <nl> add_executable ( <nl> karabiner_console_user_server <nl> src / main . cpp <nl> - . . / . . / vendor / cget / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> + . . / . . / vendor / cget / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> ) <nl> <nl> target_link_libraries ( <nl> mmm a / src / lib / libkrbn / CMakeLists . txt <nl> ppp b / src / lib / libkrbn / CMakeLists . txt <nl> add_library ( <nl> src / libkrbn_system_preferences_monitor . cpp <nl> src / libkrbn_version_monitor . cpp <nl> src / libkrbn . cpp <nl> - . . / . . / vendor / cget / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> + . . / . . / vendor / cget / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> ) <nl> mmm a / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor . hpp <nl> ppp b / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor . hpp <nl> <nl> # pragma once <nl> <nl> - / / pqrs : : osx : : frontmost_application_monitor v1 . 0 <nl> + / / pqrs : : osx : : frontmost_application_monitor v1 . 1 <nl> <nl> / / ( C ) Copyright Takayama Fumihiko 2019 . <nl> / / Distributed under the Boost Software License , Version 1 . 0 . <nl> similarity index 95 % <nl> rename from src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / objc . h <nl> rename to src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / impl / objc . h <nl> mmm a / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / objc . h <nl> ppp b / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / impl / objc . h <nl> <nl> extern " C " { <nl> # endif <nl> <nl> + / / Do not use these functions directly . <nl> + <nl> typedef void pqrs_osx_frontmost_application_monitor_objc ; <nl> typedef void ( * pqrs_osx_frontmost_application_monitor_callback ) ( const char * bundle_identifier , <nl> const char * file_path , <nl> mmm a / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / monitor . hpp <nl> ppp b / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / monitor . hpp <nl> <nl> / / ` pqrs : : osx : : frontmost_application_monitor ` can be used safely in a multi - threaded environment . <nl> <nl> # include " application . hpp " <nl> - # include " objc . h " <nl> + # include " impl / objc . h " <nl> # include < nod / nod . hpp > <nl> # include < pqrs / dispatcher . hpp > <nl> <nl> similarity index 60 % <nl> rename from src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> rename to src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> mmm a / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> ppp b / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> <nl> / / ( See http : / / www . boost . org / LICENSE_1_0 . txt ) <nl> <nl> # import < Cocoa / Cocoa . h > <nl> - # import < pqrs / osx / frontmost_application_monitor / objc . h > <nl> + # import < pqrs / osx / frontmost_application_monitor / impl / objc . h > <nl> + # import < pqrs / weakify . h > <nl> <nl> @ interface PqrsOsxFrontmostApplicationMonitor : NSObject <nl> <nl> + @ property NSOperationQueue * queue ; <nl> @ property pqrs_osx_frontmost_application_monitor_callback callback ; <nl> @ property void * context ; <nl> <nl> @ interface PqrsOsxFrontmostApplicationMonitor : NSObject <nl> <nl> @ implementation PqrsOsxFrontmostApplicationMonitor <nl> <nl> + / / This method is called in the monitor ' s dispatcher thread . <nl> - ( instancetype ) initWithCallback : ( pqrs_osx_frontmost_application_monitor_callback ) callback <nl> context : ( void * ) context { <nl> self = [ super init ] ; <nl> <nl> if ( self ) { <nl> + _queue = [ NSOperationQueue new ] ; <nl> _callback = callback ; <nl> _context = context ; <nl> <nl> - [ NSWorkspace . sharedWorkspace . notificationCenter addObserver : self <nl> - selector : @ selector ( handleNotification : ) <nl> - name : NSWorkspaceDidActivateApplicationNotification <nl> - object : nil ] ; <nl> + @ weakify ( self ) ; <nl> + <nl> + [ NSWorkspace . sharedWorkspace . notificationCenter <nl> + addObserverForName : NSWorkspaceDidActivateApplicationNotification <nl> + object : nil <nl> + queue : _queue <nl> + usingBlock : ^ ( NSNotification * notification ) { <nl> + / / This block is called in ` queue_ ` . <nl> + <nl> + @ strongify ( self ) ; <nl> + if ( ! self ) { <nl> + return ; <nl> + } <nl> + <nl> + @ try { <nl> + NSRunningApplication * runningApplication = notification . userInfo [ NSWorkspaceApplicationKey ] ; <nl> + [ self runCallback : runningApplication ] ; <nl> + } @ catch ( NSException * exception ) { <nl> + NSLog ( @ " [ PqrsOsxFrontmostApplicationMonitor NSWorkspaceDidActivateApplicationNotification ] error : % @ " , exception ) ; <nl> + } <nl> + } ] ; <nl> } <nl> <nl> return self ; <nl> } <nl> <nl> + / / This method is called in the monitor ' s dispatcher thread . <nl> - ( void ) dealloc { <nl> - [ NSNotificationCenter . defaultCenter removeObserver : self ] ; <nl> + [ NSWorkspace . sharedWorkspace . notificationCenter removeObserver : self ] ; <nl> + <nl> + [ _queue waitUntilAllOperationsAreFinished ] ; <nl> } <nl> <nl> + / / This method is called in the monitor ' s dispatcher thread . <nl> - ( void ) runCallback : ( NSRunningApplication * ) runningApplication { <nl> if ( self . callback ) { <nl> @ try { <nl> - ( void ) runCallback : ( NSRunningApplication * ) runningApplication { <nl> } <nl> } <nl> <nl> - - ( void ) handleNotification : ( NSNotification * ) notification { <nl> - @ try { <nl> - NSRunningApplication * runningApplication = notification . userInfo [ NSWorkspaceApplicationKey ] ; <nl> - [ self runCallback : runningApplication ] ; <nl> - } @ catch ( NSException * exception ) { <nl> - NSLog ( @ " [ PqrsOsxFrontmostApplicationMonitor notificationHandler ] error : % @ " , exception ) ; <nl> - } <nl> - } <nl> - <nl> + / / This method is called in the monitor ' s dispatcher thread . <nl> - ( void ) runCallbackWithFrontmostApplication { <nl> [ self runCallback : NSWorkspace . sharedWorkspace . frontmostApplication ] ; <nl> } <nl> <nl> @ end <nl> <nl> + / / This function is called in the monitor ' s dispatcher thread . <nl> bool pqrs_osx_frontmost_application_monitor_initialize ( pqrs_osx_frontmost_application_monitor_objc * * monitor , <nl> pqrs_osx_frontmost_application_monitor_callback callback , <nl> void * context ) { <nl> bool pqrs_osx_frontmost_application_monitor_initialize ( pqrs_osx_frontmost_applic <nl> return true ; <nl> } <nl> <nl> + / / This function is called in the monitor ' s dispatcher thread . <nl> void pqrs_osx_frontmost_application_monitor_terminate ( pqrs_osx_frontmost_application_monitor_objc * * monitor ) { <nl> if ( monitor ) { <nl> # ifndef __clang_analyzer__ <nl> mmm a / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - input_source / install / include / pqrs / osx / input_source . hpp <nl> ppp b / src / vendor / cget / cget / pkg / pqrs - org__cpp - osx - input_source / install / include / pqrs / osx / input_source . hpp <nl> <nl> # pragma once <nl> <nl> - / / pqrs : : osx : : input_source v1 . 0 <nl> + / / pqrs : : osx : : input_source v1 . 1 <nl> <nl> / / ( C ) Copyright Takayama Fumihiko 2019 . <nl> / / Distributed under the Boost Software License , Version 1 . 0 . <nl> <nl> namespace pqrs { <nl> namespace osx { <nl> namespace input_source { <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline cf : : cf_ptr < TISInputSourceRef > make_current_keyboard_input_source ( void ) { <nl> cf : : cf_ptr < TISInputSourceRef > result ; <nl> <nl> inline cf : : cf_ptr < TISInputSourceRef > make_current_keyboard_input_source ( void ) { <nl> return result ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : vector < cf : : cf_ptr < TISInputSourceRef > > make_selectable_keyboard_input_sources ( void ) { <nl> std : : vector < cf : : cf_ptr < TISInputSourceRef > > result ; <nl> <nl> inline std : : vector < cf : : cf_ptr < TISInputSourceRef > > make_selectable_keyboard_input <nl> return result ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : optional < std : : string > make_input_source_id ( TISInputSourceRef input_source ) { <nl> if ( input_source ) { <nl> if ( auto s = static_cast < CFStringRef > ( TISGetInputSourceProperty ( input_source , kTISPropertyInputSourceID ) ) ) { <nl> inline std : : optional < std : : string > make_input_source_id ( TISInputSourceRef input_s <nl> return std : : nullopt ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : optional < std : : string > make_localized_name ( TISInputSourceRef input_source ) { <nl> if ( input_source ) { <nl> if ( auto s = static_cast < CFStringRef > ( TISGetInputSourceProperty ( input_source , kTISPropertyLocalizedName ) ) ) { <nl> inline std : : optional < std : : string > make_localized_name ( TISInputSourceRef input_so <nl> return std : : nullopt ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : optional < std : : string > make_input_mode_id ( TISInputSourceRef input_source ) { <nl> if ( input_source ) { <nl> if ( auto s = static_cast < CFStringRef > ( TISGetInputSourceProperty ( input_source , kTISPropertyInputModeID ) ) ) { <nl> inline std : : optional < std : : string > make_input_mode_id ( TISInputSourceRef input_sou <nl> return std : : nullopt ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : vector < std : : string > make_languages ( TISInputSourceRef input_source ) { <nl> std : : vector < std : : string > result ; <nl> <nl> inline std : : vector < std : : string > make_languages ( TISInputSourceRef input_source ) { <nl> return result ; <nl> } <nl> <nl> + / / You have to call this method in main thread since TIS / TSM requires to be called in main thread . <nl> inline std : : optional < std : : string > make_first_language ( TISInputSourceRef input_source ) { <nl> if ( input_source ) { <nl> if ( auto languages = static_cast < CFArrayRef > ( TISGetInputSourceProperty ( input_source , kTISPropertyInputSourceLanguages ) ) ) { <nl> new file mode 120000 <nl> index 000000000 . . 044ba27ea <nl> mmm / dev / null <nl> ppp b / src / vendor / cget / include / pqrs / osx / frontmost_application_monitor / impl / objc . h <nl> @ @ - 0 , 0 + 1 @ @ <nl> + . . / . . / . . / . . / . . / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / impl / objc . h <nl> \ No newline at end of file <nl> deleted file mode 120000 <nl> index 7158ab57d . . 000000000 <nl> mmm a / src / vendor / cget / include / pqrs / osx / frontmost_application_monitor / objc . h <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - . . / . . / . . / . . / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / include / pqrs / osx / frontmost_application_monitor / objc . h <nl> \ No newline at end of file <nl> new file mode 120000 <nl> index 000000000 . . 509d08c1e <nl> mmm / dev / null <nl> ppp b / src / vendor / cget / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> @ @ - 0 , 0 + 1 @ @ <nl> + . . / . . / . . / . . / . . / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / impl / objc . m <nl> \ No newline at end of file <nl> deleted file mode 120000 <nl> index 7fdc762fa . . 000000000 <nl> mmm a / src / vendor / cget / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - . . / . . / . . / . . / cget / pkg / pqrs - org__cpp - osx - frontmost_application_monitor / install / src / pqrs / osx / frontmost_application_monitor / objc . m <nl> \ No newline at end of file <nl>
|
update frontmost_application_monitor
|
pqrs-org/Karabiner-Elements
|
12843940dcdbccc29e5c75756d12db9186cf07c9
|
2019-01-11T12:16:42Z
|
mmm a / lib / SILPasses / Devirtualizer . cpp <nl> ppp b / lib / SILPasses / Devirtualizer . cpp <nl> static ApplyInst * insertMonomorphicInlineCaches ( ApplyInst * AI , <nl> / / Try sinking the retain of the class instance into the diamond . This may <nl> / / allow additional ARC optimizations on the fast path . <nl> if ( It ! = Entry - > begin ( ) ) { <nl> - StrongRetainInst * SRI = dyn_cast < StrongRetainInst > ( - - It ) ; <nl> + auto * SRI = dyn_cast < StrongRetainInst > ( - - It ) ; <nl> / / Try to skip another instruction , in case the class_method came first . <nl> if ( ! SRI & & It ! = Entry - > begin ( ) ) <nl> SRI = dyn_cast < StrongRetainInst > ( - - It ) ; <nl> static ApplyInst * insertMonomorphicInlineCaches ( ApplyInst * AI , <nl> ApplyInst * IdenAI = CloneApply ( AI , IdenBuilder ) ; <nl> ApplyInst * VirtAI = CloneApply ( AI , VirtBuilder ) ; <nl> <nl> + / / See if Continue has a release on self as the instruction right after the <nl> + / / apply . If it exists , move it into position in the diamond . <nl> + if ( auto * Release = <nl> + dyn_cast < StrongReleaseInst > ( std : : next ( Continue - > begin ( ) ) ) ) { <nl> + if ( Release - > getOperand ( ) = = CMI - > getOperand ( ) ) { <nl> + VirtBuilder . createStrongRelease ( Release - > getLoc ( ) , CMI - > getOperand ( ) ) <nl> + - > setDebugScope ( Release - > getDebugScope ( ) ) ; <nl> + IdenBuilder . createStrongRelease ( Release - > getLoc ( ) , <nl> + DownCastedClassInstance ) <nl> + - > setDebugScope ( Release - > getDebugScope ( ) ) ; <nl> + Release - > eraseFromParent ( ) ; <nl> + } <nl> + } <nl> + <nl> / / Create a PHInode for returning the return value from both apply <nl> / / instructions . <nl> SILArgument * Arg = Continue - > createBBArg ( AI - > getType ( ) ) ; <nl> namespace { <nl> SmallVector < ApplyInst * , 16 > ToSpecialize ; <nl> for ( auto & BB : * getFunction ( ) ) { <nl> for ( auto II = BB . begin ( ) , IE = BB . end ( ) ; II ! = IE ; + + II ) { <nl> - ApplyInst * AI = dyn_cast < ApplyInst > ( & * II ) ; <nl> + auto * AI = dyn_cast < ApplyInst > ( & * II ) ; <nl> if ( AI & & isa < ClassMethodInst > ( AI - > getCallee ( ) ) ) <nl> ToSpecialize . push_back ( AI ) ; <nl> } <nl> mmm a / test / SILPasses / inlinecaches_arc . sil <nl> ppp b / test / SILPasses / inlinecaches_arc . sil <nl> <nl> - / / RUN : % target - sil - opt % s - inlinecaches | FileCheck % s <nl> + / / RUN : % target - sil - opt % s - inlinecaches - sil - sort - output | FileCheck % s <nl> <nl> sil_stage canonical <nl> <nl> class Foo { <nl> sil @ _TFC4main3Foo4pingfS0_FT_Si : $ @ cc ( method ) @ thin ( @ owned Foo ) - > Int <nl> sil @ _TFC4main3FoocfMS0_FT_S0_ : $ @ cc ( method ) @ thin ( @ owned Foo ) - > @ owned Foo <nl> <nl> + / / CHECK - LABEL : _TF4main7my_mainFCS_3FooSi <nl> + / / CHECK : bb0 <nl> + / / CHECK - NOT : strong_retain <nl> + / / CHECK : checked_cast_br [ exact ] % 0 : $ Foo to $ Foo <nl> + <nl> + / / CHECK : bb1 <nl> + / / CHECK : strong_retain <nl> + / / CHECK : class_method <nl> + / / CHECK - NEXT : apply <nl> + / / CHECK : strong_release <nl> + <nl> + / / CHECK : bb2 <nl> + / / CHECK : strong_retain <nl> + / / CHECK : function_ref <nl> + / / CHECK : apply <nl> + / / CHECK : strong_release <nl> + <nl> + / / CHECK : bb3 <nl> + / / CHECK - NOT : strong_release <nl> sil @ _TF4main7my_mainFCS_3FooSi : $ @ thin ( @ owned Foo ) - > Int { <nl> bb0 ( % 0 : $ Foo ) : <nl> - / / CHECK - LABLE : _TF4main7my_mainFCS_3FooSi <nl> - / / CHECK - NOT : strong_retain <nl> - / / CHECK : checked_cast_br [ exact ] % 0 : $ Foo to $ Foo <nl> - <nl> - / / CHECK : strong_retain <nl> - / / CHECK : function_ref <nl> - / / CHECK : apply <nl> - <nl> - / / CHECK : strong_retain <nl> - / / CHECK : class_method <nl> - / / CHECK - NEXT : apply <nl> debug_value % 0 : $ Foo / / let x / / id : % 1 <nl> strong_retain % 0 : $ Foo / / id : % 2 <nl> % 3 = class_method % 0 : $ Foo , # Foo . ping ! 1 : Foo - > ( ) - > Int , $ @ cc ( method ) @ thin ( @ owned Foo ) - > Int / / user : % 4 <nl> mmm a / test / SILPasses / polymorphic_inline_caches . sil <nl> ppp b / test / SILPasses / polymorphic_inline_caches . sil <nl> bb0 ( % 0 : $ A , % 1 : $ Builtin . Int32 ) : <nl> % 6 = apply % 5 ( % 1 , % 0 ) : $ @ cc ( method ) @ thin ( Builtin . Int32 , @ owned A ) - > Builtin . Int32 <nl> / / CHECK : checked_cast_br [ exact ] % 0 : $ A to $ B , bb2 , bb3 <nl> / / CHECK : bb1 <nl> - / / CHECK : strong_release % 0 : $ A <nl> strong_release % 0 : $ A <nl> / / CHECK : return <nl> return % 6 : $ Builtin . Int32 <nl> / / CHECK : bb2 <nl> / / CHECK : [ [ BPING : % . * ] ] = function_ref @ _TFC25polymorphic_inline_caches1B4pingfS0_FBi32_Bi32_ <nl> / / CHECK : apply [ [ BPING ] ] <nl> + / / CHECK : strong_release % 5 : $ B <nl> / / CHECK : bb3 <nl> / / CHECK : checked_cast_br [ exact ] % 0 : $ A to $ C , bb5 , bb6 <nl> / / CHECK : bb4 <nl> bb0 ( % 0 : $ A , % 1 : $ Builtin . Int32 ) : <nl> / / CHECK : bb5 <nl> / / CHECK : [ [ CPING : % . * ] ] = function_ref @ _TFC25polymorphic_inline_caches1C4pingfS0_FBi32_Bi32_ <nl> / / CHECK : apply [ [ CPING ] ] <nl> + / / CHECK : strong_release % 14 : $ C <nl> / / CHECK : bb6 <nl> / / CHECK : checked_cast_br [ exact ] % 0 : $ A to $ A , bb8 , bb9 <nl> / / CHECK : bb7 <nl> bb0 ( % 0 : $ A , % 1 : $ Builtin . Int32 ) : <nl> / / CHECK : bb8 <nl> / / CHECK : [ [ APING : % . * ] ] = function_ref @ _TFC25polymorphic_inline_caches1A4pingfS0_FBi32_Bi32_ <nl> / / CHECK : apply [ [ APING ] ] <nl> + / / CHECK : strong_release % 23 : $ A <nl> / / CHECK : bb9 <nl> / / CHECK : [ [ PING : % . * ] ] = class_method % 0 : $ A , # A . ping ! 1 <nl> / / CHECK : apply [ [ PING ] ] <nl>
|
[ spec - devirt ] Hoist releases right after the apply on self into the diamond .
|
apple/swift
|
faabb7ea8ab32f0889ef203292f26a9e5596549a
|
2015-04-04T20:14:47Z
|
mmm a / src / mongo / client / dbclient . cpp <nl> ppp b / src / mongo / client / dbclient . cpp <nl> namespace mongo { <nl> } <nl> <nl> void DBClientBase : : remove ( const string & ns , Query obj , bool justOne ) { <nl> + int flags = 0 ; <nl> + if ( justOne ) flags | = RemoveOption_JustOne ; <nl> + remove ( ns , obj , flags ) ; <nl> + } <nl> + <nl> + void DBClientBase : : remove ( const string & ns , Query obj , int flags ) { <nl> Message toSend ; <nl> <nl> BufBuilder b ; <nl> - int opts = 0 ; <nl> - b . appendNum ( opts ) ; <nl> - b . appendStr ( ns ) ; <nl> + int reservedFlags = 0 ; <nl> + if ( flags & WriteOption_FromWriteback ) { <nl> + reservedFlags | = WriteOption_FromWriteback ; <nl> + flags ^ = WriteOption_FromWriteback ; <nl> + } <nl> <nl> - int flags = 0 ; <nl> - if ( justOne ) <nl> - flags | = RemoveOption_JustOne ; <nl> + b . appendNum ( reservedFlags ) ; <nl> + b . appendStr ( ns ) ; <nl> b . appendNum ( flags ) ; <nl> <nl> obj . obj . appendSelfToBufBuilder ( b ) ; <nl> mmm a / src / mongo / client / dbclient_rs . cpp <nl> ppp b / src / mongo / client / dbclient_rs . cpp <nl> namespace mongo { <nl> checkMaster ( ) - > insert ( ns , v , flags ) ; <nl> } <nl> <nl> - void DBClientReplicaSet : : remove ( const string & ns , Query obj , bool justOne ) { <nl> - checkMaster ( ) - > remove ( ns , obj , justOne ) ; <nl> + void DBClientReplicaSet : : remove ( const string & ns , Query obj , int flags ) { <nl> + checkMaster ( ) - > remove ( ns , obj , flags ) ; <nl> } <nl> <nl> void DBClientReplicaSet : : update ( const string & ns , Query query , BSONObj obj , int flags ) { <nl> mmm a / src / mongo / client / dbclient_rs . h <nl> ppp b / src / mongo / client / dbclient_rs . h <nl> namespace mongo { <nl> public : <nl> using DBClientBase : : query ; <nl> using DBClientBase : : update ; <nl> + using DBClientBase : : remove ; <nl> <nl> / * * Call connect ( ) after constructing . autoReconnect is always on for DBClientReplicaSet connections . * / <nl> DBClientReplicaSet ( const string & name , const vector < HostAndPort > & servers , double so_timeout = 0 ) ; <nl> namespace mongo { <nl> is only nominally faster and not worth a special effort to try to use . * / <nl> virtual void insert ( const string & ns , const vector < BSONObj > & v , int flags = 0 ) ; <nl> <nl> - virtual void remove ( const string & ns , Query obj , bool justOne = 0 ) ; <nl> + virtual void remove ( const string & ns , Query obj , int flags ) ; <nl> <nl> virtual void update ( const string & ns , Query query , BSONObj obj , int flags ) ; <nl> <nl> mmm a / src / mongo / client / dbclientinterface . h <nl> ppp b / src / mongo / client / dbclientinterface . h <nl> namespace mongo { <nl> <nl> virtual void remove ( const string & ns , Query query , bool justOne = 0 ) = 0 ; <nl> <nl> + virtual void remove ( const string & ns , Query query , int flags ) = 0 ; <nl> + <nl> virtual void update ( const string & ns , <nl> Query query , <nl> BSONObj obj , <nl> namespace mongo { <nl> * / <nl> virtual void remove ( const string & ns , Query q , bool justOne = 0 ) ; <nl> <nl> + virtual void remove ( const string & ns , Query query , int flags ) ; <nl> + <nl> virtual bool isFailed ( ) const = 0 ; <nl> <nl> virtual void killCursor ( long long cursorID ) = 0 ; <nl> mmm a / src / mongo / client / syncclusterconnection . cpp <nl> ppp b / src / mongo / client / syncclusterconnection . cpp <nl> namespace mongo { <nl> uassert ( 10023 , " SyncClusterConnection bulk insert not implemented " , 0 ) ; <nl> } <nl> <nl> - void SyncClusterConnection : : remove ( const string & ns , Query query , bool justOne ) { <nl> + void SyncClusterConnection : : remove ( const string & ns , Query query , int flags ) { <nl> string errmsg ; <nl> if ( ! prepare ( errmsg ) ) <nl> throw UserException ( 8020 , ( string ) " SyncClusterConnection : : remove prepare failed : " + errmsg ) ; <nl> <nl> for ( size_t i = 0 ; i < _conns . size ( ) ; i + + ) { <nl> - _conns [ i ] - > remove ( ns , query , justOne ) ; <nl> + _conns [ i ] - > remove ( ns , query , flags ) ; <nl> } <nl> <nl> _checkLast ( ) ; <nl> mmm a / src / mongo / client / syncclusterconnection . h <nl> ppp b / src / mongo / client / syncclusterconnection . h <nl> namespace mongo { <nl> <nl> using DBClientBase : : query ; <nl> using DBClientBase : : update ; <nl> + using DBClientBase : : remove ; <nl> <nl> / * * <nl> * @ param commaSeparated should be 3 hosts comma separated <nl> namespace mongo { <nl> <nl> virtual void insert ( const string & ns , const vector < BSONObj > & v , int flags = 0 ) ; <nl> <nl> - virtual void remove ( const string & ns , Query query , bool justOne ) ; <nl> + virtual void remove ( const string & ns , Query query , int flags ) ; <nl> <nl> virtual void update ( const string & ns , Query query , BSONObj obj , int flags ) ; <nl> <nl> mmm a / src / mongo / s / strategy . cpp <nl> ppp b / src / mongo / s / strategy . cpp <nl> namespace mongo { <nl> / / mmm - - Strategy mmmmmm <nl> <nl> void Strategy : : doWrite ( int op , Request & r , const Shard & shard , bool checkVersion ) { <nl> + <nl> + / / Now only used for index and broadcast writes <nl> + / / TODO : Remove <nl> + <nl> ShardConnection conn ( shard , r . getns ( ) ) ; <nl> if ( ! checkVersion ) <nl> conn . donotCheckVersion ( ) ; <nl> mmm a / src / mongo / s / strategy_shard . cpp <nl> ppp b / src / mongo / s / strategy_shard . cpp <nl> namespace mongo { <nl> chunk - > splitIfShould ( d . msg ( ) . header ( ) - > dataLen ( ) ) ; <nl> } <nl> <nl> - void _delete ( Request & r , DbMessage & d , ChunkManagerPtr manager ) { <nl> <nl> + void _prepareDelete ( const string & ns , <nl> + const BSONObj & query , <nl> + int flags , <nl> + ShardPtr & shard , <nl> + ChunkManagerPtr & manager , <nl> + ShardPtr & primary , <nl> + bool reloadConfigData = false ) <nl> + { <nl> + <nl> + / / <nl> + / / Deletes also have three basic targeting options : <nl> + / / 1 ) Primary shard <nl> + / / 2 ) Single shard in collection <nl> + / / 3 ) All shards in cluster <nl> + / / <nl> + / / We don ' t ( currently ) target just a few shards because on retry we ' d need to ensure that we didn ' t send <nl> + / / the delete to a shard twice . <nl> + / / <nl> + / / TODO : Think this is fixable , if we better track where we ' re sending requests . <nl> + / / TODO : Async connection layer with error checking would make this much simpler . <nl> + / / <nl> + <nl> + / / Refresh config if specified <nl> + if ( reloadConfigData ) grid . getDBConfig ( ns ) - > getChunkManagerIfExists ( ns , true ) ; <nl> + <nl> + bool justOne = flags & RemoveOption_JustOne ; <nl> + <nl> + shard . reset ( ) ; <nl> + grid . getDBConfig ( ns ) - > getChunkManagerOrPrimary ( ns , manager , primary ) ; <nl> + <nl> + if ( primary ) { <nl> + <nl> + shard = primary ; <nl> + return ; <nl> + } <nl> + <nl> + set < Shard > shards ; <nl> + manager - > getShardsForQuery ( shards , query ) ; <nl> + <nl> + LOG ( 2 ) < < " delete : " < < query < < " \ t " < < shards . size ( ) < < " justOne : " < < justOne < < endl ; <nl> + <nl> + if ( shards . size ( ) = = 1 ) { <nl> + <nl> + shard = ShardPtr ( new Shard ( * shards . begin ( ) ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + if ( ! justOne | | query . hasField ( " _id " ) ) return ; <nl> + <nl> + / / Retry reloading the config data once <nl> + if ( ! reloadConfigData ) { <nl> + _prepareDelete ( ns , query , flags , shard , manager , primary , true ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Sleep so we don ' t DOS config server <nl> + sleepsecs ( 1 ) ; <nl> + <nl> + throw UserException ( 8015 , <nl> + " can only delete with a non - shard key pattern if can delete as many as we find " ) ; <nl> + return ; <nl> + } <nl> + <nl> + void _delete ( Request & r , DbMessage & d ) { <nl> + <nl> + / / details of the request <nl> + const string & ns = r . getns ( ) ; <nl> int flags = d . pullInt ( ) ; <nl> - bool justOne = flags & 1 ; <nl> <nl> uassert ( 10203 , " bad delete message " , d . moreJSObjs ( ) ) ; <nl> - BSONObj pattern = d . nextJsObj ( ) ; <nl> - uassert ( 13505 , " $ atomic not supported sharded " , pattern [ " $ atomic " ] . eoo ( ) ) ; <nl> <nl> - const int LEFT_START = 5 ; <nl> - int left = LEFT_START ; <nl> - while ( true ) { <nl> - try { <nl> - set < Shard > shards ; <nl> - manager - > getShardsForQuery ( shards , pattern ) ; <nl> - LOG ( 2 ) < < " delete : " < < pattern < < " \ t " < < shards . size ( ) < < " justOne : " < < justOne < < endl ; <nl> - <nl> - if ( shards . size ( ) ! = 1 ) { <nl> - / / data could be on more than one shard . must send to all <nl> - if ( justOne & & ! pattern . hasField ( " _id " ) ) <nl> - throw UserException ( 8015 , " can only delete with a non - shard key pattern if can delete as many as we find " ) ; <nl> - <nl> - int * x = ( int * ) ( r . d ( ) . afterNS ( ) ) ; <nl> - x [ 0 ] | = RemoveOption_Broadcast ; / / this means don ' t check shard version in mongod <nl> - broadcastWrite ( dbUpdate , r ) ; <nl> - return ; <nl> - } <nl> + const BSONObj query = d . nextJsObj ( ) ; <nl> <nl> - doWrite ( dbDelete , r , * shards . begin ( ) ) ; <nl> - return ; <nl> - } <nl> - catch ( StaleConfigException & e ) { <nl> - if ( left < = 0 ) <nl> - throw e ; <nl> - log ( left = = LEFT_START ) < < " delete will be retried b / c of StaleConfigException , " <nl> - < < " left : " < < left - 1 < < " ns : " < < r . getns ( ) < < " patt : " < < pattern < < endl ; <nl> - left - - ; <nl> - r . reset ( ) ; <nl> - manager = r . getChunkManager ( ) ; <nl> - uassert ( 14805 , " collection no longer sharded " , manager ) ; <nl> - } <nl> + if ( d . reservedField ( ) & Reserved_FromWriteback ) { <nl> + flags | = WriteOption_FromWriteback ; <nl> } <nl> + <nl> + _delete ( ns , query , flags , r , d ) ; <nl> } <nl> <nl> - virtual void writeOp ( int op , Request & r ) { <nl> + void _delete ( const string & ns , <nl> + const BSONObj & query , <nl> + int flags , <nl> + Request & r , DbMessage & d , / / todo : remove <nl> + int retries = 0 ) <nl> + { <nl> + <nl> + uassert ( 13505 , " $ atomic not supported sharded " , query [ " $ atomic " ] . eoo ( ) ) ; <nl> <nl> - ChunkManagerPtr info ; <nl> + ShardPtr shard ; <nl> + ChunkManagerPtr manager ; <nl> ShardPtr primary ; <nl> <nl> + _prepareDelete ( ns , query , flags , shard , manager , primary ) ; <nl> + <nl> + if ( ! shard ) { <nl> + <nl> + int * x = ( int * ) ( r . d ( ) . afterNS ( ) ) ; <nl> + x [ 0 ] | = RemoveOption_Broadcast ; / / this means don ' t check shard version in mongod <nl> + / / TODO : Why is this an update op here ? <nl> + broadcastWrite ( dbUpdate , r ) ; <nl> + return ; <nl> + } <nl> + <nl> + ShardConnection dbcon ( * shard , ns , manager ) ; <nl> + <nl> + try { <nl> + / / An exception will be thrown if the version is incompatible <nl> + dbcon . setVersion ( ) ; <nl> + } <nl> + catch ( StaleConfigException & e ) { <nl> + dbcon . done ( ) ; <nl> + _handleRetries ( " delete " , retries , query , e , r ) ; <nl> + _delete ( ns , query , flags , r , d , retries + 1 ) ; <nl> + return ; <nl> + } <nl> + <nl> + dbcon - > remove ( ns , query , flags ) ; <nl> + <nl> + dbcon . done ( ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + virtual void writeOp ( int op , Request & r ) { <nl> + <nl> const char * ns = r . getns ( ) ; <nl> <nl> - r . getConfig ( ) - > getChunkManagerOrPrimary ( r . getns ( ) , info , primary ) ; <nl> / / TODO : Index write logic needs to be audited <nl> - bool isIndexWrite = strstr ( ns , " . system . indexes " ) = = strchr ( ns , ' . ' ) & & strchr ( ns , ' . ' ) ; <nl> + bool isIndexWrite = <nl> + strstr ( ns , " . system . indexes " ) = = strchr ( ns , ' . ' ) & & strchr ( ns , ' . ' ) ; <nl> + <nl> + / / TODO : This block goes away , system . indexes needs to handle better <nl> + if ( isIndexWrite ) { <nl> <nl> - / / TODO : This block goes away , we need to handle the case where we go sharded - > unsharded or <nl> - / / vice - versa for all types of write operations . System . indexes may be the only special case . <nl> - if ( primary & & ( isIndexWrite | | op = = dbDelete ) ) { <nl> + ShardPtr primary ; <nl> + ChunkManagerPtr manager ; <nl> <nl> - if ( r . isShardingEnabled ( ) & & isIndexWrite ) { <nl> - LOG ( 1 ) < < " . system . indexes write for : " < < ns < < endl ; <nl> + r . getConfig ( ) - > getChunkManagerOrPrimary ( ns , manager , primary ) ; <nl> + <nl> + if ( manager ) { <nl> + LOG ( 1 ) < < " sharded index write for " < < ns < < endl ; <nl> handleIndexWrite ( op , r ) ; <nl> return ; <nl> } <nl> <nl> - LOG ( 3 ) < < " single write : " < < ns < < endl ; <nl> + LOG ( 3 ) < < " single index write for " < < ns < < endl ; <nl> SINGLE - > doWrite ( op , r , * primary ) ; <nl> r . gotInsert ( ) ; / / Won ' t handle mulit - insert correctly . Not worth parsing the request . <nl> <nl> return ; <nl> } <nl> else { <nl> + <nl> LOG ( 3 ) < < " write : " < < ns < < endl ; <nl> <nl> DbMessage & d = r . d ( ) ; <nl> namespace mongo { <nl> _update ( r , d ) ; <nl> } <nl> else if ( op = = dbDelete ) { <nl> - _delete ( r , d , info ) ; <nl> + _delete ( r , d ) ; <nl> } <nl> else { <nl> log ( ) < < " sharding can ' t do write op : " < < op < < endl ; <nl>
|
SERVER - 4262 remove race condition on config reload in sharded remove
|
mongodb/mongo
|
d7f89643a917538fa953a17d80acc164fb4885ad
|
2012-06-09T02:41:12Z
|
mmm a / include / fmt / core . h <nl> ppp b / include / fmt / core . h <nl> template < typename Char > struct named_arg_info { <nl> template < typename T , typename Char , size_t NUM_ARGS , size_t NUM_NAMED_ARGS > <nl> struct arg_data { <nl> / / args_ [ 0 ] . named_args points to named_args_ to avoid bloating format_args . <nl> - T args_ [ 1 + ( NUM_ARGS ! = 0 ? NUM_ARGS : 1 ) ] ; <nl> + / / + 1 to workaround a bug in gcc 7 . 5 that causes duplicated - branches warning . <nl> + T args_ [ 1 + ( NUM_ARGS ! = 0 ? NUM_ARGS : + 1 ) ] ; <nl> named_arg_info < Char > named_args_ [ NUM_NAMED_ARGS ] ; <nl> <nl> template < typename . . . U > <nl> struct arg_data { <nl> <nl> template < typename T , typename Char , size_t NUM_ARGS > <nl> struct arg_data < T , Char , NUM_ARGS , 0 > { <nl> - T args_ [ NUM_ARGS ! = 0 ? NUM_ARGS : 1 ] ; <nl> + / / + 1 to workaround a bug in gcc 7 . 5 that causes duplicated - branches warning . <nl> + T args_ [ NUM_ARGS ! = 0 ? NUM_ARGS : + 1 ] ; <nl> <nl> template < typename . . . U > <nl> FMT_INLINE arg_data ( const U & . . . init ) : args_ { init . . . } { } <nl>
|
Workaround a bug in gcc 7 . 5 ( )
|
fmtlib/fmt
|
712abe40f297bf0a1bbf3479599fd4a0d10dc0d2
|
2020-10-04T16:20:37Z
|
mmm a / src / EditDialog . cpp <nl> ppp b / src / EditDialog . cpp <nl> void EditDialog : : loadData ( const QByteArray & bArrdata ) <nl> case XML : <nl> / / Can be stored in any widget , except the ImageViewer <nl> <nl> + sciEdit - > clearTextInMargin ( ) ; <nl> + <nl> switch ( editMode ) { <nl> case TextEditor : <nl> case JsonEditor : <nl> void EditDialog : : editTextChanged ( ) <nl> if ( dataType = = Null & & isModified & & dataLength ! = 0 ) <nl> dataType = Text ; <nl> <nl> - if ( dataType ! = Null ) { <nl> - sciEdit - > clearTextInMargin ( ) ; <nl> + if ( dataType ! = Null ) <nl> ui - > labelType - > setText ( tr ( " Type of data currently in cell : Text / Numeric " ) ) ; <nl> - } <nl> ui - > labelSize - > setText ( tr ( " % n character ( s ) " , " " , dataLength ) ) ; <nl> } <nl> } <nl>
|
Remove " NULL " in margin of editor in Edit dialog for empty cells
|
sqlitebrowser/sqlitebrowser
|
f81da0d29c8b9c55927ae170b6dad93b65cfb8f1
|
2020-06-03T15:04:46Z
|
mmm a / doc / advanced / integrate - to - ios . md <nl> ppp b / doc / advanced / integrate - to - ios . md <nl> WXSDKInstance is a very imporent class , which provides you with some basic metho <nl> <nl> <nl> # # # # 5 . Destroy Weex Instance <nl> + <nl> Please release weex instance in dealloc stage of viewContoller , or it will lead to memory leak . <nl> <nl> ` ` ` <nl> Please release weex instance in dealloc stage of viewContoller , or it will lead <nl> { <nl> [ _instance destroyInstance ] ; <nl> } <nl> - ` ` ` <nl> \ No newline at end of file <nl> + ` ` ` <nl> + <nl> + # # # # 6 . Build . IPA for Weex <nl> + <nl> + We can also pack all the JS files into the app ' s resources . This way you can run your app without development server and submit it to the AppStore . <nl> + <nl> + * [ Install weex - toolkit ] ( https : / / github . com / alibaba / weex_toolchain / tree / master / toolkit ) and transform your ` . we ` file to JS by running ` weex index . we - o index . js ` , ` index . we ` is the entry file of your app . <nl> + * Move ` index . js ` to your app ' s Xcode project and add the file to your target . <nl> + * Replace ` [ _instance renderWithURL : ' httpURL ' ] ` with : ` [ _instance renderWithURL : [ [ NSBundle mainBundle ] URLForResource : @ " index " withExtension : @ " js " ] ] ` <nl> + <nl> + * Go for Product - > Archive in Xcode and follow the steps to build your . IPA file and submit it to the AppStore . <nl> \ No newline at end of file <nl>
|
Merge pull request from alibaba / doc - feature - ipa - build
|
apache/incubator-weex
|
521f45183c5d86d7bae2f957ca17ba6697c7b10b
|
2016-06-23T11:16:08Z
|
mmm a / db / repl . cpp <nl> ppp b / db / repl . cpp <nl> namespace mongo { <nl> throw SyncException ( ) ; <nl> } <nl> <nl> - / / operation type - - see logOp ( ) comments for types <nl> - const char * opType = op . getStringField ( " op " ) ; <nl> - <nl> - if ( justCreated | | / * datafiles were missing . so we need everything , no matter what sources object says * / <nl> - newDb ) / * if not in dbs , we ' ve never synced this database before , so we need everything * / <nl> - { <nl> - if ( paired & & ! justCreated ) { <nl> - if ( strcmp ( opType , " db " ) = = 0 & & strcmp ( ns , " admin . " ) = = 0 ) { <nl> - / / " admin " is a special namespace we use for priviledged commands - - ok if it exists first on <nl> - / / either side <nl> - } <nl> - else { <nl> - / * the other half of our pair has some operations . yet we already had a db on our <nl> - disk even though the db in question is not listed in the source . <nl> - * / <nl> - replAllDead = " pair : historical image missing for a db " ; <nl> - problem ( ) < < " pair : historical image missing for " < < clientName < < " , setting replAllDead = true " < < endl ; <nl> - log ( ) < < " op : " < < op . toString ( ) < < endl ; <nl> - / * <nl> - log ( ) < < " TEMP : pair : assuming we have the historical image for : " < < <nl> - clientName < < " . add extra checks here . " < < endl ; <nl> - dbs . insert ( clientName ) ; <nl> - * / <nl> - } <nl> - } <nl> - else { <nl> - nClonedThisPass + + ; <nl> - resync ( database - > name ) ; <nl> - } <nl> - addDbNextPass . erase ( clientName ) ; <nl> + / * datafiles were missing . so we need everything , no matter what sources object says * / <nl> + if ( justCreated ) { <nl> + nClonedThisPass + + ; <nl> + resync ( database - > name ) ; <nl> + save ( ) ; <nl> + } else if ( newDb & & strcmp ( clientName , " admin " ) ! = 0 ) { <nl> + replAllDead = " An initial clone by an earlier instance did not complete , " <nl> + " or a local db was was created by the user with the same name as a db on the remote instance ; " <nl> + " resync required " ; <nl> + problem ( ) < < replAllDead ; <nl> + problem ( ) < < " op : " < < op < < endl ; <nl> + } else { <nl> + applyOperation ( op ) ; <nl> } <nl> - <nl> - applyOperation ( op ) ; <nl> + addDbNextPass . erase ( clientName ) ; <nl> database = 0 ; <nl> } <nl> <nl> namespace mongo { <nl> } <nl> if ( ! haveDbList_ ) { <nl> haveDbList_ = true ; <nl> + set < string > localDbs ; <nl> + vector < string > diskDbs ; <nl> + getDatabaseNames ( diskDbs ) ; <nl> + for ( vector < string > : : iterator i = diskDbs . begin ( ) ; i ! = diskDbs . end ( ) ; + + i ) <nl> + localDbs . insert ( * i ) ; <nl> + for ( map < string , Database * > : : iterator i = databases . begin ( ) ; i ! = databases . end ( ) ; + + i ) <nl> + localDbs . insert ( i - > first ) ; <nl> BSONObj info ; <nl> bool ok = conn - > runCommand ( " admin " , BSON ( " listDatabases " < < 1 ) , info ) ; <nl> massert ( " Unable to get database list " , ok ) ; <nl> namespace mongo { <nl> if ( e . eoo ( ) ) <nl> break ; <nl> string name = e . embeddedObject ( ) . getField ( " name " ) . valuestr ( ) ; <nl> - if ( name ! = " local " ) { <nl> + / / We may be paired , so only attempt to add databases not already present . <nl> + if ( name ! = " local " & & localDbs . count ( name ) = = 0 ) { <nl> addDbNextPass . insert ( name ) ; <nl> } <nl> } <nl> mmm a / jstests / repl / pair1 . js <nl> ppp b / jstests / repl / pair1 . js <nl> var baseName = " jstests_pair1test " ; <nl> <nl> ismaster = function ( n ) { <nl> im = n . getDB ( " admin " ) . runCommand ( { " ismaster " : 1 } ) ; <nl> + / / print ( " ismaster : " + tojson ( im ) ) ; <nl> assert ( im ) ; <nl> return im . ismaster ; <nl> } <nl> mmm a / jstests / repl / pair2 . js <nl> ppp b / jstests / repl / pair2 . js <nl> ismaster = function ( n ) { <nl> <nl> soonCount = function ( count ) { <nl> assert . soon ( function ( ) { <nl> + / / print ( " counting " ) ; <nl> if ( - 1 = = l . getDBNames ( ) . indexOf ( baseName ) ) <nl> return false ; <nl> if ( - 1 = = l . getDB ( baseName ) . getCollectionNames ( ) . indexOf ( " z " ) ) <nl> return false ; <nl> + / / print ( " counted : " + l . getDB ( baseName ) . z . find ( ) . count ( ) ) ; <nl> return l . getDB ( baseName ) . z . find ( ) . count ( ) = = count ; <nl> } ) ; <nl> } <nl> doTest = function ( signal ) { <nl> <nl> assert . soon ( function ( ) { return ( ismaster ( l ) = = 0 & & ismaster ( r ) = = 1 ) ; } ) ; <nl> <nl> - lz = l . getDB ( baseName ) . z <nl> rz = r . getDB ( baseName ) . z <nl> <nl> rz . save ( { _id : new ObjectId ( ) } ) ; <nl> soonCount ( 1 ) ; <nl> assert . eq ( 0 , l . getDB ( " admin " ) . runCommand ( { " resync " : 1 } ) . ok ) ; <nl> - <nl> - / / Allow slave to save its db list - - eventually we can remove the sleep . <nl> - sleep ( 10000 ) ; <nl> - <nl> + <nl> stopMongod ( 27019 , signal ) ; <nl> <nl> big = new Array ( 2000 ) . toString ( ) ; <nl> doTest = function ( signal ) { <nl> l . setSlaveOk ( ) ; <nl> assert . soon ( function ( ) { return 1 = = l . getDB ( " admin " ) . runCommand ( { " resync " : 1 } ) . ok ; } ) ; <nl> <nl> - sleep ( 10000 ) ; <nl> + sleep ( 3000 ) ; <nl> <nl> soonCount ( 1001 ) ; <nl> lz = l . getDB ( baseName ) . z <nl> mmm a / jstests / repl / repl1 . js <nl> ppp b / jstests / repl / repl1 . js <nl> <nl> <nl> var baseName = " jstests_repl1test " ; <nl> <nl> + soonCount = function ( count ) { <nl> + assert . soon ( function ( ) { <nl> + / / print ( " check count " ) ; <nl> + if ( - 1 = = s . getDBNames ( ) . indexOf ( baseName ) ) <nl> + return false ; <nl> + if ( - 1 = = s . getDB ( baseName ) . getCollectionNames ( ) . indexOf ( " a " ) ) <nl> + return false ; <nl> + / / print ( " count : " + s . getDB ( baseName ) . z . find ( ) . count ( ) ) ; <nl> + return s . getDB ( baseName ) . a . find ( ) . count ( ) = = count ; <nl> + } ) ; <nl> + } <nl> + <nl> doTest = function ( signal ) { <nl> <nl> / / spec small oplog for fast startup on 64bit machines <nl> doTest = function ( signal ) { <nl> s = startMongod ( " - - port " , " 27019 " , " - - dbpath " , " / data / db / " + baseName + " - slave " , " - - slave " , " - - source " , " 127 . 0 . 0 . 1 : 27018 " ) ; <nl> <nl> am = m . getDB ( baseName ) . a <nl> - as = s . getDB ( baseName ) . a <nl> <nl> for ( i = 0 ; i < 1000 ; + + i ) <nl> am . save ( { _id : new ObjectId ( ) , i : i } ) ; <nl> - <nl> - assert . soon ( function ( ) { return as . find ( ) . count ( ) = = 1000 ; } ) ; <nl> - <nl> + <nl> + soonCount ( 1000 ) ; <nl> + as = s . getDB ( baseName ) . a <nl> assert . eq ( 1 , as . find ( { i : 0 } ) . count ( ) ) ; <nl> assert . eq ( 1 , as . find ( { i : 999 } ) . count ( ) ) ; <nl> <nl> doTest = function ( signal ) { <nl> am . save ( { _id : new ObjectId ( ) , i : i } ) ; <nl> <nl> s = startMongoProgram ( " mongod " , " - - port " , " 27019 " , " - - dbpath " , " / data / db / " + baseName + " - slave " , " - - slave " , " - - source " , " 127 . 0 . 0 . 1 : 27018 " ) ; <nl> + soonCount ( 1010 ) ; <nl> as = s . getDB ( baseName ) . a <nl> - assert . soon ( function ( ) { return as . find ( ) . count ( ) = = 1010 ; } ) ; <nl> assert . eq ( 1 , as . find ( { i : 1009 } ) . count ( ) ) ; <nl> <nl> stopMongod ( 27018 , signal ) ; <nl> mmm a / jstests / repl / repl2 . js <nl> ppp b / jstests / repl / repl2 . js <nl> <nl> <nl> var baseName = " jstests_repl2test " ; <nl> <nl> + soonCount = function ( count ) { <nl> + assert . soon ( function ( ) { <nl> + / / print ( " check count " ) ; <nl> + if ( - 1 = = s . getDBNames ( ) . indexOf ( baseName ) ) <nl> + return false ; <nl> + if ( - 1 = = s . getDB ( baseName ) . getCollectionNames ( ) . indexOf ( " a " ) ) <nl> + return false ; <nl> + / / print ( " count : " + s . getDB ( baseName ) . z . find ( ) . count ( ) ) ; <nl> + return s . getDB ( baseName ) . a . find ( ) . count ( ) = = count ; <nl> + } ) ; <nl> + } <nl> + <nl> doTest = function ( signal ) { <nl> <nl> / / spec small oplog to make slave get out of sync <nl> doTest = function ( signal ) { <nl> s = startMongod ( " - - port " , " 27019 " , " - - dbpath " , " / data / db / " + baseName + " - slave " , " - - slave " , " - - source " , " 127 . 0 . 0 . 1 : 27018 " ) ; <nl> <nl> am = m . getDB ( baseName ) . a <nl> - as = s . getDB ( baseName ) . a <nl> <nl> am . save ( { _id : new ObjectId ( ) } ) ; <nl> - assert . soon ( function ( ) { return as . find ( ) . count ( ) = = 1 ; } ) ; <nl> + soonCount ( 1 ) ; <nl> assert . eq ( 0 , s . getDB ( " admin " ) . runCommand ( { " resync " : 1 } ) . ok ) ; <nl> stopMongod ( 27019 , signal ) ; <nl> <nl> doTest = function ( signal ) { <nl> <nl> s = startMongoProgram ( " mongod " , " - - port " , " 27019 " , " - - dbpath " , " / data / db / " + baseName + " - slave " , " - - slave " , " - - source " , " 127 . 0 . 0 . 1 : 27018 " ) ; <nl> assert . soon ( function ( ) { return 1 = = s . getDB ( " admin " ) . runCommand ( { " resync " : 1 } ) . ok ; } ) ; <nl> - <nl> - assert . soon ( function ( ) { return s . getDBNames ( ) . indexOf ( baseName ) ! = - 1 ; } ) ; <nl> - as = s . getDB ( baseName ) . a <nl> - <nl> + <nl> sleep ( 10000 ) ; <nl> - assert . soon ( function ( ) { return 1001 = = as . find ( ) . count ( ) ; } ) ; <nl> + soonCount ( 1001 ) ; <nl> + as = s . getDB ( baseName ) . a <nl> assert . eq ( 1 , as . find ( { i : 0 } ) . count ( ) ) ; <nl> assert . eq ( 1 , as . find ( { i : 999 } ) . count ( ) ) ; <nl> <nl> mmm a / jstests / repl / repl3 . js <nl> ppp b / jstests / repl / repl3 . js <nl> <nl> <nl> var baseName = " jstests_repl3test " ; <nl> <nl> + soonCount = function ( count ) { <nl> + assert . soon ( function ( ) { <nl> + / / print ( " check count " ) ; <nl> + if ( - 1 = = s . getDBNames ( ) . indexOf ( baseName ) ) <nl> + return false ; <nl> + if ( - 1 = = s . getDB ( baseName ) . getCollectionNames ( ) . indexOf ( " a " ) ) <nl> + return false ; <nl> + / / print ( " count : " + s . getDB ( baseName ) . z . find ( ) . count ( ) ) ; <nl> + return s . getDB ( baseName ) . a . find ( ) . count ( ) = = count ; <nl> + } ) ; <nl> + } <nl> + <nl> doTest = function ( signal ) { <nl> <nl> / / spec small oplog to make slave get out of sync <nl> doTest = function ( signal ) { <nl> s = startMongod ( " - - port " , " 27019 " , " - - dbpath " , " / data / db / " + baseName + " - slave " , " - - slave " , " - - source " , " 127 . 0 . 0 . 1 : 27018 " ) ; <nl> <nl> am = m . getDB ( baseName ) . a <nl> - as = s . getDB ( baseName ) . a <nl> <nl> am . save ( { _id : new ObjectId ( ) } ) ; <nl> - assert . soon ( function ( ) { return as . find ( ) . count ( ) = = 1 ; } ) ; <nl> + soonCount ( 1 ) ; <nl> stopMongod ( 27019 , signal ) ; <nl> <nl> big = new Array ( 2000 ) . toString ( ) ; <nl> doTest = function ( signal ) { <nl> / / Need the 2 additional seconds timeout , since commands don ' t work on an ' allDead ' node . <nl> assert . soon ( function ( ) { return s . getDBNames ( ) . indexOf ( baseName ) ! = - 1 ; } ) ; <nl> assert . soon ( function ( ) { return s . getDB ( baseName ) . getCollectionNames ( ) . indexOf ( " a " ) ! = - 1 ; } ) ; <nl> - <nl> + <nl> + soonCount ( 1001 ) ; <nl> as = s . getDB ( baseName ) . a <nl> - assert . soon ( function ( ) { return 1001 = = as . find ( ) . count ( ) ; } ) ; <nl> assert . eq ( 1 , as . find ( { i : 0 } ) . count ( ) ) ; <nl> assert . eq ( 1 , as . find ( { i : 999 } ) . count ( ) ) ; <nl> <nl>
|
More robust / accurate checking of previous failed initial clone
|
mongodb/mongo
|
0a578392a6c9f766b4f18cf0f8df8e034e6198cb
|
2009-03-17T21:20:08Z
|
mmm a / src / extract / filewalk . cc <nl> ppp b / src / extract / filewalk . cc <nl> void dump_pair_value ( dumper_t & dumper , direct_file_t & file , const cfg_t cfg , con <nl> void walkfile ( dumper_t & dumper , const char * path ) ; <nl> <nl> <nl> + / / A small simple helper , refactor if we ever use smart pointers elsewhere . <nl> + class freer { <nl> + public : <nl> + freer ( ) { } <nl> + ~ freer ( ) { for ( size_t i = 0 ; i < ptrs . size ( ) ; + + i ) free ( ptrs [ i ] ) ; } <nl> + void add ( void * p ) { ptrs . push_back ( p ) ; } <nl> + private : <nl> + std : : vector < void * , gnew_alloc < void * > > ptrs ; <nl> + DISABLE_COPYING ( freer ) ; <nl> + } ; <nl> <nl> bool check_config ( size_t filesize , const cfg_t cfg ) { <nl> / / Check that we have reasonable block_size and extent_size . <nl> mmm a / src / fsck / checker . cc <nl> ppp b / src / fsck / checker . cc <nl> void check_lba_shard ( direct_file_t * file , file_knowledge * knog , lba_shard_metabl <nl> / / 1 . Read the entries from the superblock ( if there is one ) . <nl> if ( shards [ shard_number ] . lba_superblock_offset ! = - 1 ) { <nl> require_valid_device_block ( knog , shards [ shard_number ] . lba_superblock_offset , " lba_superblock_offset " ) ; <nl> - lba_superblock_t * buf = ( lba_superblock_t * ) malloc_aligned ( superblock_aligned_size , DEVICE_BLOCK_SIZE ) ; <nl> - freer f ; <nl> - f . add ( buf ) ; <nl> - file - > read_blocking ( shards [ shard_number ] . lba_superblock_offset , superblock_aligned_size , buf ) ; <nl> + block superblock ( superblock_aligned_size , file , shards [ shard_number ] . lba_superblock_offset ) ; <nl> + lba_superblock_t * buf = ( lba_superblock_t * ) superblock . buf ; <nl> <nl> unrecoverable_fact ( ! memcmp ( buf , lba_super_magic , LBA_SUPER_MAGIC_SIZE ) , " lba superblock magic " ) ; <nl> <nl> mmm a / src / utils2 . hpp <nl> ppp b / src / utils2 . hpp <nl> int randint ( int n ) ; <nl> void operator = ( const T & ) <nl> <nl> <nl> - / / A small simple helper , refactor if we ever use smart pointers elsewhere . <nl> - class freer { <nl> - public : <nl> - freer ( ) { } <nl> - ~ freer ( ) { for ( size_t i = 0 ; i < ptrs . size ( ) ; + + i ) free ( ptrs [ i ] ) ; } <nl> - void add ( void * p ) { ptrs . push_back ( p ) ; } <nl> - private : <nl> - std : : vector < void * , gnew_alloc < void * > > ptrs ; <nl> - DISABLE_COPYING ( freer ) ; <nl> - } ; <nl> - <nl> # include " utils2 . tcc " <nl> <nl> # endif / * __UTILS2_HPP__ * / <nl>
|
Moved freer back to filewalk . cc .
|
rethinkdb/rethinkdb
|
a370df06fa2be1f9989e979e332c0197468fd892
|
2010-11-11T21:45:56Z
|
mmm a / doc / examples / README . link <nl> ppp b / doc / examples / README . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / TarF5pPn9NtHQjhf " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / 7HlactSAaECZWYmb " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / diff . link <nl> ppp b / doc / examples / diff . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / tfI8DuCuZs3VB9VF " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / 3OPLSVPyweUyEHaX " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / flatten . link <nl> ppp b / doc / examples / flatten . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / E1HQedkl1zo48WW5 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / 4bn447WQbTERfBaL " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / from_cbor . link <nl> ppp b / doc / examples / from_cbor . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / mya8dUDcDDVoUlBZ " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / AHKW5EMQN4YQ68TY " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / from_msgpack . link <nl> ppp b / doc / examples / from_msgpack . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / sMmEKxW5MGOgLC7z " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / J0KoQF8sOpdMg4kN " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / from_ubjson . link <nl> ppp b / doc / examples / from_ubjson . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / qq29jfETq7nZRrh5 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / uuQK0DAjhbSd96K6 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / meta . link <nl> ppp b / doc / examples / meta . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / 0zdmfNQCe4TMw0iI " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / eFzRNyod3g4aVkvl " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / operator_deserialize . link <nl> ppp b / doc / examples / operator_deserialize . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / YrUqrUFMD7JHwSQR " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / IvgowYGaX0SgOFIG " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / operator_serialize . link <nl> ppp b / doc / examples / operator_serialize . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / wXcm4ObnoaXw7CRt " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / ckGZIBookDffV00n " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / operatorarray__key_type . link <nl> ppp b / doc / examples / operatorarray__key_type . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / vxt8d8qvYorXS2yq " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / oKnfnFrLHG8H1OAl " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / parse__array__parser_callback_t . link <nl> ppp b / doc / examples / parse__array__parser_callback_t . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / TSNxHmegVwLW2pXf " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / i3BBhl7Ub5y9b0yp " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / parse__contiguouscontainer__parser_callback_t . link <nl> ppp b / doc / examples / parse__contiguouscontainer__parser_callback_t . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / l3zNo3YKC2X8yAw9 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / sGdJMOaJnFNJBtH7 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / parse__istream__parser_callback_t . link <nl> ppp b / doc / examples / parse__istream__parser_callback_t . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / Mf7A6JtvqT1Na7Pk " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / UZgRBIeqdZhm6M8F " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / parse__iteratortype__parser_callback_t . link <nl> ppp b / doc / examples / parse__iteratortype__parser_callback_t . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / oa6BVkBXjG8DNkzX " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / VThe0hdMSUdNSOLK " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / parse__string__parser_callback_t . link <nl> ppp b / doc / examples / parse__string__parser_callback_t . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / QXdl4yzts3qPeZ0U " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / QZgjsR0PiAw2Lqpk " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / patch . link <nl> ppp b / doc / examples / patch . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / 8ObNa6ejw4BXQ5qG " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / hFd1W46W2Hb81sHN " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / to_cbor . link <nl> ppp b / doc / examples / to_cbor . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / 4bQSclXeqjVFYVL3 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / LRM37xarSuPJmv92 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / to_msgpack . link <nl> ppp b / doc / examples / to_msgpack . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / WvT2Q0r9vlJYyMM8 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / CaRFhkrefL4miesE " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / to_ubjson . link <nl> ppp b / doc / examples / to_ubjson . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / j3HE6cOkCmKbxxAt " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / 2luqHy9iADx4UNm7 " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / unflatten . link <nl> ppp b / doc / examples / unflatten . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / U45AGi5nsDtoDf3u " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / knK4jnD2hIVxQoyk " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / update . link <nl> ppp b / doc / examples / update . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / TGvdYyJtstacZxWq " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / kjcoWACW7FMqKRBG " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> mmm a / doc / examples / update__range . link <nl> ppp b / doc / examples / update__range . link <nl> @ @ - 1 + 1 @ @ <nl> - < a target = " _blank " href = " https : / / wandbox . org / permlink / BMlas6312rkE4cxz " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> + < a target = " _blank " href = " https : / / wandbox . org / permlink / 0LBIsEa18IrerWwy " > < b > online < / b > < / a > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 831c6a4cd . . 000000000 <nl> mmm a / doc / tmp / nlohmann / json . hpp <nl> ppp / dev / null <nl> <nl> - / * <nl> - __ _____ _____ _____ <nl> - __ | | __ | | | | JSON for Modern C + + <nl> - | | | __ | | | | | | version 3 . 1 . 2 <nl> - | _____ | _____ | _____ | _ | ___ | https : / / github . com / nlohmann / json <nl> - <nl> - Licensed under the MIT License < http : / / opensource . org / licenses / MIT > . <nl> - SPDX - License - Identifier : MIT <nl> - Copyright ( c ) 2013 - 2018 Niels Lohmann < http : / / nlohmann . me > . <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in all <nl> - copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE <nl> - SOFTWARE . <nl> - * / <nl> - <nl> - # ifndef NLOHMANN_JSON_HPP <nl> - # define NLOHMANN_JSON_HPP <nl> - <nl> - # define NLOHMANN_JSON_VERSION_MAJOR 3 <nl> - # define NLOHMANN_JSON_VERSION_MINOR 1 <nl> - # define NLOHMANN_JSON_VERSION_PATCH 2 <nl> - <nl> - # include < algorithm > / / all_of , find , for_each <nl> - # include < cassert > / / assert <nl> - # include < ciso646 > / / and , not , or <nl> - # include < cstddef > / / nullptr_t , ptrdiff_t , size_t <nl> - # include < functional > / / hash , less <nl> - # include < initializer_list > / / initializer_list <nl> - # include < iosfwd > / / istream , ostream <nl> - # include < iterator > / / iterator_traits , random_access_iterator_tag <nl> - # include < numeric > / / accumulate <nl> - # include < string > / / string , stoi , to_string <nl> - # include < utility > / / declval , forward , move , pair , swap <nl> - <nl> - / / # include < nlohmann / json_fwd . hpp > <nl> - # ifndef NLOHMANN_JSON_FWD_HPP <nl> - # define NLOHMANN_JSON_FWD_HPP <nl> - <nl> - # include < cstdint > / / int64_t , uint64_t <nl> - # include < map > / / map <nl> - # include < memory > / / allocator <nl> - # include < string > / / string <nl> - # include < vector > / / vector <nl> - <nl> - / * ! <nl> - @ brief namespace for Niels Lohmann <nl> - @ see https : / / github . com / nlohmann <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - namespace nlohmann <nl> - { <nl> - / * ! <nl> - @ brief default JSONSerializer template argument <nl> - <nl> - This serializer ignores the template arguments and uses ADL <nl> - ( [ argument - dependent lookup ] ( https : / / en . cppreference . com / w / cpp / language / adl ) ) <nl> - for serialization . <nl> - * / <nl> - template < typename T = void , typename SFINAE = void > <nl> - struct adl_serializer ; <nl> - <nl> - template < template < typename U , typename V , typename . . . Args > class ObjectType = <nl> - std : : map , <nl> - template < typename U , typename . . . Args > class ArrayType = std : : vector , <nl> - class StringType = std : : string , class BooleanType = bool , <nl> - class NumberIntegerType = std : : int64_t , <nl> - class NumberUnsignedType = std : : uint64_t , <nl> - class NumberFloatType = double , <nl> - template < typename U > class AllocatorType = std : : allocator , <nl> - template < typename T , typename SFINAE = void > class JSONSerializer = <nl> - adl_serializer > <nl> - class basic_json ; <nl> - <nl> - / * ! <nl> - @ brief JSON Pointer <nl> - <nl> - A JSON pointer defines a string syntax for identifying a specific value <nl> - within a JSON document . It can be used with functions ` at ` and <nl> - ` operator [ ] ` . Furthermore , JSON pointers are the base for JSON patches . <nl> - <nl> - @ sa [ RFC 6901 ] ( https : / / tools . ietf . org / html / rfc6901 ) <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - template < typename BasicJsonType > <nl> - class json_pointer ; <nl> - <nl> - / * ! <nl> - @ brief default JSON class <nl> - <nl> - This type is the default specialization of the @ ref basic_json class which <nl> - uses the standard template types . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using json = basic_json < > ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - <nl> - / / This file contains all internal macro definitions <nl> - / / You MUST include macro_unscope . hpp at the end of json . hpp to undef all of them <nl> - <nl> - / / exclude unsupported compilers <nl> - # if ! defined ( JSON_SKIP_UNSUPPORTED_COMPILER_CHECK ) <nl> - # if defined ( __clang__ ) <nl> - # if ( __clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__ ) < 30400 <nl> - # error " unsupported Clang version - see https : / / github . com / nlohmann / json # supported - compilers " <nl> - # endif <nl> - # elif defined ( __GNUC__ ) & & ! ( defined ( __ICC ) | | defined ( __INTEL_COMPILER ) ) <nl> - # if ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ ) < 40900 <nl> - # error " unsupported GCC version - see https : / / github . com / nlohmann / json # supported - compilers " <nl> - # endif <nl> - # endif <nl> - # endif <nl> - <nl> - / / disable float - equal warnings on GCC / clang <nl> - # if defined ( __clang__ ) | | defined ( __GNUC__ ) | | defined ( __GNUG__ ) <nl> - # pragma GCC diagnostic push <nl> - # pragma GCC diagnostic ignored " - Wfloat - equal " <nl> - # endif <nl> - <nl> - / / disable documentation warnings on clang <nl> - # if defined ( __clang__ ) <nl> - # pragma GCC diagnostic push <nl> - # pragma GCC diagnostic ignored " - Wdocumentation " <nl> - # endif <nl> - <nl> - / / allow for portable deprecation warnings <nl> - # if defined ( __clang__ ) | | defined ( __GNUC__ ) | | defined ( __GNUG__ ) <nl> - # define JSON_DEPRECATED __attribute__ ( ( deprecated ) ) <nl> - # elif defined ( _MSC_VER ) <nl> - # define JSON_DEPRECATED __declspec ( deprecated ) <nl> - # else <nl> - # define JSON_DEPRECATED <nl> - # endif <nl> - <nl> - / / allow to disable exceptions <nl> - # if ( defined ( __cpp_exceptions ) | | defined ( __EXCEPTIONS ) | | defined ( _CPPUNWIND ) ) & & ! defined ( JSON_NOEXCEPTION ) <nl> - # define JSON_THROW ( exception ) throw exception <nl> - # define JSON_TRY try <nl> - # define JSON_CATCH ( exception ) catch ( exception ) <nl> - # define JSON_INTERNAL_CATCH ( exception ) catch ( exception ) <nl> - # else <nl> - # define JSON_THROW ( exception ) std : : abort ( ) <nl> - # define JSON_TRY if ( true ) <nl> - # define JSON_CATCH ( exception ) if ( false ) <nl> - # define JSON_INTERNAL_CATCH ( exception ) if ( false ) <nl> - # endif <nl> - <nl> - / / override exception macros <nl> - # if defined ( JSON_THROW_USER ) <nl> - # undef JSON_THROW <nl> - # define JSON_THROW JSON_THROW_USER <nl> - # endif <nl> - # if defined ( JSON_TRY_USER ) <nl> - # undef JSON_TRY <nl> - # define JSON_TRY JSON_TRY_USER <nl> - # endif <nl> - # if defined ( JSON_CATCH_USER ) <nl> - # undef JSON_CATCH <nl> - # define JSON_CATCH JSON_CATCH_USER <nl> - # define JSON_INTERNAL_CATCH JSON_CATCH_USER <nl> - # endif <nl> - # if defined ( JSON_INTERNAL_CATCH_USER ) <nl> - # undef JSON_INTERNAL_CATCH <nl> - # define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER <nl> - # endif <nl> - <nl> - / / manual branch prediction <nl> - # if defined ( __clang__ ) | | defined ( __GNUC__ ) | | defined ( __GNUG__ ) <nl> - # define JSON_LIKELY ( x ) __builtin_expect ( ! ! ( x ) , 1 ) <nl> - # define JSON_UNLIKELY ( x ) __builtin_expect ( ! ! ( x ) , 0 ) <nl> - # else <nl> - # define JSON_LIKELY ( x ) x <nl> - # define JSON_UNLIKELY ( x ) x <nl> - # endif <nl> - <nl> - / / C + + language standard detection <nl> - # if ( defined ( __cplusplus ) & & __cplusplus > = 201703L ) | | ( defined ( _HAS_CXX17 ) & & _HAS_CXX17 = = 1 ) / / fix for issue # 464 <nl> - # define JSON_HAS_CPP_17 <nl> - # define JSON_HAS_CPP_14 <nl> - # elif ( defined ( __cplusplus ) & & __cplusplus > = 201402L ) | | ( defined ( _HAS_CXX14 ) & & _HAS_CXX14 = = 1 ) <nl> - # define JSON_HAS_CPP_14 <nl> - # endif <nl> - <nl> - / / Ugly macros to avoid uglier copy - paste when specializing basic_json . They <nl> - / / may be removed in the future once the class is split . <nl> - <nl> - # define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ <nl> - template < template < typename , typename , typename . . . > class ObjectType , \ <nl> - template < typename , typename . . . > class ArrayType , \ <nl> - class StringType , class BooleanType , class NumberIntegerType , \ <nl> - class NumberUnsignedType , class NumberFloatType , \ <nl> - template < typename > class AllocatorType , \ <nl> - template < typename , typename = void > class JSONSerializer > <nl> - <nl> - # define NLOHMANN_BASIC_JSON_TPL \ <nl> - basic_json < ObjectType , ArrayType , StringType , BooleanType , \ <nl> - NumberIntegerType , NumberUnsignedType , NumberFloatType , \ <nl> - AllocatorType , JSONSerializer > <nl> - <nl> - / * ! <nl> - @ brief Helper to determine whether there ' s a key_type for T . <nl> - <nl> - This helper is used to tell associative containers apart from other containers <nl> - such as sequence containers . For instance , ` std : : map ` passes the test as it <nl> - contains a ` mapped_type ` , whereas ` std : : vector ` fails the test . <nl> - <nl> - @ sa http : / / stackoverflow . com / a / 7728728 / 266378 <nl> - @ since version 1 . 0 . 0 , overworked in version 2 . 0 . 6 <nl> - * / <nl> - # define NLOHMANN_JSON_HAS_HELPER ( type ) \ <nl> - template < typename T > struct has_ # # type { \ <nl> - private : \ <nl> - template < typename U , typename = typename U : : type > \ <nl> - static int detect ( U & & ) ; \ <nl> - static void detect ( . . . ) ; \ <nl> - public : \ <nl> - static constexpr bool value = \ <nl> - std : : is_integral < decltype ( detect ( std : : declval < T > ( ) ) ) > : : value ; \ <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - <nl> - # include < ciso646 > / / not <nl> - # include < cstddef > / / size_t <nl> - # include < type_traits > / / conditional , enable_if , false_type , integral_constant , is_constructible , is_integral , is_same , remove_cv , remove_reference , true_type <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / alias templates to reduce boilerplate <nl> - template < bool B , typename T = void > <nl> - using enable_if_t = typename std : : enable_if < B , T > : : type ; <nl> - <nl> - template < typename T > <nl> - using uncvref_t = typename std : : remove_cv < typename std : : remove_reference < T > : : type > : : type ; <nl> - <nl> - / / implementation of C + + 14 index_sequence and affiliates <nl> - / / source : https : / / stackoverflow . com / a / 32223343 <nl> - template < std : : size_t . . . Ints > <nl> - struct index_sequence <nl> - { <nl> - using type = index_sequence ; <nl> - using value_type = std : : size_t ; <nl> - static constexpr std : : size_t size ( ) noexcept <nl> - { <nl> - return sizeof . . . ( Ints ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < class Sequence1 , class Sequence2 > <nl> - struct merge_and_renumber ; <nl> - <nl> - template < std : : size_t . . . I1 , std : : size_t . . . I2 > <nl> - struct merge_and_renumber < index_sequence < I1 . . . > , index_sequence < I2 . . . > > <nl> - : index_sequence < I1 . . . , ( sizeof . . . ( I1 ) + I2 ) . . . > { } ; <nl> - <nl> - template < std : : size_t N > <nl> - struct make_index_sequence <nl> - : merge_and_renumber < typename make_index_sequence < N / 2 > : : type , <nl> - typename make_index_sequence < N - N / 2 > : : type > { } ; <nl> - <nl> - template < > struct make_index_sequence < 0 > : index_sequence < > { } ; <nl> - template < > struct make_index_sequence < 1 > : index_sequence < 0 > { } ; <nl> - <nl> - template < typename . . . Ts > <nl> - using index_sequence_for = make_index_sequence < sizeof . . . ( Ts ) > ; <nl> - <nl> - / * <nl> - Implementation of two C + + 17 constructs : conjunction , negation . This is needed <nl> - to avoid evaluating all the traits in a condition <nl> - <nl> - For example : not std : : is_same < void , T > : : value and has_value_type < T > : : value <nl> - will not compile when T = void ( on MSVC at least ) . Whereas <nl> - conjunction < negation < std : : is_same < void , T > > , has_value_type < T > > : : value will <nl> - stop evaluating if negation < . . . > : : value = = false <nl> - <nl> - Please note that those constructs must be used with caution , since symbols can <nl> - become very long quickly ( which can slow down compilation and cause MSVC <nl> - internal compiler errors ) . Only use it when you have to ( see example ahead ) . <nl> - * / <nl> - template < class . . . > struct conjunction : std : : true_type { } ; <nl> - template < class B1 > struct conjunction < B1 > : B1 { } ; <nl> - template < class B1 , class . . . Bn > <nl> - struct conjunction < B1 , Bn . . . > : std : : conditional < bool ( B1 : : value ) , conjunction < Bn . . . > , B1 > : : type { } ; <nl> - <nl> - template < class B > struct negation : std : : integral_constant < bool , not B : : value > { } ; <nl> - <nl> - / / dispatch utility ( taken from ranges - v3 ) <nl> - template < unsigned N > struct priority_tag : priority_tag < N - 1 > { } ; <nl> - template < > struct priority_tag < 0 > { } ; <nl> - <nl> - / / taken from ranges - v3 <nl> - template < typename T > <nl> - struct static_const <nl> - { <nl> - static constexpr T value { } ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - constexpr T static_const < T > : : value ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / meta / type_traits . hpp > <nl> - <nl> - <nl> - # include < ciso646 > / / not <nl> - # include < limits > / / numeric_limits <nl> - # include < type_traits > / / false_type , is_constructible , is_integral , is_same , true_type <nl> - # include < utility > / / declval <nl> - <nl> - / / # include < nlohmann / json_fwd . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - / * ! <nl> - @ brief detail namespace with internal helper functions <nl> - <nl> - This namespace collects functions that should not be exposed , <nl> - implementations of some @ ref basic_json methods , and meta - programming helpers . <nl> - <nl> - @ since version 2 . 1 . 0 <nl> - * / <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / <nl> - / / helpers / / <nl> - / / / / / / / / / / / / / <nl> - <nl> - template < typename > struct is_basic_json : std : : false_type { } ; <nl> - <nl> - NLOHMANN_BASIC_JSON_TPL_DECLARATION <nl> - struct is_basic_json < NLOHMANN_BASIC_JSON_TPL > : std : : true_type { } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / has_ / is_ functions / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / source : https : / / stackoverflow . com / a / 37193089 / 4116453 <nl> - <nl> - template < typename T , typename = void > <nl> - struct is_complete_type : std : : false_type { } ; <nl> - <nl> - template < typename T > <nl> - struct is_complete_type < T , decltype ( void ( sizeof ( T ) ) ) > : std : : true_type { } ; <nl> - <nl> - NLOHMANN_JSON_HAS_HELPER ( mapped_type ) ; <nl> - NLOHMANN_JSON_HAS_HELPER ( key_type ) ; <nl> - NLOHMANN_JSON_HAS_HELPER ( value_type ) ; <nl> - NLOHMANN_JSON_HAS_HELPER ( iterator ) ; <nl> - <nl> - template < bool B , class RealType , class CompatibleObjectType > <nl> - struct is_compatible_object_type_impl : std : : false_type { } ; <nl> - <nl> - template < class RealType , class CompatibleObjectType > <nl> - struct is_compatible_object_type_impl < true , RealType , CompatibleObjectType > <nl> - { <nl> - static constexpr auto value = <nl> - std : : is_constructible < typename RealType : : key_type , typename CompatibleObjectType : : key_type > : : value and <nl> - std : : is_constructible < typename RealType : : mapped_type , typename CompatibleObjectType : : mapped_type > : : value ; <nl> - } ; <nl> - <nl> - template < bool B , class RealType , class CompatibleStringType > <nl> - struct is_compatible_string_type_impl : std : : false_type { } ; <nl> - <nl> - template < class RealType , class CompatibleStringType > <nl> - struct is_compatible_string_type_impl < true , RealType , CompatibleStringType > <nl> - { <nl> - static constexpr auto value = <nl> - std : : is_same < typename RealType : : value_type , typename CompatibleStringType : : value_type > : : value and <nl> - std : : is_constructible < RealType , CompatibleStringType > : : value ; <nl> - } ; <nl> - <nl> - template < class BasicJsonType , class CompatibleObjectType > <nl> - struct is_compatible_object_type <nl> - { <nl> - static auto constexpr value = is_compatible_object_type_impl < <nl> - conjunction < negation < std : : is_same < void , CompatibleObjectType > > , <nl> - has_mapped_type < CompatibleObjectType > , <nl> - has_key_type < CompatibleObjectType > > : : value , <nl> - typename BasicJsonType : : object_t , CompatibleObjectType > : : value ; <nl> - } ; <nl> - <nl> - template < class BasicJsonType , class CompatibleStringType > <nl> - struct is_compatible_string_type <nl> - { <nl> - static auto constexpr value = is_compatible_string_type_impl < <nl> - conjunction < negation < std : : is_same < void , CompatibleStringType > > , <nl> - has_value_type < CompatibleStringType > > : : value , <nl> - typename BasicJsonType : : string_t , CompatibleStringType > : : value ; <nl> - } ; <nl> - <nl> - template < typename BasicJsonType , typename T > <nl> - struct is_basic_json_nested_type <nl> - { <nl> - static auto constexpr value = std : : is_same < T , typename BasicJsonType : : iterator > : : value or <nl> - std : : is_same < T , typename BasicJsonType : : const_iterator > : : value or <nl> - std : : is_same < T , typename BasicJsonType : : reverse_iterator > : : value or <nl> - std : : is_same < T , typename BasicJsonType : : const_reverse_iterator > : : value ; <nl> - } ; <nl> - <nl> - template < class BasicJsonType , class CompatibleArrayType > <nl> - struct is_compatible_array_type <nl> - { <nl> - static auto constexpr value = <nl> - conjunction < negation < std : : is_same < void , CompatibleArrayType > > , <nl> - negation < is_compatible_object_type < <nl> - BasicJsonType , CompatibleArrayType > > , <nl> - negation < std : : is_constructible < typename BasicJsonType : : string_t , <nl> - CompatibleArrayType > > , <nl> - negation < is_basic_json_nested_type < BasicJsonType , CompatibleArrayType > > , <nl> - has_value_type < CompatibleArrayType > , <nl> - has_iterator < CompatibleArrayType > > : : value ; <nl> - } ; <nl> - <nl> - template < bool , typename , typename > <nl> - struct is_compatible_integer_type_impl : std : : false_type { } ; <nl> - <nl> - template < typename RealIntegerType , typename CompatibleNumberIntegerType > <nl> - struct is_compatible_integer_type_impl < true , RealIntegerType , CompatibleNumberIntegerType > <nl> - { <nl> - / / is there an assert somewhere on overflows ? <nl> - using RealLimits = std : : numeric_limits < RealIntegerType > ; <nl> - using CompatibleLimits = std : : numeric_limits < CompatibleNumberIntegerType > ; <nl> - <nl> - static constexpr auto value = <nl> - std : : is_constructible < RealIntegerType , CompatibleNumberIntegerType > : : value and <nl> - CompatibleLimits : : is_integer and <nl> - RealLimits : : is_signed = = CompatibleLimits : : is_signed ; <nl> - } ; <nl> - <nl> - template < typename RealIntegerType , typename CompatibleNumberIntegerType > <nl> - struct is_compatible_integer_type <nl> - { <nl> - static constexpr auto value = <nl> - is_compatible_integer_type_impl < <nl> - std : : is_integral < CompatibleNumberIntegerType > : : value and <nl> - not std : : is_same < bool , CompatibleNumberIntegerType > : : value , <nl> - RealIntegerType , CompatibleNumberIntegerType > : : value ; <nl> - } ; <nl> - <nl> - / / trait checking if JSONSerializer < T > : : from_json ( json const & , udt & ) exists <nl> - template < typename BasicJsonType , typename T > <nl> - struct has_from_json <nl> - { <nl> - private : <nl> - / / also check the return type of from_json <nl> - template < typename U , typename = enable_if_t < std : : is_same < void , decltype ( uncvref_t < U > : : from_json ( <nl> - std : : declval < BasicJsonType > ( ) , std : : declval < T & > ( ) ) ) > : : value > > <nl> - static int detect ( U & & ) ; <nl> - static void detect ( . . . ) ; <nl> - <nl> - public : <nl> - static constexpr bool value = std : : is_integral < decltype ( <nl> - detect ( std : : declval < typename BasicJsonType : : template json_serializer < T , void > > ( ) ) ) > : : value ; <nl> - } ; <nl> - <nl> - / / This trait checks if JSONSerializer < T > : : from_json ( json const & ) exists <nl> - / / this overload is used for non - default - constructible user - defined - types <nl> - template < typename BasicJsonType , typename T > <nl> - struct has_non_default_from_json <nl> - { <nl> - private : <nl> - template < <nl> - typename U , <nl> - typename = enable_if_t < std : : is_same < <nl> - T , decltype ( uncvref_t < U > : : from_json ( std : : declval < BasicJsonType > ( ) ) ) > : : value > > <nl> - static int detect ( U & & ) ; <nl> - static void detect ( . . . ) ; <nl> - <nl> - public : <nl> - static constexpr bool value = std : : is_integral < decltype ( detect ( <nl> - std : : declval < typename BasicJsonType : : template json_serializer < T , void > > ( ) ) ) > : : value ; <nl> - } ; <nl> - <nl> - / / This trait checks if BasicJsonType : : json_serializer < T > : : to_json exists <nl> - template < typename BasicJsonType , typename T > <nl> - struct has_to_json <nl> - { <nl> - private : <nl> - template < typename U , typename = decltype ( uncvref_t < U > : : to_json ( <nl> - std : : declval < BasicJsonType & > ( ) , std : : declval < T > ( ) ) ) > <nl> - static int detect ( U & & ) ; <nl> - static void detect ( . . . ) ; <nl> - <nl> - public : <nl> - static constexpr bool value = std : : is_integral < decltype ( detect ( <nl> - std : : declval < typename BasicJsonType : : template json_serializer < T , void > > ( ) ) ) > : : value ; <nl> - } ; <nl> - <nl> - template < typename BasicJsonType , typename CompatibleCompleteType > <nl> - struct is_compatible_complete_type <nl> - { <nl> - static constexpr bool value = <nl> - not std : : is_base_of < std : : istream , CompatibleCompleteType > : : value and <nl> - not is_basic_json < CompatibleCompleteType > : : value and <nl> - not is_basic_json_nested_type < BasicJsonType , CompatibleCompleteType > : : value and <nl> - has_to_json < BasicJsonType , CompatibleCompleteType > : : value ; <nl> - } ; <nl> - <nl> - template < typename BasicJsonType , typename CompatibleType > <nl> - struct is_compatible_type <nl> - : conjunction < is_complete_type < CompatibleType > , <nl> - is_compatible_complete_type < BasicJsonType , CompatibleType > > <nl> - { <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - <nl> - # include < exception > / / exception <nl> - # include < stdexcept > / / runtime_error <nl> - # include < string > / / to_string <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / <nl> - / / exceptions / / <nl> - / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief general exception of the @ ref basic_json class <nl> - <nl> - This class is an extension of ` std : : exception ` objects with a member @ a id for <nl> - exception ids . It is used as the base class for all exceptions thrown by the <nl> - @ ref basic_json class . This class can hence be used as " wildcard " to catch <nl> - exceptions . <nl> - <nl> - Subclasses : <nl> - - @ ref parse_error for exceptions indicating a parse error <nl> - - @ ref invalid_iterator for exceptions indicating errors with iterators <nl> - - @ ref type_error for exceptions indicating executing a member function with <nl> - a wrong type <nl> - - @ ref out_of_range for exceptions indicating access out of the defined range <nl> - - @ ref other_error for exceptions indicating other library errors <nl> - <nl> - @ internal <nl> - @ note To have nothrow - copy - constructible exceptions , we internally use <nl> - ` std : : runtime_error ` which can cope with arbitrary - length error messages . <nl> - Intermediate strings are built with static functions and then passed to <nl> - the actual constructor . <nl> - @ endinternal <nl> - <nl> - @ liveexample { The following code shows how arbitrary library exceptions can be <nl> - caught . , exception } <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class exception : public std : : exception <nl> - { <nl> - public : <nl> - / / / returns the explanatory string <nl> - const char * what ( ) const noexcept override <nl> - { <nl> - return m . what ( ) ; <nl> - } <nl> - <nl> - / / / the id of the exception <nl> - const int id ; <nl> - <nl> - protected : <nl> - exception ( int id_ , const char * what_arg ) : id ( id_ ) , m ( what_arg ) { } <nl> - <nl> - static std : : string name ( const std : : string & ename , int id_ ) <nl> - { <nl> - return " [ json . exception . " + ename + " . " + std : : to_string ( id_ ) + " ] " ; <nl> - } <nl> - <nl> - private : <nl> - / / / an exception object as storage for error messages <nl> - std : : runtime_error m ; <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief exception indicating a parse error <nl> - <nl> - This exception is thrown by the library when a parse error occurs . Parse errors <nl> - can occur during the deserialization of JSON text , CBOR , MessagePack , as well <nl> - as when using JSON Patch . <nl> - <nl> - Member @ a byte holds the byte index of the last read character in the input <nl> - file . <nl> - <nl> - Exceptions have ids 1xx . <nl> - <nl> - name / id | example message | description <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - json . exception . parse_error . 101 | parse error at 2 : unexpected end of input ; expected string literal | This error indicates a syntax error while deserializing a JSON text . The error message describes that an unexpected token ( character ) was encountered , and the member @ a byte indicates the error position . <nl> - json . exception . parse_error . 102 | parse error at 14 : missing or wrong low surrogate | JSON uses the ` \ uxxxx ` format to describe Unicode characters . Code points above above 0xFFFF are split into two ` \ uxxxx ` entries ( " surrogate pairs " ) . This error indicates that the surrogate pair is incomplete or contains an invalid code point . <nl> - json . exception . parse_error . 103 | parse error : code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF . Code points above 0x10FFFF are invalid . <nl> - json . exception . parse_error . 104 | parse error : JSON patch must be an array of objects | [ RFC 6902 ] ( https : / / tools . ietf . org / html / rfc6902 ) requires a JSON Patch document to be a JSON document that represents an array of objects . <nl> - json . exception . parse_error . 105 | parse error : operation must have string member ' op ' | An operation of a JSON Patch document must contain exactly one " op " member , whose value indicates the operation to perform . Its value must be one of " add " , " remove " , " replace " , " move " , " copy " , or " test " ; other values are errors . <nl> - json . exception . parse_error . 106 | parse error : array index ' 01 ' must not begin with ' 0 ' | An array index in a JSON Pointer ( [ RFC 6901 ] ( https : / / tools . ietf . org / html / rfc6901 ) ) may be ` 0 ` or any number without a leading ` 0 ` . <nl> - json . exception . parse_error . 107 | parse error : JSON pointer must be empty or begin with ' / ' - was : ' foo ' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens , each prefixed by a ` / ` character . <nl> - json . exception . parse_error . 108 | parse error : escape character ' ~ ' must be followed with ' 0 ' or ' 1 ' | In a JSON Pointer , only ` ~ 0 ` and ` ~ 1 ` are valid escape sequences . <nl> - json . exception . parse_error . 109 | parse error : array index ' one ' is not a number | A JSON Pointer array index must be a number . <nl> - json . exception . parse_error . 110 | parse error at 1 : cannot read 2 bytes from vector | When parsing CBOR or MessagePack , the byte vector ends before the complete value has been read . <nl> - json . exception . parse_error . 112 | parse error at 1 : error reading CBOR ; last byte : 0xF8 | Not all types of CBOR or MessagePack are supported . This exception occurs if an unsupported byte was read . <nl> - json . exception . parse_error . 113 | parse error at 2 : expected a CBOR string ; last byte : 0x98 | While parsing a map key , a value that is not a string has been read . <nl> - <nl> - @ note For an input with n bytes , 1 is the index of the first character and n + 1 <nl> - is the index of the terminating null byte or the end of file . This also <nl> - holds true when reading a byte vector ( CBOR or MessagePack ) . <nl> - <nl> - @ liveexample { The following code shows how a ` parse_error ` exception can be <nl> - caught . , parse_error } <nl> - <nl> - @ sa @ ref exception for the base class of the library exceptions <nl> - @ sa @ ref invalid_iterator for exceptions indicating errors with iterators <nl> - @ sa @ ref type_error for exceptions indicating executing a member function with <nl> - a wrong type <nl> - @ sa @ ref out_of_range for exceptions indicating access out of the defined range <nl> - @ sa @ ref other_error for exceptions indicating other library errors <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class parse_error : public exception <nl> - { <nl> - public : <nl> - / * ! <nl> - @ brief create a parse error exception <nl> - @ param [ in ] id_ the id of the exception <nl> - @ param [ in ] byte_ the byte index where the error occurred ( or 0 if the <nl> - position cannot be determined ) <nl> - @ param [ in ] what_arg the explanatory string <nl> - @ return parse_error object <nl> - * / <nl> - static parse_error create ( int id_ , std : : size_t byte_ , const std : : string & what_arg ) <nl> - { <nl> - std : : string w = exception : : name ( " parse_error " , id_ ) + " parse error " + <nl> - ( byte_ ! = 0 ? ( " at " + std : : to_string ( byte_ ) ) : " " ) + <nl> - " : " + what_arg ; <nl> - return parse_error ( id_ , byte_ , w . c_str ( ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief byte index of the parse error <nl> - <nl> - The byte index of the last read character in the input file . <nl> - <nl> - @ note For an input with n bytes , 1 is the index of the first character and <nl> - n + 1 is the index of the terminating null byte or the end of file . <nl> - This also holds true when reading a byte vector ( CBOR or MessagePack ) . <nl> - * / <nl> - const std : : size_t byte ; <nl> - <nl> - private : <nl> - parse_error ( int id_ , std : : size_t byte_ , const char * what_arg ) <nl> - : exception ( id_ , what_arg ) , byte ( byte_ ) { } <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief exception indicating errors with iterators <nl> - <nl> - This exception is thrown if iterators passed to a library function do not match <nl> - the expected semantics . <nl> - <nl> - Exceptions have ids 2xx . <nl> - <nl> - name / id | example message | description <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - json . exception . invalid_iterator . 201 | iterators are not compatible | The iterators passed to constructor @ ref basic_json ( InputIT first , InputIT last ) are not compatible , meaning they do not belong to the same container . Therefore , the range ( @ a first , @ a last ) is invalid . <nl> - json . exception . invalid_iterator . 202 | iterator does not fit current value | In an erase or insert function , the passed iterator @ a pos does not belong to the JSON value for which the function was called . It hence does not define a valid position for the deletion / insertion . <nl> - json . exception . invalid_iterator . 203 | iterators do not fit current value | Either iterator passed to function @ ref erase ( IteratorType first , IteratorType last ) does not belong to the JSON value from which values shall be erased . It hence does not define a valid range to delete values from . <nl> - json . exception . invalid_iterator . 204 | iterators out of range | When an iterator range for a primitive type ( number , boolean , or string ) is passed to a constructor or an erase function , this range has to be exactly ( @ ref begin ( ) , @ ref end ( ) ) , because this is the only way the single stored value is expressed . All other ranges are invalid . <nl> - json . exception . invalid_iterator . 205 | iterator out of range | When an iterator for a primitive type ( number , boolean , or string ) is passed to an erase function , the iterator has to be the @ ref begin ( ) iterator , because it is the only way to address the stored value . All other iterators are invalid . <nl> - json . exception . invalid_iterator . 206 | cannot construct with iterators from null | The iterators passed to constructor @ ref basic_json ( InputIT first , InputIT last ) belong to a JSON null value and hence to not define a valid range . <nl> - json . exception . invalid_iterator . 207 | cannot use key ( ) for non - object iterators | The key ( ) member function can only be used on iterators belonging to a JSON object , because other types do not have a concept of a key . <nl> - json . exception . invalid_iterator . 208 | cannot use operator [ ] for object iterators | The operator [ ] to specify a concrete offset cannot be used on iterators belonging to a JSON object , because JSON objects are unordered . <nl> - json . exception . invalid_iterator . 209 | cannot use offsets with object iterators | The offset operators ( + , - , + = , - = ) cannot be used on iterators belonging to a JSON object , because JSON objects are unordered . <nl> - json . exception . invalid_iterator . 210 | iterators do not fit | The iterator range passed to the insert function are not compatible , meaning they do not belong to the same container . Therefore , the range ( @ a first , @ a last ) is invalid . <nl> - json . exception . invalid_iterator . 211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to . <nl> - json . exception . invalid_iterator . 212 | cannot compare iterators of different containers | When two iterators are compared , they must belong to the same container . <nl> - json . exception . invalid_iterator . 213 | cannot compare order of object iterators | The order of object iterators cannot be compared , because JSON objects are unordered . <nl> - json . exception . invalid_iterator . 214 | cannot get value | Cannot get value for iterator : Either the iterator belongs to a null value or it is an iterator to a primitive type ( number , boolean , or string ) , but the iterator is different to @ ref begin ( ) . <nl> - <nl> - @ liveexample { The following code shows how an ` invalid_iterator ` exception can be <nl> - caught . , invalid_iterator } <nl> - <nl> - @ sa @ ref exception for the base class of the library exceptions <nl> - @ sa @ ref parse_error for exceptions indicating a parse error <nl> - @ sa @ ref type_error for exceptions indicating executing a member function with <nl> - a wrong type <nl> - @ sa @ ref out_of_range for exceptions indicating access out of the defined range <nl> - @ sa @ ref other_error for exceptions indicating other library errors <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class invalid_iterator : public exception <nl> - { <nl> - public : <nl> - static invalid_iterator create ( int id_ , const std : : string & what_arg ) <nl> - { <nl> - std : : string w = exception : : name ( " invalid_iterator " , id_ ) + what_arg ; <nl> - return invalid_iterator ( id_ , w . c_str ( ) ) ; <nl> - } <nl> - <nl> - private : <nl> - invalid_iterator ( int id_ , const char * what_arg ) <nl> - : exception ( id_ , what_arg ) { } <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief exception indicating executing a member function with a wrong type <nl> - <nl> - This exception is thrown in case of a type error ; that is , a library function is <nl> - executed on a JSON value whose type does not match the expected semantics . <nl> - <nl> - Exceptions have ids 3xx . <nl> - <nl> - name / id | example message | description <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - json . exception . type_error . 301 | cannot create object from initializer list | To create an object from an initializer list , the initializer list must consist only of a list of pairs whose first element is a string . When this constraint is violated , an array is created instead . <nl> - json . exception . type_error . 302 | type must be object , but is array | During implicit or explicit value conversion , the JSON type must be compatible to the target type . For instance , a JSON string can only be converted into string types , but not into numbers or boolean types . <nl> - json . exception . type_error . 303 | incompatible ReferenceType for get_ref , actual type is object | To retrieve a reference to a value stored in a @ ref basic_json object with @ ref get_ref , the type of the reference must match the value type . For instance , for a JSON array , the @ a ReferenceType must be @ ref array_t & . <nl> - json . exception . type_error . 304 | cannot use at ( ) with string | The @ ref at ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 305 | cannot use operator [ ] with string | The @ ref operator [ ] member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 306 | cannot use value ( ) with string | The @ ref value ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 307 | cannot use erase ( ) with string | The @ ref erase ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 308 | cannot use push_back ( ) with string | The @ ref push_back ( ) and @ ref operator + = member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 309 | cannot use insert ( ) with | The @ ref insert ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 310 | cannot use swap ( ) with number | The @ ref swap ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 311 | cannot use emplace_back ( ) with string | The @ ref emplace_back ( ) member function can only be executed for certain JSON types . <nl> - json . exception . type_error . 312 | cannot use update ( ) with string | The @ ref update ( ) member functions can only be executed for certain JSON types . <nl> - json . exception . type_error . 313 | invalid value to unflatten | The @ ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value . The JSON Pointers must not overlap , because then the resulting value would not be well defined . <nl> - json . exception . type_error . 314 | only objects can be unflattened | The @ ref unflatten function only works for an object whose keys are JSON Pointers . <nl> - json . exception . type_error . 315 | values in object must be primitive | The @ ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive . <nl> - json . exception . type_error . 316 | invalid UTF - 8 byte at index 10 : 0x7E | The @ ref dump function only works with UTF - 8 encoded strings ; that is , if you assign a ` std : : string ` to a JSON value , make sure it is UTF - 8 encoded . | <nl> - <nl> - @ liveexample { The following code shows how a ` type_error ` exception can be <nl> - caught . , type_error } <nl> - <nl> - @ sa @ ref exception for the base class of the library exceptions <nl> - @ sa @ ref parse_error for exceptions indicating a parse error <nl> - @ sa @ ref invalid_iterator for exceptions indicating errors with iterators <nl> - @ sa @ ref out_of_range for exceptions indicating access out of the defined range <nl> - @ sa @ ref other_error for exceptions indicating other library errors <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class type_error : public exception <nl> - { <nl> - public : <nl> - static type_error create ( int id_ , const std : : string & what_arg ) <nl> - { <nl> - std : : string w = exception : : name ( " type_error " , id_ ) + what_arg ; <nl> - return type_error ( id_ , w . c_str ( ) ) ; <nl> - } <nl> - <nl> - private : <nl> - type_error ( int id_ , const char * what_arg ) : exception ( id_ , what_arg ) { } <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief exception indicating access out of the defined range <nl> - <nl> - This exception is thrown in case a library function is called on an input <nl> - parameter that exceeds the expected range , for instance in case of array <nl> - indices or nonexisting object keys . <nl> - <nl> - Exceptions have ids 4xx . <nl> - <nl> - name / id | example message | description <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - json . exception . out_of_range . 401 | array index 3 is out of range | The provided array index @ a i is larger than @ a size - 1 . <nl> - json . exception . out_of_range . 402 | array index ' - ' ( 3 ) is out of range | The special array index ` - ` in a JSON Pointer never describes a valid element of the array , but the index past the end . That is , it can only be used to add elements at this position , but not to read it . <nl> - json . exception . out_of_range . 403 | key ' foo ' not found | The provided key was not found in the JSON object . <nl> - json . exception . out_of_range . 404 | unresolved reference token ' foo ' | A reference token in a JSON Pointer could not be resolved . <nl> - json . exception . out_of_range . 405 | JSON pointer has no parent | The JSON Patch operations ' remove ' and ' add ' can not be applied to the root element of the JSON value . <nl> - json . exception . out_of_range . 406 | number overflow parsing ' 10E1000 ' | A parsed number could not be stored as without changing it to NaN or INF . <nl> - json . exception . out_of_range . 407 | number overflow serializing ' 9223372036854775808 ' | UBJSON only supports integers numbers up to 9223372036854775807 . | <nl> - json . exception . out_of_range . 408 | excessive array size : 8658170730974374167 | The size ( following ` # ` ) of an UBJSON array or object exceeds the maximal capacity . | <nl> - <nl> - @ liveexample { The following code shows how an ` out_of_range ` exception can be <nl> - caught . , out_of_range } <nl> - <nl> - @ sa @ ref exception for the base class of the library exceptions <nl> - @ sa @ ref parse_error for exceptions indicating a parse error <nl> - @ sa @ ref invalid_iterator for exceptions indicating errors with iterators <nl> - @ sa @ ref type_error for exceptions indicating executing a member function with <nl> - a wrong type <nl> - @ sa @ ref other_error for exceptions indicating other library errors <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class out_of_range : public exception <nl> - { <nl> - public : <nl> - static out_of_range create ( int id_ , const std : : string & what_arg ) <nl> - { <nl> - std : : string w = exception : : name ( " out_of_range " , id_ ) + what_arg ; <nl> - return out_of_range ( id_ , w . c_str ( ) ) ; <nl> - } <nl> - <nl> - private : <nl> - out_of_range ( int id_ , const char * what_arg ) : exception ( id_ , what_arg ) { } <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief exception indicating other library errors <nl> - <nl> - This exception is thrown in case of errors that cannot be classified with the <nl> - other exception types . <nl> - <nl> - Exceptions have ids 5xx . <nl> - <nl> - name / id | example message | description <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - json . exception . other_error . 501 | unsuccessful : { " op " : " test " , " path " : " / baz " , " value " : " bar " } | A JSON Patch operation ' test ' failed . The unsuccessful operation is also printed . <nl> - <nl> - @ sa @ ref exception for the base class of the library exceptions <nl> - @ sa @ ref parse_error for exceptions indicating a parse error <nl> - @ sa @ ref invalid_iterator for exceptions indicating errors with iterators <nl> - @ sa @ ref type_error for exceptions indicating executing a member function with <nl> - a wrong type <nl> - @ sa @ ref out_of_range for exceptions indicating access out of the defined range <nl> - <nl> - @ liveexample { The following code shows how an ` other_error ` exception can be <nl> - caught . , other_error } <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - class other_error : public exception <nl> - { <nl> - public : <nl> - static other_error create ( int id_ , const std : : string & what_arg ) <nl> - { <nl> - std : : string w = exception : : name ( " other_error " , id_ ) + what_arg ; <nl> - return other_error ( id_ , w . c_str ( ) ) ; <nl> - } <nl> - <nl> - private : <nl> - other_error ( int id_ , const char * what_arg ) : exception ( id_ , what_arg ) { } <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - # include < array > / / array <nl> - # include < ciso646 > / / and <nl> - # include < cstddef > / / size_t <nl> - # include < cstdint > / / uint8_t <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON type enumeration / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief the JSON type enumeration <nl> - <nl> - This enumeration collects the different JSON types . It is internally used to <nl> - distinguish the stored values , and the functions @ ref basic_json : : is_null ( ) , <nl> - @ ref basic_json : : is_object ( ) , @ ref basic_json : : is_array ( ) , <nl> - @ ref basic_json : : is_string ( ) , @ ref basic_json : : is_boolean ( ) , <nl> - @ ref basic_json : : is_number ( ) ( with @ ref basic_json : : is_number_integer ( ) , <nl> - @ ref basic_json : : is_number_unsigned ( ) , and @ ref basic_json : : is_number_float ( ) ) , <nl> - @ ref basic_json : : is_discarded ( ) , @ ref basic_json : : is_primitive ( ) , and <nl> - @ ref basic_json : : is_structured ( ) rely on it . <nl> - <nl> - @ note There are three enumeration entries ( number_integer , number_unsigned , and <nl> - number_float ) , because the library distinguishes these three types for numbers : <nl> - @ ref basic_json : : number_unsigned_t is used for unsigned integers , <nl> - @ ref basic_json : : number_integer_t is used for signed integers , and <nl> - @ ref basic_json : : number_float_t is used for floating - point numbers or to <nl> - approximate integers which do not fit in the limits of their respective type . <nl> - <nl> - @ sa @ ref basic_json : : basic_json ( const value_t value_type ) - - create a JSON <nl> - value with the default value for a given type <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - enum class value_t : std : : uint8_t <nl> - { <nl> - null , / / / < null value <nl> - object , / / / < object ( unordered set of name / value pairs ) <nl> - array , / / / < array ( ordered collection of values ) <nl> - string , / / / < string value <nl> - boolean , / / / < boolean value <nl> - number_integer , / / / < number value ( signed integer ) <nl> - number_unsigned , / / / < number value ( unsigned integer ) <nl> - number_float , / / / < number value ( floating - point ) <nl> - discarded / / / < discarded by the the parser callback function <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief comparison operator for JSON types <nl> - <nl> - Returns an ordering that is similar to Python : <nl> - - order : null < boolean < number < object < array < string <nl> - - furthermore , each type is not smaller than itself <nl> - - discarded values are not comparable <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - inline bool operator < ( const value_t lhs , const value_t rhs ) noexcept <nl> - { <nl> - static constexpr std : : array < std : : uint8_t , 8 > order = { { <nl> - 0 / * null * / , 3 / * object * / , 4 / * array * / , 5 / * string * / , <nl> - 1 / * boolean * / , 2 / * integer * / , 2 / * unsigned * / , 2 / * float * / <nl> - } <nl> - } ; <nl> - <nl> - const auto l_index = static_cast < std : : size_t > ( lhs ) ; <nl> - const auto r_index = static_cast < std : : size_t > ( rhs ) ; <nl> - return l_index < order . size ( ) and r_index < order . size ( ) and order [ l_index ] < order [ r_index ] ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / conversions / from_json . hpp > <nl> - <nl> - <nl> - # include < algorithm > / / transform <nl> - # include < array > / / array <nl> - # include < ciso646 > / / and , not <nl> - # include < forward_list > / / forward_list <nl> - # include < iterator > / / inserter , front_inserter , end <nl> - # include < map > / / map <nl> - # include < string > / / string <nl> - # include < tuple > / / tuple , make_tuple <nl> - # include < type_traits > / / is_arithmetic , is_same , is_enum , underlying_type , is_convertible <nl> - # include < unordered_map > / / unordered_map <nl> - # include < utility > / / pair , declval <nl> - # include < valarray > / / valarray <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / type_traits . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename std : : nullptr_t & n ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_null ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be null , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - n = nullptr ; <nl> - } <nl> - <nl> - / / overloads for basic_json template parameters <nl> - template < typename BasicJsonType , typename ArithmeticType , <nl> - enable_if_t < std : : is_arithmetic < ArithmeticType > : : value and <nl> - not std : : is_same < ArithmeticType , typename BasicJsonType : : boolean_t > : : value , <nl> - int > = 0 > <nl> - void get_arithmetic_value ( const BasicJsonType & j , ArithmeticType & val ) <nl> - { <nl> - switch ( static_cast < value_t > ( j ) ) <nl> - { <nl> - case value_t : : number_unsigned : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_unsigned_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - case value_t : : number_integer : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_integer_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - case value_t : : number_float : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_float_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be number , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : boolean_t & b ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_boolean ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be boolean , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - b = * j . template get_ptr < const typename BasicJsonType : : boolean_t * > ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : string_t & s ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_string ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be string , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - s = * j . template get_ptr < const typename BasicJsonType : : string_t * > ( ) ; <nl> - } <nl> - <nl> - template < <nl> - typename BasicJsonType , typename CompatibleStringType , <nl> - enable_if_t < <nl> - is_compatible_string_type < BasicJsonType , CompatibleStringType > : : value and <nl> - not std : : is_same < typename BasicJsonType : : string_t , <nl> - CompatibleStringType > : : value , <nl> - int > = 0 > <nl> - void from_json ( const BasicJsonType & j , CompatibleStringType & s ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_string ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be string , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - s = * j . template get_ptr < const typename BasicJsonType : : string_t * > ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : number_float_t & val ) <nl> - { <nl> - get_arithmetic_value ( j , val ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : number_unsigned_t & val ) <nl> - { <nl> - get_arithmetic_value ( j , val ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : number_integer_t & val ) <nl> - { <nl> - get_arithmetic_value ( j , val ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename EnumType , <nl> - enable_if_t < std : : is_enum < EnumType > : : value , int > = 0 > <nl> - void from_json ( const BasicJsonType & j , EnumType & e ) <nl> - { <nl> - typename std : : underlying_type < EnumType > : : type val ; <nl> - get_arithmetic_value ( j , val ) ; <nl> - e = static_cast < EnumType > ( val ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void from_json ( const BasicJsonType & j , typename BasicJsonType : : array_t & arr ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - arr = * j . template get_ptr < const typename BasicJsonType : : array_t * > ( ) ; <nl> - } <nl> - <nl> - / / forward_list doesn ' t have an insert method <nl> - template < typename BasicJsonType , typename T , typename Allocator , <nl> - enable_if_t < std : : is_convertible < BasicJsonType , T > : : value , int > = 0 > <nl> - void from_json ( const BasicJsonType & j , std : : forward_list < T , Allocator > & l ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - std : : transform ( j . rbegin ( ) , j . rend ( ) , <nl> - std : : front_inserter ( l ) , [ ] ( const BasicJsonType & i ) <nl> - { <nl> - return i . template get < T > ( ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - / / valarray doesn ' t have an insert method <nl> - template < typename BasicJsonType , typename T , <nl> - enable_if_t < std : : is_convertible < BasicJsonType , T > : : value , int > = 0 > <nl> - void from_json ( const BasicJsonType & j , std : : valarray < T > & l ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - l . resize ( j . size ( ) ) ; <nl> - std : : copy ( j . m_value . array - > begin ( ) , j . m_value . array - > end ( ) , std : : begin ( l ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleArrayType > <nl> - void from_json_array_impl ( const BasicJsonType & j , CompatibleArrayType & arr , priority_tag < 0 > / * unused * / ) <nl> - { <nl> - using std : : end ; <nl> - <nl> - std : : transform ( j . begin ( ) , j . end ( ) , <nl> - std : : inserter ( arr , end ( arr ) ) , [ ] ( const BasicJsonType & i ) <nl> - { <nl> - / / get < BasicJsonType > ( ) returns * this , this won ' t call a from_json <nl> - / / method when value_type is BasicJsonType <nl> - return i . template get < typename CompatibleArrayType : : value_type > ( ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleArrayType > <nl> - auto from_json_array_impl ( const BasicJsonType & j , CompatibleArrayType & arr , priority_tag < 1 > / * unused * / ) <nl> - - > decltype ( <nl> - arr . reserve ( std : : declval < typename CompatibleArrayType : : size_type > ( ) ) , <nl> - void ( ) ) <nl> - { <nl> - using std : : end ; <nl> - <nl> - arr . reserve ( j . size ( ) ) ; <nl> - std : : transform ( j . begin ( ) , j . end ( ) , <nl> - std : : inserter ( arr , end ( arr ) ) , [ ] ( const BasicJsonType & i ) <nl> - { <nl> - / / get < BasicJsonType > ( ) returns * this , this won ' t call a from_json <nl> - / / method when value_type is BasicJsonType <nl> - return i . template get < typename CompatibleArrayType : : value_type > ( ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T , std : : size_t N > <nl> - void from_json_array_impl ( const BasicJsonType & j , std : : array < T , N > & arr , priority_tag < 2 > / * unused * / ) <nl> - { <nl> - for ( std : : size_t i = 0 ; i < N ; + + i ) <nl> - { <nl> - arr [ i ] = j . at ( i ) . template get < T > ( ) ; <nl> - } <nl> - } <nl> - <nl> - template < <nl> - typename BasicJsonType , typename CompatibleArrayType , <nl> - enable_if_t < <nl> - is_compatible_array_type < BasicJsonType , CompatibleArrayType > : : value and <nl> - not std : : is_same < typename BasicJsonType : : array_t , <nl> - CompatibleArrayType > : : value and <nl> - std : : is_constructible < <nl> - BasicJsonType , typename CompatibleArrayType : : value_type > : : value , <nl> - int > = 0 > <nl> - void from_json ( const BasicJsonType & j , CompatibleArrayType & arr ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + <nl> - std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - from_json_array_impl ( j , arr , priority_tag < 2 > { } ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleObjectType , <nl> - enable_if_t < is_compatible_object_type < BasicJsonType , CompatibleObjectType > : : value , int > = 0 > <nl> - void from_json ( const BasicJsonType & j , CompatibleObjectType & obj ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be object , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - auto inner_object = j . template get_ptr < const typename BasicJsonType : : object_t * > ( ) ; <nl> - using value_type = typename CompatibleObjectType : : value_type ; <nl> - std : : transform ( <nl> - inner_object - > begin ( ) , inner_object - > end ( ) , <nl> - std : : inserter ( obj , obj . begin ( ) ) , <nl> - [ ] ( typename BasicJsonType : : object_t : : value_type const & p ) <nl> - { <nl> - return value_type ( p . first , p . second . template get < typename CompatibleObjectType : : mapped_type > ( ) ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - / / overload for arithmetic types , not chosen for basic_json template arguments <nl> - / / ( BooleanType , etc . . ) ; note : Is it really necessary to provide explicit <nl> - / / overloads for boolean_t etc . in case of a custom BooleanType which is not <nl> - / / an arithmetic type ? <nl> - template < typename BasicJsonType , typename ArithmeticType , <nl> - enable_if_t < <nl> - std : : is_arithmetic < ArithmeticType > : : value and <nl> - not std : : is_same < ArithmeticType , typename BasicJsonType : : number_unsigned_t > : : value and <nl> - not std : : is_same < ArithmeticType , typename BasicJsonType : : number_integer_t > : : value and <nl> - not std : : is_same < ArithmeticType , typename BasicJsonType : : number_float_t > : : value and <nl> - not std : : is_same < ArithmeticType , typename BasicJsonType : : boolean_t > : : value , <nl> - int > = 0 > <nl> - void from_json ( const BasicJsonType & j , ArithmeticType & val ) <nl> - { <nl> - switch ( static_cast < value_t > ( j ) ) <nl> - { <nl> - case value_t : : number_unsigned : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_unsigned_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - case value_t : : number_integer : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_integer_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - case value_t : : number_float : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : number_float_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - case value_t : : boolean : <nl> - { <nl> - val = static_cast < ArithmeticType > ( * j . template get_ptr < const typename BasicJsonType : : boolean_t * > ( ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be number , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename A1 , typename A2 > <nl> - void from_json ( const BasicJsonType & j , std : : pair < A1 , A2 > & p ) <nl> - { <nl> - p = { j . at ( 0 ) . template get < A1 > ( ) , j . at ( 1 ) . template get < A2 > ( ) } ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename Tuple , std : : size_t . . . Idx > <nl> - void from_json_tuple_impl ( const BasicJsonType & j , Tuple & t , index_sequence < Idx . . . > ) <nl> - { <nl> - t = std : : make_tuple ( j . at ( Idx ) . template get < typename std : : tuple_element < Idx , Tuple > : : type > ( ) . . . ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename . . . Args > <nl> - void from_json ( const BasicJsonType & j , std : : tuple < Args . . . > & t ) <nl> - { <nl> - from_json_tuple_impl ( j , t , index_sequence_for < Args . . . > { } ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename Key , typename Value , typename Compare , typename Allocator , <nl> - typename = enable_if_t < not std : : is_constructible < <nl> - typename BasicJsonType : : string_t , Key > : : value > > <nl> - void from_json ( const BasicJsonType & j , std : : map < Key , Value , Compare , Allocator > & m ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - for ( const auto & p : j ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not p . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( p . type_name ( ) ) ) ) ; <nl> - } <nl> - m . emplace ( p . at ( 0 ) . template get < Key > ( ) , p . at ( 1 ) . template get < Value > ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename Key , typename Value , typename Hash , typename KeyEqual , typename Allocator , <nl> - typename = enable_if_t < not std : : is_constructible < <nl> - typename BasicJsonType : : string_t , Key > : : value > > <nl> - void from_json ( const BasicJsonType & j , std : : unordered_map < Key , Value , Hash , KeyEqual , Allocator > & m ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not j . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - for ( const auto & p : j ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not p . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be array , but is " + std : : string ( p . type_name ( ) ) ) ) ; <nl> - } <nl> - m . emplace ( p . at ( 0 ) . template get < Key > ( ) , p . at ( 1 ) . template get < Value > ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - struct from_json_fn <nl> - { <nl> - private : <nl> - template < typename BasicJsonType , typename T > <nl> - auto call ( const BasicJsonType & j , T & val , priority_tag < 1 > / * unused * / ) const <nl> - noexcept ( noexcept ( from_json ( j , val ) ) ) <nl> - - > decltype ( from_json ( j , val ) , void ( ) ) <nl> - { <nl> - return from_json ( j , val ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T > <nl> - void call ( const BasicJsonType & / * unused * / , T & / * unused * / , priority_tag < 0 > / * unused * / ) const noexcept <nl> - { <nl> - static_assert ( sizeof ( BasicJsonType ) = = 0 , <nl> - " could not find from_json ( ) method in T ' s namespace " ) ; <nl> - # ifdef _MSC_VER <nl> - / / MSVC does not show a stacktrace for the above assert <nl> - using decayed = uncvref_t < T > ; <nl> - static_assert ( sizeof ( typename decayed : : force_msvc_stacktrace ) = = 0 , <nl> - " forcing MSVC stacktrace to show which T we ' re talking about . " ) ; <nl> - # endif <nl> - } <nl> - <nl> - public : <nl> - template < typename BasicJsonType , typename T > <nl> - void operator ( ) ( const BasicJsonType & j , T & val ) const <nl> - noexcept ( noexcept ( std : : declval < from_json_fn > ( ) . call ( j , val , priority_tag < 1 > { } ) ) ) <nl> - { <nl> - return call ( j , val , priority_tag < 1 > { } ) ; <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - / / / namespace to hold default ` from_json ` function <nl> - / / / to see why this is required : <nl> - / / / http : / / www . open - std . org / jtc1 / sc22 / wg21 / docs / papers / 2015 / n4381 . html <nl> - namespace <nl> - { <nl> - constexpr const auto & from_json = detail : : static_const < detail : : from_json_fn > : : value ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / conversions / to_json . hpp > <nl> - <nl> - <nl> - # include < ciso646 > / / or , and , not <nl> - # include < iterator > / / begin , end <nl> - # include < tuple > / / tuple , get <nl> - # include < type_traits > / / is_same , is_constructible , is_floating_point , is_enum , underlying_type <nl> - # include < utility > / / move , forward , declval , pair <nl> - # include < valarray > / / valarray <nl> - # include < vector > / / vector <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / type_traits . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - / / # include < nlohmann / detail / iterators / iteration_proxy . hpp > <nl> - <nl> - <nl> - # include < cstddef > / / size_t <nl> - # include < string > / / string , to_string <nl> - # include < iterator > / / input_iterator_tag <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / proxy class for the items ( ) function <nl> - template < typename IteratorType > class iteration_proxy <nl> - { <nl> - private : <nl> - / / / helper class for iteration <nl> - class iteration_proxy_internal <nl> - { <nl> - public : <nl> - using difference_type = std : : ptrdiff_t ; <nl> - using value_type = iteration_proxy_internal ; <nl> - using pointer = iteration_proxy_internal * ; <nl> - using reference = iteration_proxy_internal & ; <nl> - using iterator_category = std : : input_iterator_tag ; <nl> - <nl> - private : <nl> - / / / the iterator <nl> - IteratorType anchor ; <nl> - / / / an index for arrays ( used to create key names ) <nl> - std : : size_t array_index = 0 ; <nl> - / / / last stringified array index <nl> - mutable std : : size_t array_index_last = 0 ; <nl> - / / / a string representation of the array index <nl> - mutable std : : string array_index_str = " 0 " ; <nl> - / / / an empty string ( to return a reference for primitive values ) <nl> - const std : : string empty_str = " " ; <nl> - <nl> - public : <nl> - explicit iteration_proxy_internal ( IteratorType it ) noexcept : anchor ( it ) { } <nl> - <nl> - iteration_proxy_internal ( const iteration_proxy_internal & ) = default ; <nl> - iteration_proxy_internal & operator = ( const iteration_proxy_internal & ) = default ; <nl> - <nl> - / / / dereference operator ( needed for range - based for ) <nl> - iteration_proxy_internal & operator * ( ) <nl> - { <nl> - return * this ; <nl> - } <nl> - <nl> - / / / increment operator ( needed for range - based for ) <nl> - iteration_proxy_internal & operator + + ( ) <nl> - { <nl> - + + anchor ; <nl> - + + array_index ; <nl> - <nl> - return * this ; <nl> - } <nl> - <nl> - / / / equality operator ( needed for InputIterator ) <nl> - bool operator = = ( const iteration_proxy_internal & o ) const noexcept <nl> - { <nl> - return anchor = = o . anchor ; <nl> - } <nl> - <nl> - / / / inequality operator ( needed for range - based for ) <nl> - bool operator ! = ( const iteration_proxy_internal & o ) const noexcept <nl> - { <nl> - return anchor ! = o . anchor ; <nl> - } <nl> - <nl> - / / / return key of the iterator <nl> - const std : : string & key ( ) const <nl> - { <nl> - assert ( anchor . m_object ! = nullptr ) ; <nl> - <nl> - switch ( anchor . m_object - > type ( ) ) <nl> - { <nl> - / / use integer array index as key <nl> - case value_t : : array : <nl> - { <nl> - if ( array_index ! = array_index_last ) <nl> - { <nl> - array_index_str = std : : to_string ( array_index ) ; <nl> - array_index_last = array_index ; <nl> - } <nl> - return array_index_str ; <nl> - } <nl> - <nl> - / / use key from the object <nl> - case value_t : : object : <nl> - return anchor . key ( ) ; <nl> - <nl> - / / use an empty key for all primitive types <nl> - default : <nl> - return empty_str ; <nl> - } <nl> - } <nl> - <nl> - / / / return value of the iterator <nl> - typename IteratorType : : reference value ( ) const <nl> - { <nl> - return anchor . value ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / / the container to iterate <nl> - typename IteratorType : : reference container ; <nl> - <nl> - public : <nl> - / / / construct iteration proxy from a container <nl> - explicit iteration_proxy ( typename IteratorType : : reference cont ) noexcept <nl> - : container ( cont ) { } <nl> - <nl> - / / / return iterator begin ( needed for range - based for ) <nl> - iteration_proxy_internal begin ( ) noexcept <nl> - { <nl> - return iteration_proxy_internal ( container . begin ( ) ) ; <nl> - } <nl> - <nl> - / / / return iterator end ( needed for range - based for ) <nl> - iteration_proxy_internal end ( ) noexcept <nl> - { <nl> - return iteration_proxy_internal ( container . end ( ) ) ; <nl> - } <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / <nl> - / / constructors / / <nl> - / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < value_t > struct external_constructor ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : boolean > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : boolean_t b ) noexcept <nl> - { <nl> - j . m_type = value_t : : boolean ; <nl> - j . m_value = b ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : string > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , const typename BasicJsonType : : string_t & s ) <nl> - { <nl> - j . m_type = value_t : : string ; <nl> - j . m_value = s ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : string_t & & s ) <nl> - { <nl> - j . m_type = value_t : : string ; <nl> - j . m_value = std : : move ( s ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleStringType , <nl> - enable_if_t < not std : : is_same < CompatibleStringType , typename BasicJsonType : : string_t > : : value , <nl> - int > = 0 > <nl> - static void construct ( BasicJsonType & j , const CompatibleStringType & str ) <nl> - { <nl> - j . m_type = value_t : : string ; <nl> - j . m_value . string = j . template create < typename BasicJsonType : : string_t > ( str ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : number_float > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : number_float_t val ) noexcept <nl> - { <nl> - j . m_type = value_t : : number_float ; <nl> - j . m_value = val ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : number_unsigned > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : number_unsigned_t val ) noexcept <nl> - { <nl> - j . m_type = value_t : : number_unsigned ; <nl> - j . m_value = val ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : number_integer > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : number_integer_t val ) noexcept <nl> - { <nl> - j . m_type = value_t : : number_integer ; <nl> - j . m_value = val ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : array > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , const typename BasicJsonType : : array_t & arr ) <nl> - { <nl> - j . m_type = value_t : : array ; <nl> - j . m_value = arr ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : array_t & & arr ) <nl> - { <nl> - j . m_type = value_t : : array ; <nl> - j . m_value = std : : move ( arr ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleArrayType , <nl> - enable_if_t < not std : : is_same < CompatibleArrayType , typename BasicJsonType : : array_t > : : value , <nl> - int > = 0 > <nl> - static void construct ( BasicJsonType & j , const CompatibleArrayType & arr ) <nl> - { <nl> - using std : : begin ; <nl> - using std : : end ; <nl> - j . m_type = value_t : : array ; <nl> - j . m_value . array = j . template create < typename BasicJsonType : : array_t > ( begin ( arr ) , end ( arr ) ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , const std : : vector < bool > & arr ) <nl> - { <nl> - j . m_type = value_t : : array ; <nl> - j . m_value = value_t : : array ; <nl> - j . m_value . array - > reserve ( arr . size ( ) ) ; <nl> - for ( const bool x : arr ) <nl> - { <nl> - j . m_value . array - > push_back ( x ) ; <nl> - } <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T , <nl> - enable_if_t < std : : is_convertible < T , BasicJsonType > : : value , int > = 0 > <nl> - static void construct ( BasicJsonType & j , const std : : valarray < T > & arr ) <nl> - { <nl> - j . m_type = value_t : : array ; <nl> - j . m_value = value_t : : array ; <nl> - j . m_value . array - > resize ( arr . size ( ) ) ; <nl> - std : : copy ( std : : begin ( arr ) , std : : end ( arr ) , j . m_value . array - > begin ( ) ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct external_constructor < value_t : : object > <nl> - { <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , const typename BasicJsonType : : object_t & obj ) <nl> - { <nl> - j . m_type = value_t : : object ; <nl> - j . m_value = obj ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - static void construct ( BasicJsonType & j , typename BasicJsonType : : object_t & & obj ) <nl> - { <nl> - j . m_type = value_t : : object ; <nl> - j . m_value = std : : move ( obj ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleObjectType , <nl> - enable_if_t < not std : : is_same < CompatibleObjectType , typename BasicJsonType : : object_t > : : value , int > = 0 > <nl> - static void construct ( BasicJsonType & j , const CompatibleObjectType & obj ) <nl> - { <nl> - using std : : begin ; <nl> - using std : : end ; <nl> - <nl> - j . m_type = value_t : : object ; <nl> - j . m_value . object = j . template create < typename BasicJsonType : : object_t > ( begin ( obj ) , end ( obj ) ) ; <nl> - j . assert_invariant ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / / / / / / / / / / / / <nl> - / / to_json / / <nl> - / / / / / / / / / / / / / <nl> - <nl> - template < typename BasicJsonType , typename T , <nl> - enable_if_t < std : : is_same < T , typename BasicJsonType : : boolean_t > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , T b ) noexcept <nl> - { <nl> - external_constructor < value_t : : boolean > : : construct ( j , b ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleString , <nl> - enable_if_t < std : : is_constructible < typename BasicJsonType : : string_t , CompatibleString > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , const CompatibleString & s ) <nl> - { <nl> - external_constructor < value_t : : string > : : construct ( j , s ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void to_json ( BasicJsonType & j , typename BasicJsonType : : string_t & & s ) <nl> - { <nl> - external_constructor < value_t : : string > : : construct ( j , std : : move ( s ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename FloatType , <nl> - enable_if_t < std : : is_floating_point < FloatType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , FloatType val ) noexcept <nl> - { <nl> - external_constructor < value_t : : number_float > : : construct ( j , static_cast < typename BasicJsonType : : number_float_t > ( val ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleNumberUnsignedType , <nl> - enable_if_t < is_compatible_integer_type < typename BasicJsonType : : number_unsigned_t , CompatibleNumberUnsignedType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , CompatibleNumberUnsignedType val ) noexcept <nl> - { <nl> - external_constructor < value_t : : number_unsigned > : : construct ( j , static_cast < typename BasicJsonType : : number_unsigned_t > ( val ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleNumberIntegerType , <nl> - enable_if_t < is_compatible_integer_type < typename BasicJsonType : : number_integer_t , CompatibleNumberIntegerType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , CompatibleNumberIntegerType val ) noexcept <nl> - { <nl> - external_constructor < value_t : : number_integer > : : construct ( j , static_cast < typename BasicJsonType : : number_integer_t > ( val ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename EnumType , <nl> - enable_if_t < std : : is_enum < EnumType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , EnumType e ) noexcept <nl> - { <nl> - using underlying_type = typename std : : underlying_type < EnumType > : : type ; <nl> - external_constructor < value_t : : number_integer > : : construct ( j , static_cast < underlying_type > ( e ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void to_json ( BasicJsonType & j , const std : : vector < bool > & e ) <nl> - { <nl> - external_constructor < value_t : : array > : : construct ( j , e ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleArrayType , <nl> - enable_if_t < is_compatible_array_type < BasicJsonType , CompatibleArrayType > : : value or <nl> - std : : is_same < typename BasicJsonType : : array_t , CompatibleArrayType > : : value , <nl> - int > = 0 > <nl> - void to_json ( BasicJsonType & j , const CompatibleArrayType & arr ) <nl> - { <nl> - external_constructor < value_t : : array > : : construct ( j , arr ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T , <nl> - enable_if_t < std : : is_convertible < T , BasicJsonType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , const std : : valarray < T > & arr ) <nl> - { <nl> - external_constructor < value_t : : array > : : construct ( j , std : : move ( arr ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void to_json ( BasicJsonType & j , typename BasicJsonType : : array_t & & arr ) <nl> - { <nl> - external_constructor < value_t : : array > : : construct ( j , std : : move ( arr ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename CompatibleObjectType , <nl> - enable_if_t < is_compatible_object_type < BasicJsonType , CompatibleObjectType > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , const CompatibleObjectType & obj ) <nl> - { <nl> - external_constructor < value_t : : object > : : construct ( j , obj ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType > <nl> - void to_json ( BasicJsonType & j , typename BasicJsonType : : object_t & & obj ) <nl> - { <nl> - external_constructor < value_t : : object > : : construct ( j , std : : move ( obj ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T , std : : size_t N , <nl> - enable_if_t < not std : : is_constructible < typename BasicJsonType : : string_t , T ( & ) [ N ] > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , T ( & arr ) [ N ] ) <nl> - { <nl> - external_constructor < value_t : : array > : : construct ( j , arr ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename . . . Args > <nl> - void to_json ( BasicJsonType & j , const std : : pair < Args . . . > & p ) <nl> - { <nl> - j = { p . first , p . second } ; <nl> - } <nl> - <nl> - / / for https : / / github . com / nlohmann / json / pull / 1134 <nl> - template < typename BasicJsonType , typename T , <nl> - enable_if_t < std : : is_same < T , typename iteration_proxy < typename BasicJsonType : : iterator > : : iteration_proxy_internal > : : value , int > = 0 > <nl> - void to_json ( BasicJsonType & j , T b ) noexcept <nl> - { <nl> - j = { { b . key ( ) , b . value ( ) } } ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename Tuple , std : : size_t . . . Idx > <nl> - void to_json_tuple_impl ( BasicJsonType & j , const Tuple & t , index_sequence < Idx . . . > ) <nl> - { <nl> - j = { std : : get < Idx > ( t ) . . . } ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename . . . Args > <nl> - void to_json ( BasicJsonType & j , const std : : tuple < Args . . . > & t ) <nl> - { <nl> - to_json_tuple_impl ( j , t , index_sequence_for < Args . . . > { } ) ; <nl> - } <nl> - <nl> - struct to_json_fn <nl> - { <nl> - private : <nl> - template < typename BasicJsonType , typename T > <nl> - auto call ( BasicJsonType & j , T & & val , priority_tag < 1 > / * unused * / ) const noexcept ( noexcept ( to_json ( j , std : : forward < T > ( val ) ) ) ) <nl> - - > decltype ( to_json ( j , std : : forward < T > ( val ) ) , void ( ) ) <nl> - { <nl> - return to_json ( j , std : : forward < T > ( val ) ) ; <nl> - } <nl> - <nl> - template < typename BasicJsonType , typename T > <nl> - void call ( BasicJsonType & / * unused * / , T & & / * unused * / , priority_tag < 0 > / * unused * / ) const noexcept <nl> - { <nl> - static_assert ( sizeof ( BasicJsonType ) = = 0 , <nl> - " could not find to_json ( ) method in T ' s namespace " ) ; <nl> - <nl> - # ifdef _MSC_VER <nl> - / / MSVC does not show a stacktrace for the above assert <nl> - using decayed = uncvref_t < T > ; <nl> - static_assert ( sizeof ( typename decayed : : force_msvc_stacktrace ) = = 0 , <nl> - " forcing MSVC stacktrace to show which T we ' re talking about . " ) ; <nl> - # endif <nl> - } <nl> - <nl> - public : <nl> - template < typename BasicJsonType , typename T > <nl> - void operator ( ) ( BasicJsonType & j , T & & val ) const <nl> - noexcept ( noexcept ( std : : declval < to_json_fn > ( ) . call ( j , std : : forward < T > ( val ) , priority_tag < 1 > { } ) ) ) <nl> - { <nl> - return call ( j , std : : forward < T > ( val ) , priority_tag < 1 > { } ) ; <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - / / / namespace to hold default ` to_json ` function <nl> - namespace <nl> - { <nl> - constexpr const auto & to_json = detail : : static_const < detail : : to_json_fn > : : value ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / input_adapters . hpp > <nl> - <nl> - <nl> - # include < cassert > / / assert <nl> - # include < cstddef > / / size_t <nl> - # include < cstring > / / strlen <nl> - # include < istream > / / istream <nl> - # include < iterator > / / begin , end , iterator_traits , random_access_iterator_tag , distance , next <nl> - # include < memory > / / shared_ptr , make_shared , addressof <nl> - # include < numeric > / / accumulate <nl> - # include < string > / / string , char_traits <nl> - # include < type_traits > / / enable_if , is_base_of , is_pointer , is_integral , remove_pointer <nl> - # include < utility > / / pair , declval <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / the supported input formats <nl> - enum class input_format_t { json , cbor , msgpack , ubjson } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / <nl> - / / input adapters / / <nl> - / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief abstract input adapter interface <nl> - <nl> - Produces a stream of std : : char_traits < char > : : int_type characters from a <nl> - std : : istream , a buffer , or some other input type . Accepts the return of <nl> - exactly one non - EOF character for future input . The int_type characters <nl> - returned consist of all valid char values as positive values ( typically <nl> - unsigned char ) , plus an EOF value outside that range , specified by the value <nl> - of the function std : : char_traits < char > : : eof ( ) . This value is typically - 1 , but <nl> - could be any arbitrary value which is not a valid char value . <nl> - * / <nl> - struct input_adapter_protocol <nl> - { <nl> - / / / get a character [ 0 , 255 ] or std : : char_traits < char > : : eof ( ) . <nl> - virtual std : : char_traits < char > : : int_type get_character ( ) = 0 ; <nl> - virtual ~ input_adapter_protocol ( ) = default ; <nl> - } ; <nl> - <nl> - / / / a type to simplify interfaces <nl> - using input_adapter_t = std : : shared_ptr < input_adapter_protocol > ; <nl> - <nl> - / * ! <nl> - Input adapter for a ( caching ) istream . Ignores a UFT Byte Order Mark at <nl> - beginning of input . Does not support changing the underlying std : : streambuf <nl> - in mid - input . Maintains underlying std : : istream and std : : streambuf to support <nl> - subsequent use of standard std : : istream operations to process any input <nl> - characters following those used in parsing the JSON input . Clears the <nl> - std : : istream flags ; any input errors ( e . g . , EOF ) will be detected by the first <nl> - subsequent call for input from the std : : istream . <nl> - * / <nl> - class input_stream_adapter : public input_adapter_protocol <nl> - { <nl> - public : <nl> - ~ input_stream_adapter ( ) override <nl> - { <nl> - / / clear stream flags ; we use underlying streambuf I / O , do not <nl> - / / maintain ifstream flags <nl> - is . clear ( ) ; <nl> - } <nl> - <nl> - explicit input_stream_adapter ( std : : istream & i ) <nl> - : is ( i ) , sb ( * i . rdbuf ( ) ) <nl> - { } <nl> - <nl> - / / delete because of pointer members <nl> - input_stream_adapter ( const input_stream_adapter & ) = delete ; <nl> - input_stream_adapter & operator = ( input_stream_adapter & ) = delete ; <nl> - <nl> - / / std : : istream / std : : streambuf use std : : char_traits < char > : : to_int_type , to <nl> - / / ensure that std : : char_traits < char > : : eof ( ) and the character 0xFF do not <nl> - / / end up as the same value , eg . 0xFFFFFFFF . <nl> - std : : char_traits < char > : : int_type get_character ( ) override <nl> - { <nl> - return sb . sbumpc ( ) ; <nl> - } <nl> - <nl> - private : <nl> - / / / the associated input stream <nl> - std : : istream & is ; <nl> - std : : streambuf & sb ; <nl> - } ; <nl> - <nl> - / / / input adapter for buffer input <nl> - class input_buffer_adapter : public input_adapter_protocol <nl> - { <nl> - public : <nl> - input_buffer_adapter ( const char * b , const std : : size_t l ) <nl> - : cursor ( b ) , limit ( b + l ) <nl> - { } <nl> - <nl> - / / delete because of pointer members <nl> - input_buffer_adapter ( const input_buffer_adapter & ) = delete ; <nl> - input_buffer_adapter & operator = ( input_buffer_adapter & ) = delete ; <nl> - <nl> - std : : char_traits < char > : : int_type get_character ( ) noexcept override <nl> - { <nl> - if ( JSON_LIKELY ( cursor < limit ) ) <nl> - { <nl> - return std : : char_traits < char > : : to_int_type ( * ( cursor + + ) ) ; <nl> - } <nl> - <nl> - return std : : char_traits < char > : : eof ( ) ; <nl> - } <nl> - <nl> - private : <nl> - / / / pointer to the current character <nl> - const char * cursor ; <nl> - / / / pointer past the last character <nl> - const char * const limit ; <nl> - } ; <nl> - <nl> - template < typename WideStringType > <nl> - class wide_string_input_adapter : public input_adapter_protocol <nl> - { <nl> - public : <nl> - explicit wide_string_input_adapter ( const WideStringType & w ) : str ( w ) { } <nl> - <nl> - std : : char_traits < char > : : int_type get_character ( ) noexcept override <nl> - { <nl> - / / check if buffer needs to be filled <nl> - if ( utf8_bytes_index = = utf8_bytes_filled ) <nl> - { <nl> - if ( sizeof ( typename WideStringType : : value_type ) = = 2 ) <nl> - { <nl> - fill_buffer_utf16 ( ) ; <nl> - } <nl> - else <nl> - { <nl> - fill_buffer_utf32 ( ) ; <nl> - } <nl> - <nl> - assert ( utf8_bytes_filled > 0 ) ; <nl> - assert ( utf8_bytes_index = = 0 ) ; <nl> - } <nl> - <nl> - / / use buffer <nl> - assert ( utf8_bytes_filled > 0 ) ; <nl> - assert ( utf8_bytes_index < utf8_bytes_filled ) ; <nl> - return utf8_bytes [ utf8_bytes_index + + ] ; <nl> - } <nl> - <nl> - private : <nl> - void fill_buffer_utf16 ( ) <nl> - { <nl> - utf8_bytes_index = 0 ; <nl> - <nl> - if ( current_wchar = = str . size ( ) ) <nl> - { <nl> - utf8_bytes [ 0 ] = std : : char_traits < char > : : eof ( ) ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - else <nl> - { <nl> - / / get the current character <nl> - const int wc = static_cast < int > ( str [ current_wchar + + ] ) ; <nl> - <nl> - / / UTF - 16 to UTF - 8 encoding <nl> - if ( wc < 0x80 ) <nl> - { <nl> - utf8_bytes [ 0 ] = wc ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - else if ( wc < = 0x7FF ) <nl> - { <nl> - utf8_bytes [ 0 ] = 0xC0 | ( ( wc > > 6 ) ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( wc & 0x3F ) ; <nl> - utf8_bytes_filled = 2 ; <nl> - } <nl> - else if ( 0xD800 > wc or wc > = 0xE000 ) <nl> - { <nl> - utf8_bytes [ 0 ] = 0xE0 | ( ( wc > > 12 ) ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( ( wc > > 6 ) & 0x3F ) ; <nl> - utf8_bytes [ 2 ] = 0x80 | ( wc & 0x3F ) ; <nl> - utf8_bytes_filled = 3 ; <nl> - } <nl> - else <nl> - { <nl> - if ( current_wchar < str . size ( ) ) <nl> - { <nl> - const int wc2 = static_cast < int > ( str [ current_wchar + + ] ) ; <nl> - const int charcode = 0x10000 + ( ( ( wc & 0x3FF ) < < 10 ) | ( wc2 & 0x3FF ) ) ; <nl> - utf8_bytes [ 0 ] = 0xf0 | ( charcode > > 18 ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( ( charcode > > 12 ) & 0x3F ) ; <nl> - utf8_bytes [ 2 ] = 0x80 | ( ( charcode > > 6 ) & 0x3F ) ; <nl> - utf8_bytes [ 3 ] = 0x80 | ( charcode & 0x3F ) ; <nl> - utf8_bytes_filled = 4 ; <nl> - } <nl> - else <nl> - { <nl> - / / unknown character <nl> - + + current_wchar ; <nl> - utf8_bytes [ 0 ] = wc ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void fill_buffer_utf32 ( ) <nl> - { <nl> - utf8_bytes_index = 0 ; <nl> - <nl> - if ( current_wchar = = str . size ( ) ) <nl> - { <nl> - utf8_bytes [ 0 ] = std : : char_traits < char > : : eof ( ) ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - else <nl> - { <nl> - / / get the current character <nl> - const int wc = static_cast < int > ( str [ current_wchar + + ] ) ; <nl> - <nl> - / / UTF - 32 to UTF - 8 encoding <nl> - if ( wc < 0x80 ) <nl> - { <nl> - utf8_bytes [ 0 ] = wc ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - else if ( wc < = 0x7FF ) <nl> - { <nl> - utf8_bytes [ 0 ] = 0xC0 | ( ( wc > > 6 ) & 0x1F ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( wc & 0x3F ) ; <nl> - utf8_bytes_filled = 2 ; <nl> - } <nl> - else if ( wc < = 0xFFFF ) <nl> - { <nl> - utf8_bytes [ 0 ] = 0xE0 | ( ( wc > > 12 ) & 0x0F ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( ( wc > > 6 ) & 0x3F ) ; <nl> - utf8_bytes [ 2 ] = 0x80 | ( wc & 0x3F ) ; <nl> - utf8_bytes_filled = 3 ; <nl> - } <nl> - else if ( wc < = 0x10FFFF ) <nl> - { <nl> - utf8_bytes [ 0 ] = 0xF0 | ( ( wc > > 18 ) & 0x07 ) ; <nl> - utf8_bytes [ 1 ] = 0x80 | ( ( wc > > 12 ) & 0x3F ) ; <nl> - utf8_bytes [ 2 ] = 0x80 | ( ( wc > > 6 ) & 0x3F ) ; <nl> - utf8_bytes [ 3 ] = 0x80 | ( wc & 0x3F ) ; <nl> - utf8_bytes_filled = 4 ; <nl> - } <nl> - else <nl> - { <nl> - / / unknown character <nl> - utf8_bytes [ 0 ] = wc ; <nl> - utf8_bytes_filled = 1 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - private : <nl> - / / / the wstring to process <nl> - const WideStringType & str ; <nl> - <nl> - / / / index of the current wchar in str <nl> - std : : size_t current_wchar = 0 ; <nl> - <nl> - / / / a buffer for UTF - 8 bytes <nl> - std : : array < std : : char_traits < char > : : int_type , 4 > utf8_bytes = { { 0 , 0 , 0 , 0 } } ; <nl> - <nl> - / / / index to the utf8_codes array for the next valid byte <nl> - std : : size_t utf8_bytes_index = 0 ; <nl> - / / / number of valid bytes in the utf8_codes array <nl> - std : : size_t utf8_bytes_filled = 0 ; <nl> - } ; <nl> - <nl> - class input_adapter <nl> - { <nl> - public : <nl> - / / native support <nl> - <nl> - / / / input adapter for input stream <nl> - input_adapter ( std : : istream & i ) <nl> - : ia ( std : : make_shared < input_stream_adapter > ( i ) ) { } <nl> - <nl> - / / / input adapter for input stream <nl> - input_adapter ( std : : istream & & i ) <nl> - : ia ( std : : make_shared < input_stream_adapter > ( i ) ) { } <nl> - <nl> - input_adapter ( const std : : wstring & ws ) <nl> - : ia ( std : : make_shared < wide_string_input_adapter < std : : wstring > > ( ws ) ) { } <nl> - <nl> - input_adapter ( const std : : u16string & ws ) <nl> - : ia ( std : : make_shared < wide_string_input_adapter < std : : u16string > > ( ws ) ) { } <nl> - <nl> - input_adapter ( const std : : u32string & ws ) <nl> - : ia ( std : : make_shared < wide_string_input_adapter < std : : u32string > > ( ws ) ) { } <nl> - <nl> - / / / input adapter for buffer <nl> - template < typename CharT , <nl> - typename std : : enable_if < <nl> - std : : is_pointer < CharT > : : value and <nl> - std : : is_integral < typename std : : remove_pointer < CharT > : : type > : : value and <nl> - sizeof ( typename std : : remove_pointer < CharT > : : type ) = = 1 , <nl> - int > : : type = 0 > <nl> - input_adapter ( CharT b , std : : size_t l ) <nl> - : ia ( std : : make_shared < input_buffer_adapter > ( reinterpret_cast < const char * > ( b ) , l ) ) { } <nl> - <nl> - / / derived support <nl> - <nl> - / / / input adapter for string literal <nl> - template < typename CharT , <nl> - typename std : : enable_if < <nl> - std : : is_pointer < CharT > : : value and <nl> - std : : is_integral < typename std : : remove_pointer < CharT > : : type > : : value and <nl> - sizeof ( typename std : : remove_pointer < CharT > : : type ) = = 1 , <nl> - int > : : type = 0 > <nl> - input_adapter ( CharT b ) <nl> - : input_adapter ( reinterpret_cast < const char * > ( b ) , <nl> - std : : strlen ( reinterpret_cast < const char * > ( b ) ) ) { } <nl> - <nl> - / / / input adapter for iterator range with contiguous storage <nl> - template < class IteratorType , <nl> - typename std : : enable_if < <nl> - std : : is_same < typename std : : iterator_traits < IteratorType > : : iterator_category , std : : random_access_iterator_tag > : : value , <nl> - int > : : type = 0 > <nl> - input_adapter ( IteratorType first , IteratorType last ) <nl> - { <nl> - / / assertion to check that the iterator range is indeed contiguous , <nl> - / / see http : / / stackoverflow . com / a / 35008842 / 266378 for more discussion <nl> - assert ( std : : accumulate ( <nl> - first , last , std : : pair < bool , int > ( true , 0 ) , <nl> - [ & first ] ( std : : pair < bool , int > res , decltype ( * first ) val ) <nl> - { <nl> - res . first & = ( val = = * ( std : : next ( std : : addressof ( * first ) , res . second + + ) ) ) ; <nl> - return res ; <nl> - } ) . first ) ; <nl> - <nl> - / / assertion to check that each element is 1 byte long <nl> - static_assert ( <nl> - sizeof ( typename std : : iterator_traits < IteratorType > : : value_type ) = = 1 , <nl> - " each element in the iterator range must have the size of 1 byte " ) ; <nl> - <nl> - const auto len = static_cast < size_t > ( std : : distance ( first , last ) ) ; <nl> - if ( JSON_LIKELY ( len > 0 ) ) <nl> - { <nl> - / / there is at least one element : use the address of first <nl> - ia = std : : make_shared < input_buffer_adapter > ( reinterpret_cast < const char * > ( & ( * first ) ) , len ) ; <nl> - } <nl> - else <nl> - { <nl> - / / the address of first cannot be used : use nullptr <nl> - ia = std : : make_shared < input_buffer_adapter > ( nullptr , len ) ; <nl> - } <nl> - } <nl> - <nl> - / / / input adapter for array <nl> - template < class T , std : : size_t N > <nl> - input_adapter ( T ( & array ) [ N ] ) <nl> - : input_adapter ( std : : begin ( array ) , std : : end ( array ) ) { } <nl> - <nl> - / / / input adapter for contiguous container <nl> - template < class ContiguousContainer , typename <nl> - std : : enable_if < not std : : is_pointer < ContiguousContainer > : : value and <nl> - std : : is_base_of < std : : random_access_iterator_tag , typename std : : iterator_traits < decltype ( std : : begin ( std : : declval < ContiguousContainer const > ( ) ) ) > : : iterator_category > : : value , <nl> - int > : : type = 0 > <nl> - input_adapter ( const ContiguousContainer & c ) <nl> - : input_adapter ( std : : begin ( c ) , std : : end ( c ) ) { } <nl> - <nl> - operator input_adapter_t ( ) <nl> - { <nl> - return ia ; <nl> - } <nl> - <nl> - private : <nl> - / / / the actual adapter <nl> - input_adapter_t ia = nullptr ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / lexer . hpp > <nl> - <nl> - <nl> - # include < clocale > / / localeconv <nl> - # include < cstddef > / / size_t <nl> - # include < cstdlib > / / strtof , strtod , strtold , strtoll , strtoull <nl> - # include < cstdio > / / snprintf <nl> - # include < initializer_list > / / initializer_list <nl> - # include < string > / / char_traits , string <nl> - # include < vector > / / vector <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / input / input_adapters . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / <nl> - / / lexer / / <nl> - / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief lexical analysis <nl> - <nl> - This class organizes the lexical analysis during JSON deserialization . <nl> - * / <nl> - template < typename BasicJsonType > <nl> - class lexer <nl> - { <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - <nl> - public : <nl> - / / / token types for the parser <nl> - enum class token_type <nl> - { <nl> - uninitialized , / / / < indicating the scanner is uninitialized <nl> - literal_true , / / / < the ` true ` literal <nl> - literal_false , / / / < the ` false ` literal <nl> - literal_null , / / / < the ` null ` literal <nl> - value_string , / / / < a string - - use get_string ( ) for actual value <nl> - value_unsigned , / / / < an unsigned integer - - use get_number_unsigned ( ) for actual value <nl> - value_integer , / / / < a signed integer - - use get_number_integer ( ) for actual value <nl> - value_float , / / / < an floating point number - - use get_number_float ( ) for actual value <nl> - begin_array , / / / < the character for array begin ` [ ` <nl> - begin_object , / / / < the character for object begin ` { ` <nl> - end_array , / / / < the character for array end ` ] ` <nl> - end_object , / / / < the character for object end ` } ` <nl> - name_separator , / / / < the name separator ` : ` <nl> - value_separator , / / / < the value separator ` , ` <nl> - parse_error , / / / < indicating a parse error <nl> - end_of_input , / / / < indicating the end of the input buffer <nl> - literal_or_value / / / < a literal or the begin of a value ( only for diagnostics ) <nl> - } ; <nl> - <nl> - / / / return name of values of type token_type ( only used for errors ) <nl> - static const char * token_type_name ( const token_type t ) noexcept <nl> - { <nl> - switch ( t ) <nl> - { <nl> - case token_type : : uninitialized : <nl> - return " < uninitialized > " ; <nl> - case token_type : : literal_true : <nl> - return " true literal " ; <nl> - case token_type : : literal_false : <nl> - return " false literal " ; <nl> - case token_type : : literal_null : <nl> - return " null literal " ; <nl> - case token_type : : value_string : <nl> - return " string literal " ; <nl> - case lexer : : token_type : : value_unsigned : <nl> - case lexer : : token_type : : value_integer : <nl> - case lexer : : token_type : : value_float : <nl> - return " number literal " ; <nl> - case token_type : : begin_array : <nl> - return " ' [ ' " ; <nl> - case token_type : : begin_object : <nl> - return " ' { ' " ; <nl> - case token_type : : end_array : <nl> - return " ' ] ' " ; <nl> - case token_type : : end_object : <nl> - return " ' } ' " ; <nl> - case token_type : : name_separator : <nl> - return " ' : ' " ; <nl> - case token_type : : value_separator : <nl> - return " ' , ' " ; <nl> - case token_type : : parse_error : <nl> - return " < parse error > " ; <nl> - case token_type : : end_of_input : <nl> - return " end of input " ; <nl> - case token_type : : literal_or_value : <nl> - return " ' [ ' , ' { ' , or a literal " ; <nl> - default : / / catch non - enum values <nl> - return " unknown token " ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - <nl> - explicit lexer ( detail : : input_adapter_t & & adapter ) <nl> - : ia ( std : : move ( adapter ) ) , decimal_point_char ( get_decimal_point ( ) ) { } <nl> - <nl> - / / delete because of pointer members <nl> - lexer ( const lexer & ) = delete ; <nl> - lexer & operator = ( lexer & ) = delete ; <nl> - <nl> - private : <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / locales <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / return the locale - dependent decimal point <nl> - static char get_decimal_point ( ) noexcept <nl> - { <nl> - const auto loc = localeconv ( ) ; <nl> - assert ( loc ! = nullptr ) ; <nl> - return ( loc - > decimal_point = = nullptr ) ? ' . ' : * ( loc - > decimal_point ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / scan functions <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief get codepoint from 4 hex characters following ` \ u ` <nl> - <nl> - For input " \ u c1 c2 c3 c4 " the codepoint is : <nl> - ( c1 * 0x1000 ) + ( c2 * 0x0100 ) + ( c3 * 0x0010 ) + c4 <nl> - = ( c1 < < 12 ) + ( c2 < < 8 ) + ( c3 < < 4 ) + ( c4 < < 0 ) <nl> - <nl> - Furthermore , the possible characters ' 0 ' . . ' 9 ' , ' A ' . . ' F ' , and ' a ' . . ' f ' <nl> - must be converted to the integers 0x0 . . 0x9 , 0xA . . 0xF , 0xA . . 0xF , resp . The <nl> - conversion is done by subtracting the offset ( 0x30 , 0x37 , and 0x57 ) <nl> - between the ASCII value of the character and the desired integer value . <nl> - <nl> - @ return codepoint ( 0x0000 . . 0xFFFF ) or - 1 in case of an error ( e . g . EOF or <nl> - non - hex character ) <nl> - * / <nl> - int get_codepoint ( ) <nl> - { <nl> - / / this function only makes sense after reading ` \ u ` <nl> - assert ( current = = ' u ' ) ; <nl> - int codepoint = 0 ; <nl> - <nl> - const auto factors = { 12 , 8 , 4 , 0 } ; <nl> - for ( const auto factor : factors ) <nl> - { <nl> - get ( ) ; <nl> - <nl> - if ( current > = ' 0 ' and current < = ' 9 ' ) <nl> - { <nl> - codepoint + = ( ( current - 0x30 ) < < factor ) ; <nl> - } <nl> - else if ( current > = ' A ' and current < = ' F ' ) <nl> - { <nl> - codepoint + = ( ( current - 0x37 ) < < factor ) ; <nl> - } <nl> - else if ( current > = ' a ' and current < = ' f ' ) <nl> - { <nl> - codepoint + = ( ( current - 0x57 ) < < factor ) ; <nl> - } <nl> - else <nl> - { <nl> - return - 1 ; <nl> - } <nl> - } <nl> - <nl> - assert ( 0x0000 < = codepoint and codepoint < = 0xFFFF ) ; <nl> - return codepoint ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief check if the next byte ( s ) are inside a given range <nl> - <nl> - Adds the current byte and , for each passed range , reads a new byte and <nl> - checks if it is inside the range . If a violation was detected , set up an <nl> - error message and return false . Otherwise , return true . <nl> - <nl> - @ param [ in ] ranges list of integers ; interpreted as list of pairs of <nl> - inclusive lower and upper bound , respectively <nl> - <nl> - @ pre The passed list @ a ranges must have 2 , 4 , or 6 elements ; that is , <nl> - 1 , 2 , or 3 pairs . This precondition is enforced by an assertion . <nl> - <nl> - @ return true if and only if no range violation was detected <nl> - * / <nl> - bool next_byte_in_range ( std : : initializer_list < int > ranges ) <nl> - { <nl> - assert ( ranges . size ( ) = = 2 or ranges . size ( ) = = 4 or ranges . size ( ) = = 6 ) ; <nl> - add ( current ) ; <nl> - <nl> - for ( auto range = ranges . begin ( ) ; range ! = ranges . end ( ) ; + + range ) <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_LIKELY ( * range < = current and current < = * ( + + range ) ) ) <nl> - { <nl> - add ( current ) ; <nl> - } <nl> - else <nl> - { <nl> - error_message = " invalid string : ill - formed UTF - 8 byte " ; <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief scan a string literal <nl> - <nl> - This function scans a string according to Sect . 7 of RFC 7159 . While <nl> - scanning , bytes are escaped and copied into buffer token_buffer . Then the <nl> - function returns successfully , token_buffer is * not * null - terminated ( as it <nl> - may contain \ 0 bytes ) , and token_buffer . size ( ) is the number of bytes in the <nl> - string . <nl> - <nl> - @ return token_type : : value_string if string could be successfully scanned , <nl> - token_type : : parse_error otherwise <nl> - <nl> - @ note In case of errors , variable error_message contains a textual <nl> - description . <nl> - * / <nl> - token_type scan_string ( ) <nl> - { <nl> - / / reset token_buffer ( ignore opening quote ) <nl> - reset ( ) ; <nl> - <nl> - / / we entered the function by reading an open quote <nl> - assert ( current = = ' \ " ' ) ; <nl> - <nl> - while ( true ) <nl> - { <nl> - / / get next character <nl> - switch ( get ( ) ) <nl> - { <nl> - / / end of file while parsing string <nl> - case std : : char_traits < char > : : eof ( ) : <nl> - { <nl> - error_message = " invalid string : missing closing quote " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - / / closing quote <nl> - case ' \ " ' : <nl> - { <nl> - return token_type : : value_string ; <nl> - } <nl> - <nl> - / / escapes <nl> - case ' \ \ ' : <nl> - { <nl> - switch ( get ( ) ) <nl> - { <nl> - / / quotation mark <nl> - case ' \ " ' : <nl> - add ( ' \ " ' ) ; <nl> - break ; <nl> - / / reverse solidus <nl> - case ' \ \ ' : <nl> - add ( ' \ \ ' ) ; <nl> - break ; <nl> - / / solidus <nl> - case ' / ' : <nl> - add ( ' / ' ) ; <nl> - break ; <nl> - / / backspace <nl> - case ' b ' : <nl> - add ( ' \ b ' ) ; <nl> - break ; <nl> - / / form feed <nl> - case ' f ' : <nl> - add ( ' \ f ' ) ; <nl> - break ; <nl> - / / line feed <nl> - case ' n ' : <nl> - add ( ' \ n ' ) ; <nl> - break ; <nl> - / / carriage return <nl> - case ' r ' : <nl> - add ( ' \ r ' ) ; <nl> - break ; <nl> - / / tab <nl> - case ' t ' : <nl> - add ( ' \ t ' ) ; <nl> - break ; <nl> - <nl> - / / unicode escapes <nl> - case ' u ' : <nl> - { <nl> - const int codepoint1 = get_codepoint ( ) ; <nl> - int codepoint = codepoint1 ; / / start with codepoint1 <nl> - <nl> - if ( JSON_UNLIKELY ( codepoint1 = = - 1 ) ) <nl> - { <nl> - error_message = " invalid string : ' \ \ u ' must be followed by 4 hex digits " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - / / check if code point is a high surrogate <nl> - if ( 0xD800 < = codepoint1 and codepoint1 < = 0xDBFF ) <nl> - { <nl> - / / expect next \ uxxxx entry <nl> - if ( JSON_LIKELY ( get ( ) = = ' \ \ ' and get ( ) = = ' u ' ) ) <nl> - { <nl> - const int codepoint2 = get_codepoint ( ) ; <nl> - <nl> - if ( JSON_UNLIKELY ( codepoint2 = = - 1 ) ) <nl> - { <nl> - error_message = " invalid string : ' \ \ u ' must be followed by 4 hex digits " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - / / check if codepoint2 is a low surrogate <nl> - if ( JSON_LIKELY ( 0xDC00 < = codepoint2 and codepoint2 < = 0xDFFF ) ) <nl> - { <nl> - / / overwrite codepoint <nl> - codepoint = <nl> - / / high surrogate occupies the most significant 22 bits <nl> - ( codepoint1 < < 10 ) <nl> - / / low surrogate occupies the least significant 15 bits <nl> - + codepoint2 <nl> - / / there is still the 0xD800 , 0xDC00 and 0x10000 noise <nl> - / / in the result so we have to subtract with : <nl> - / / ( 0xD800 < < 10 ) + DC00 - 0x10000 = 0x35FDC00 <nl> - - 0x35FDC00 ; <nl> - } <nl> - else <nl> - { <nl> - error_message = " invalid string : surrogate U + DC00 . . U + DFFF must be followed by U + DC00 . . U + DFFF " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - error_message = " invalid string : surrogate U + DC00 . . U + DFFF must be followed by U + DC00 . . U + DFFF " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( 0xDC00 < = codepoint1 and codepoint1 < = 0xDFFF ) ) <nl> - { <nl> - error_message = " invalid string : surrogate U + DC00 . . U + DFFF must follow U + D800 . . U + DBFF " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - / / result of the above calculation yields a proper codepoint <nl> - assert ( 0x00 < = codepoint and codepoint < = 0x10FFFF ) ; <nl> - <nl> - / / translate codepoint into bytes <nl> - if ( codepoint < 0x80 ) <nl> - { <nl> - / / 1 - byte characters : 0xxxxxxx ( ASCII ) <nl> - add ( codepoint ) ; <nl> - } <nl> - else if ( codepoint < = 0x7FF ) <nl> - { <nl> - / / 2 - byte characters : 110xxxxx 10xxxxxx <nl> - add ( 0xC0 | ( codepoint > > 6 ) ) ; <nl> - add ( 0x80 | ( codepoint & 0x3F ) ) ; <nl> - } <nl> - else if ( codepoint < = 0xFFFF ) <nl> - { <nl> - / / 3 - byte characters : 1110xxxx 10xxxxxx 10xxxxxx <nl> - add ( 0xE0 | ( codepoint > > 12 ) ) ; <nl> - add ( 0x80 | ( ( codepoint > > 6 ) & 0x3F ) ) ; <nl> - add ( 0x80 | ( codepoint & 0x3F ) ) ; <nl> - } <nl> - else <nl> - { <nl> - / / 4 - byte characters : 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx <nl> - add ( 0xF0 | ( codepoint > > 18 ) ) ; <nl> - add ( 0x80 | ( ( codepoint > > 12 ) & 0x3F ) ) ; <nl> - add ( 0x80 | ( ( codepoint > > 6 ) & 0x3F ) ) ; <nl> - add ( 0x80 | ( codepoint & 0x3F ) ) ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - / / other characters after escape <nl> - default : <nl> - error_message = " invalid string : forbidden character after backslash " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - / / invalid control characters <nl> - case 0x00 : <nl> - case 0x01 : <nl> - case 0x02 : <nl> - case 0x03 : <nl> - case 0x04 : <nl> - case 0x05 : <nl> - case 0x06 : <nl> - case 0x07 : <nl> - case 0x08 : <nl> - case 0x09 : <nl> - case 0x0A : <nl> - case 0x0B : <nl> - case 0x0C : <nl> - case 0x0D : <nl> - case 0x0E : <nl> - case 0x0F : <nl> - case 0x10 : <nl> - case 0x11 : <nl> - case 0x12 : <nl> - case 0x13 : <nl> - case 0x14 : <nl> - case 0x15 : <nl> - case 0x16 : <nl> - case 0x17 : <nl> - case 0x18 : <nl> - case 0x19 : <nl> - case 0x1A : <nl> - case 0x1B : <nl> - case 0x1C : <nl> - case 0x1D : <nl> - case 0x1E : <nl> - case 0x1F : <nl> - { <nl> - error_message = " invalid string : control character must be escaped " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - / / U + 0020 . . U + 007F ( except U + 0022 ( quote ) and U + 005C ( backspace ) ) <nl> - case 0x20 : <nl> - case 0x21 : <nl> - case 0x23 : <nl> - case 0x24 : <nl> - case 0x25 : <nl> - case 0x26 : <nl> - case 0x27 : <nl> - case 0x28 : <nl> - case 0x29 : <nl> - case 0x2A : <nl> - case 0x2B : <nl> - case 0x2C : <nl> - case 0x2D : <nl> - case 0x2E : <nl> - case 0x2F : <nl> - case 0x30 : <nl> - case 0x31 : <nl> - case 0x32 : <nl> - case 0x33 : <nl> - case 0x34 : <nl> - case 0x35 : <nl> - case 0x36 : <nl> - case 0x37 : <nl> - case 0x38 : <nl> - case 0x39 : <nl> - case 0x3A : <nl> - case 0x3B : <nl> - case 0x3C : <nl> - case 0x3D : <nl> - case 0x3E : <nl> - case 0x3F : <nl> - case 0x40 : <nl> - case 0x41 : <nl> - case 0x42 : <nl> - case 0x43 : <nl> - case 0x44 : <nl> - case 0x45 : <nl> - case 0x46 : <nl> - case 0x47 : <nl> - case 0x48 : <nl> - case 0x49 : <nl> - case 0x4A : <nl> - case 0x4B : <nl> - case 0x4C : <nl> - case 0x4D : <nl> - case 0x4E : <nl> - case 0x4F : <nl> - case 0x50 : <nl> - case 0x51 : <nl> - case 0x52 : <nl> - case 0x53 : <nl> - case 0x54 : <nl> - case 0x55 : <nl> - case 0x56 : <nl> - case 0x57 : <nl> - case 0x58 : <nl> - case 0x59 : <nl> - case 0x5A : <nl> - case 0x5B : <nl> - case 0x5D : <nl> - case 0x5E : <nl> - case 0x5F : <nl> - case 0x60 : <nl> - case 0x61 : <nl> - case 0x62 : <nl> - case 0x63 : <nl> - case 0x64 : <nl> - case 0x65 : <nl> - case 0x66 : <nl> - case 0x67 : <nl> - case 0x68 : <nl> - case 0x69 : <nl> - case 0x6A : <nl> - case 0x6B : <nl> - case 0x6C : <nl> - case 0x6D : <nl> - case 0x6E : <nl> - case 0x6F : <nl> - case 0x70 : <nl> - case 0x71 : <nl> - case 0x72 : <nl> - case 0x73 : <nl> - case 0x74 : <nl> - case 0x75 : <nl> - case 0x76 : <nl> - case 0x77 : <nl> - case 0x78 : <nl> - case 0x79 : <nl> - case 0x7A : <nl> - case 0x7B : <nl> - case 0x7C : <nl> - case 0x7D : <nl> - case 0x7E : <nl> - case 0x7F : <nl> - { <nl> - add ( current ) ; <nl> - break ; <nl> - } <nl> - <nl> - / / U + 0080 . . U + 07FF : bytes C2 . . DF 80 . . BF <nl> - case 0xC2 : <nl> - case 0xC3 : <nl> - case 0xC4 : <nl> - case 0xC5 : <nl> - case 0xC6 : <nl> - case 0xC7 : <nl> - case 0xC8 : <nl> - case 0xC9 : <nl> - case 0xCA : <nl> - case 0xCB : <nl> - case 0xCC : <nl> - case 0xCD : <nl> - case 0xCE : <nl> - case 0xCF : <nl> - case 0xD0 : <nl> - case 0xD1 : <nl> - case 0xD2 : <nl> - case 0xD3 : <nl> - case 0xD4 : <nl> - case 0xD5 : <nl> - case 0xD6 : <nl> - case 0xD7 : <nl> - case 0xD8 : <nl> - case 0xD9 : <nl> - case 0xDA : <nl> - case 0xDB : <nl> - case 0xDC : <nl> - case 0xDD : <nl> - case 0xDE : <nl> - case 0xDF : <nl> - { <nl> - if ( JSON_UNLIKELY ( not next_byte_in_range ( { 0x80 , 0xBF } ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + 0800 . . U + 0FFF : bytes E0 A0 . . BF 80 . . BF <nl> - case 0xE0 : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0xA0 , 0xBF , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + 1000 . . U + CFFF : bytes E1 . . EC 80 . . BF 80 . . BF <nl> - / / U + E000 . . U + FFFF : bytes EE . . EF 80 . . BF 80 . . BF <nl> - case 0xE1 : <nl> - case 0xE2 : <nl> - case 0xE3 : <nl> - case 0xE4 : <nl> - case 0xE5 : <nl> - case 0xE6 : <nl> - case 0xE7 : <nl> - case 0xE8 : <nl> - case 0xE9 : <nl> - case 0xEA : <nl> - case 0xEB : <nl> - case 0xEC : <nl> - case 0xEE : <nl> - case 0xEF : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0x80 , 0xBF , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + D000 . . U + D7FF : bytes ED 80 . . 9F 80 . . BF <nl> - case 0xED : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0x80 , 0x9F , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + 10000 . . U + 3FFFF F0 90 . . BF 80 . . BF 80 . . BF <nl> - case 0xF0 : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0x90 , 0xBF , 0x80 , 0xBF , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + 40000 . . U + FFFFF F1 . . F3 80 . . BF 80 . . BF 80 . . BF <nl> - case 0xF1 : <nl> - case 0xF2 : <nl> - case 0xF3 : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0x80 , 0xBF , 0x80 , 0xBF , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / U + 100000 . . U + 10FFFF F4 80 . . 8F 80 . . BF 80 . . BF <nl> - case 0xF4 : <nl> - { <nl> - if ( JSON_UNLIKELY ( not ( next_byte_in_range ( { 0x80 , 0x8F , 0x80 , 0xBF , 0x80 , 0xBF } ) ) ) ) <nl> - { <nl> - return token_type : : parse_error ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / remaining bytes ( 80 . . C1 and F5 . . FF ) are ill - formed <nl> - default : <nl> - { <nl> - error_message = " invalid string : ill - formed UTF - 8 byte " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - static void strtof ( float & f , const char * str , char * * endptr ) noexcept <nl> - { <nl> - f = std : : strtof ( str , endptr ) ; <nl> - } <nl> - <nl> - static void strtof ( double & f , const char * str , char * * endptr ) noexcept <nl> - { <nl> - f = std : : strtod ( str , endptr ) ; <nl> - } <nl> - <nl> - static void strtof ( long double & f , const char * str , char * * endptr ) noexcept <nl> - { <nl> - f = std : : strtold ( str , endptr ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief scan a number literal <nl> - <nl> - This function scans a string according to Sect . 6 of RFC 7159 . <nl> - <nl> - The function is realized with a deterministic finite state machine derived <nl> - from the grammar described in RFC 7159 . Starting in state " init " , the <nl> - input is read and used to determined the next state . Only state " done " <nl> - accepts the number . State " error " is a trap state to model errors . In the <nl> - table below , " anything " means any character but the ones listed before . <nl> - <nl> - state | 0 | 1 - 9 | e E | + | - | . | anything <nl> - mmmmmmmmm | mmmmmmmmm - | mmmmmmmmm - | mmmmmmmmm - | mmmmmmmmm | mmmmmmmmm | mmmmmmmmm - | mmmmmmmmm - - <nl> - init | zero | any1 | [ error ] | [ error ] | minus | [ error ] | [ error ] <nl> - minus | zero | any1 | [ error ] | [ error ] | [ error ] | [ error ] | [ error ] <nl> - zero | done | done | exponent | done | done | decimal1 | done <nl> - any1 | any1 | any1 | exponent | done | done | decimal1 | done <nl> - decimal1 | decimal2 | [ error ] | [ error ] | [ error ] | [ error ] | [ error ] | [ error ] <nl> - decimal2 | decimal2 | decimal2 | exponent | done | done | done | done <nl> - exponent | any2 | any2 | [ error ] | sign | sign | [ error ] | [ error ] <nl> - sign | any2 | any2 | [ error ] | [ error ] | [ error ] | [ error ] | [ error ] <nl> - any2 | any2 | any2 | done | done | done | done | done <nl> - <nl> - The state machine is realized with one label per state ( prefixed with <nl> - " scan_number_ " ) and ` goto ` statements between them . The state machine <nl> - contains cycles , but any cycle can be left when EOF is read . Therefore , <nl> - the function is guaranteed to terminate . <nl> - <nl> - During scanning , the read bytes are stored in token_buffer . This string is <nl> - then converted to a signed integer , an unsigned integer , or a <nl> - floating - point number . <nl> - <nl> - @ return token_type : : value_unsigned , token_type : : value_integer , or <nl> - token_type : : value_float if number could be successfully scanned , <nl> - token_type : : parse_error otherwise <nl> - <nl> - @ note The scanner is independent of the current locale . Internally , the <nl> - locale ' s decimal point is used instead of ` . ` to work with the <nl> - locale - dependent converters . <nl> - * / <nl> - token_type scan_number ( ) <nl> - { <nl> - / / reset token_buffer to store the number ' s bytes <nl> - reset ( ) ; <nl> - <nl> - / / the type of the parsed number ; initially set to unsigned ; will be <nl> - / / changed if minus sign , decimal point or exponent is read <nl> - token_type number_type = token_type : : value_unsigned ; <nl> - <nl> - / / state ( init ) : we just found out we need to scan a number <nl> - switch ( current ) <nl> - { <nl> - case ' - ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_minus ; <nl> - } <nl> - <nl> - case ' 0 ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_zero ; <nl> - } <nl> - <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any1 ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / all other characters are rejected outside scan_number ( ) <nl> - assert ( false ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - <nl> - scan_number_minus : <nl> - / / state : we just parsed a leading minus sign <nl> - number_type = token_type : : value_integer ; <nl> - switch ( get ( ) ) <nl> - { <nl> - case ' 0 ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_zero ; <nl> - } <nl> - <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any1 ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - error_message = " invalid number ; expected digit after ' - ' " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - scan_number_zero : <nl> - / / state : we just parse a zero ( maybe with a leading minus sign ) <nl> - switch ( get ( ) ) <nl> - { <nl> - case ' . ' : <nl> - { <nl> - add ( decimal_point_char ) ; <nl> - goto scan_number_decimal1 ; <nl> - } <nl> - <nl> - case ' e ' : <nl> - case ' E ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_exponent ; <nl> - } <nl> - <nl> - default : <nl> - goto scan_number_done ; <nl> - } <nl> - <nl> - scan_number_any1 : <nl> - / / state : we just parsed a number 0 - 9 ( maybe with a leading minus sign ) <nl> - switch ( get ( ) ) <nl> - { <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any1 ; <nl> - } <nl> - <nl> - case ' . ' : <nl> - { <nl> - add ( decimal_point_char ) ; <nl> - goto scan_number_decimal1 ; <nl> - } <nl> - <nl> - case ' e ' : <nl> - case ' E ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_exponent ; <nl> - } <nl> - <nl> - default : <nl> - goto scan_number_done ; <nl> - } <nl> - <nl> - scan_number_decimal1 : <nl> - / / state : we just parsed a decimal point <nl> - number_type = token_type : : value_float ; <nl> - switch ( get ( ) ) <nl> - { <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_decimal2 ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - error_message = " invalid number ; expected digit after ' . ' " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - scan_number_decimal2 : <nl> - / / we just parsed at least one number after a decimal point <nl> - switch ( get ( ) ) <nl> - { <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_decimal2 ; <nl> - } <nl> - <nl> - case ' e ' : <nl> - case ' E ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_exponent ; <nl> - } <nl> - <nl> - default : <nl> - goto scan_number_done ; <nl> - } <nl> - <nl> - scan_number_exponent : <nl> - / / we just parsed an exponent <nl> - number_type = token_type : : value_float ; <nl> - switch ( get ( ) ) <nl> - { <nl> - case ' + ' : <nl> - case ' - ' : <nl> - { <nl> - add ( current ) ; <nl> - goto scan_number_sign ; <nl> - } <nl> - <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any2 ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - error_message = <nl> - " invalid number ; expected ' + ' , ' - ' , or digit after exponent " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - scan_number_sign : <nl> - / / we just parsed an exponent sign <nl> - switch ( get ( ) ) <nl> - { <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any2 ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - error_message = " invalid number ; expected digit after exponent sign " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - scan_number_any2 : <nl> - / / we just parsed a number after the exponent or exponent sign <nl> - switch ( get ( ) ) <nl> - { <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> - { <nl> - add ( current ) ; <nl> - goto scan_number_any2 ; <nl> - } <nl> - <nl> - default : <nl> - goto scan_number_done ; <nl> - } <nl> - <nl> - scan_number_done : <nl> - / / unget the character after the number ( we only read it to know that <nl> - / / we are done scanning a number ) <nl> - unget ( ) ; <nl> - <nl> - char * endptr = nullptr ; <nl> - errno = 0 ; <nl> - <nl> - / / try to parse integers first and fall back to floats <nl> - if ( number_type = = token_type : : value_unsigned ) <nl> - { <nl> - const auto x = std : : strtoull ( token_buffer . data ( ) , & endptr , 10 ) ; <nl> - <nl> - / / we checked the number format before <nl> - assert ( endptr = = token_buffer . data ( ) + token_buffer . size ( ) ) ; <nl> - <nl> - if ( errno = = 0 ) <nl> - { <nl> - value_unsigned = static_cast < number_unsigned_t > ( x ) ; <nl> - if ( value_unsigned = = x ) <nl> - { <nl> - return token_type : : value_unsigned ; <nl> - } <nl> - } <nl> - } <nl> - else if ( number_type = = token_type : : value_integer ) <nl> - { <nl> - const auto x = std : : strtoll ( token_buffer . data ( ) , & endptr , 10 ) ; <nl> - <nl> - / / we checked the number format before <nl> - assert ( endptr = = token_buffer . data ( ) + token_buffer . size ( ) ) ; <nl> - <nl> - if ( errno = = 0 ) <nl> - { <nl> - value_integer = static_cast < number_integer_t > ( x ) ; <nl> - if ( value_integer = = x ) <nl> - { <nl> - return token_type : : value_integer ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / this code is reached if we parse a floating - point number or if an <nl> - / / integer conversion above failed <nl> - strtof ( value_float , token_buffer . data ( ) , & endptr ) ; <nl> - <nl> - / / we checked the number format before <nl> - assert ( endptr = = token_buffer . data ( ) + token_buffer . size ( ) ) ; <nl> - <nl> - return token_type : : value_float ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] literal_text the literal text to expect <nl> - @ param [ in ] length the length of the passed literal text <nl> - @ param [ in ] return_type the token type to return on success <nl> - * / <nl> - token_type scan_literal ( const char * literal_text , const std : : size_t length , <nl> - token_type return_type ) <nl> - { <nl> - assert ( current = = literal_text [ 0 ] ) ; <nl> - for ( std : : size_t i = 1 ; i < length ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( get ( ) ! = literal_text [ i ] ) ) <nl> - { <nl> - error_message = " invalid literal " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - return return_type ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / input management <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / reset token_buffer ; current character is beginning of token <nl> - void reset ( ) noexcept <nl> - { <nl> - token_buffer . clear ( ) ; <nl> - token_string . clear ( ) ; <nl> - token_string . push_back ( std : : char_traits < char > : : to_char_type ( current ) ) ; <nl> - } <nl> - <nl> - / * <nl> - @ brief get next character from the input <nl> - <nl> - This function provides the interface to the used input adapter . It does <nl> - not throw in case the input reached EOF , but returns a <nl> - ` std : : char_traits < char > : : eof ( ) ` in that case . Stores the scanned characters <nl> - for use in error messages . <nl> - <nl> - @ return character read from the input <nl> - * / <nl> - std : : char_traits < char > : : int_type get ( ) <nl> - { <nl> - + + chars_read ; <nl> - if ( next_unget ) <nl> - { <nl> - / / just reset the next_unget variable and work with current <nl> - next_unget = false ; <nl> - } <nl> - else <nl> - { <nl> - current = ia - > get_character ( ) ; <nl> - } <nl> - <nl> - if ( JSON_LIKELY ( current ! = std : : char_traits < char > : : eof ( ) ) ) <nl> - { <nl> - token_string . push_back ( std : : char_traits < char > : : to_char_type ( current ) ) ; <nl> - } <nl> - return current ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief unget current character ( read it again on next get ) <nl> - <nl> - We implement unget by setting variable next_unget to true . The input is not <nl> - changed - we just simulate ungetting by modifying chars_read and <nl> - token_string . The next call to get ( ) will behave as if the unget character <nl> - is read again . <nl> - * / <nl> - void unget ( ) <nl> - { <nl> - next_unget = true ; <nl> - - - chars_read ; <nl> - if ( JSON_LIKELY ( current ! = std : : char_traits < char > : : eof ( ) ) ) <nl> - { <nl> - assert ( token_string . size ( ) ! = 0 ) ; <nl> - token_string . pop_back ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / / add a character to token_buffer <nl> - void add ( int c ) <nl> - { <nl> - token_buffer . push_back ( std : : char_traits < char > : : to_char_type ( c ) ) ; <nl> - } <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / value getters <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / return integer value <nl> - constexpr number_integer_t get_number_integer ( ) const noexcept <nl> - { <nl> - return value_integer ; <nl> - } <nl> - <nl> - / / / return unsigned integer value <nl> - constexpr number_unsigned_t get_number_unsigned ( ) const noexcept <nl> - { <nl> - return value_unsigned ; <nl> - } <nl> - <nl> - / / / return floating - point value <nl> - constexpr number_float_t get_number_float ( ) const noexcept <nl> - { <nl> - return value_float ; <nl> - } <nl> - <nl> - / / / return current string value ( implicitly resets the token ; useful only once ) <nl> - string_t & get_string ( ) <nl> - { <nl> - return token_buffer ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / diagnostics <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / return position of last read token <nl> - constexpr std : : size_t get_position ( ) const noexcept <nl> - { <nl> - return chars_read ; <nl> - } <nl> - <nl> - / / / return the last read token ( for errors only ) . Will never contain EOF <nl> - / / / ( an arbitrary value that is not a valid char value , often - 1 ) , because <nl> - / / / 255 may legitimately occur . May contain NUL , which should be escaped . <nl> - std : : string get_token_string ( ) const <nl> - { <nl> - / / escape control characters <nl> - std : : string result ; <nl> - for ( const auto c : token_string ) <nl> - { <nl> - if ( ' \ x00 ' < = c and c < = ' \ x1F ' ) <nl> - { <nl> - / / escape control characters <nl> - char cs [ 9 ] ; <nl> - snprintf ( cs , 9 , " < U + % . 4X > " , static_cast < unsigned char > ( c ) ) ; <nl> - result + = cs ; <nl> - } <nl> - else <nl> - { <nl> - / / add character as is <nl> - result . push_back ( c ) ; <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / / / return syntax error message <nl> - constexpr const char * get_error_message ( ) const noexcept <nl> - { <nl> - return error_message ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / actual scanner <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief skip the UTF - 8 byte order mark <nl> - @ return true iff there is no BOM or the correct BOM has been skipped <nl> - * / <nl> - bool skip_bom ( ) <nl> - { <nl> - if ( get ( ) = = 0xEF ) <nl> - { <nl> - if ( get ( ) = = 0xBB and get ( ) = = 0xBF ) <nl> - { <nl> - / / we completely parsed the BOM <nl> - return true ; <nl> - } <nl> - else <nl> - { <nl> - / / after reading 0xEF , an unexpected character followed <nl> - return false ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / the first character is not the beginning of the BOM ; unget it to <nl> - / / process is later <nl> - unget ( ) ; <nl> - return true ; <nl> - } <nl> - } <nl> - <nl> - token_type scan ( ) <nl> - { <nl> - / / initially , skip the BOM <nl> - if ( chars_read = = 0 and not skip_bom ( ) ) <nl> - { <nl> - error_message = " invalid BOM ; must be 0xEF 0xBB 0xBF if given " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - <nl> - / / read next character and ignore whitespace <nl> - do <nl> - { <nl> - get ( ) ; <nl> - } <nl> - while ( current = = ' ' or current = = ' \ t ' or current = = ' \ n ' or current = = ' \ r ' ) ; <nl> - <nl> - switch ( current ) <nl> - { <nl> - / / structural characters <nl> - case ' [ ' : <nl> - return token_type : : begin_array ; <nl> - case ' ] ' : <nl> - return token_type : : end_array ; <nl> - case ' { ' : <nl> - return token_type : : begin_object ; <nl> - case ' } ' : <nl> - return token_type : : end_object ; <nl> - case ' : ' : <nl> - return token_type : : name_separator ; <nl> - case ' , ' : <nl> - return token_type : : value_separator ; <nl> - <nl> - / / literals <nl> - case ' t ' : <nl> - return scan_literal ( " true " , 4 , token_type : : literal_true ) ; <nl> - case ' f ' : <nl> - return scan_literal ( " false " , 5 , token_type : : literal_false ) ; <nl> - case ' n ' : <nl> - return scan_literal ( " null " , 4 , token_type : : literal_null ) ; <nl> - <nl> - / / string <nl> - case ' \ " ' : <nl> - return scan_string ( ) ; <nl> - <nl> - / / number <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> - return scan_number ( ) ; <nl> - <nl> - / / end of input ( the null byte is needed when parsing from <nl> - / / string literals ) <nl> - case ' \ 0 ' : <nl> - case std : : char_traits < char > : : eof ( ) : <nl> - return token_type : : end_of_input ; <nl> - <nl> - / / error <nl> - default : <nl> - error_message = " invalid literal " ; <nl> - return token_type : : parse_error ; <nl> - } <nl> - } <nl> - <nl> - private : <nl> - / / / input adapter <nl> - detail : : input_adapter_t ia = nullptr ; <nl> - <nl> - / / / the current character <nl> - std : : char_traits < char > : : int_type current = std : : char_traits < char > : : eof ( ) ; <nl> - <nl> - / / / whether the next get ( ) call should just return current <nl> - bool next_unget = false ; <nl> - <nl> - / / / the number of characters read <nl> - std : : size_t chars_read = 0 ; <nl> - <nl> - / / / raw input token string ( for error messages ) <nl> - std : : vector < char > token_string { } ; <nl> - <nl> - / / / buffer for variable - length tokens ( numbers , strings ) <nl> - string_t token_buffer { } ; <nl> - <nl> - / / / a description of occurred lexer errors <nl> - const char * error_message = " " ; <nl> - <nl> - / / number values <nl> - number_integer_t value_integer = 0 ; <nl> - number_unsigned_t value_unsigned = 0 ; <nl> - number_float_t value_float = 0 ; <nl> - <nl> - / / / the decimal point <nl> - const char decimal_point_char = ' . ' ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / parser . hpp > <nl> - <nl> - <nl> - # include < cassert > / / assert <nl> - # include < cmath > / / isfinite <nl> - # include < cstdint > / / uint8_t <nl> - # include < functional > / / function <nl> - # include < string > / / string <nl> - # include < utility > / / move <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / is_sax . hpp > <nl> - <nl> - <nl> - # include < cstdint > / / size_t <nl> - # include < utility > / / declval <nl> - <nl> - / / # include < nlohmann / detail / meta / detected . hpp > <nl> - <nl> - <nl> - # include < type_traits > <nl> - <nl> - / / # include < nlohmann / detail / meta / void_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - template < typename . . . > <nl> - using void_t = void ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / http : / / en . cppreference . com / w / cpp / experimental / is_detected <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - struct nonesuch <nl> - { <nl> - nonesuch ( ) = delete ; <nl> - ~ nonesuch ( ) = delete ; <nl> - nonesuch ( nonesuch const & ) = delete ; <nl> - void operator = ( nonesuch const & ) = delete ; <nl> - } ; <nl> - <nl> - template < class Default , <nl> - class AlwaysVoid , <nl> - template < class . . . > class Op , <nl> - class . . . Args > <nl> - struct detector <nl> - { <nl> - using value_t = std : : false_type ; <nl> - using type = Default ; <nl> - } ; <nl> - <nl> - template < class Default , template < class . . . > class Op , class . . . Args > <nl> - struct detector < Default , void_t < Op < Args . . . > > , Op , Args . . . > <nl> - { <nl> - using value_t = std : : true_type ; <nl> - using type = Op < Args . . . > ; <nl> - } ; <nl> - <nl> - template < template < class . . . > class Op , class . . . Args > <nl> - using is_detected = typename detector < nonesuch , void , Op , Args . . . > : : value_t ; <nl> - <nl> - template < template < class . . . > class Op , class . . . Args > <nl> - using detected_t = typename detector < nonesuch , void , Op , Args . . . > : : type ; <nl> - <nl> - template < class Default , template < class . . . > class Op , class . . . Args > <nl> - using detected_or = detector < Default , void , Op , Args . . . > ; <nl> - <nl> - template < class Default , template < class . . . > class Op , class . . . Args > <nl> - using detected_or_t = typename detected_or < Default , Op , Args . . . > : : type ; <nl> - <nl> - template < class Expected , template < class . . . > class Op , class . . . Args > <nl> - using is_detected_exact = std : : is_same < Expected , detected_t < Op , Args . . . > > ; <nl> - <nl> - template < class To , template < class . . . > class Op , class . . . Args > <nl> - using is_detected_convertible = <nl> - std : : is_convertible < detected_t < Op , Args . . . > , To > ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / meta / type_traits . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - template < typename T > <nl> - using null_function_t = decltype ( std : : declval < T & > ( ) . null ( ) ) ; <nl> - <nl> - template < typename T > <nl> - using boolean_function_t = <nl> - decltype ( std : : declval < T & > ( ) . boolean ( std : : declval < bool > ( ) ) ) ; <nl> - <nl> - template < typename T , typename Integer > <nl> - using number_integer_function_t = <nl> - decltype ( std : : declval < T & > ( ) . number_integer ( std : : declval < Integer > ( ) ) ) ; <nl> - <nl> - template < typename T , typename Unsigned > <nl> - using number_unsigned_function_t = <nl> - decltype ( std : : declval < T & > ( ) . number_unsigned ( std : : declval < Unsigned > ( ) ) ) ; <nl> - <nl> - template < typename T , typename Float , typename String > <nl> - using number_float_function_t = decltype ( std : : declval < T & > ( ) . number_float ( <nl> - std : : declval < Float > ( ) , std : : declval < const String & > ( ) ) ) ; <nl> - <nl> - template < typename T , typename String > <nl> - using string_function_t = <nl> - decltype ( std : : declval < T & > ( ) . string ( std : : declval < String & > ( ) ) ) ; <nl> - <nl> - template < typename T > <nl> - using start_object_function_t = <nl> - decltype ( std : : declval < T & > ( ) . start_object ( std : : declval < std : : size_t > ( ) ) ) ; <nl> - <nl> - template < typename T , typename String > <nl> - using key_function_t = <nl> - decltype ( std : : declval < T & > ( ) . key ( std : : declval < String & > ( ) ) ) ; <nl> - <nl> - template < typename T > <nl> - using end_object_function_t = decltype ( std : : declval < T & > ( ) . end_object ( ) ) ; <nl> - <nl> - template < typename T > <nl> - using start_array_function_t = <nl> - decltype ( std : : declval < T & > ( ) . start_array ( std : : declval < std : : size_t > ( ) ) ) ; <nl> - <nl> - template < typename T > <nl> - using end_array_function_t = decltype ( std : : declval < T & > ( ) . end_array ( ) ) ; <nl> - <nl> - template < typename T , typename Exception > <nl> - using parse_error_function_t = decltype ( std : : declval < T & > ( ) . parse_error ( <nl> - std : : declval < std : : size_t > ( ) , std : : declval < const std : : string & > ( ) , <nl> - std : : declval < const Exception & > ( ) ) ) ; <nl> - <nl> - template < typename SAX , typename BasicJsonType > <nl> - struct is_sax <nl> - { <nl> - private : <nl> - static_assert ( is_basic_json < BasicJsonType > : : value , <nl> - " BasicJsonType must be of type basic_json < . . . > " ) ; <nl> - <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using exception_t = typename BasicJsonType : : exception ; <nl> - <nl> - public : <nl> - static constexpr bool value = <nl> - is_detected_exact < bool , null_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , boolean_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , number_integer_function_t , SAX , <nl> - number_integer_t > : : value & & <nl> - is_detected_exact < bool , number_unsigned_function_t , SAX , <nl> - number_unsigned_t > : : value & & <nl> - is_detected_exact < bool , number_float_function_t , SAX , number_float_t , <nl> - string_t > : : value & & <nl> - is_detected_exact < bool , string_function_t , SAX , string_t > : : value & & <nl> - is_detected_exact < bool , start_object_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , key_function_t , SAX , string_t > : : value & & <nl> - is_detected_exact < bool , end_object_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , start_array_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , end_array_function_t , SAX > : : value & & <nl> - is_detected_exact < bool , parse_error_function_t , SAX , exception_t > : : value ; <nl> - } ; <nl> - <nl> - template < typename SAX , typename BasicJsonType > <nl> - struct is_sax_static_asserts <nl> - { <nl> - private : <nl> - static_assert ( is_basic_json < BasicJsonType > : : value , <nl> - " BasicJsonType must be of type basic_json < . . . > " ) ; <nl> - <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using exception_t = typename BasicJsonType : : exception ; <nl> - <nl> - public : <nl> - static_assert ( is_detected_exact < bool , null_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool null ( ) " ) ; <nl> - static_assert ( is_detected_exact < bool , boolean_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool boolean ( bool ) " ) ; <nl> - static_assert ( is_detected_exact < bool , boolean_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool boolean ( bool ) " ) ; <nl> - static_assert ( <nl> - is_detected_exact < bool , number_integer_function_t , SAX , <nl> - number_integer_t > : : value , <nl> - " Missing / invalid function : bool number_integer ( number_integer_t ) " ) ; <nl> - static_assert ( <nl> - is_detected_exact < bool , number_unsigned_function_t , SAX , <nl> - number_unsigned_t > : : value , <nl> - " Missing / invalid function : bool number_unsigned ( number_unsigned_t ) " ) ; <nl> - static_assert ( is_detected_exact < bool , number_float_function_t , SAX , <nl> - number_float_t , string_t > : : value , <nl> - " Missing / invalid function : bool number_float ( number_float_t , const string_t & ) " ) ; <nl> - static_assert ( <nl> - is_detected_exact < bool , string_function_t , SAX , string_t > : : value , <nl> - " Missing / invalid function : bool string ( string_t & ) " ) ; <nl> - static_assert ( is_detected_exact < bool , start_object_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool start_object ( std : : size_t ) " ) ; <nl> - static_assert ( is_detected_exact < bool , key_function_t , SAX , string_t > : : value , <nl> - " Missing / invalid function : bool key ( string_t & ) " ) ; <nl> - static_assert ( is_detected_exact < bool , end_object_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool end_object ( ) " ) ; <nl> - static_assert ( is_detected_exact < bool , start_array_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool start_array ( std : : size_t ) " ) ; <nl> - static_assert ( is_detected_exact < bool , end_array_function_t , SAX > : : value , <nl> - " Missing / invalid function : bool end_array ( ) " ) ; <nl> - static_assert ( <nl> - is_detected_exact < bool , parse_error_function_t , SAX , exception_t > : : value , <nl> - " Missing / invalid function : bool parse_error ( std : : size_t , const " <nl> - " std : : string & , const exception & ) " ) ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / input_adapters . hpp > <nl> - <nl> - / / # include < nlohmann / detail / input / json_sax . hpp > <nl> - <nl> - <nl> - # include < cstddef > <nl> - # include < string > <nl> - # include < vector > <nl> - <nl> - / / # include < nlohmann / detail / input / parser . hpp > <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - <nl> - / * ! <nl> - @ brief SAX interface <nl> - <nl> - This class describes the SAX interface used by @ ref nlohmann : : json : : sax_parse . <nl> - Each function is called in different situations while the input is parsed . The <nl> - boolean return value informs the parser whether to continue processing the <nl> - input . <nl> - * / <nl> - template < typename BasicJsonType > <nl> - struct json_sax <nl> - { <nl> - / / / type for ( signed ) integers <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - / / / type for unsigned integers <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - / / / type for floating - point numbers <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - / / / type for strings <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - <nl> - / * ! <nl> - @ brief a null value was read <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool null ( ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief a boolean value was read <nl> - @ param [ in ] val boolean value <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool boolean ( bool val ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief an integer number was read <nl> - @ param [ in ] val integer value <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool number_integer ( number_integer_t val ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief an unsigned integer number was read <nl> - @ param [ in ] val unsigned integer value <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool number_unsigned ( number_unsigned_t val ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief an floating - point number was read <nl> - @ param [ in ] val floating - point value <nl> - @ param [ in ] s raw token value <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool number_float ( number_float_t val , const string_t & s ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief a string was read <nl> - @ param [ in ] val string value <nl> - @ return whether parsing should proceed <nl> - @ note It is safe to move the passed string . <nl> - * / <nl> - virtual bool string ( string_t & val ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief the beginning of an object was read <nl> - @ param [ in ] elements number of object elements or - 1 if unknown <nl> - @ return whether parsing should proceed <nl> - @ note binary formats may report the number of elements <nl> - * / <nl> - virtual bool start_object ( std : : size_t elements ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief an object key was read <nl> - @ param [ in ] val object key <nl> - @ return whether parsing should proceed <nl> - @ note It is safe to move the passed string . <nl> - * / <nl> - virtual bool key ( string_t & val ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief the end of an object was read <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool end_object ( ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief the beginning of an array was read <nl> - @ param [ in ] elements number of array elements or - 1 if unknown <nl> - @ return whether parsing should proceed <nl> - @ note binary formats may report the number of elements <nl> - * / <nl> - virtual bool start_array ( std : : size_t elements ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief the end of an array was read <nl> - @ return whether parsing should proceed <nl> - * / <nl> - virtual bool end_array ( ) = 0 ; <nl> - <nl> - / * ! <nl> - @ brief a parse error occurred <nl> - @ param [ in ] position the position in the input where the error occurs <nl> - @ param [ in ] last_token the last read token <nl> - @ param [ in ] error_msg a detailed error message <nl> - @ return whether parsing should proceed ( must return false ) <nl> - * / <nl> - virtual bool parse_error ( std : : size_t position , <nl> - const std : : string & last_token , <nl> - const detail : : exception & ex ) = 0 ; <nl> - <nl> - virtual ~ json_sax ( ) = default ; <nl> - } ; <nl> - <nl> - <nl> - namespace detail <nl> - { <nl> - / * ! <nl> - @ brief SAX implementation to create a JSON value from SAX events <nl> - <nl> - This class implements the @ ref json_sax interface and processes the SAX events <nl> - to create a JSON value which makes it basically a DOM parser . The structure or <nl> - hierarchy of the JSON value is managed by the stack ` ref_stack ` which contains <nl> - a pointer to the respective array or object for each recursion depth . <nl> - <nl> - After successful parsing , the value that is passed by reference to the <nl> - constructor contains the parsed value . <nl> - <nl> - @ tparam BasicJsonType the JSON type <nl> - * / <nl> - template < typename BasicJsonType > <nl> - class json_sax_dom_parser <nl> - { <nl> - public : <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - <nl> - / * ! <nl> - @ param [ in , out ] r reference to a JSON value that is manipulated while <nl> - parsing <nl> - @ param [ in ] allow_exceptions_ whether parse errors yield exceptions <nl> - * / <nl> - explicit json_sax_dom_parser ( BasicJsonType & r , const bool allow_exceptions_ = true ) <nl> - : root ( r ) , allow_exceptions ( allow_exceptions_ ) <nl> - { } <nl> - <nl> - bool null ( ) <nl> - { <nl> - handle_value ( nullptr ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool boolean ( bool val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_integer ( number_integer_t val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_unsigned ( number_unsigned_t val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_float ( number_float_t val , const string_t & ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool string ( string_t & val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool start_object ( std : : size_t len ) <nl> - { <nl> - ref_stack . push_back ( handle_value ( BasicJsonType : : value_t : : object ) ) ; <nl> - <nl> - if ( JSON_UNLIKELY ( len ! = std : : size_t ( - 1 ) and len > ref_stack . back ( ) - > max_size ( ) ) ) <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 408 , <nl> - " excessive object size : " + std : : to_string ( len ) ) ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool key ( string_t & val ) <nl> - { <nl> - / / add null at given key and store the reference for later <nl> - object_element = & ( ref_stack . back ( ) - > m_value . object - > operator [ ] ( val ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool end_object ( ) <nl> - { <nl> - ref_stack . pop_back ( ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool start_array ( std : : size_t len ) <nl> - { <nl> - ref_stack . push_back ( handle_value ( BasicJsonType : : value_t : : array ) ) ; <nl> - <nl> - if ( JSON_UNLIKELY ( len ! = std : : size_t ( - 1 ) and len > ref_stack . back ( ) - > max_size ( ) ) ) <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 408 , <nl> - " excessive array size : " + std : : to_string ( len ) ) ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool end_array ( ) <nl> - { <nl> - ref_stack . pop_back ( ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool parse_error ( std : : size_t , const std : : string & , <nl> - const detail : : exception & ex ) <nl> - { <nl> - errored = true ; <nl> - if ( allow_exceptions ) <nl> - { <nl> - / / determine the proper exception type from the id <nl> - switch ( ( ex . id / 100 ) % 100 ) <nl> - { <nl> - case 1 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : parse_error * > ( & ex ) ) ; <nl> - case 2 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : invalid_iterator * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - case 3 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : type_error * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - case 4 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : out_of_range * > ( & ex ) ) ; <nl> - case 5 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : other_error * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - default : <nl> - assert ( false ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - constexpr bool is_errored ( ) const <nl> - { <nl> - return errored ; <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ invariant If the ref stack is empty , then the passed value will be the new <nl> - root . <nl> - @ invariant If the ref stack contains a value , then it is an array or an <nl> - object to which we can add elements <nl> - * / <nl> - template < typename Value > <nl> - BasicJsonType * handle_value ( Value & & v ) <nl> - { <nl> - if ( ref_stack . empty ( ) ) <nl> - { <nl> - root = BasicJsonType ( std : : forward < Value > ( v ) ) ; <nl> - return & root ; <nl> - } <nl> - else <nl> - { <nl> - assert ( ref_stack . back ( ) - > is_array ( ) or ref_stack . back ( ) - > is_object ( ) ) ; <nl> - if ( ref_stack . back ( ) - > is_array ( ) ) <nl> - { <nl> - ref_stack . back ( ) - > m_value . array - > emplace_back ( std : : forward < Value > ( v ) ) ; <nl> - return & ( ref_stack . back ( ) - > m_value . array - > back ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - assert ( object_element ) ; <nl> - * object_element = BasicJsonType ( std : : forward < Value > ( v ) ) ; <nl> - return object_element ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / the parsed JSON value <nl> - BasicJsonType & root ; <nl> - / / / stack to model hierarchy of values <nl> - std : : vector < BasicJsonType * > ref_stack ; <nl> - / / / helper to hold the reference for the next object element <nl> - BasicJsonType * object_element = nullptr ; <nl> - / / / whether a syntax error occurred <nl> - bool errored = false ; <nl> - / / / whether to throw exceptions in case of errors <nl> - const bool allow_exceptions = true ; <nl> - } ; <nl> - <nl> - template < typename BasicJsonType > <nl> - class json_sax_dom_callback_parser <nl> - { <nl> - public : <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using parser_callback_t = typename BasicJsonType : : parser_callback_t ; <nl> - using parse_event_t = typename BasicJsonType : : parse_event_t ; <nl> - <nl> - json_sax_dom_callback_parser ( BasicJsonType & r , <nl> - const parser_callback_t cb , <nl> - const bool allow_exceptions_ = true ) <nl> - : root ( r ) , callback ( cb ) , allow_exceptions ( allow_exceptions_ ) <nl> - { <nl> - keep_stack . push_back ( true ) ; <nl> - } <nl> - <nl> - bool null ( ) <nl> - { <nl> - handle_value ( nullptr ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool boolean ( bool val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_integer ( number_integer_t val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_unsigned ( number_unsigned_t val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool number_float ( number_float_t val , const string_t & ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool string ( string_t & val ) <nl> - { <nl> - handle_value ( val ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool start_object ( std : : size_t len ) <nl> - { <nl> - / / check callback for object start <nl> - const bool keep = callback ( static_cast < int > ( ref_stack . size ( ) ) , parse_event_t : : object_start , discarded ) ; <nl> - keep_stack . push_back ( keep ) ; <nl> - <nl> - auto val = handle_value ( BasicJsonType : : value_t : : object , true ) ; <nl> - ref_stack . push_back ( val . second ) ; <nl> - <nl> - / / check object limit <nl> - if ( ref_stack . back ( ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( len ! = std : : size_t ( - 1 ) and len > ref_stack . back ( ) - > max_size ( ) ) ) <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 408 , <nl> - " excessive object size : " + std : : to_string ( len ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool key ( string_t & val ) <nl> - { <nl> - BasicJsonType k = BasicJsonType ( val ) ; <nl> - <nl> - / / check callback for key <nl> - const bool keep = callback ( static_cast < int > ( ref_stack . size ( ) ) , parse_event_t : : key , k ) ; <nl> - key_keep_stack . push_back ( keep ) ; <nl> - <nl> - / / add discarded value at given key and store the reference for later <nl> - if ( keep and ref_stack . back ( ) ) <nl> - { <nl> - object_element = & ( ref_stack . back ( ) - > m_value . object - > operator [ ] ( val ) = discarded ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool end_object ( ) <nl> - { <nl> - if ( ref_stack . back ( ) ) <nl> - { <nl> - if ( not callback ( static_cast < int > ( ref_stack . size ( ) ) - 1 , parse_event_t : : object_end , * ref_stack . back ( ) ) ) <nl> - { <nl> - / / discard object <nl> - * ref_stack . back ( ) = discarded ; <nl> - } <nl> - } <nl> - <nl> - assert ( not ref_stack . empty ( ) ) ; <nl> - assert ( not keep_stack . empty ( ) ) ; <nl> - ref_stack . pop_back ( ) ; <nl> - keep_stack . pop_back ( ) ; <nl> - <nl> - if ( not ref_stack . empty ( ) and ref_stack . back ( ) ) <nl> - { <nl> - / / remove discarded value <nl> - if ( ref_stack . back ( ) - > is_object ( ) ) <nl> - { <nl> - for ( auto it = ref_stack . back ( ) - > begin ( ) ; it ! = ref_stack . back ( ) - > end ( ) ; + + it ) <nl> - { <nl> - if ( it - > is_discarded ( ) ) <nl> - { <nl> - ref_stack . back ( ) - > erase ( it ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool start_array ( std : : size_t len ) <nl> - { <nl> - const bool keep = callback ( static_cast < int > ( ref_stack . size ( ) ) , parse_event_t : : array_start , discarded ) ; <nl> - keep_stack . push_back ( keep ) ; <nl> - <nl> - auto val = handle_value ( BasicJsonType : : value_t : : array , true ) ; <nl> - ref_stack . push_back ( val . second ) ; <nl> - <nl> - / / check array limit <nl> - if ( ref_stack . back ( ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( len ! = std : : size_t ( - 1 ) and len > ref_stack . back ( ) - > max_size ( ) ) ) <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 408 , <nl> - " excessive array size : " + std : : to_string ( len ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool end_array ( ) <nl> - { <nl> - bool keep = true ; <nl> - <nl> - if ( ref_stack . back ( ) ) <nl> - { <nl> - keep = callback ( static_cast < int > ( ref_stack . size ( ) ) - 1 , parse_event_t : : array_end , * ref_stack . back ( ) ) ; <nl> - if ( not keep ) <nl> - { <nl> - / / discard array <nl> - * ref_stack . back ( ) = discarded ; <nl> - } <nl> - } <nl> - <nl> - assert ( not ref_stack . empty ( ) ) ; <nl> - assert ( not keep_stack . empty ( ) ) ; <nl> - ref_stack . pop_back ( ) ; <nl> - keep_stack . pop_back ( ) ; <nl> - <nl> - / / remove discarded value <nl> - if ( not keep and not ref_stack . empty ( ) ) <nl> - { <nl> - if ( ref_stack . back ( ) - > is_array ( ) ) <nl> - { <nl> - ref_stack . back ( ) - > m_value . array - > pop_back ( ) ; <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool parse_error ( std : : size_t , const std : : string & , <nl> - const detail : : exception & ex ) <nl> - { <nl> - errored = true ; <nl> - if ( allow_exceptions ) <nl> - { <nl> - / / determine the proper exception type from the id <nl> - switch ( ( ex . id / 100 ) % 100 ) <nl> - { <nl> - case 1 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : parse_error * > ( & ex ) ) ; <nl> - case 2 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : invalid_iterator * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - case 3 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : type_error * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - case 4 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : out_of_range * > ( & ex ) ) ; <nl> - case 5 : <nl> - JSON_THROW ( * reinterpret_cast < const detail : : other_error * > ( & ex ) ) ; / / LCOV_EXCL_LINE <nl> - default : <nl> - assert ( false ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - constexpr bool is_errored ( ) const <nl> - { <nl> - return errored ; <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ param [ in ] v value to add to the JSON value we build during parsing <nl> - @ param [ in ] skip_callback whether we should skip calling the callback <nl> - function ; this is required after start_array ( ) and <nl> - start_object ( ) SAX events , because otherwise we would call the <nl> - callback function with an empty array or object , respectively . <nl> - <nl> - @ invariant If the ref stack is empty , then the passed value will be the new <nl> - root . <nl> - @ invariant If the ref stack contains a value , then it is an array or an <nl> - object to which we can add elements <nl> - <nl> - @ return pair of boolean ( whether value should be kept ) and pointer ( to the <nl> - passed value in the ref_stack hierarchy ; nullptr if not kept ) <nl> - * / <nl> - template < typename Value > <nl> - std : : pair < bool , BasicJsonType * > handle_value ( Value & & v , const bool skip_callback = false ) <nl> - { <nl> - assert ( not keep_stack . empty ( ) ) ; <nl> - <nl> - / / do not handle this value if we know it would be added to a discarded <nl> - / / container <nl> - if ( not keep_stack . back ( ) ) <nl> - { <nl> - return { false , nullptr } ; <nl> - } <nl> - <nl> - / / create value <nl> - auto value = BasicJsonType ( std : : forward < Value > ( v ) ) ; <nl> - <nl> - / / check callback <nl> - const bool keep = skip_callback or callback ( static_cast < int > ( ref_stack . size ( ) ) , parse_event_t : : value , value ) ; <nl> - <nl> - / / do not handle this value if we just learnt it shall be discarded <nl> - if ( not keep ) <nl> - { <nl> - return { false , nullptr } ; <nl> - } <nl> - <nl> - if ( ref_stack . empty ( ) ) <nl> - { <nl> - root = std : : move ( value ) ; <nl> - return { true , & root } ; <nl> - } <nl> - else <nl> - { <nl> - assert ( ref_stack . back ( ) - > is_array ( ) or ref_stack . back ( ) - > is_object ( ) ) ; <nl> - if ( ref_stack . back ( ) - > is_array ( ) ) <nl> - { <nl> - ref_stack . back ( ) - > m_value . array - > push_back ( std : : move ( value ) ) ; <nl> - return { true , & ( ref_stack . back ( ) - > m_value . array - > back ( ) ) } ; <nl> - } <nl> - else <nl> - { <nl> - / / check if we should store an element for the current key <nl> - assert ( not key_keep_stack . empty ( ) ) ; <nl> - const bool store_element = key_keep_stack . back ( ) ; <nl> - key_keep_stack . pop_back ( ) ; <nl> - <nl> - if ( not store_element ) <nl> - { <nl> - return { false , nullptr } ; <nl> - } <nl> - <nl> - assert ( object_element ) ; <nl> - * object_element = std : : move ( value ) ; <nl> - return { true , object_element } ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / the parsed JSON value <nl> - BasicJsonType & root ; <nl> - / / / stack to model hierarchy of values <nl> - std : : vector < BasicJsonType * > ref_stack ; <nl> - / / / stack to manage which values to keep <nl> - std : : vector < bool > keep_stack ; <nl> - / / / stack to manage which object keys to keep <nl> - std : : vector < bool > key_keep_stack ; <nl> - / / / helper to hold the reference for the next object element <nl> - BasicJsonType * object_element = nullptr ; <nl> - / / / whether a syntax error occurred <nl> - bool errored = false ; <nl> - / / / callback function <nl> - const parser_callback_t callback = nullptr ; <nl> - / / / whether to throw exceptions in case of errors <nl> - const bool allow_exceptions = true ; <nl> - / / / a discarded value for the callback <nl> - BasicJsonType discarded = BasicJsonType : : value_t : : discarded ; <nl> - } ; <nl> - <nl> - template < typename BasicJsonType > <nl> - class json_sax_acceptor <nl> - { <nl> - public : <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - <nl> - bool null ( ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool boolean ( bool ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool number_integer ( number_integer_t ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool number_unsigned ( number_unsigned_t ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool number_float ( number_float_t , const string_t & ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool string ( string_t & ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool start_object ( std : : size_t = std : : size_t ( - 1 ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool key ( string_t & ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool end_object ( ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool start_array ( std : : size_t = std : : size_t ( - 1 ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool end_array ( ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - bool parse_error ( std : : size_t , const std : : string & , const detail : : exception & ) <nl> - { <nl> - return false ; <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / lexer . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / <nl> - / / parser / / <nl> - / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief syntax analysis <nl> - <nl> - This class implements a recursive decent parser . <nl> - * / <nl> - template < typename BasicJsonType > <nl> - class parser <nl> - { <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using lexer_t = lexer < BasicJsonType > ; <nl> - using token_type = typename lexer_t : : token_type ; <nl> - <nl> - public : <nl> - enum class parse_event_t : uint8_t <nl> - { <nl> - / / / the parser read ` { ` and started to process a JSON object <nl> - object_start , <nl> - / / / the parser read ` } ` and finished processing a JSON object <nl> - object_end , <nl> - / / / the parser read ` [ ` and started to process a JSON array <nl> - array_start , <nl> - / / / the parser read ` ] ` and finished processing a JSON array <nl> - array_end , <nl> - / / / the parser read a key of a value in an object <nl> - key , <nl> - / / / the parser finished reading a JSON value <nl> - value <nl> - } ; <nl> - <nl> - using parser_callback_t = <nl> - std : : function < bool ( int depth , parse_event_t event , BasicJsonType & parsed ) > ; <nl> - <nl> - / / / a parser reading from an input adapter <nl> - explicit parser ( detail : : input_adapter_t & & adapter , <nl> - const parser_callback_t cb = nullptr , <nl> - const bool allow_exceptions_ = true ) <nl> - : callback ( cb ) , m_lexer ( std : : move ( adapter ) ) , allow_exceptions ( allow_exceptions_ ) <nl> - { <nl> - / / read first token <nl> - get_token ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief public parser interface <nl> - <nl> - @ param [ in ] strict whether to expect the last token to be EOF <nl> - @ param [ in , out ] result parsed JSON value <nl> - <nl> - @ throw parse_error . 101 in case of an unexpected token <nl> - @ throw parse_error . 102 if to_unicode fails or surrogate error <nl> - @ throw parse_error . 103 if to_unicode fails <nl> - * / <nl> - void parse ( const bool strict , BasicJsonType & result ) <nl> - { <nl> - if ( callback ) <nl> - { <nl> - json_sax_dom_callback_parser < BasicJsonType > sdp ( result , callback , allow_exceptions ) ; <nl> - sax_parse_internal ( & sdp ) ; <nl> - result . assert_invariant ( ) ; <nl> - <nl> - / / in strict mode , input must be completely read <nl> - if ( strict and ( get_token ( ) ! = token_type : : end_of_input ) ) <nl> - { <nl> - sdp . parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : end_of_input ) ) ) ; <nl> - } <nl> - <nl> - / / in case of an error , return discarded value <nl> - if ( sdp . is_errored ( ) ) <nl> - { <nl> - result = value_t : : discarded ; <nl> - return ; <nl> - } <nl> - <nl> - / / set top - level value to null if it was discarded by the callback <nl> - / / function <nl> - if ( result . is_discarded ( ) ) <nl> - { <nl> - result = nullptr ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - json_sax_dom_parser < BasicJsonType > sdp ( result , allow_exceptions ) ; <nl> - sax_parse_internal ( & sdp ) ; <nl> - result . assert_invariant ( ) ; <nl> - <nl> - / / in strict mode , input must be completely read <nl> - if ( strict and ( get_token ( ) ! = token_type : : end_of_input ) ) <nl> - { <nl> - sdp . parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : end_of_input ) ) ) ; <nl> - } <nl> - <nl> - / / in case of an error , return discarded value <nl> - if ( sdp . is_errored ( ) ) <nl> - { <nl> - result = value_t : : discarded ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief public accept interface <nl> - <nl> - @ param [ in ] strict whether to expect the last token to be EOF <nl> - @ return whether the input is a proper JSON text <nl> - * / <nl> - bool accept ( const bool strict = true ) <nl> - { <nl> - json_sax_acceptor < BasicJsonType > sax_acceptor ; <nl> - return sax_parse ( & sax_acceptor , strict ) ; <nl> - } <nl> - <nl> - template < typename SAX > <nl> - bool sax_parse ( SAX * sax , const bool strict = true ) <nl> - { <nl> - ( void ) detail : : is_sax_static_asserts < SAX , BasicJsonType > { } ; <nl> - const bool result = sax_parse_internal ( sax ) ; <nl> - <nl> - / / strict mode : next byte must be EOF <nl> - if ( result and strict and ( get_token ( ) ! = token_type : : end_of_input ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : end_of_input ) ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - private : <nl> - template < typename SAX > <nl> - bool sax_parse_internal ( SAX * sax ) <nl> - { <nl> - / / stack to remember the hieararchy of structured values we are parsing <nl> - / / true = array ; false = object <nl> - std : : vector < bool > states ; <nl> - / / value to avoid a goto ( see comment where set to true ) <nl> - bool skip_to_state_evaluation = false ; <nl> - <nl> - while ( true ) <nl> - { <nl> - if ( not skip_to_state_evaluation ) <nl> - { <nl> - / / invariant : get_token ( ) was called before each iteration <nl> - switch ( last_token ) <nl> - { <nl> - case token_type : : begin_object : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_object ( std : : size_t ( - 1 ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / closing } - > we are done <nl> - if ( get_token ( ) = = token_type : : end_object ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > end_object ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / parse key <nl> - if ( JSON_UNLIKELY ( last_token ! = token_type : : value_string ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : value_string ) ) ) ; <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > key ( m_lexer . get_string ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - / / parse separator ( : ) <nl> - if ( JSON_UNLIKELY ( get_token ( ) ! = token_type : : name_separator ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : name_separator ) ) ) ; <nl> - } <nl> - <nl> - / / remember we are now inside an object <nl> - states . push_back ( false ) ; <nl> - <nl> - / / parse values <nl> - get_token ( ) ; <nl> - continue ; <nl> - } <nl> - <nl> - case token_type : : begin_array : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_array ( std : : size_t ( - 1 ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / closing ] - > we are done <nl> - if ( get_token ( ) = = token_type : : end_array ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > end_array ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / remember we are now inside an array <nl> - states . push_back ( true ) ; <nl> - <nl> - / / parse values ( no need to call get_token ) <nl> - continue ; <nl> - } <nl> - <nl> - case token_type : : value_float : <nl> - { <nl> - const auto res = m_lexer . get_number_float ( ) ; <nl> - <nl> - if ( JSON_UNLIKELY ( not std : : isfinite ( res ) ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - out_of_range : : create ( 406 , " number overflow parsing ' " + m_lexer . get_token_string ( ) + " ' " ) ) ; <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > number_float ( res , m_lexer . get_string ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - case token_type : : literal_false : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > boolean ( false ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : literal_null : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > null ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : literal_true : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > boolean ( true ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : value_integer : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > number_integer ( m_lexer . get_number_integer ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : value_string : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > string ( m_lexer . get_string ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : value_unsigned : <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > number_unsigned ( m_lexer . get_number_unsigned ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case token_type : : parse_error : <nl> - { <nl> - / / using " uninitialized " to avoid " expected " message <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : uninitialized ) ) ) ; <nl> - } <nl> - <nl> - default : / / the last token was unexpected <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : literal_or_value ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - skip_to_state_evaluation = false ; <nl> - } <nl> - <nl> - / / we reached this line after we successfully parsed a value <nl> - if ( states . empty ( ) ) <nl> - { <nl> - / / empty stack : we reached the end of the hieararchy : done <nl> - return true ; <nl> - } <nl> - else <nl> - { <nl> - if ( states . back ( ) ) / / array <nl> - { <nl> - / / comma - > next value <nl> - if ( get_token ( ) = = token_type : : value_separator ) <nl> - { <nl> - / / parse a new value <nl> - get_token ( ) ; <nl> - continue ; <nl> - } <nl> - <nl> - / / closing ] <nl> - if ( JSON_LIKELY ( last_token = = token_type : : end_array ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > end_array ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / We are done with this array . Before we can parse a <nl> - / / new value , we need to evaluate the new state first . <nl> - / / By setting skip_to_state_evaluation to false , we <nl> - / / are effectively jumping to the beginning of this if . <nl> - assert ( not states . empty ( ) ) ; <nl> - states . pop_back ( ) ; <nl> - skip_to_state_evaluation = true ; <nl> - continue ; <nl> - } <nl> - else <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : end_array ) ) ) ; <nl> - } <nl> - } <nl> - else / / object <nl> - { <nl> - / / comma - > next value <nl> - if ( get_token ( ) = = token_type : : value_separator ) <nl> - { <nl> - / / parse key <nl> - if ( JSON_UNLIKELY ( get_token ( ) ! = token_type : : value_string ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : value_string ) ) ) ; <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > key ( m_lexer . get_string ( ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - / / parse separator ( : ) <nl> - if ( JSON_UNLIKELY ( get_token ( ) ! = token_type : : name_separator ) ) <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : name_separator ) ) ) ; <nl> - } <nl> - <nl> - / / parse values <nl> - get_token ( ) ; <nl> - continue ; <nl> - } <nl> - <nl> - / / closing } <nl> - if ( JSON_LIKELY ( last_token = = token_type : : end_object ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > end_object ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / We are done with this object . Before we can parse a <nl> - / / new value , we need to evaluate the new state first . <nl> - / / By setting skip_to_state_evaluation to false , we <nl> - / / are effectively jumping to the beginning of this if . <nl> - assert ( not states . empty ( ) ) ; <nl> - states . pop_back ( ) ; <nl> - skip_to_state_evaluation = true ; <nl> - continue ; <nl> - } <nl> - else <nl> - { <nl> - return sax - > parse_error ( m_lexer . get_position ( ) , <nl> - m_lexer . get_token_string ( ) , <nl> - parse_error : : create ( 101 , m_lexer . get_position ( ) , exception_message ( token_type : : end_object ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / get next token from lexer <nl> - token_type get_token ( ) <nl> - { <nl> - return ( last_token = m_lexer . scan ( ) ) ; <nl> - } <nl> - <nl> - std : : string exception_message ( const token_type expected ) <nl> - { <nl> - std : : string error_msg = " syntax error - " ; <nl> - if ( last_token = = token_type : : parse_error ) <nl> - { <nl> - error_msg + = std : : string ( m_lexer . get_error_message ( ) ) + " ; last read : ' " + <nl> - m_lexer . get_token_string ( ) + " ' " ; <nl> - } <nl> - else <nl> - { <nl> - error_msg + = " unexpected " + std : : string ( lexer_t : : token_type_name ( last_token ) ) ; <nl> - } <nl> - <nl> - if ( expected ! = token_type : : uninitialized ) <nl> - { <nl> - error_msg + = " ; expected " + std : : string ( lexer_t : : token_type_name ( expected ) ) ; <nl> - } <nl> - <nl> - return error_msg ; <nl> - } <nl> - <nl> - private : <nl> - / / / callback function <nl> - const parser_callback_t callback = nullptr ; <nl> - / / / the type of the last read token <nl> - token_type last_token = token_type : : uninitialized ; <nl> - / / / the lexer <nl> - lexer_t m_lexer ; <nl> - / / / whether to throw exceptions in case of errors <nl> - const bool allow_exceptions = true ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / iterators / primitive_iterator . hpp > <nl> - <nl> - <nl> - # include < cstddef > / / ptrdiff_t <nl> - # include < limits > / / numeric_limits <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / * <nl> - @ brief an iterator for primitive JSON types <nl> - <nl> - This class models an iterator for primitive JSON types ( boolean , number , <nl> - string ) . It ' s only purpose is to allow the iterator / const_iterator classes <nl> - to " iterate " over primitive values . Internally , the iterator is modeled by <nl> - a ` difference_type ` variable . Value begin_value ( ` 0 ` ) models the begin , <nl> - end_value ( ` 1 ` ) models past the end . <nl> - * / <nl> - class primitive_iterator_t <nl> - { <nl> - private : <nl> - using difference_type = std : : ptrdiff_t ; <nl> - static constexpr difference_type begin_value = 0 ; <nl> - static constexpr difference_type end_value = begin_value + 1 ; <nl> - <nl> - / / / iterator as signed integer type <nl> - difference_type m_it = ( std : : numeric_limits < std : : ptrdiff_t > : : min ) ( ) ; <nl> - <nl> - public : <nl> - constexpr difference_type get_value ( ) const noexcept <nl> - { <nl> - return m_it ; <nl> - } <nl> - <nl> - / / / set iterator to a defined beginning <nl> - void set_begin ( ) noexcept <nl> - { <nl> - m_it = begin_value ; <nl> - } <nl> - <nl> - / / / set iterator to a defined past the end <nl> - void set_end ( ) noexcept <nl> - { <nl> - m_it = end_value ; <nl> - } <nl> - <nl> - / / / return whether the iterator can be dereferenced <nl> - constexpr bool is_begin ( ) const noexcept <nl> - { <nl> - return m_it = = begin_value ; <nl> - } <nl> - <nl> - / / / return whether the iterator is at end <nl> - constexpr bool is_end ( ) const noexcept <nl> - { <nl> - return m_it = = end_value ; <nl> - } <nl> - <nl> - friend constexpr bool operator = = ( primitive_iterator_t lhs , primitive_iterator_t rhs ) noexcept <nl> - { <nl> - return lhs . m_it = = rhs . m_it ; <nl> - } <nl> - <nl> - friend constexpr bool operator < ( primitive_iterator_t lhs , primitive_iterator_t rhs ) noexcept <nl> - { <nl> - return lhs . m_it < rhs . m_it ; <nl> - } <nl> - <nl> - primitive_iterator_t operator + ( difference_type n ) noexcept <nl> - { <nl> - auto result = * this ; <nl> - result + = n ; <nl> - return result ; <nl> - } <nl> - <nl> - friend constexpr difference_type operator - ( primitive_iterator_t lhs , primitive_iterator_t rhs ) noexcept <nl> - { <nl> - return lhs . m_it - rhs . m_it ; <nl> - } <nl> - <nl> - primitive_iterator_t & operator + + ( ) noexcept <nl> - { <nl> - + + m_it ; <nl> - return * this ; <nl> - } <nl> - <nl> - primitive_iterator_t const operator + + ( int ) noexcept <nl> - { <nl> - auto result = * this ; <nl> - + + m_it ; <nl> - return result ; <nl> - } <nl> - <nl> - primitive_iterator_t & operator - - ( ) noexcept <nl> - { <nl> - - - m_it ; <nl> - return * this ; <nl> - } <nl> - <nl> - primitive_iterator_t const operator - - ( int ) noexcept <nl> - { <nl> - auto result = * this ; <nl> - - - m_it ; <nl> - return result ; <nl> - } <nl> - <nl> - primitive_iterator_t & operator + = ( difference_type n ) noexcept <nl> - { <nl> - m_it + = n ; <nl> - return * this ; <nl> - } <nl> - <nl> - primitive_iterator_t & operator - = ( difference_type n ) noexcept <nl> - { <nl> - m_it - = n ; <nl> - return * this ; <nl> - } <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / iterators / internal_iterator . hpp > <nl> - <nl> - <nl> - / / # include < nlohmann / detail / iterators / primitive_iterator . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / * ! <nl> - @ brief an iterator value <nl> - <nl> - @ note This structure could easily be a union , but MSVC currently does not allow <nl> - unions members with complex constructors , see https : / / github . com / nlohmann / json / pull / 105 . <nl> - * / <nl> - template < typename BasicJsonType > struct internal_iterator <nl> - { <nl> - / / / iterator for JSON objects <nl> - typename BasicJsonType : : object_t : : iterator object_iterator { } ; <nl> - / / / iterator for JSON arrays <nl> - typename BasicJsonType : : array_t : : iterator array_iterator { } ; <nl> - / / / generic iterator for all other types <nl> - primitive_iterator_t primitive_iterator { } ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / iterators / iter_impl . hpp > <nl> - <nl> - <nl> - # include < ciso646 > / / not <nl> - # include < iterator > / / iterator , random_access_iterator_tag , bidirectional_iterator_tag , advance , next <nl> - # include < type_traits > / / conditional , is_const , remove_const <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / iterators / internal_iterator . hpp > <nl> - <nl> - / / # include < nlohmann / detail / iterators / primitive_iterator . hpp > <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / forward declare , to be able to friend it later on <nl> - template < typename IteratorType > class iteration_proxy ; <nl> - <nl> - / * ! <nl> - @ brief a template for a bidirectional iterator for the @ ref basic_json class <nl> - <nl> - This class implements a both iterators ( iterator and const_iterator ) for the <nl> - @ ref basic_json class . <nl> - <nl> - @ note An iterator is called * initialized * when a pointer to a JSON value has <nl> - been set ( e . g . , by a constructor or a copy assignment ) . If the iterator is <nl> - default - constructed , it is * uninitialized * and most methods are undefined . <nl> - * * The library uses assertions to detect calls on uninitialized iterators . * * <nl> - <nl> - @ requirement The class satisfies the following concept requirements : <nl> - - <nl> - [ BidirectionalIterator ] ( https : / / en . cppreference . com / w / cpp / named_req / BidirectionalIterator ) : <nl> - The iterator that can be moved can be moved in both directions ( i . e . <nl> - incremented and decremented ) . <nl> - <nl> - @ since version 1 . 0 . 0 , simplified in version 2 . 0 . 9 , change to bidirectional <nl> - iterators in version 3 . 0 . 0 ( see https : / / github . com / nlohmann / json / issues / 593 ) <nl> - * / <nl> - template < typename BasicJsonType > <nl> - class iter_impl <nl> - { <nl> - / / / allow basic_json to access private members <nl> - friend iter_impl < typename std : : conditional < std : : is_const < BasicJsonType > : : value , typename std : : remove_const < BasicJsonType > : : type , const BasicJsonType > : : type > ; <nl> - friend BasicJsonType ; <nl> - friend iteration_proxy < iter_impl > ; <nl> - <nl> - using object_t = typename BasicJsonType : : object_t ; <nl> - using array_t = typename BasicJsonType : : array_t ; <nl> - / / make sure BasicJsonType is basic_json or const basic_json <nl> - static_assert ( is_basic_json < typename std : : remove_const < BasicJsonType > : : type > : : value , <nl> - " iter_impl only accepts ( const ) basic_json " ) ; <nl> - <nl> - public : <nl> - <nl> - / / / The std : : iterator class template ( used as a base class to provide typedefs ) is deprecated in C + + 17 . <nl> - / / / The C + + Standard has never required user - defined iterators to derive from std : : iterator . <nl> - / / / A user - defined iterator should provide publicly accessible typedefs named <nl> - / / / iterator_category , value_type , difference_type , pointer , and reference . <nl> - / / / Note that value_type is required to be non - const , even for constant iterators . <nl> - using iterator_category = std : : bidirectional_iterator_tag ; <nl> - <nl> - / / / the type of the values when the iterator is dereferenced <nl> - using value_type = typename BasicJsonType : : value_type ; <nl> - / / / a type to represent differences between iterators <nl> - using difference_type = typename BasicJsonType : : difference_type ; <nl> - / / / defines a pointer to the type iterated over ( value_type ) <nl> - using pointer = typename std : : conditional < std : : is_const < BasicJsonType > : : value , <nl> - typename BasicJsonType : : const_pointer , <nl> - typename BasicJsonType : : pointer > : : type ; <nl> - / / / defines a reference to the type iterated over ( value_type ) <nl> - using reference = <nl> - typename std : : conditional < std : : is_const < BasicJsonType > : : value , <nl> - typename BasicJsonType : : const_reference , <nl> - typename BasicJsonType : : reference > : : type ; <nl> - <nl> - / / / default constructor <nl> - iter_impl ( ) = default ; <nl> - <nl> - / * ! <nl> - @ brief constructor for a given JSON instance <nl> - @ param [ in ] object pointer to a JSON object for this iterator <nl> - @ pre object ! = nullptr <nl> - @ post The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - explicit iter_impl ( pointer object ) noexcept : m_object ( object ) <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - m_it . object_iterator = typename object_t : : iterator ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_it . array_iterator = typename array_t : : iterator ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - m_it . primitive_iterator = primitive_iterator_t ( ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ note The conventional copy constructor and copy assignment are implicitly <nl> - defined . Combined with the following converting constructor and <nl> - assignment , they support : ( 1 ) copy from iterator to iterator , ( 2 ) <nl> - copy from const iterator to const iterator , and ( 3 ) conversion from <nl> - iterator to const iterator . However conversion from const iterator <nl> - to iterator is not defined . <nl> - * / <nl> - <nl> - / * ! <nl> - @ brief converting constructor <nl> - @ param [ in ] other non - const iterator to copy from <nl> - @ note It is not checked whether @ a other is initialized . <nl> - * / <nl> - iter_impl ( const iter_impl < typename std : : remove_const < BasicJsonType > : : type > & other ) noexcept <nl> - : m_object ( other . m_object ) , m_it ( other . m_it ) { } <nl> - <nl> - / * ! <nl> - @ brief converting assignment <nl> - @ param [ in , out ] other non - const iterator to copy from <nl> - @ return const / non - const iterator <nl> - @ note It is not checked whether @ a other is initialized . <nl> - * / <nl> - iter_impl & operator = ( const iter_impl < typename std : : remove_const < BasicJsonType > : : type > & other ) noexcept <nl> - { <nl> - m_object = other . m_object ; <nl> - m_it = other . m_it ; <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ brief set the iterator to the first value <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - void set_begin ( ) noexcept <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - m_it . object_iterator = m_object - > m_value . object - > begin ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_it . array_iterator = m_object - > m_value . array - > begin ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : null : <nl> - { <nl> - / / set to end so begin ( ) = = end ( ) is true : null is empty <nl> - m_it . primitive_iterator . set_end ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - m_it . primitive_iterator . set_begin ( ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief set the iterator past the last value <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - void set_end ( ) noexcept <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - m_it . object_iterator = m_object - > m_value . object - > end ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_it . array_iterator = m_object - > m_value . array - > end ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - m_it . primitive_iterator . set_end ( ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - public : <nl> - / * ! <nl> - @ brief return a reference to the value pointed to by the iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - reference operator * ( ) const <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - assert ( m_it . object_iterator ! = m_object - > m_value . object - > end ( ) ) ; <nl> - return m_it . object_iterator - > second ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - assert ( m_it . array_iterator ! = m_object - > m_value . array - > end ( ) ) ; <nl> - return * m_it . array_iterator ; <nl> - } <nl> - <nl> - case value_t : : null : <nl> - JSON_THROW ( invalid_iterator : : create ( 214 , " cannot get value " ) ) ; <nl> - <nl> - default : <nl> - { <nl> - if ( JSON_LIKELY ( m_it . primitive_iterator . is_begin ( ) ) ) <nl> - { <nl> - return * m_object ; <nl> - } <nl> - <nl> - JSON_THROW ( invalid_iterator : : create ( 214 , " cannot get value " ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief dereference the iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - pointer operator - > ( ) const <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - assert ( m_it . object_iterator ! = m_object - > m_value . object - > end ( ) ) ; <nl> - return & ( m_it . object_iterator - > second ) ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - assert ( m_it . array_iterator ! = m_object - > m_value . array - > end ( ) ) ; <nl> - return & * m_it . array_iterator ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - if ( JSON_LIKELY ( m_it . primitive_iterator . is_begin ( ) ) ) <nl> - { <nl> - return m_object ; <nl> - } <nl> - <nl> - JSON_THROW ( invalid_iterator : : create ( 214 , " cannot get value " ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief post - increment ( it + + ) <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl const operator + + ( int ) <nl> - { <nl> - auto result = * this ; <nl> - + + ( * this ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief pre - increment ( + + it ) <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl & operator + + ( ) <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - std : : advance ( m_it . object_iterator , 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - std : : advance ( m_it . array_iterator , 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - + + m_it . primitive_iterator ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief post - decrement ( it - - ) <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl const operator - - ( int ) <nl> - { <nl> - auto result = * this ; <nl> - - - ( * this ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief pre - decrement ( - - it ) <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl & operator - - ( ) <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - std : : advance ( m_it . object_iterator , - 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - std : : advance ( m_it . array_iterator , - 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - - - m_it . primitive_iterator ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : equal <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator = = ( const iter_impl & other ) const <nl> - { <nl> - / / if objects are not the same , the comparison is undefined <nl> - if ( JSON_UNLIKELY ( m_object ! = other . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 212 , " cannot compare iterators of different containers " ) ) ; <nl> - } <nl> - <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - return ( m_it . object_iterator = = other . m_it . object_iterator ) ; <nl> - <nl> - case value_t : : array : <nl> - return ( m_it . array_iterator = = other . m_it . array_iterator ) ; <nl> - <nl> - default : <nl> - return ( m_it . primitive_iterator = = other . m_it . primitive_iterator ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : not equal <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator ! = ( const iter_impl & other ) const <nl> - { <nl> - return not operator = = ( other ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : smaller <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator < ( const iter_impl & other ) const <nl> - { <nl> - / / if objects are not the same , the comparison is undefined <nl> - if ( JSON_UNLIKELY ( m_object ! = other . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 212 , " cannot compare iterators of different containers " ) ) ; <nl> - } <nl> - <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - JSON_THROW ( invalid_iterator : : create ( 213 , " cannot compare order of object iterators " ) ) ; <nl> - <nl> - case value_t : : array : <nl> - return ( m_it . array_iterator < other . m_it . array_iterator ) ; <nl> - <nl> - default : <nl> - return ( m_it . primitive_iterator < other . m_it . primitive_iterator ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than or equal <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator < = ( const iter_impl & other ) const <nl> - { <nl> - return not other . operator < ( * this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator > ( const iter_impl & other ) const <nl> - { <nl> - return not operator < = ( other ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than or equal <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - bool operator > = ( const iter_impl & other ) const <nl> - { <nl> - return not operator < ( other ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add to iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl & operator + = ( difference_type i ) <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - JSON_THROW ( invalid_iterator : : create ( 209 , " cannot use offsets with object iterators " ) ) ; <nl> - <nl> - case value_t : : array : <nl> - { <nl> - std : : advance ( m_it . array_iterator , i ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - m_it . primitive_iterator + = i ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief subtract from iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl & operator - = ( difference_type i ) <nl> - { <nl> - return operator + = ( - i ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add to iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl operator + ( difference_type i ) const <nl> - { <nl> - auto result = * this ; <nl> - result + = i ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief addition of distance and iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - friend iter_impl operator + ( difference_type i , const iter_impl & it ) <nl> - { <nl> - auto result = it ; <nl> - result + = i ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief subtract from iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - iter_impl operator - ( difference_type i ) const <nl> - { <nl> - auto result = * this ; <nl> - result - = i ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return difference <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - difference_type operator - ( const iter_impl & other ) const <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - JSON_THROW ( invalid_iterator : : create ( 209 , " cannot use offsets with object iterators " ) ) ; <nl> - <nl> - case value_t : : array : <nl> - return m_it . array_iterator - other . m_it . array_iterator ; <nl> - <nl> - default : <nl> - return m_it . primitive_iterator - other . m_it . primitive_iterator ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access to successor <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - reference operator [ ] ( difference_type n ) const <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - switch ( m_object - > m_type ) <nl> - { <nl> - case value_t : : object : <nl> - JSON_THROW ( invalid_iterator : : create ( 208 , " cannot use operator [ ] for object iterators " ) ) ; <nl> - <nl> - case value_t : : array : <nl> - return * std : : next ( m_it . array_iterator , n ) ; <nl> - <nl> - case value_t : : null : <nl> - JSON_THROW ( invalid_iterator : : create ( 214 , " cannot get value " ) ) ; <nl> - <nl> - default : <nl> - { <nl> - if ( JSON_LIKELY ( m_it . primitive_iterator . get_value ( ) = = - n ) ) <nl> - { <nl> - return * m_object ; <nl> - } <nl> - <nl> - JSON_THROW ( invalid_iterator : : create ( 214 , " cannot get value " ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return the key of an object iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - const typename object_t : : key_type & key ( ) const <nl> - { <nl> - assert ( m_object ! = nullptr ) ; <nl> - <nl> - if ( JSON_LIKELY ( m_object - > is_object ( ) ) ) <nl> - { <nl> - return m_it . object_iterator - > first ; <nl> - } <nl> - <nl> - JSON_THROW ( invalid_iterator : : create ( 207 , " cannot use key ( ) for non - object iterators " ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return the value of an iterator <nl> - @ pre The iterator is initialized ; i . e . ` m_object ! = nullptr ` . <nl> - * / <nl> - reference value ( ) const <nl> - { <nl> - return operator * ( ) ; <nl> - } <nl> - <nl> - private : <nl> - / / / associated JSON instance <nl> - pointer m_object = nullptr ; <nl> - / / / the actual iterator of the associated instance <nl> - internal_iterator < typename std : : remove_const < BasicJsonType > : : type > m_it ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / iterators / iteration_proxy . hpp > <nl> - <nl> - / / # include < nlohmann / detail / iterators / json_reverse_iterator . hpp > <nl> - <nl> - <nl> - # include < cstddef > / / ptrdiff_t <nl> - # include < iterator > / / reverse_iterator <nl> - # include < utility > / / declval <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / <nl> - / / reverse_iterator / / <nl> - / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief a template for a reverse iterator class <nl> - <nl> - @ tparam Base the base iterator type to reverse . Valid types are @ ref <nl> - iterator ( to create @ ref reverse_iterator ) and @ ref const_iterator ( to <nl> - create @ ref const_reverse_iterator ) . <nl> - <nl> - @ requirement The class satisfies the following concept requirements : <nl> - - <nl> - [ BidirectionalIterator ] ( https : / / en . cppreference . com / w / cpp / named_req / BidirectionalIterator ) : <nl> - The iterator that can be moved can be moved in both directions ( i . e . <nl> - incremented and decremented ) . <nl> - - [ OutputIterator ] ( https : / / en . cppreference . com / w / cpp / named_req / OutputIterator ) : <nl> - It is possible to write to the pointed - to element ( only if @ a Base is <nl> - @ ref iterator ) . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename Base > <nl> - class json_reverse_iterator : public std : : reverse_iterator < Base > <nl> - { <nl> - public : <nl> - using difference_type = std : : ptrdiff_t ; <nl> - / / / shortcut to the reverse iterator adapter <nl> - using base_iterator = std : : reverse_iterator < Base > ; <nl> - / / / the reference type for the pointed - to element <nl> - using reference = typename Base : : reference ; <nl> - <nl> - / / / create reverse iterator from iterator <nl> - explicit json_reverse_iterator ( const typename base_iterator : : iterator_type & it ) noexcept <nl> - : base_iterator ( it ) { } <nl> - <nl> - / / / create reverse iterator from base class <nl> - explicit json_reverse_iterator ( const base_iterator & it ) noexcept : base_iterator ( it ) { } <nl> - <nl> - / / / post - increment ( it + + ) <nl> - json_reverse_iterator const operator + + ( int ) <nl> - { <nl> - return static_cast < json_reverse_iterator > ( base_iterator : : operator + + ( 1 ) ) ; <nl> - } <nl> - <nl> - / / / pre - increment ( + + it ) <nl> - json_reverse_iterator & operator + + ( ) <nl> - { <nl> - return static_cast < json_reverse_iterator & > ( base_iterator : : operator + + ( ) ) ; <nl> - } <nl> - <nl> - / / / post - decrement ( it - - ) <nl> - json_reverse_iterator const operator - - ( int ) <nl> - { <nl> - return static_cast < json_reverse_iterator > ( base_iterator : : operator - - ( 1 ) ) ; <nl> - } <nl> - <nl> - / / / pre - decrement ( - - it ) <nl> - json_reverse_iterator & operator - - ( ) <nl> - { <nl> - return static_cast < json_reverse_iterator & > ( base_iterator : : operator - - ( ) ) ; <nl> - } <nl> - <nl> - / / / add to iterator <nl> - json_reverse_iterator & operator + = ( difference_type i ) <nl> - { <nl> - return static_cast < json_reverse_iterator & > ( base_iterator : : operator + = ( i ) ) ; <nl> - } <nl> - <nl> - / / / add to iterator <nl> - json_reverse_iterator operator + ( difference_type i ) const <nl> - { <nl> - return static_cast < json_reverse_iterator > ( base_iterator : : operator + ( i ) ) ; <nl> - } <nl> - <nl> - / / / subtract from iterator <nl> - json_reverse_iterator operator - ( difference_type i ) const <nl> - { <nl> - return static_cast < json_reverse_iterator > ( base_iterator : : operator - ( i ) ) ; <nl> - } <nl> - <nl> - / / / return difference <nl> - difference_type operator - ( const json_reverse_iterator & other ) const <nl> - { <nl> - return base_iterator ( * this ) - base_iterator ( other ) ; <nl> - } <nl> - <nl> - / / / access to successor <nl> - reference operator [ ] ( difference_type n ) const <nl> - { <nl> - return * ( this - > operator + ( n ) ) ; <nl> - } <nl> - <nl> - / / / return the key of an object iterator <nl> - auto key ( ) const - > decltype ( std : : declval < Base > ( ) . key ( ) ) <nl> - { <nl> - auto it = - - this - > base ( ) ; <nl> - return it . key ( ) ; <nl> - } <nl> - <nl> - / / / return the value of an iterator <nl> - reference value ( ) const <nl> - { <nl> - auto it = - - this - > base ( ) ; <nl> - return it . operator * ( ) ; <nl> - } <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / output / output_adapters . hpp > <nl> - <nl> - <nl> - # include < algorithm > / / copy <nl> - # include < cstddef > / / size_t <nl> - # include < ios > / / streamsize <nl> - # include < iterator > / / back_inserter <nl> - # include < memory > / / shared_ptr , make_shared <nl> - # include < ostream > / / basic_ostream <nl> - # include < string > / / basic_string <nl> - # include < vector > / / vector <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / abstract output adapter interface <nl> - template < typename CharType > struct output_adapter_protocol <nl> - { <nl> - virtual void write_character ( CharType c ) = 0 ; <nl> - virtual void write_characters ( const CharType * s , std : : size_t length ) = 0 ; <nl> - virtual ~ output_adapter_protocol ( ) = default ; <nl> - } ; <nl> - <nl> - / / / a type to simplify interfaces <nl> - template < typename CharType > <nl> - using output_adapter_t = std : : shared_ptr < output_adapter_protocol < CharType > > ; <nl> - <nl> - / / / output adapter for byte vectors <nl> - template < typename CharType > <nl> - class output_vector_adapter : public output_adapter_protocol < CharType > <nl> - { <nl> - public : <nl> - explicit output_vector_adapter ( std : : vector < CharType > & vec ) : v ( vec ) { } <nl> - <nl> - void write_character ( CharType c ) override <nl> - { <nl> - v . push_back ( c ) ; <nl> - } <nl> - <nl> - void write_characters ( const CharType * s , std : : size_t length ) override <nl> - { <nl> - std : : copy ( s , s + length , std : : back_inserter ( v ) ) ; <nl> - } <nl> - <nl> - private : <nl> - std : : vector < CharType > & v ; <nl> - } ; <nl> - <nl> - / / / output adapter for output streams <nl> - template < typename CharType > <nl> - class output_stream_adapter : public output_adapter_protocol < CharType > <nl> - { <nl> - public : <nl> - explicit output_stream_adapter ( std : : basic_ostream < CharType > & s ) : stream ( s ) { } <nl> - <nl> - void write_character ( CharType c ) override <nl> - { <nl> - stream . put ( c ) ; <nl> - } <nl> - <nl> - void write_characters ( const CharType * s , std : : size_t length ) override <nl> - { <nl> - stream . write ( s , static_cast < std : : streamsize > ( length ) ) ; <nl> - } <nl> - <nl> - private : <nl> - std : : basic_ostream < CharType > & stream ; <nl> - } ; <nl> - <nl> - / / / output adapter for basic_string <nl> - template < typename CharType , typename StringType = std : : basic_string < CharType > > <nl> - class output_string_adapter : public output_adapter_protocol < CharType > <nl> - { <nl> - public : <nl> - explicit output_string_adapter ( StringType & s ) : str ( s ) { } <nl> - <nl> - void write_character ( CharType c ) override <nl> - { <nl> - str . push_back ( c ) ; <nl> - } <nl> - <nl> - void write_characters ( const CharType * s , std : : size_t length ) override <nl> - { <nl> - str . append ( s , length ) ; <nl> - } <nl> - <nl> - private : <nl> - StringType & str ; <nl> - } ; <nl> - <nl> - template < typename CharType , typename StringType = std : : basic_string < CharType > > <nl> - class output_adapter <nl> - { <nl> - public : <nl> - output_adapter ( std : : vector < CharType > & vec ) <nl> - : oa ( std : : make_shared < output_vector_adapter < CharType > > ( vec ) ) { } <nl> - <nl> - output_adapter ( std : : basic_ostream < CharType > & s ) <nl> - : oa ( std : : make_shared < output_stream_adapter < CharType > > ( s ) ) { } <nl> - <nl> - output_adapter ( StringType & s ) <nl> - : oa ( std : : make_shared < output_string_adapter < CharType , StringType > > ( s ) ) { } <nl> - <nl> - operator output_adapter_t < CharType > ( ) <nl> - { <nl> - return oa ; <nl> - } <nl> - <nl> - private : <nl> - output_adapter_t < CharType > oa = nullptr ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / input / binary_reader . hpp > <nl> - <nl> - <nl> - # include < algorithm > / / generate_n <nl> - # include < array > / / array <nl> - # include < cassert > / / assert <nl> - # include < cmath > / / ldexp <nl> - # include < cstddef > / / size_t <nl> - # include < cstdint > / / uint8_t , uint16_t , uint32_t , uint64_t <nl> - # include < cstdio > / / snprintf <nl> - # include < cstring > / / memcpy <nl> - # include < iterator > / / back_inserter <nl> - # include < limits > / / numeric_limits <nl> - # include < string > / / char_traits , string <nl> - # include < utility > / / make_pair , move <nl> - <nl> - / / # include < nlohmann / detail / input / input_adapters . hpp > <nl> - <nl> - / / # include < nlohmann / detail / input / json_sax . hpp > <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / is_sax . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / <nl> - / / binary reader / / <nl> - / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief deserialization of CBOR , MessagePack , and UBJSON values <nl> - * / <nl> - template < typename BasicJsonType , typename SAX = json_sax_dom_parser < BasicJsonType > > <nl> - class binary_reader <nl> - { <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using json_sax_t = SAX ; <nl> - <nl> - public : <nl> - / * ! <nl> - @ brief create a binary reader <nl> - <nl> - @ param [ in ] adapter input adapter to read from <nl> - * / <nl> - explicit binary_reader ( input_adapter_t adapter ) : ia ( std : : move ( adapter ) ) <nl> - { <nl> - ( void ) detail : : is_sax_static_asserts < SAX , BasicJsonType > { } ; <nl> - assert ( ia ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] format the binary format to parse <nl> - @ param [ in ] sax_ a SAX event processor <nl> - @ param [ in ] strict whether to expect the input to be consumed completed <nl> - <nl> - @ return <nl> - * / <nl> - bool sax_parse ( const input_format_t format , <nl> - json_sax_t * sax_ , <nl> - const bool strict = true ) <nl> - { <nl> - sax = sax_ ; <nl> - bool result ; <nl> - <nl> - switch ( format ) <nl> - { <nl> - case input_format_t : : cbor : <nl> - result = parse_cbor_internal ( ) ; <nl> - break ; <nl> - <nl> - case input_format_t : : msgpack : <nl> - result = parse_msgpack_internal ( ) ; <nl> - break ; <nl> - <nl> - case input_format_t : : ubjson : <nl> - result = parse_ubjson_internal ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - assert ( false ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - <nl> - / / strict mode : next byte must be EOF <nl> - if ( result and strict ) <nl> - { <nl> - if ( format = = input_format_t : : ubjson ) <nl> - { <nl> - get_ignore_noop ( ) ; <nl> - } <nl> - else <nl> - { <nl> - get ( ) ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( current ! = std : : char_traits < char > : : eof ( ) ) ) <nl> - { <nl> - return sax - > parse_error ( chars_read , get_token_string ( ) , parse_error : : create ( 110 , chars_read , " expected end of input " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief determine system byte order <nl> - <nl> - @ return true if and only if system ' s byte order is little endian <nl> - <nl> - @ note from http : / / stackoverflow . com / a / 1001328 / 266378 <nl> - * / <nl> - static constexpr bool little_endianess ( int num = 1 ) noexcept <nl> - { <nl> - return ( * reinterpret_cast < char * > ( & num ) = = 1 ) ; <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ param [ in ] get_char whether a new character should be retrieved from the <nl> - input ( true , default ) or whether the last read <nl> - character should be considered instead <nl> - <nl> - @ return whether a valid CBOR value was passed to the SAX parser <nl> - * / <nl> - bool parse_cbor_internal ( const bool get_char = true ) <nl> - { <nl> - switch ( get_char ? get ( ) : current ) <nl> - { <nl> - / / EOF <nl> - case std : : char_traits < char > : : eof ( ) : <nl> - return unexpect_eof ( ) ; <nl> - <nl> - / / Integer 0x00 . . 0x17 ( 0 . . 23 ) <nl> - case 0x00 : <nl> - case 0x01 : <nl> - case 0x02 : <nl> - case 0x03 : <nl> - case 0x04 : <nl> - case 0x05 : <nl> - case 0x06 : <nl> - case 0x07 : <nl> - case 0x08 : <nl> - case 0x09 : <nl> - case 0x0A : <nl> - case 0x0B : <nl> - case 0x0C : <nl> - case 0x0D : <nl> - case 0x0E : <nl> - case 0x0F : <nl> - case 0x10 : <nl> - case 0x11 : <nl> - case 0x12 : <nl> - case 0x13 : <nl> - case 0x14 : <nl> - case 0x15 : <nl> - case 0x16 : <nl> - case 0x17 : <nl> - return sax - > number_unsigned ( static_cast < number_unsigned_t > ( current ) ) ; <nl> - <nl> - case 0x18 : / / Unsigned integer ( one - byte uint8_t follows ) <nl> - { <nl> - uint8_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0x19 : / / Unsigned integer ( two - byte uint16_t follows ) <nl> - { <nl> - uint16_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0x1A : / / Unsigned integer ( four - byte uint32_t follows ) <nl> - { <nl> - uint32_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0x1B : / / Unsigned integer ( eight - byte uint64_t follows ) <nl> - { <nl> - uint64_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - / / Negative integer - 1 - 0x00 . . - 1 - 0x17 ( - 1 . . - 24 ) <nl> - case 0x20 : <nl> - case 0x21 : <nl> - case 0x22 : <nl> - case 0x23 : <nl> - case 0x24 : <nl> - case 0x25 : <nl> - case 0x26 : <nl> - case 0x27 : <nl> - case 0x28 : <nl> - case 0x29 : <nl> - case 0x2A : <nl> - case 0x2B : <nl> - case 0x2C : <nl> - case 0x2D : <nl> - case 0x2E : <nl> - case 0x2F : <nl> - case 0x30 : <nl> - case 0x31 : <nl> - case 0x32 : <nl> - case 0x33 : <nl> - case 0x34 : <nl> - case 0x35 : <nl> - case 0x36 : <nl> - case 0x37 : <nl> - return sax - > number_integer ( static_cast < int8_t > ( 0x20 - 1 - current ) ) ; <nl> - <nl> - case 0x38 : / / Negative integer ( one - byte uint8_t follows ) <nl> - { <nl> - uint8_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( static_cast < number_integer_t > ( - 1 ) - number ) ; <nl> - } <nl> - <nl> - case 0x39 : / / Negative integer - 1 - n ( two - byte uint16_t follows ) <nl> - { <nl> - uint16_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( static_cast < number_integer_t > ( - 1 ) - number ) ; <nl> - } <nl> - <nl> - case 0x3A : / / Negative integer - 1 - n ( four - byte uint32_t follows ) <nl> - { <nl> - uint32_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( static_cast < number_integer_t > ( - 1 ) - number ) ; <nl> - } <nl> - <nl> - case 0x3B : / / Negative integer - 1 - n ( eight - byte uint64_t follows ) <nl> - { <nl> - uint64_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( static_cast < number_integer_t > ( - 1 ) <nl> - - static_cast < number_integer_t > ( number ) ) ; <nl> - } <nl> - <nl> - / / UTF - 8 string ( 0x00 . . 0x17 bytes follow ) <nl> - case 0x60 : <nl> - case 0x61 : <nl> - case 0x62 : <nl> - case 0x63 : <nl> - case 0x64 : <nl> - case 0x65 : <nl> - case 0x66 : <nl> - case 0x67 : <nl> - case 0x68 : <nl> - case 0x69 : <nl> - case 0x6A : <nl> - case 0x6B : <nl> - case 0x6C : <nl> - case 0x6D : <nl> - case 0x6E : <nl> - case 0x6F : <nl> - case 0x70 : <nl> - case 0x71 : <nl> - case 0x72 : <nl> - case 0x73 : <nl> - case 0x74 : <nl> - case 0x75 : <nl> - case 0x76 : <nl> - case 0x77 : <nl> - case 0x78 : / / UTF - 8 string ( one - byte uint8_t for n follows ) <nl> - case 0x79 : / / UTF - 8 string ( two - byte uint16_t for n follow ) <nl> - case 0x7A : / / UTF - 8 string ( four - byte uint32_t for n follow ) <nl> - case 0x7B : / / UTF - 8 string ( eight - byte uint64_t for n follow ) <nl> - case 0x7F : / / UTF - 8 string ( indefinite length ) <nl> - { <nl> - string_t s ; <nl> - return get_cbor_string ( s ) and sax - > string ( s ) ; <nl> - } <nl> - <nl> - / / array ( 0x00 . . 0x17 data items follow ) <nl> - case 0x80 : <nl> - case 0x81 : <nl> - case 0x82 : <nl> - case 0x83 : <nl> - case 0x84 : <nl> - case 0x85 : <nl> - case 0x86 : <nl> - case 0x87 : <nl> - case 0x88 : <nl> - case 0x89 : <nl> - case 0x8A : <nl> - case 0x8B : <nl> - case 0x8C : <nl> - case 0x8D : <nl> - case 0x8E : <nl> - case 0x8F : <nl> - case 0x90 : <nl> - case 0x91 : <nl> - case 0x92 : <nl> - case 0x93 : <nl> - case 0x94 : <nl> - case 0x95 : <nl> - case 0x96 : <nl> - case 0x97 : <nl> - return get_cbor_array ( static_cast < std : : size_t > ( current & 0x1F ) ) ; <nl> - <nl> - case 0x98 : / / array ( one - byte uint8_t for n follows ) <nl> - { <nl> - uint8_t len ; <nl> - return get_number ( len ) and get_cbor_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0x99 : / / array ( two - byte uint16_t for n follow ) <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_cbor_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0x9A : / / array ( four - byte uint32_t for n follow ) <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_cbor_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0x9B : / / array ( eight - byte uint64_t for n follow ) <nl> - { <nl> - uint64_t len ; <nl> - return get_number ( len ) and get_cbor_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0x9F : / / array ( indefinite length ) <nl> - return get_cbor_array ( std : : size_t ( - 1 ) ) ; <nl> - <nl> - / / map ( 0x00 . . 0x17 pairs of data items follow ) <nl> - case 0xA0 : <nl> - case 0xA1 : <nl> - case 0xA2 : <nl> - case 0xA3 : <nl> - case 0xA4 : <nl> - case 0xA5 : <nl> - case 0xA6 : <nl> - case 0xA7 : <nl> - case 0xA8 : <nl> - case 0xA9 : <nl> - case 0xAA : <nl> - case 0xAB : <nl> - case 0xAC : <nl> - case 0xAD : <nl> - case 0xAE : <nl> - case 0xAF : <nl> - case 0xB0 : <nl> - case 0xB1 : <nl> - case 0xB2 : <nl> - case 0xB3 : <nl> - case 0xB4 : <nl> - case 0xB5 : <nl> - case 0xB6 : <nl> - case 0xB7 : <nl> - return get_cbor_object ( static_cast < std : : size_t > ( current & 0x1F ) ) ; <nl> - <nl> - case 0xB8 : / / map ( one - byte uint8_t for n follows ) <nl> - { <nl> - uint8_t len ; <nl> - return get_number ( len ) and get_cbor_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xB9 : / / map ( two - byte uint16_t for n follow ) <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_cbor_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xBA : / / map ( four - byte uint32_t for n follow ) <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_cbor_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xBB : / / map ( eight - byte uint64_t for n follow ) <nl> - { <nl> - uint64_t len ; <nl> - return get_number ( len ) and get_cbor_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xBF : / / map ( indefinite length ) <nl> - return get_cbor_object ( std : : size_t ( - 1 ) ) ; <nl> - <nl> - case 0xF4 : / / false <nl> - return sax - > boolean ( false ) ; <nl> - <nl> - case 0xF5 : / / true <nl> - return sax - > boolean ( true ) ; <nl> - <nl> - case 0xF6 : / / null <nl> - return sax - > null ( ) ; <nl> - <nl> - case 0xF9 : / / Half - Precision Float ( two - byte IEEE 754 ) <nl> - { <nl> - const int byte1 = get ( ) ; <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - const int byte2 = get ( ) ; <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / code from RFC 7049 , Appendix D , Figure 3 : <nl> - / / As half - precision floating - point numbers were only added <nl> - / / to IEEE 754 in 2008 , today ' s programming platforms often <nl> - / / still only have limited support for them . It is very <nl> - / / easy to include at least decoding support for them even <nl> - / / without such support . An example of a small decoder for <nl> - / / half - precision floating - point numbers in the C language <nl> - / / is shown in Fig . 3 . <nl> - const int half = ( byte1 < < 8 ) + byte2 ; <nl> - const double val = [ & half ] <nl> - { <nl> - const int exp = ( half > > 10 ) & 0x1F ; <nl> - const int mant = half & 0x3FF ; <nl> - assert ( 0 < = exp and exp < = 32 ) ; <nl> - assert ( 0 < = mant and mant < = 1024 ) ; <nl> - switch ( exp ) <nl> - { <nl> - case 0 : <nl> - return std : : ldexp ( mant , - 24 ) ; <nl> - case 31 : <nl> - return ( mant = = 0 ) <nl> - ? std : : numeric_limits < double > : : infinity ( ) <nl> - : std : : numeric_limits < double > : : quiet_NaN ( ) ; <nl> - default : <nl> - return std : : ldexp ( mant + 1024 , exp - 25 ) ; <nl> - } <nl> - } ( ) ; <nl> - return sax - > number_float ( ( half & 0x8000 ) ! = 0 <nl> - ? static_cast < number_float_t > ( - val ) <nl> - : static_cast < number_float_t > ( val ) , " " ) ; <nl> - } <nl> - <nl> - case 0xFA : / / Single - Precision Float ( four - byte IEEE 754 ) <nl> - { <nl> - float number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - case 0xFB : / / Double - Precision Float ( eight - byte IEEE 754 ) <nl> - { <nl> - double number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - default : / / anything else ( 0xFF is handled inside the other types ) <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 112 , chars_read , " error reading CBOR ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ return whether a valid MessagePack value was passed to the SAX parser <nl> - * / <nl> - bool parse_msgpack_internal ( ) <nl> - { <nl> - switch ( get ( ) ) <nl> - { <nl> - / / EOF <nl> - case std : : char_traits < char > : : eof ( ) : <nl> - return unexpect_eof ( ) ; <nl> - <nl> - / / positive fixint <nl> - case 0x00 : <nl> - case 0x01 : <nl> - case 0x02 : <nl> - case 0x03 : <nl> - case 0x04 : <nl> - case 0x05 : <nl> - case 0x06 : <nl> - case 0x07 : <nl> - case 0x08 : <nl> - case 0x09 : <nl> - case 0x0A : <nl> - case 0x0B : <nl> - case 0x0C : <nl> - case 0x0D : <nl> - case 0x0E : <nl> - case 0x0F : <nl> - case 0x10 : <nl> - case 0x11 : <nl> - case 0x12 : <nl> - case 0x13 : <nl> - case 0x14 : <nl> - case 0x15 : <nl> - case 0x16 : <nl> - case 0x17 : <nl> - case 0x18 : <nl> - case 0x19 : <nl> - case 0x1A : <nl> - case 0x1B : <nl> - case 0x1C : <nl> - case 0x1D : <nl> - case 0x1E : <nl> - case 0x1F : <nl> - case 0x20 : <nl> - case 0x21 : <nl> - case 0x22 : <nl> - case 0x23 : <nl> - case 0x24 : <nl> - case 0x25 : <nl> - case 0x26 : <nl> - case 0x27 : <nl> - case 0x28 : <nl> - case 0x29 : <nl> - case 0x2A : <nl> - case 0x2B : <nl> - case 0x2C : <nl> - case 0x2D : <nl> - case 0x2E : <nl> - case 0x2F : <nl> - case 0x30 : <nl> - case 0x31 : <nl> - case 0x32 : <nl> - case 0x33 : <nl> - case 0x34 : <nl> - case 0x35 : <nl> - case 0x36 : <nl> - case 0x37 : <nl> - case 0x38 : <nl> - case 0x39 : <nl> - case 0x3A : <nl> - case 0x3B : <nl> - case 0x3C : <nl> - case 0x3D : <nl> - case 0x3E : <nl> - case 0x3F : <nl> - case 0x40 : <nl> - case 0x41 : <nl> - case 0x42 : <nl> - case 0x43 : <nl> - case 0x44 : <nl> - case 0x45 : <nl> - case 0x46 : <nl> - case 0x47 : <nl> - case 0x48 : <nl> - case 0x49 : <nl> - case 0x4A : <nl> - case 0x4B : <nl> - case 0x4C : <nl> - case 0x4D : <nl> - case 0x4E : <nl> - case 0x4F : <nl> - case 0x50 : <nl> - case 0x51 : <nl> - case 0x52 : <nl> - case 0x53 : <nl> - case 0x54 : <nl> - case 0x55 : <nl> - case 0x56 : <nl> - case 0x57 : <nl> - case 0x58 : <nl> - case 0x59 : <nl> - case 0x5A : <nl> - case 0x5B : <nl> - case 0x5C : <nl> - case 0x5D : <nl> - case 0x5E : <nl> - case 0x5F : <nl> - case 0x60 : <nl> - case 0x61 : <nl> - case 0x62 : <nl> - case 0x63 : <nl> - case 0x64 : <nl> - case 0x65 : <nl> - case 0x66 : <nl> - case 0x67 : <nl> - case 0x68 : <nl> - case 0x69 : <nl> - case 0x6A : <nl> - case 0x6B : <nl> - case 0x6C : <nl> - case 0x6D : <nl> - case 0x6E : <nl> - case 0x6F : <nl> - case 0x70 : <nl> - case 0x71 : <nl> - case 0x72 : <nl> - case 0x73 : <nl> - case 0x74 : <nl> - case 0x75 : <nl> - case 0x76 : <nl> - case 0x77 : <nl> - case 0x78 : <nl> - case 0x79 : <nl> - case 0x7A : <nl> - case 0x7B : <nl> - case 0x7C : <nl> - case 0x7D : <nl> - case 0x7E : <nl> - case 0x7F : <nl> - return sax - > number_unsigned ( static_cast < number_unsigned_t > ( current ) ) ; <nl> - <nl> - / / fixmap <nl> - case 0x80 : <nl> - case 0x81 : <nl> - case 0x82 : <nl> - case 0x83 : <nl> - case 0x84 : <nl> - case 0x85 : <nl> - case 0x86 : <nl> - case 0x87 : <nl> - case 0x88 : <nl> - case 0x89 : <nl> - case 0x8A : <nl> - case 0x8B : <nl> - case 0x8C : <nl> - case 0x8D : <nl> - case 0x8E : <nl> - case 0x8F : <nl> - return get_msgpack_object ( static_cast < std : : size_t > ( current & 0x0F ) ) ; <nl> - <nl> - / / fixarray <nl> - case 0x90 : <nl> - case 0x91 : <nl> - case 0x92 : <nl> - case 0x93 : <nl> - case 0x94 : <nl> - case 0x95 : <nl> - case 0x96 : <nl> - case 0x97 : <nl> - case 0x98 : <nl> - case 0x99 : <nl> - case 0x9A : <nl> - case 0x9B : <nl> - case 0x9C : <nl> - case 0x9D : <nl> - case 0x9E : <nl> - case 0x9F : <nl> - return get_msgpack_array ( static_cast < std : : size_t > ( current & 0x0F ) ) ; <nl> - <nl> - / / fixstr <nl> - case 0xA0 : <nl> - case 0xA1 : <nl> - case 0xA2 : <nl> - case 0xA3 : <nl> - case 0xA4 : <nl> - case 0xA5 : <nl> - case 0xA6 : <nl> - case 0xA7 : <nl> - case 0xA8 : <nl> - case 0xA9 : <nl> - case 0xAA : <nl> - case 0xAB : <nl> - case 0xAC : <nl> - case 0xAD : <nl> - case 0xAE : <nl> - case 0xAF : <nl> - case 0xB0 : <nl> - case 0xB1 : <nl> - case 0xB2 : <nl> - case 0xB3 : <nl> - case 0xB4 : <nl> - case 0xB5 : <nl> - case 0xB6 : <nl> - case 0xB7 : <nl> - case 0xB8 : <nl> - case 0xB9 : <nl> - case 0xBA : <nl> - case 0xBB : <nl> - case 0xBC : <nl> - case 0xBD : <nl> - case 0xBE : <nl> - case 0xBF : <nl> - { <nl> - string_t s ; <nl> - return get_msgpack_string ( s ) and sax - > string ( s ) ; <nl> - } <nl> - <nl> - case 0xC0 : / / nil <nl> - return sax - > null ( ) ; <nl> - <nl> - case 0xC2 : / / false <nl> - return sax - > boolean ( false ) ; <nl> - <nl> - case 0xC3 : / / true <nl> - return sax - > boolean ( true ) ; <nl> - <nl> - case 0xCA : / / float 32 <nl> - { <nl> - float number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - case 0xCB : / / float 64 <nl> - { <nl> - double number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - case 0xCC : / / uint 8 <nl> - { <nl> - uint8_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0xCD : / / uint 16 <nl> - { <nl> - uint16_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0xCE : / / uint 32 <nl> - { <nl> - uint32_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0xCF : / / uint 64 <nl> - { <nl> - uint64_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case 0xD0 : / / int 8 <nl> - { <nl> - int8_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case 0xD1 : / / int 16 <nl> - { <nl> - int16_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case 0xD2 : / / int 32 <nl> - { <nl> - int32_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case 0xD3 : / / int 64 <nl> - { <nl> - int64_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case 0xD9 : / / str 8 <nl> - case 0xDA : / / str 16 <nl> - case 0xDB : / / str 32 <nl> - { <nl> - string_t s ; <nl> - return get_msgpack_string ( s ) and sax - > string ( s ) ; <nl> - } <nl> - <nl> - case 0xDC : / / array 16 <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_msgpack_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xDD : / / array 32 <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_msgpack_array ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xDE : / / map 16 <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_msgpack_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - case 0xDF : / / map 32 <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_msgpack_object ( static_cast < std : : size_t > ( len ) ) ; <nl> - } <nl> - <nl> - / / negative fixint <nl> - case 0xE0 : <nl> - case 0xE1 : <nl> - case 0xE2 : <nl> - case 0xE3 : <nl> - case 0xE4 : <nl> - case 0xE5 : <nl> - case 0xE6 : <nl> - case 0xE7 : <nl> - case 0xE8 : <nl> - case 0xE9 : <nl> - case 0xEA : <nl> - case 0xEB : <nl> - case 0xEC : <nl> - case 0xED : <nl> - case 0xEE : <nl> - case 0xEF : <nl> - case 0xF0 : <nl> - case 0xF1 : <nl> - case 0xF2 : <nl> - case 0xF3 : <nl> - case 0xF4 : <nl> - case 0xF5 : <nl> - case 0xF6 : <nl> - case 0xF7 : <nl> - case 0xF8 : <nl> - case 0xF9 : <nl> - case 0xFA : <nl> - case 0xFB : <nl> - case 0xFC : <nl> - case 0xFD : <nl> - case 0xFE : <nl> - case 0xFF : <nl> - return sax - > number_integer ( static_cast < int8_t > ( current ) ) ; <nl> - <nl> - default : / / anything else <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 112 , chars_read , " error reading MessagePack ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] get_char whether a new character should be retrieved from the <nl> - input ( true , default ) or whether the last read <nl> - character should be considered instead <nl> - <nl> - @ return whether a valid UBJSON value was passed to the SAX parser <nl> - * / <nl> - bool parse_ubjson_internal ( const bool get_char = true ) <nl> - { <nl> - return get_ubjson_value ( get_char ? get_ignore_noop ( ) : current ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get next character from the input <nl> - <nl> - This function provides the interface to the used input adapter . It does <nl> - not throw in case the input reached EOF , but returns a - ' ve valued <nl> - ` std : : char_traits < char > : : eof ( ) ` in that case . <nl> - <nl> - @ return character read from the input <nl> - * / <nl> - int get ( ) <nl> - { <nl> - + + chars_read ; <nl> - return ( current = ia - > get_character ( ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ return character read from the input after ignoring all ' N ' entries <nl> - * / <nl> - int get_ignore_noop ( ) <nl> - { <nl> - do <nl> - { <nl> - get ( ) ; <nl> - } <nl> - while ( current = = ' N ' ) ; <nl> - <nl> - return current ; <nl> - } <nl> - <nl> - / * <nl> - @ brief read a number from the input <nl> - <nl> - @ tparam NumberType the type of the number <nl> - @ param [ out ] result number of type @ a NumberType <nl> - <nl> - @ return whether conversion completed <nl> - <nl> - @ note This function needs to respect the system ' s endianess , because <nl> - bytes in CBOR , MessagePack , and UBJSON are stored in network order <nl> - ( big endian ) and therefore need reordering on little endian systems . <nl> - * / <nl> - template < typename NumberType > <nl> - bool get_number ( NumberType & result ) <nl> - { <nl> - / / step 1 : read input into array with system ' s byte order <nl> - std : : array < uint8_t , sizeof ( NumberType ) > vec ; <nl> - for ( std : : size_t i = 0 ; i < sizeof ( NumberType ) ; + + i ) <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - / / reverse byte order prior to conversion if necessary <nl> - if ( is_little_endian ) <nl> - { <nl> - vec [ sizeof ( NumberType ) - i - 1 ] = static_cast < uint8_t > ( current ) ; <nl> - } <nl> - else <nl> - { <nl> - vec [ i ] = static_cast < uint8_t > ( current ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - <nl> - / / step 2 : convert array into number of type T and return <nl> - std : : memcpy ( & result , vec . data ( ) , sizeof ( NumberType ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a string by reading characters from the input <nl> - <nl> - @ tparam NumberType the type of the number <nl> - @ param [ in ] len number of characters to read <nl> - @ param [ out ] string created by reading @ a len bytes <nl> - <nl> - @ return whether string creation completed <nl> - <nl> - @ note We can not reserve @ a len bytes for the result , because @ a len <nl> - may be too large . Usually , @ ref unexpect_eof ( ) detects the end of <nl> - the input before we run out of string memory . <nl> - * / <nl> - template < typename NumberType > <nl> - bool get_string ( const NumberType len , string_t & result ) <nl> - { <nl> - bool success = true ; <nl> - std : : generate_n ( std : : back_inserter ( result ) , len , [ this , & success ] ( ) <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - success = false ; <nl> - } <nl> - return static_cast < char > ( current ) ; <nl> - } ) ; <nl> - return success ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief reads a CBOR string <nl> - <nl> - This function first reads starting bytes to determine the expected <nl> - string length and then copies this number of bytes into a string . <nl> - Additionally , CBOR ' s strings with indefinite lengths are supported . <nl> - <nl> - @ param [ out ] result created string <nl> - <nl> - @ return whether string creation completed <nl> - * / <nl> - bool get_cbor_string ( string_t & result ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - switch ( current ) <nl> - { <nl> - / / UTF - 8 string ( 0x00 . . 0x17 bytes follow ) <nl> - case 0x60 : <nl> - case 0x61 : <nl> - case 0x62 : <nl> - case 0x63 : <nl> - case 0x64 : <nl> - case 0x65 : <nl> - case 0x66 : <nl> - case 0x67 : <nl> - case 0x68 : <nl> - case 0x69 : <nl> - case 0x6A : <nl> - case 0x6B : <nl> - case 0x6C : <nl> - case 0x6D : <nl> - case 0x6E : <nl> - case 0x6F : <nl> - case 0x70 : <nl> - case 0x71 : <nl> - case 0x72 : <nl> - case 0x73 : <nl> - case 0x74 : <nl> - case 0x75 : <nl> - case 0x76 : <nl> - case 0x77 : <nl> - { <nl> - return get_string ( current & 0x1F , result ) ; <nl> - } <nl> - <nl> - case 0x78 : / / UTF - 8 string ( one - byte uint8_t for n follows ) <nl> - { <nl> - uint8_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0x79 : / / UTF - 8 string ( two - byte uint16_t for n follow ) <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0x7A : / / UTF - 8 string ( four - byte uint32_t for n follow ) <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0x7B : / / UTF - 8 string ( eight - byte uint64_t for n follow ) <nl> - { <nl> - uint64_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0x7F : / / UTF - 8 string ( indefinite length ) <nl> - { <nl> - while ( get ( ) ! = 0xFF ) <nl> - { <nl> - string_t chunk ; <nl> - if ( not get_cbor_string ( chunk ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result . append ( chunk ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 113 , chars_read , " expected a CBOR string ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] len the length of the array or std : : size_t ( - 1 ) for an <nl> - array of indefinite size <nl> - @ return whether array creation completed <nl> - * / <nl> - bool get_cbor_array ( const std : : size_t len ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_array ( len ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( len ! = std : : size_t ( - 1 ) ) <nl> - for ( std : : size_t i = 0 ; i < len ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not parse_cbor_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - while ( get ( ) ! = 0xFF ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not parse_cbor_internal ( false ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return sax - > end_array ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] len the length of the object or std : : size_t ( - 1 ) for an <nl> - object of indefinite size <nl> - @ return whether object creation completed <nl> - * / <nl> - bool get_cbor_object ( const std : : size_t len ) <nl> - { <nl> - if ( not JSON_UNLIKELY ( sax - > start_object ( len ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - string_t key ; <nl> - if ( len ! = std : : size_t ( - 1 ) ) <nl> - { <nl> - for ( std : : size_t i = 0 ; i < len ; + + i ) <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_UNLIKELY ( not get_cbor_string ( key ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not parse_cbor_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - key . clear ( ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - while ( get ( ) ! = 0xFF ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not get_cbor_string ( key ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not parse_cbor_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - key . clear ( ) ; <nl> - } <nl> - } <nl> - <nl> - return sax - > end_object ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief reads a MessagePack string <nl> - <nl> - This function first reads starting bytes to determine the expected <nl> - string length and then copies this number of bytes into a string . <nl> - <nl> - @ param [ out ] result created string <nl> - <nl> - @ return whether string creation completed <nl> - * / <nl> - bool get_msgpack_string ( string_t & result ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - switch ( current ) <nl> - { <nl> - / / fixstr <nl> - case 0xA0 : <nl> - case 0xA1 : <nl> - case 0xA2 : <nl> - case 0xA3 : <nl> - case 0xA4 : <nl> - case 0xA5 : <nl> - case 0xA6 : <nl> - case 0xA7 : <nl> - case 0xA8 : <nl> - case 0xA9 : <nl> - case 0xAA : <nl> - case 0xAB : <nl> - case 0xAC : <nl> - case 0xAD : <nl> - case 0xAE : <nl> - case 0xAF : <nl> - case 0xB0 : <nl> - case 0xB1 : <nl> - case 0xB2 : <nl> - case 0xB3 : <nl> - case 0xB4 : <nl> - case 0xB5 : <nl> - case 0xB6 : <nl> - case 0xB7 : <nl> - case 0xB8 : <nl> - case 0xB9 : <nl> - case 0xBA : <nl> - case 0xBB : <nl> - case 0xBC : <nl> - case 0xBD : <nl> - case 0xBE : <nl> - case 0xBF : <nl> - { <nl> - return get_string ( current & 0x1F , result ) ; <nl> - } <nl> - <nl> - case 0xD9 : / / str 8 <nl> - { <nl> - uint8_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0xDA : / / str 16 <nl> - { <nl> - uint16_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case 0xDB : / / str 32 <nl> - { <nl> - uint32_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 113 , chars_read , " expected a MessagePack string ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] len the length of the array <nl> - @ return whether array creation completed <nl> - * / <nl> - bool get_msgpack_array ( const std : : size_t len ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_array ( len ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - for ( std : : size_t i = 0 ; i < len ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not parse_msgpack_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - return sax - > end_array ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] len the length of the object <nl> - @ return whether object creation completed <nl> - * / <nl> - bool get_msgpack_object ( const std : : size_t len ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_object ( len ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - string_t key ; <nl> - for ( std : : size_t i = 0 ; i < len ; + + i ) <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_UNLIKELY ( not get_msgpack_string ( key ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not parse_msgpack_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - key . clear ( ) ; <nl> - } <nl> - <nl> - return sax - > end_object ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief reads a UBJSON string <nl> - <nl> - This function is either called after reading the ' S ' byte explicitly <nl> - indicating a string , or in case of an object key where the ' S ' byte can be <nl> - left out . <nl> - <nl> - @ param [ out ] result created string <nl> - @ param [ in ] get_char whether a new character should be retrieved from the <nl> - input ( true , default ) or whether the last read <nl> - character should be considered instead <nl> - <nl> - @ return whether string creation completed <nl> - * / <nl> - bool get_ubjson_string ( string_t & result , const bool get_char = true ) <nl> - { <nl> - if ( get_char ) <nl> - { <nl> - get ( ) ; / / TODO : may we ignore N here ? <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - switch ( current ) <nl> - { <nl> - case ' U ' : <nl> - { <nl> - uint8_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case ' i ' : <nl> - { <nl> - int8_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case ' I ' : <nl> - { <nl> - int16_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case ' l ' : <nl> - { <nl> - int32_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - case ' L ' : <nl> - { <nl> - int64_t len ; <nl> - return get_number ( len ) and get_string ( len , result ) ; <nl> - } <nl> - <nl> - default : <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 113 , chars_read , " expected a UBJSON string ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ out ] result determined size <nl> - @ return whether size determination completed <nl> - * / <nl> - bool get_ubjson_size_value ( std : : size_t & result ) <nl> - { <nl> - switch ( get_ignore_noop ( ) ) <nl> - { <nl> - case ' U ' : <nl> - { <nl> - uint8_t number ; <nl> - if ( JSON_UNLIKELY ( not get_number ( number ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result = static_cast < std : : size_t > ( number ) ; <nl> - return true ; <nl> - } <nl> - <nl> - case ' i ' : <nl> - { <nl> - int8_t number ; <nl> - if ( JSON_UNLIKELY ( not get_number ( number ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result = static_cast < std : : size_t > ( number ) ; <nl> - return true ; <nl> - } <nl> - <nl> - case ' I ' : <nl> - { <nl> - int16_t number ; <nl> - if ( JSON_UNLIKELY ( not get_number ( number ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result = static_cast < std : : size_t > ( number ) ; <nl> - return true ; <nl> - } <nl> - <nl> - case ' l ' : <nl> - { <nl> - int32_t number ; <nl> - if ( JSON_UNLIKELY ( not get_number ( number ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result = static_cast < std : : size_t > ( number ) ; <nl> - return true ; <nl> - } <nl> - <nl> - case ' L ' : <nl> - { <nl> - int64_t number ; <nl> - if ( JSON_UNLIKELY ( not get_number ( number ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - result = static_cast < std : : size_t > ( number ) ; <nl> - return true ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 113 , chars_read , " byte after ' # ' must denote a number type ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief determine the type and size for a container <nl> - <nl> - In the optimized UBJSON format , a type and a size can be provided to allow <nl> - for a more compact representation . <nl> - <nl> - @ param [ out ] result pair of the size and the type <nl> - <nl> - @ return whether pair creation completed <nl> - * / <nl> - bool get_ubjson_size_type ( std : : pair < std : : size_t , int > & result ) <nl> - { <nl> - result . first = string_t : : npos ; / / size <nl> - result . second = 0 ; / / type <nl> - <nl> - get_ignore_noop ( ) ; <nl> - <nl> - if ( current = = ' $ ' ) <nl> - { <nl> - result . second = get ( ) ; / / must not ignore ' N ' , because ' N ' maybe the type <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - get_ignore_noop ( ) ; <nl> - if ( JSON_UNLIKELY ( current ! = ' # ' ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 112 , chars_read , " expected ' # ' after UBJSON type information ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - <nl> - return get_ubjson_size_value ( result . first ) ; <nl> - } <nl> - else if ( current = = ' # ' ) <nl> - { <nl> - return get_ubjson_size_value ( result . first ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param prefix the previously read or set type prefix <nl> - @ return whether value creation completed <nl> - * / <nl> - bool get_ubjson_value ( const int prefix ) <nl> - { <nl> - switch ( prefix ) <nl> - { <nl> - case std : : char_traits < char > : : eof ( ) : / / EOF <nl> - return unexpect_eof ( ) ; <nl> - <nl> - case ' T ' : / / true <nl> - return sax - > boolean ( true ) ; <nl> - case ' F ' : / / false <nl> - return sax - > boolean ( false ) ; <nl> - <nl> - case ' Z ' : / / null <nl> - return sax - > null ( ) ; <nl> - <nl> - case ' U ' : <nl> - { <nl> - uint8_t number ; <nl> - return get_number ( number ) and sax - > number_unsigned ( number ) ; <nl> - } <nl> - <nl> - case ' i ' : <nl> - { <nl> - int8_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case ' I ' : <nl> - { <nl> - int16_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case ' l ' : <nl> - { <nl> - int32_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case ' L ' : <nl> - { <nl> - int64_t number ; <nl> - return get_number ( number ) and sax - > number_integer ( number ) ; <nl> - } <nl> - <nl> - case ' d ' : <nl> - { <nl> - float number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - case ' D ' : <nl> - { <nl> - double number ; <nl> - return get_number ( number ) and sax - > number_float ( static_cast < number_float_t > ( number ) , " " ) ; <nl> - } <nl> - <nl> - case ' C ' : / / char <nl> - { <nl> - get ( ) ; <nl> - if ( JSON_UNLIKELY ( not unexpect_eof ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - if ( JSON_UNLIKELY ( current > 127 ) ) <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 113 , chars_read , " byte after ' C ' must be in range 0x00 . . 0x7F ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - string_t s ( 1 , static_cast < char > ( current ) ) ; <nl> - return sax - > string ( s ) ; <nl> - } <nl> - <nl> - case ' S ' : / / string <nl> - { <nl> - string_t s ; <nl> - return get_ubjson_string ( s ) and sax - > string ( s ) ; <nl> - } <nl> - <nl> - case ' [ ' : / / array <nl> - return get_ubjson_array ( ) ; <nl> - <nl> - case ' { ' : / / object <nl> - return get_ubjson_object ( ) ; <nl> - <nl> - default : / / anything else <nl> - { <nl> - auto last_token = get_token_string ( ) ; <nl> - return sax - > parse_error ( chars_read , last_token , parse_error : : create ( 112 , chars_read , " error reading UBJSON ; last byte : 0x " + last_token ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ return whether array creation completed <nl> - * / <nl> - bool get_ubjson_array ( ) <nl> - { <nl> - std : : pair < std : : size_t , int > size_and_type ; <nl> - if ( JSON_UNLIKELY ( not get_ubjson_size_type ( size_and_type ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( size_and_type . first ! = string_t : : npos ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_array ( size_and_type . first ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( size_and_type . second ! = 0 ) <nl> - { <nl> - if ( size_and_type . second ! = ' N ' ) <nl> - { <nl> - for ( std : : size_t i = 0 ; i < size_and_type . first ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not get_ubjson_value ( size_and_type . second ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - for ( std : : size_t i = 0 ; i < size_and_type . first ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not parse_ubjson_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_array ( std : : size_t ( - 1 ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - while ( current ! = ' ] ' ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not parse_ubjson_internal ( false ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - get_ignore_noop ( ) ; <nl> - } <nl> - } <nl> - <nl> - return sax - > end_array ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ return whether object creation completed <nl> - * / <nl> - bool get_ubjson_object ( ) <nl> - { <nl> - std : : pair < std : : size_t , int > size_and_type ; <nl> - if ( JSON_UNLIKELY ( not get_ubjson_size_type ( size_and_type ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - string_t key ; <nl> - if ( size_and_type . first ! = string_t : : npos ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_object ( size_and_type . first ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( size_and_type . second ! = 0 ) <nl> - { <nl> - for ( std : : size_t i = 0 ; i < size_and_type . first ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not get_ubjson_string ( key ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - if ( JSON_UNLIKELY ( not get_ubjson_value ( size_and_type . second ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - key . clear ( ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - for ( std : : size_t i = 0 ; i < size_and_type . first ; + + i ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not get_ubjson_string ( key ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - if ( JSON_UNLIKELY ( not parse_ubjson_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - key . clear ( ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( JSON_UNLIKELY ( not sax - > start_object ( std : : size_t ( - 1 ) ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - while ( current ! = ' } ' ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not get_ubjson_string ( key , false ) or not sax - > key ( key ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - if ( JSON_UNLIKELY ( not parse_ubjson_internal ( ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - get_ignore_noop ( ) ; <nl> - key . clear ( ) ; <nl> - } <nl> - } <nl> - <nl> - return sax - > end_object ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ return whether the last read character is not EOF <nl> - * / <nl> - bool unexpect_eof ( ) const <nl> - { <nl> - if ( JSON_UNLIKELY ( current = = std : : char_traits < char > : : eof ( ) ) ) <nl> - { <nl> - return sax - > parse_error ( chars_read , " < end of file > " , parse_error : : create ( 110 , chars_read , " unexpected end of input " ) ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - / * ! <nl> - @ return a string representation of the last read byte <nl> - * / <nl> - std : : string get_token_string ( ) const <nl> - { <nl> - char cr [ 3 ] ; <nl> - snprintf ( cr , 3 , " % . 2hhX " , static_cast < unsigned char > ( current ) ) ; <nl> - return std : : string { cr } ; <nl> - } <nl> - <nl> - private : <nl> - / / / input adapter <nl> - input_adapter_t ia = nullptr ; <nl> - <nl> - / / / the current character <nl> - int current = std : : char_traits < char > : : eof ( ) ; <nl> - <nl> - / / / the number of characters read <nl> - std : : size_t chars_read = 0 ; <nl> - <nl> - / / / whether we can assume little endianess <nl> - const bool is_little_endian = little_endianess ( ) ; <nl> - <nl> - / / / the SAX parser <nl> - json_sax_t * sax = nullptr ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / output / binary_writer . hpp > <nl> - <nl> - <nl> - # include < algorithm > / / reverse <nl> - # include < array > / / array <nl> - # include < cstdint > / / uint8_t , uint16_t , uint32_t , uint64_t <nl> - # include < cstring > / / memcpy <nl> - # include < limits > / / numeric_limits <nl> - <nl> - / / # include < nlohmann / detail / input / binary_reader . hpp > <nl> - <nl> - / / # include < nlohmann / detail / output / output_adapters . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / <nl> - / / binary writer / / <nl> - / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief serialization to CBOR and MessagePack values <nl> - * / <nl> - template < typename BasicJsonType , typename CharType > <nl> - class binary_writer <nl> - { <nl> - public : <nl> - / * ! <nl> - @ brief create a binary writer <nl> - <nl> - @ param [ in ] adapter output adapter to write to <nl> - * / <nl> - explicit binary_writer ( output_adapter_t < CharType > adapter ) : oa ( adapter ) <nl> - { <nl> - assert ( oa ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief [ in ] j JSON value to serialize <nl> - * / <nl> - void write_cbor ( const BasicJsonType & j ) <nl> - { <nl> - switch ( j . type ( ) ) <nl> - { <nl> - case value_t : : null : <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xF6 ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - oa - > write_character ( j . m_value . boolean <nl> - ? static_cast < CharType > ( 0xF5 ) <nl> - : static_cast < CharType > ( 0xF4 ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - if ( j . m_value . number_integer > = 0 ) <nl> - { <nl> - / / CBOR does not differentiate between positive signed <nl> - / / integers and unsigned integers . Therefore , we used the <nl> - / / code from the value_t : : number_unsigned case here . <nl> - if ( j . m_value . number_integer < = 0x17 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x18 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x19 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x1A ) ) ; <nl> - write_number ( static_cast < uint32_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x1B ) ) ; <nl> - write_number ( static_cast < uint64_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / The conversions below encode the sign in the first <nl> - / / byte , and the value is converted to a positive number . <nl> - const auto positive_number = - 1 - j . m_value . number_integer ; <nl> - if ( j . m_value . number_integer > = - 24 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( 0x20 + positive_number ) ) ; <nl> - } <nl> - else if ( positive_number < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x38 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( positive_number ) ) ; <nl> - } <nl> - else if ( positive_number < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x39 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( positive_number ) ) ; <nl> - } <nl> - else if ( positive_number < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x3A ) ) ; <nl> - write_number ( static_cast < uint32_t > ( positive_number ) ) ; <nl> - } <nl> - else <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x3B ) ) ; <nl> - write_number ( static_cast < uint64_t > ( positive_number ) ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - if ( j . m_value . number_unsigned < = 0x17 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_unsigned ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x18 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_unsigned ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x19 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( j . m_value . number_unsigned ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x1A ) ) ; <nl> - write_number ( static_cast < uint32_t > ( j . m_value . number_unsigned ) ) ; <nl> - } <nl> - else <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x1B ) ) ; <nl> - write_number ( static_cast < uint64_t > ( j . m_value . number_unsigned ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - oa - > write_character ( get_cbor_float_prefix ( j . m_value . number_float ) ) ; <nl> - write_number ( j . m_value . number_float ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - / / step 1 : write control byte and the string length <nl> - const auto N = j . m_value . string - > size ( ) ; <nl> - if ( N < = 0x17 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( 0x60 + N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x78 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x79 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x7A ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_START <nl> - else if ( N < = ( std : : numeric_limits < uint64_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x7B ) ) ; <nl> - write_number ( static_cast < uint64_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_STOP <nl> - <nl> - / / step 2 : write the string <nl> - oa - > write_characters ( <nl> - reinterpret_cast < const CharType * > ( j . m_value . string - > c_str ( ) ) , <nl> - j . m_value . string - > size ( ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - / / step 1 : write control byte and the array size <nl> - const auto N = j . m_value . array - > size ( ) ; <nl> - if ( N < = 0x17 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( 0x80 + N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x98 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x99 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x9A ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_START <nl> - else if ( N < = ( std : : numeric_limits < uint64_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0x9B ) ) ; <nl> - write_number ( static_cast < uint64_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_STOP <nl> - <nl> - / / step 2 : write each element <nl> - for ( const auto & el : * j . m_value . array ) <nl> - { <nl> - write_cbor ( el ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / step 1 : write control byte and the object size <nl> - const auto N = j . m_value . object - > size ( ) ; <nl> - if ( N < = 0x17 ) <nl> - { <nl> - write_number ( static_cast < uint8_t > ( 0xA0 + N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xB8 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xB9 ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xBA ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_START <nl> - else if ( N < = ( std : : numeric_limits < uint64_t > : : max ) ( ) ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xBB ) ) ; <nl> - write_number ( static_cast < uint64_t > ( N ) ) ; <nl> - } <nl> - / / LCOV_EXCL_STOP <nl> - <nl> - / / step 2 : write each element <nl> - for ( const auto & el : * j . m_value . object ) <nl> - { <nl> - write_cbor ( el . first ) ; <nl> - write_cbor ( el . second ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief [ in ] j JSON value to serialize <nl> - * / <nl> - void write_msgpack ( const BasicJsonType & j ) <nl> - { <nl> - switch ( j . type ( ) ) <nl> - { <nl> - case value_t : : null : / / nil <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( 0xC0 ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : / / true and false <nl> - { <nl> - oa - > write_character ( j . m_value . boolean <nl> - ? static_cast < CharType > ( 0xC3 ) <nl> - : static_cast < CharType > ( 0xC2 ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - if ( j . m_value . number_integer > = 0 ) <nl> - { <nl> - / / MessagePack does not differentiate between positive <nl> - / / signed integers and unsigned integers . Therefore , we used <nl> - / / the code from the value_t : : number_unsigned case here . <nl> - if ( j . m_value . number_unsigned < 128 ) <nl> - { <nl> - / / positive fixnum <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 8 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCC ) ) ; <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCD ) ) ; <nl> - write_number ( static_cast < uint16_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCE ) ) ; <nl> - write_number ( static_cast < uint32_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint64_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 64 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCF ) ) ; <nl> - write_number ( static_cast < uint64_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( j . m_value . number_integer > = - 32 ) <nl> - { <nl> - / / negative fixnum <nl> - write_number ( static_cast < int8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer > = ( std : : numeric_limits < int8_t > : : min ) ( ) and <nl> - j . m_value . number_integer < = ( std : : numeric_limits < int8_t > : : max ) ( ) ) <nl> - { <nl> - / / int 8 <nl> - oa - > write_character ( static_cast < CharType > ( 0xD0 ) ) ; <nl> - write_number ( static_cast < int8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer > = ( std : : numeric_limits < int16_t > : : min ) ( ) and <nl> - j . m_value . number_integer < = ( std : : numeric_limits < int16_t > : : max ) ( ) ) <nl> - { <nl> - / / int 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xD1 ) ) ; <nl> - write_number ( static_cast < int16_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer > = ( std : : numeric_limits < int32_t > : : min ) ( ) and <nl> - j . m_value . number_integer < = ( std : : numeric_limits < int32_t > : : max ) ( ) ) <nl> - { <nl> - / / int 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xD2 ) ) ; <nl> - write_number ( static_cast < int32_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_integer > = ( std : : numeric_limits < int64_t > : : min ) ( ) and <nl> - j . m_value . number_integer < = ( std : : numeric_limits < int64_t > : : max ) ( ) ) <nl> - { <nl> - / / int 64 <nl> - oa - > write_character ( static_cast < CharType > ( 0xD3 ) ) ; <nl> - write_number ( static_cast < int64_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - if ( j . m_value . number_unsigned < 128 ) <nl> - { <nl> - / / positive fixnum <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 8 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCC ) ) ; <nl> - write_number ( static_cast < uint8_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCD ) ) ; <nl> - write_number ( static_cast < uint16_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCE ) ) ; <nl> - write_number ( static_cast < uint32_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint64_t > : : max ) ( ) ) <nl> - { <nl> - / / uint 64 <nl> - oa - > write_character ( static_cast < CharType > ( 0xCF ) ) ; <nl> - write_number ( static_cast < uint64_t > ( j . m_value . number_integer ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - oa - > write_character ( get_msgpack_float_prefix ( j . m_value . number_float ) ) ; <nl> - write_number ( j . m_value . number_float ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - / / step 1 : write control byte and the string length <nl> - const auto N = j . m_value . string - > size ( ) ; <nl> - if ( N < = 31 ) <nl> - { <nl> - / / fixstr <nl> - write_number ( static_cast < uint8_t > ( 0xA0 | N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - / / str 8 <nl> - oa - > write_character ( static_cast < CharType > ( 0xD9 ) ) ; <nl> - write_number ( static_cast < uint8_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - / / str 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDA ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - / / str 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDB ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - <nl> - / / step 2 : write the string <nl> - oa - > write_characters ( <nl> - reinterpret_cast < const CharType * > ( j . m_value . string - > c_str ( ) ) , <nl> - j . m_value . string - > size ( ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - / / step 1 : write control byte and the array size <nl> - const auto N = j . m_value . array - > size ( ) ; <nl> - if ( N < = 15 ) <nl> - { <nl> - / / fixarray <nl> - write_number ( static_cast < uint8_t > ( 0x90 | N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - / / array 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDC ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - / / array 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDD ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - <nl> - / / step 2 : write each element <nl> - for ( const auto & el : * j . m_value . array ) <nl> - { <nl> - write_msgpack ( el ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / step 1 : write control byte and the object size <nl> - const auto N = j . m_value . object - > size ( ) ; <nl> - if ( N < = 15 ) <nl> - { <nl> - / / fixmap <nl> - write_number ( static_cast < uint8_t > ( 0x80 | ( N & 0xF ) ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint16_t > : : max ) ( ) ) <nl> - { <nl> - / / map 16 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDE ) ) ; <nl> - write_number ( static_cast < uint16_t > ( N ) ) ; <nl> - } <nl> - else if ( N < = ( std : : numeric_limits < uint32_t > : : max ) ( ) ) <nl> - { <nl> - / / map 32 <nl> - oa - > write_character ( static_cast < CharType > ( 0xDF ) ) ; <nl> - write_number ( static_cast < uint32_t > ( N ) ) ; <nl> - } <nl> - <nl> - / / step 2 : write each element <nl> - for ( const auto & el : * j . m_value . object ) <nl> - { <nl> - write_msgpack ( el . first ) ; <nl> - write_msgpack ( el . second ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] j JSON value to serialize <nl> - @ param [ in ] use_count whether to use ' # ' prefixes ( optimized format ) <nl> - @ param [ in ] use_type whether to use ' $ ' prefixes ( optimized format ) <nl> - @ param [ in ] add_prefix whether prefixes need to be used for this value <nl> - * / <nl> - void write_ubjson ( const BasicJsonType & j , const bool use_count , <nl> - const bool use_type , const bool add_prefix = true ) <nl> - { <nl> - switch ( j . type ( ) ) <nl> - { <nl> - case value_t : : null : <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' Z ' ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - if ( add_prefix ) <nl> - oa - > write_character ( j . m_value . boolean <nl> - ? static_cast < CharType > ( ' T ' ) <nl> - : static_cast < CharType > ( ' F ' ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - write_number_with_ubjson_prefix ( j . m_value . number_integer , add_prefix ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - write_number_with_ubjson_prefix ( j . m_value . number_unsigned , add_prefix ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - write_number_with_ubjson_prefix ( j . m_value . number_float , add_prefix ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' S ' ) ) ; <nl> - } <nl> - write_number_with_ubjson_prefix ( j . m_value . string - > size ( ) , true ) ; <nl> - oa - > write_characters ( <nl> - reinterpret_cast < const CharType * > ( j . m_value . string - > c_str ( ) ) , <nl> - j . m_value . string - > size ( ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' [ ' ) ) ; <nl> - } <nl> - <nl> - bool prefix_required = true ; <nl> - if ( use_type and not j . m_value . array - > empty ( ) ) <nl> - { <nl> - assert ( use_count ) ; <nl> - const CharType first_prefix = ubjson_prefix ( j . front ( ) ) ; <nl> - const bool same_prefix = std : : all_of ( j . begin ( ) + 1 , j . end ( ) , <nl> - [ this , first_prefix ] ( const BasicJsonType & v ) <nl> - { <nl> - return ubjson_prefix ( v ) = = first_prefix ; <nl> - } ) ; <nl> - <nl> - if ( same_prefix ) <nl> - { <nl> - prefix_required = false ; <nl> - oa - > write_character ( static_cast < CharType > ( ' $ ' ) ) ; <nl> - oa - > write_character ( first_prefix ) ; <nl> - } <nl> - } <nl> - <nl> - if ( use_count ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' # ' ) ) ; <nl> - write_number_with_ubjson_prefix ( j . m_value . array - > size ( ) , true ) ; <nl> - } <nl> - <nl> - for ( const auto & el : * j . m_value . array ) <nl> - { <nl> - write_ubjson ( el , use_count , use_type , prefix_required ) ; <nl> - } <nl> - <nl> - if ( not use_count ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' ] ' ) ) ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' { ' ) ) ; <nl> - } <nl> - <nl> - bool prefix_required = true ; <nl> - if ( use_type and not j . m_value . object - > empty ( ) ) <nl> - { <nl> - assert ( use_count ) ; <nl> - const CharType first_prefix = ubjson_prefix ( j . front ( ) ) ; <nl> - const bool same_prefix = std : : all_of ( j . begin ( ) , j . end ( ) , <nl> - [ this , first_prefix ] ( const BasicJsonType & v ) <nl> - { <nl> - return ubjson_prefix ( v ) = = first_prefix ; <nl> - } ) ; <nl> - <nl> - if ( same_prefix ) <nl> - { <nl> - prefix_required = false ; <nl> - oa - > write_character ( static_cast < CharType > ( ' $ ' ) ) ; <nl> - oa - > write_character ( first_prefix ) ; <nl> - } <nl> - } <nl> - <nl> - if ( use_count ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' # ' ) ) ; <nl> - write_number_with_ubjson_prefix ( j . m_value . object - > size ( ) , true ) ; <nl> - } <nl> - <nl> - for ( const auto & el : * j . m_value . object ) <nl> - { <nl> - write_number_with_ubjson_prefix ( el . first . size ( ) , true ) ; <nl> - oa - > write_characters ( <nl> - reinterpret_cast < const CharType * > ( el . first . c_str ( ) ) , <nl> - el . first . size ( ) ) ; <nl> - write_ubjson ( el . second , use_count , use_type , prefix_required ) ; <nl> - } <nl> - <nl> - if ( not use_count ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' } ' ) ) ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - private : <nl> - / * <nl> - @ brief write a number to output input <nl> - <nl> - @ param [ in ] n number of type @ a NumberType <nl> - @ tparam NumberType the type of the number <nl> - <nl> - @ note This function needs to respect the system ' s endianess , because bytes <nl> - in CBOR , MessagePack , and UBJSON are stored in network order ( big <nl> - endian ) and therefore need reordering on little endian systems . <nl> - * / <nl> - template < typename NumberType > <nl> - void write_number ( const NumberType n ) <nl> - { <nl> - / / step 1 : write number to array of length NumberType <nl> - std : : array < CharType , sizeof ( NumberType ) > vec ; <nl> - std : : memcpy ( vec . data ( ) , & n , sizeof ( NumberType ) ) ; <nl> - <nl> - / / step 2 : write array to output ( with possible reordering ) <nl> - if ( is_little_endian ) <nl> - { <nl> - / / reverse byte order prior to conversion if necessary <nl> - std : : reverse ( vec . begin ( ) , vec . end ( ) ) ; <nl> - } <nl> - <nl> - oa - > write_characters ( vec . data ( ) , sizeof ( NumberType ) ) ; <nl> - } <nl> - <nl> - / / UBJSON : write number ( floating point ) <nl> - template < typename NumberType , typename std : : enable_if < <nl> - std : : is_floating_point < NumberType > : : value , int > : : type = 0 > <nl> - void write_number_with_ubjson_prefix ( const NumberType n , <nl> - const bool add_prefix ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( get_ubjson_float_prefix ( n ) ) ; <nl> - } <nl> - write_number ( n ) ; <nl> - } <nl> - <nl> - / / UBJSON : write number ( unsigned integer ) <nl> - template < typename NumberType , typename std : : enable_if < <nl> - std : : is_unsigned < NumberType > : : value , int > : : type = 0 > <nl> - void write_number_with_ubjson_prefix ( const NumberType n , <nl> - const bool add_prefix ) <nl> - { <nl> - if ( n < = static_cast < uint64_t > ( ( std : : numeric_limits < int8_t > : : max ) ( ) ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' i ' ) ) ; / / int8 <nl> - } <nl> - write_number ( static_cast < uint8_t > ( n ) ) ; <nl> - } <nl> - else if ( n < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' U ' ) ) ; / / uint8 <nl> - } <nl> - write_number ( static_cast < uint8_t > ( n ) ) ; <nl> - } <nl> - else if ( n < = static_cast < uint64_t > ( ( std : : numeric_limits < int16_t > : : max ) ( ) ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' I ' ) ) ; / / int16 <nl> - } <nl> - write_number ( static_cast < int16_t > ( n ) ) ; <nl> - } <nl> - else if ( n < = static_cast < uint64_t > ( ( std : : numeric_limits < int32_t > : : max ) ( ) ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' l ' ) ) ; / / int32 <nl> - } <nl> - write_number ( static_cast < int32_t > ( n ) ) ; <nl> - } <nl> - else if ( n < = static_cast < uint64_t > ( ( std : : numeric_limits < int64_t > : : max ) ( ) ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' L ' ) ) ; / / int64 <nl> - } <nl> - write_number ( static_cast < int64_t > ( n ) ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 407 , " number overflow serializing " + std : : to_string ( n ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / UBJSON : write number ( signed integer ) <nl> - template < typename NumberType , typename std : : enable_if < <nl> - std : : is_signed < NumberType > : : value and <nl> - not std : : is_floating_point < NumberType > : : value , int > : : type = 0 > <nl> - void write_number_with_ubjson_prefix ( const NumberType n , <nl> - const bool add_prefix ) <nl> - { <nl> - if ( ( std : : numeric_limits < int8_t > : : min ) ( ) < = n and n < = ( std : : numeric_limits < int8_t > : : max ) ( ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' i ' ) ) ; / / int8 <nl> - } <nl> - write_number ( static_cast < int8_t > ( n ) ) ; <nl> - } <nl> - else if ( static_cast < int64_t > ( ( std : : numeric_limits < uint8_t > : : min ) ( ) ) < = n and n < = static_cast < int64_t > ( ( std : : numeric_limits < uint8_t > : : max ) ( ) ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' U ' ) ) ; / / uint8 <nl> - } <nl> - write_number ( static_cast < uint8_t > ( n ) ) ; <nl> - } <nl> - else if ( ( std : : numeric_limits < int16_t > : : min ) ( ) < = n and n < = ( std : : numeric_limits < int16_t > : : max ) ( ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' I ' ) ) ; / / int16 <nl> - } <nl> - write_number ( static_cast < int16_t > ( n ) ) ; <nl> - } <nl> - else if ( ( std : : numeric_limits < int32_t > : : min ) ( ) < = n and n < = ( std : : numeric_limits < int32_t > : : max ) ( ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' l ' ) ) ; / / int32 <nl> - } <nl> - write_number ( static_cast < int32_t > ( n ) ) ; <nl> - } <nl> - else if ( ( std : : numeric_limits < int64_t > : : min ) ( ) < = n and n < = ( std : : numeric_limits < int64_t > : : max ) ( ) ) <nl> - { <nl> - if ( add_prefix ) <nl> - { <nl> - oa - > write_character ( static_cast < CharType > ( ' L ' ) ) ; / / int64 <nl> - } <nl> - write_number ( static_cast < int64_t > ( n ) ) ; <nl> - } <nl> - / / LCOV_EXCL_START <nl> - else <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 407 , " number overflow serializing " + std : : to_string ( n ) ) ) ; <nl> - } <nl> - / / LCOV_EXCL_STOP <nl> - } <nl> - <nl> - / * ! <nl> - @ brief determine the type prefix of container values <nl> - <nl> - @ note This function does not need to be 100 % accurate when it comes to <nl> - integer limits . In case a number exceeds the limits of int64_t , <nl> - this will be detected by a later call to function <nl> - write_number_with_ubjson_prefix . Therefore , we return ' L ' for any <nl> - value that does not fit the previous limits . <nl> - * / <nl> - CharType ubjson_prefix ( const BasicJsonType & j ) const noexcept <nl> - { <nl> - switch ( j . type ( ) ) <nl> - { <nl> - case value_t : : null : <nl> - return ' Z ' ; <nl> - <nl> - case value_t : : boolean : <nl> - return j . m_value . boolean ? ' T ' : ' F ' ; <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - if ( ( std : : numeric_limits < int8_t > : : min ) ( ) < = j . m_value . number_integer and j . m_value . number_integer < = ( std : : numeric_limits < int8_t > : : max ) ( ) ) <nl> - { <nl> - return ' i ' ; <nl> - } <nl> - else if ( ( std : : numeric_limits < uint8_t > : : min ) ( ) < = j . m_value . number_integer and j . m_value . number_integer < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - return ' U ' ; <nl> - } <nl> - else if ( ( std : : numeric_limits < int16_t > : : min ) ( ) < = j . m_value . number_integer and j . m_value . number_integer < = ( std : : numeric_limits < int16_t > : : max ) ( ) ) <nl> - { <nl> - return ' I ' ; <nl> - } <nl> - else if ( ( std : : numeric_limits < int32_t > : : min ) ( ) < = j . m_value . number_integer and j . m_value . number_integer < = ( std : : numeric_limits < int32_t > : : max ) ( ) ) <nl> - { <nl> - return ' l ' ; <nl> - } <nl> - else / / no check and assume int64_t ( see note above ) <nl> - { <nl> - return ' L ' ; <nl> - } <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - if ( j . m_value . number_unsigned < = ( std : : numeric_limits < int8_t > : : max ) ( ) ) <nl> - { <nl> - return ' i ' ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < uint8_t > : : max ) ( ) ) <nl> - { <nl> - return ' U ' ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < int16_t > : : max ) ( ) ) <nl> - { <nl> - return ' I ' ; <nl> - } <nl> - else if ( j . m_value . number_unsigned < = ( std : : numeric_limits < int32_t > : : max ) ( ) ) <nl> - { <nl> - return ' l ' ; <nl> - } <nl> - else / / no check and assume int64_t ( see note above ) <nl> - { <nl> - return ' L ' ; <nl> - } <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - return get_ubjson_float_prefix ( j . m_value . number_float ) ; <nl> - <nl> - case value_t : : string : <nl> - return ' S ' ; <nl> - <nl> - case value_t : : array : <nl> - return ' [ ' ; <nl> - <nl> - case value_t : : object : <nl> - return ' { ' ; <nl> - <nl> - default : / / discarded values <nl> - return ' N ' ; <nl> - } <nl> - } <nl> - <nl> - static constexpr CharType get_cbor_float_prefix ( float ) <nl> - { <nl> - return static_cast < CharType > ( 0xFA ) ; / / Single - Precision Float <nl> - } <nl> - <nl> - static constexpr CharType get_cbor_float_prefix ( double ) <nl> - { <nl> - return static_cast < CharType > ( 0xFB ) ; / / Double - Precision Float <nl> - } <nl> - <nl> - static constexpr CharType get_msgpack_float_prefix ( float ) <nl> - { <nl> - return static_cast < CharType > ( 0xCA ) ; / / float 32 <nl> - } <nl> - <nl> - static constexpr CharType get_msgpack_float_prefix ( double ) <nl> - { <nl> - return static_cast < CharType > ( 0xCB ) ; / / float 64 <nl> - } <nl> - <nl> - static constexpr CharType get_ubjson_float_prefix ( float ) <nl> - { <nl> - return ' d ' ; / / float 32 <nl> - } <nl> - <nl> - static constexpr CharType get_ubjson_float_prefix ( double ) <nl> - { <nl> - return ' D ' ; / / float 64 <nl> - } <nl> - <nl> - private : <nl> - / / / whether we can assume little endianess <nl> - const bool is_little_endian = binary_reader < BasicJsonType > : : little_endianess ( ) ; <nl> - <nl> - / / / the output <nl> - output_adapter_t < CharType > oa = nullptr ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / output / serializer . hpp > <nl> - <nl> - <nl> - # include < algorithm > / / reverse , remove , fill , find , none_of <nl> - # include < array > / / array <nl> - # include < cassert > / / assert <nl> - # include < ciso646 > / / and , or <nl> - # include < clocale > / / localeconv , lconv <nl> - # include < cmath > / / labs , isfinite , isnan , signbit <nl> - # include < cstddef > / / size_t , ptrdiff_t <nl> - # include < cstdint > / / uint8_t <nl> - # include < cstdio > / / snprintf <nl> - # include < limits > / / numeric_limits <nl> - # include < string > / / string <nl> - # include < type_traits > / / is_same <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / conversions / to_chars . hpp > <nl> - <nl> - <nl> - # include < cassert > / / assert <nl> - # include < ciso646 > / / or , and , not <nl> - # include < cmath > / / signbit , isfinite <nl> - # include < cstdint > / / intN_t , uintN_t <nl> - # include < cstring > / / memcpy , memmove <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - <nl> - / * ! <nl> - @ brief implements the Grisu2 algorithm for binary to decimal floating - point <nl> - conversion . <nl> - <nl> - This implementation is a slightly modified version of the reference <nl> - implementation which may be obtained from <nl> - http : / / florian . loitsch . com / publications ( bench . tar . gz ) . <nl> - <nl> - The code is distributed under the MIT license , Copyright ( c ) 2009 Florian Loitsch . <nl> - <nl> - For a detailed description of the algorithm see : <nl> - <nl> - [ 1 ] Loitsch , " Printing Floating - Point Numbers Quickly and Accurately with <nl> - Integers " , Proceedings of the ACM SIGPLAN 2010 Conference on Programming <nl> - Language Design and Implementation , PLDI 2010 <nl> - [ 2 ] Burger , Dybvig , " Printing Floating - Point Numbers Quickly and Accurately " , <nl> - Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language <nl> - Design and Implementation , PLDI 1996 <nl> - * / <nl> - namespace dtoa_impl <nl> - { <nl> - <nl> - template < typename Target , typename Source > <nl> - Target reinterpret_bits ( const Source source ) <nl> - { <nl> - static_assert ( sizeof ( Target ) = = sizeof ( Source ) , " size mismatch " ) ; <nl> - <nl> - Target target ; <nl> - std : : memcpy ( & target , & source , sizeof ( Source ) ) ; <nl> - return target ; <nl> - } <nl> - <nl> - struct diyfp / / f * 2 ^ e <nl> - { <nl> - static constexpr int kPrecision = 64 ; / / = q <nl> - <nl> - uint64_t f ; <nl> - int e ; <nl> - <nl> - constexpr diyfp ( ) noexcept : f ( 0 ) , e ( 0 ) { } <nl> - constexpr diyfp ( uint64_t f_ , int e_ ) noexcept : f ( f_ ) , e ( e_ ) { } <nl> - <nl> - / * ! <nl> - @ brief returns x - y <nl> - @ pre x . e = = y . e and x . f > = y . f <nl> - * / <nl> - static diyfp sub ( const diyfp & x , const diyfp & y ) noexcept <nl> - { <nl> - assert ( x . e = = y . e ) ; <nl> - assert ( x . f > = y . f ) ; <nl> - <nl> - return diyfp ( x . f - y . f , x . e ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns x * y <nl> - @ note The result is rounded . ( Only the upper q bits are returned . ) <nl> - * / <nl> - static diyfp mul ( const diyfp & x , const diyfp & y ) noexcept <nl> - { <nl> - static_assert ( kPrecision = = 64 , " internal error " ) ; <nl> - <nl> - / / Computes : <nl> - / / f = round ( ( x . f * y . f ) / 2 ^ q ) <nl> - / / e = x . e + y . e + q <nl> - <nl> - / / Emulate the 64 - bit * 64 - bit multiplication : <nl> - / / <nl> - / / p = u * v <nl> - / / = ( u_lo + 2 ^ 32 u_hi ) ( v_lo + 2 ^ 32 v_hi ) <nl> - / / = ( u_lo v_lo ) + 2 ^ 32 ( ( u_lo v_hi ) + ( u_hi v_lo ) ) + 2 ^ 64 ( u_hi v_hi ) <nl> - / / = ( p0 ) + 2 ^ 32 ( ( p1 ) + ( p2 ) ) + 2 ^ 64 ( p3 ) <nl> - / / = ( p0_lo + 2 ^ 32 p0_hi ) + 2 ^ 32 ( ( p1_lo + 2 ^ 32 p1_hi ) + ( p2_lo + 2 ^ 32 p2_hi ) ) + 2 ^ 64 ( p3 ) <nl> - / / = ( p0_lo ) + 2 ^ 32 ( p0_hi + p1_lo + p2_lo ) + 2 ^ 64 ( p1_hi + p2_hi + p3 ) <nl> - / / = ( p0_lo ) + 2 ^ 32 ( Q ) + 2 ^ 64 ( H ) <nl> - / / = ( p0_lo ) + 2 ^ 32 ( Q_lo + 2 ^ 32 Q_hi ) + 2 ^ 64 ( H ) <nl> - / / <nl> - / / ( Since Q might be larger than 2 ^ 32 - 1 ) <nl> - / / <nl> - / / = ( p0_lo + 2 ^ 32 Q_lo ) + 2 ^ 64 ( Q_hi + H ) <nl> - / / <nl> - / / ( Q_hi + H does not overflow a 64 - bit int ) <nl> - / / <nl> - / / = p_lo + 2 ^ 64 p_hi <nl> - <nl> - const uint64_t u_lo = x . f & 0xFFFFFFFF ; <nl> - const uint64_t u_hi = x . f > > 32 ; <nl> - const uint64_t v_lo = y . f & 0xFFFFFFFF ; <nl> - const uint64_t v_hi = y . f > > 32 ; <nl> - <nl> - const uint64_t p0 = u_lo * v_lo ; <nl> - const uint64_t p1 = u_lo * v_hi ; <nl> - const uint64_t p2 = u_hi * v_lo ; <nl> - const uint64_t p3 = u_hi * v_hi ; <nl> - <nl> - const uint64_t p0_hi = p0 > > 32 ; <nl> - const uint64_t p1_lo = p1 & 0xFFFFFFFF ; <nl> - const uint64_t p1_hi = p1 > > 32 ; <nl> - const uint64_t p2_lo = p2 & 0xFFFFFFFF ; <nl> - const uint64_t p2_hi = p2 > > 32 ; <nl> - <nl> - uint64_t Q = p0_hi + p1_lo + p2_lo ; <nl> - <nl> - / / The full product might now be computed as <nl> - / / <nl> - / / p_hi = p3 + p2_hi + p1_hi + ( Q > > 32 ) <nl> - / / p_lo = p0_lo + ( Q < < 32 ) <nl> - / / <nl> - / / But in this particular case here , the full p_lo is not required . <nl> - / / Effectively we only need to add the highest bit in p_lo to p_hi ( and <nl> - / / Q_hi + 1 does not overflow ) . <nl> - <nl> - Q + = uint64_t { 1 } < < ( 64 - 32 - 1 ) ; / / round , ties up <nl> - <nl> - const uint64_t h = p3 + p2_hi + p1_hi + ( Q > > 32 ) ; <nl> - <nl> - return diyfp ( h , x . e + y . e + 64 ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief normalize x such that the significand is > = 2 ^ ( q - 1 ) <nl> - @ pre x . f ! = 0 <nl> - * / <nl> - static diyfp normalize ( diyfp x ) noexcept <nl> - { <nl> - assert ( x . f ! = 0 ) ; <nl> - <nl> - while ( ( x . f > > 63 ) = = 0 ) <nl> - { <nl> - x . f < < = 1 ; <nl> - x . e - - ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief normalize x such that the result has the exponent E <nl> - @ pre e > = x . e and the upper e - x . e bits of x . f must be zero . <nl> - * / <nl> - static diyfp normalize_to ( const diyfp & x , const int target_exponent ) noexcept <nl> - { <nl> - const int delta = x . e - target_exponent ; <nl> - <nl> - assert ( delta > = 0 ) ; <nl> - assert ( ( ( x . f < < delta ) > > delta ) = = x . f ) ; <nl> - <nl> - return diyfp ( x . f < < delta , target_exponent ) ; <nl> - } <nl> - } ; <nl> - <nl> - struct boundaries <nl> - { <nl> - diyfp w ; <nl> - diyfp minus ; <nl> - diyfp plus ; <nl> - } ; <nl> - <nl> - / * ! <nl> - Compute the ( normalized ) diyfp representing the input number ' value ' and its <nl> - boundaries . <nl> - <nl> - @ pre value must be finite and positive <nl> - * / <nl> - template < typename FloatType > <nl> - boundaries compute_boundaries ( FloatType value ) <nl> - { <nl> - assert ( std : : isfinite ( value ) ) ; <nl> - assert ( value > 0 ) ; <nl> - <nl> - / / Convert the IEEE representation into a diyfp . <nl> - / / <nl> - / / If v is denormal : <nl> - / / value = 0 . F * 2 ^ ( 1 - bias ) = ( F ) * 2 ^ ( 1 - bias - ( p - 1 ) ) <nl> - / / If v is normalized : <nl> - / / value = 1 . F * 2 ^ ( E - bias ) = ( 2 ^ ( p - 1 ) + F ) * 2 ^ ( E - bias - ( p - 1 ) ) <nl> - <nl> - static_assert ( std : : numeric_limits < FloatType > : : is_iec559 , <nl> - " internal error : dtoa_short requires an IEEE - 754 floating - point implementation " ) ; <nl> - <nl> - constexpr int kPrecision = std : : numeric_limits < FloatType > : : digits ; / / = p ( includes the hidden bit ) <nl> - constexpr int kBias = std : : numeric_limits < FloatType > : : max_exponent - 1 + ( kPrecision - 1 ) ; <nl> - constexpr int kMinExp = 1 - kBias ; <nl> - constexpr uint64_t kHiddenBit = uint64_t { 1 } < < ( kPrecision - 1 ) ; / / = 2 ^ ( p - 1 ) <nl> - <nl> - using bits_type = typename std : : conditional < kPrecision = = 24 , uint32_t , uint64_t > : : type ; <nl> - <nl> - const uint64_t bits = reinterpret_bits < bits_type > ( value ) ; <nl> - const uint64_t E = bits > > ( kPrecision - 1 ) ; <nl> - const uint64_t F = bits & ( kHiddenBit - 1 ) ; <nl> - <nl> - const bool is_denormal = ( E = = 0 ) ; <nl> - const diyfp v = is_denormal <nl> - ? diyfp ( F , kMinExp ) <nl> - : diyfp ( F + kHiddenBit , static_cast < int > ( E ) - kBias ) ; <nl> - <nl> - / / Compute the boundaries m - and m + of the floating - point value <nl> - / / v = f * 2 ^ e . <nl> - / / <nl> - / / Determine v - and v + , the floating - point predecessor and successor if v , <nl> - / / respectively . <nl> - / / <nl> - / / v - = v - 2 ^ e if f ! = 2 ^ ( p - 1 ) or e = = e_min ( A ) <nl> - / / = v - 2 ^ ( e - 1 ) if f = = 2 ^ ( p - 1 ) and e > e_min ( B ) <nl> - / / <nl> - / / v + = v + 2 ^ e <nl> - / / <nl> - / / Let m - = ( v - + v ) / 2 and m + = ( v + v + ) / 2 . All real numbers _strictly_ <nl> - / / between m - and m + round to v , regardless of how the input rounding <nl> - / / algorithm breaks ties . <nl> - / / <nl> - / / mmm + mmmmmmmmmmmm - + mmmmmmmmmmmm - + mmmmmmmmmmmm - + mmmmmmmmmmmm - + mmm ( A ) <nl> - / / v - m - v m + v + <nl> - / / <nl> - / / mmmmmmmmmmmmmmm - - + mmmmmm + mmmmmm + mmmmmmmmmmmm - + mmmmmmmmmmmm - + mmm ( B ) <nl> - / / v - m - v m + v + <nl> - <nl> - const bool lower_boundary_is_closer = ( F = = 0 and E > 1 ) ; <nl> - const diyfp m_plus = diyfp ( 2 * v . f + 1 , v . e - 1 ) ; <nl> - const diyfp m_minus = lower_boundary_is_closer <nl> - ? diyfp ( 4 * v . f - 1 , v . e - 2 ) / / ( B ) <nl> - : diyfp ( 2 * v . f - 1 , v . e - 1 ) ; / / ( A ) <nl> - <nl> - / / Determine the normalized w + = m + . <nl> - const diyfp w_plus = diyfp : : normalize ( m_plus ) ; <nl> - <nl> - / / Determine w - = m - such that e_ ( w - ) = e_ ( w + ) . <nl> - const diyfp w_minus = diyfp : : normalize_to ( m_minus , w_plus . e ) ; <nl> - <nl> - return { diyfp : : normalize ( v ) , w_minus , w_plus } ; <nl> - } <nl> - <nl> - / / Given normalized diyfp w , Grisu needs to find a ( normalized ) cached <nl> - / / power - of - ten c , such that the exponent of the product c * w = f * 2 ^ e lies <nl> - / / within a certain range [ alpha , gamma ] ( Definition 3 . 2 from [ 1 ] ) <nl> - / / <nl> - / / alpha < = e = e_c + e_w + q < = gamma <nl> - / / <nl> - / / or <nl> - / / <nl> - / / f_c * f_w * 2 ^ alpha < = f_c 2 ^ ( e_c ) * f_w 2 ^ ( e_w ) * 2 ^ q <nl> - / / < = f_c * f_w * 2 ^ gamma <nl> - / / <nl> - / / Since c and w are normalized , i . e . 2 ^ ( q - 1 ) < = f < 2 ^ q , this implies <nl> - / / <nl> - / / 2 ^ ( q - 1 ) * 2 ^ ( q - 1 ) * 2 ^ alpha < = c * w * 2 ^ q < 2 ^ q * 2 ^ q * 2 ^ gamma <nl> - / / <nl> - / / or <nl> - / / <nl> - / / 2 ^ ( q - 2 + alpha ) < = c * w < 2 ^ ( q + gamma ) <nl> - / / <nl> - / / The choice of ( alpha , gamma ) determines the size of the table and the form of <nl> - / / the digit generation procedure . Using ( alpha , gamma ) = ( - 60 , - 32 ) works out well <nl> - / / in practice : <nl> - / / <nl> - / / The idea is to cut the number c * w = f * 2 ^ e into two parts , which can be <nl> - / / processed independently : An integral part p1 , and a fractional part p2 : <nl> - / / <nl> - / / f * 2 ^ e = ( ( f div 2 ^ - e ) * 2 ^ - e + ( f mod 2 ^ - e ) ) * 2 ^ e <nl> - / / = ( f div 2 ^ - e ) + ( f mod 2 ^ - e ) * 2 ^ e <nl> - / / = p1 + p2 * 2 ^ e <nl> - / / <nl> - / / The conversion of p1 into decimal form requires a series of divisions and <nl> - / / modulos by ( a power of ) 10 . These operations are faster for 32 - bit than for <nl> - / / 64 - bit integers , so p1 should ideally fit into a 32 - bit integer . This can be <nl> - / / achieved by choosing <nl> - / / <nl> - / / - e > = 32 or e < = - 32 : = gamma <nl> - / / <nl> - / / In order to convert the fractional part <nl> - / / <nl> - / / p2 * 2 ^ e = p2 / 2 ^ - e = d [ - 1 ] / 10 ^ 1 + d [ - 2 ] / 10 ^ 2 + . . . <nl> - / / <nl> - / / into decimal form , the fraction is repeatedly multiplied by 10 and the digits <nl> - / / d [ - i ] are extracted in order : <nl> - / / <nl> - / / ( 10 * p2 ) div 2 ^ - e = d [ - 1 ] <nl> - / / ( 10 * p2 ) mod 2 ^ - e = d [ - 2 ] / 10 ^ 1 + . . . <nl> - / / <nl> - / / The multiplication by 10 must not overflow . It is sufficient to choose <nl> - / / <nl> - / / 10 * p2 < 16 * p2 = 2 ^ 4 * p2 < = 2 ^ 64 . <nl> - / / <nl> - / / Since p2 = f mod 2 ^ - e < 2 ^ - e , <nl> - / / <nl> - / / - e < = 60 or e > = - 60 : = alpha <nl> - <nl> - constexpr int kAlpha = - 60 ; <nl> - constexpr int kGamma = - 32 ; <nl> - <nl> - struct cached_power / / c = f * 2 ^ e ~ = 10 ^ k <nl> - { <nl> - uint64_t f ; <nl> - int e ; <nl> - int k ; <nl> - } ; <nl> - <nl> - / * ! <nl> - For a normalized diyfp w = f * 2 ^ e , this function returns a ( normalized ) cached <nl> - power - of - ten c = f_c * 2 ^ e_c , such that the exponent of the product w * c <nl> - satisfies ( Definition 3 . 2 from [ 1 ] ) <nl> - <nl> - alpha < = e_c + e + q < = gamma . <nl> - * / <nl> - inline cached_power get_cached_power_for_binary_exponent ( int e ) <nl> - { <nl> - / / Now <nl> - / / <nl> - / / alpha < = e_c + e + q < = gamma ( 1 ) <nl> - / / = = > f_c * 2 ^ alpha < = c * 2 ^ e * 2 ^ q <nl> - / / <nl> - / / and since the c ' s are normalized , 2 ^ ( q - 1 ) < = f_c , <nl> - / / <nl> - / / = = > 2 ^ ( q - 1 + alpha ) < = c * 2 ^ ( e + q ) <nl> - / / = = > 2 ^ ( alpha - e - 1 ) < = c <nl> - / / <nl> - / / If c were an exakt power of ten , i . e . c = 10 ^ k , one may determine k as <nl> - / / <nl> - / / k = ceil ( log_10 ( 2 ^ ( alpha - e - 1 ) ) ) <nl> - / / = ceil ( ( alpha - e - 1 ) * log_10 ( 2 ) ) <nl> - / / <nl> - / / From the paper : <nl> - / / " In theory the result of the procedure could be wrong since c is rounded , <nl> - / / and the computation itself is approximated [ . . . ] . In practice , however , <nl> - / / this simple function is sufficient . " <nl> - / / <nl> - / / For IEEE double precision floating - point numbers converted into <nl> - / / normalized diyfp ' s w = f * 2 ^ e , with q = 64 , <nl> - / / <nl> - / / e > = - 1022 ( min IEEE exponent ) <nl> - / / - 52 ( p - 1 ) <nl> - / / - 52 ( p - 1 , possibly normalize denormal IEEE numbers ) <nl> - / / - 11 ( normalize the diyfp ) <nl> - / / = - 1137 <nl> - / / <nl> - / / and <nl> - / / <nl> - / / e < = + 1023 ( max IEEE exponent ) <nl> - / / - 52 ( p - 1 ) <nl> - / / - 11 ( normalize the diyfp ) <nl> - / / = 960 <nl> - / / <nl> - / / This binary exponent range [ - 1137 , 960 ] results in a decimal exponent <nl> - / / range [ - 307 , 324 ] . One does not need to store a cached power for each <nl> - / / k in this range . For each such k it suffices to find a cached power <nl> - / / such that the exponent of the product lies in [ alpha , gamma ] . <nl> - / / This implies that the difference of the decimal exponents of adjacent <nl> - / / table entries must be less than or equal to <nl> - / / <nl> - / / floor ( ( gamma - alpha ) * log_10 ( 2 ) ) = 8 . <nl> - / / <nl> - / / ( A smaller distance gamma - alpha would require a larger table . ) <nl> - <nl> - / / NB : <nl> - / / Actually this function returns c , such that - 60 < = e_c + e + 64 < = - 34 . <nl> - <nl> - constexpr int kCachedPowersSize = 79 ; <nl> - constexpr int kCachedPowersMinDecExp = - 300 ; <nl> - constexpr int kCachedPowersDecStep = 8 ; <nl> - <nl> - static constexpr cached_power kCachedPowers [ ] = <nl> - { <nl> - { 0xAB70FE17C79AC6CA , - 1060 , - 300 } , <nl> - { 0xFF77B1FCBEBCDC4F , - 1034 , - 292 } , <nl> - { 0xBE5691EF416BD60C , - 1007 , - 284 } , <nl> - { 0x8DD01FAD907FFC3C , - 980 , - 276 } , <nl> - { 0xD3515C2831559A83 , - 954 , - 268 } , <nl> - { 0x9D71AC8FADA6C9B5 , - 927 , - 260 } , <nl> - { 0xEA9C227723EE8BCB , - 901 , - 252 } , <nl> - { 0xAECC49914078536D , - 874 , - 244 } , <nl> - { 0x823C12795DB6CE57 , - 847 , - 236 } , <nl> - { 0xC21094364DFB5637 , - 821 , - 228 } , <nl> - { 0x9096EA6F3848984F , - 794 , - 220 } , <nl> - { 0xD77485CB25823AC7 , - 768 , - 212 } , <nl> - { 0xA086CFCD97BF97F4 , - 741 , - 204 } , <nl> - { 0xEF340A98172AACE5 , - 715 , - 196 } , <nl> - { 0xB23867FB2A35B28E , - 688 , - 188 } , <nl> - { 0x84C8D4DFD2C63F3B , - 661 , - 180 } , <nl> - { 0xC5DD44271AD3CDBA , - 635 , - 172 } , <nl> - { 0x936B9FCEBB25C996 , - 608 , - 164 } , <nl> - { 0xDBAC6C247D62A584 , - 582 , - 156 } , <nl> - { 0xA3AB66580D5FDAF6 , - 555 , - 148 } , <nl> - { 0xF3E2F893DEC3F126 , - 529 , - 140 } , <nl> - { 0xB5B5ADA8AAFF80B8 , - 502 , - 132 } , <nl> - { 0x87625F056C7C4A8B , - 475 , - 124 } , <nl> - { 0xC9BCFF6034C13053 , - 449 , - 116 } , <nl> - { 0x964E858C91BA2655 , - 422 , - 108 } , <nl> - { 0xDFF9772470297EBD , - 396 , - 100 } , <nl> - { 0xA6DFBD9FB8E5B88F , - 369 , - 92 } , <nl> - { 0xF8A95FCF88747D94 , - 343 , - 84 } , <nl> - { 0xB94470938FA89BCF , - 316 , - 76 } , <nl> - { 0x8A08F0F8BF0F156B , - 289 , - 68 } , <nl> - { 0xCDB02555653131B6 , - 263 , - 60 } , <nl> - { 0x993FE2C6D07B7FAC , - 236 , - 52 } , <nl> - { 0xE45C10C42A2B3B06 , - 210 , - 44 } , <nl> - { 0xAA242499697392D3 , - 183 , - 36 } , <nl> - { 0xFD87B5F28300CA0E , - 157 , - 28 } , <nl> - { 0xBCE5086492111AEB , - 130 , - 20 } , <nl> - { 0x8CBCCC096F5088CC , - 103 , - 12 } , <nl> - { 0xD1B71758E219652C , - 77 , - 4 } , <nl> - { 0x9C40000000000000 , - 50 , 4 } , <nl> - { 0xE8D4A51000000000 , - 24 , 12 } , <nl> - { 0xAD78EBC5AC620000 , 3 , 20 } , <nl> - { 0x813F3978F8940984 , 30 , 28 } , <nl> - { 0xC097CE7BC90715B3 , 56 , 36 } , <nl> - { 0x8F7E32CE7BEA5C70 , 83 , 44 } , <nl> - { 0xD5D238A4ABE98068 , 109 , 52 } , <nl> - { 0x9F4F2726179A2245 , 136 , 60 } , <nl> - { 0xED63A231D4C4FB27 , 162 , 68 } , <nl> - { 0xB0DE65388CC8ADA8 , 189 , 76 } , <nl> - { 0x83C7088E1AAB65DB , 216 , 84 } , <nl> - { 0xC45D1DF942711D9A , 242 , 92 } , <nl> - { 0x924D692CA61BE758 , 269 , 100 } , <nl> - { 0xDA01EE641A708DEA , 295 , 108 } , <nl> - { 0xA26DA3999AEF774A , 322 , 116 } , <nl> - { 0xF209787BB47D6B85 , 348 , 124 } , <nl> - { 0xB454E4A179DD1877 , 375 , 132 } , <nl> - { 0x865B86925B9BC5C2 , 402 , 140 } , <nl> - { 0xC83553C5C8965D3D , 428 , 148 } , <nl> - { 0x952AB45CFA97A0B3 , 455 , 156 } , <nl> - { 0xDE469FBD99A05FE3 , 481 , 164 } , <nl> - { 0xA59BC234DB398C25 , 508 , 172 } , <nl> - { 0xF6C69A72A3989F5C , 534 , 180 } , <nl> - { 0xB7DCBF5354E9BECE , 561 , 188 } , <nl> - { 0x88FCF317F22241E2 , 588 , 196 } , <nl> - { 0xCC20CE9BD35C78A5 , 614 , 204 } , <nl> - { 0x98165AF37B2153DF , 641 , 212 } , <nl> - { 0xE2A0B5DC971F303A , 667 , 220 } , <nl> - { 0xA8D9D1535CE3B396 , 694 , 228 } , <nl> - { 0xFB9B7CD9A4A7443C , 720 , 236 } , <nl> - { 0xBB764C4CA7A44410 , 747 , 244 } , <nl> - { 0x8BAB8EEFB6409C1A , 774 , 252 } , <nl> - { 0xD01FEF10A657842C , 800 , 260 } , <nl> - { 0x9B10A4E5E9913129 , 827 , 268 } , <nl> - { 0xE7109BFBA19C0C9D , 853 , 276 } , <nl> - { 0xAC2820D9623BF429 , 880 , 284 } , <nl> - { 0x80444B5E7AA7CF85 , 907 , 292 } , <nl> - { 0xBF21E44003ACDD2D , 933 , 300 } , <nl> - { 0x8E679C2F5E44FF8F , 960 , 308 } , <nl> - { 0xD433179D9C8CB841 , 986 , 316 } , <nl> - { 0x9E19DB92B4E31BA9 , 1013 , 324 } , <nl> - } ; <nl> - <nl> - / / This computation gives exactly the same results for k as <nl> - / / k = ceil ( ( kAlpha - e - 1 ) * 0 . 30102999566398114 ) <nl> - / / for | e | < = 1500 , but doesn ' t require floating - point operations . <nl> - / / NB : log_10 ( 2 ) ~ = 78913 / 2 ^ 18 <nl> - assert ( e > = - 1500 ) ; <nl> - assert ( e < = 1500 ) ; <nl> - const int f = kAlpha - e - 1 ; <nl> - const int k = ( f * 78913 ) / ( 1 < < 18 ) + ( f > 0 ) ; <nl> - <nl> - const int index = ( - kCachedPowersMinDecExp + k + ( kCachedPowersDecStep - 1 ) ) / kCachedPowersDecStep ; <nl> - assert ( index > = 0 ) ; <nl> - assert ( index < kCachedPowersSize ) ; <nl> - static_cast < void > ( kCachedPowersSize ) ; / / Fix warning . <nl> - <nl> - const cached_power cached = kCachedPowers [ index ] ; <nl> - assert ( kAlpha < = cached . e + e + 64 ) ; <nl> - assert ( kGamma > = cached . e + e + 64 ) ; <nl> - <nl> - return cached ; <nl> - } <nl> - <nl> - / * ! <nl> - For n ! = 0 , returns k , such that pow10 : = 10 ^ ( k - 1 ) < = n < 10 ^ k . <nl> - For n = = 0 , returns 1 and sets pow10 : = 1 . <nl> - * / <nl> - inline int find_largest_pow10 ( const uint32_t n , uint32_t & pow10 ) <nl> - { <nl> - / / LCOV_EXCL_START <nl> - if ( n > = 1000000000 ) <nl> - { <nl> - pow10 = 1000000000 ; <nl> - return 10 ; <nl> - } <nl> - / / LCOV_EXCL_STOP <nl> - else if ( n > = 100000000 ) <nl> - { <nl> - pow10 = 100000000 ; <nl> - return 9 ; <nl> - } <nl> - else if ( n > = 10000000 ) <nl> - { <nl> - pow10 = 10000000 ; <nl> - return 8 ; <nl> - } <nl> - else if ( n > = 1000000 ) <nl> - { <nl> - pow10 = 1000000 ; <nl> - return 7 ; <nl> - } <nl> - else if ( n > = 100000 ) <nl> - { <nl> - pow10 = 100000 ; <nl> - return 6 ; <nl> - } <nl> - else if ( n > = 10000 ) <nl> - { <nl> - pow10 = 10000 ; <nl> - return 5 ; <nl> - } <nl> - else if ( n > = 1000 ) <nl> - { <nl> - pow10 = 1000 ; <nl> - return 4 ; <nl> - } <nl> - else if ( n > = 100 ) <nl> - { <nl> - pow10 = 100 ; <nl> - return 3 ; <nl> - } <nl> - else if ( n > = 10 ) <nl> - { <nl> - pow10 = 10 ; <nl> - return 2 ; <nl> - } <nl> - else <nl> - { <nl> - pow10 = 1 ; <nl> - return 1 ; <nl> - } <nl> - } <nl> - <nl> - inline void grisu2_round ( char * buf , int len , uint64_t dist , uint64_t delta , <nl> - uint64_t rest , uint64_t ten_k ) <nl> - { <nl> - assert ( len > = 1 ) ; <nl> - assert ( dist < = delta ) ; <nl> - assert ( rest < = delta ) ; <nl> - assert ( ten_k > 0 ) ; <nl> - <nl> - / / < mmmmmmmmmmmmmmmmmmmmmmmmmmm delta mmm - > <nl> - / / < mmm - dist mmmmmmmmm > <nl> - / / mmmmmmmmmmmm - - [ mmmmmmmmmmmmmmmmmm + mmmmmmmmmmmmmmmmmm - ] mmmmmmmmmmmm - - <nl> - / / M - w M + <nl> - / / <nl> - / / ten_k <nl> - / / < mmmmmm > <nl> - / / < mmm - rest mmm - > <nl> - / / mmmmmmmmmmmm - - [ mmmmmmmmmmmmmmmmmm + mmm - + mmmmmmmmmmmm - - ] mmmmmmmmmmmm - - <nl> - / / w V <nl> - / / = buf * 10 ^ k <nl> - / / <nl> - / / ten_k represents a unit - in - the - last - place in the decimal representation <nl> - / / stored in buf . <nl> - / / Decrement buf by ten_k while this takes buf closer to w . <nl> - <nl> - / / The tests are written in this order to avoid overflow in unsigned <nl> - / / integer arithmetic . <nl> - <nl> - while ( rest < dist <nl> - and delta - rest > = ten_k <nl> - and ( rest + ten_k < dist or dist - rest > rest + ten_k - dist ) ) <nl> - { <nl> - assert ( buf [ len - 1 ] ! = ' 0 ' ) ; <nl> - buf [ len - 1 ] - - ; <nl> - rest + = ten_k ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - Generates V = buffer * 10 ^ decimal_exponent , such that M - < = V < = M + . <nl> - M - and M + must be normalized and share the same exponent - 60 < = e < = - 32 . <nl> - * / <nl> - inline void grisu2_digit_gen ( char * buffer , int & length , int & decimal_exponent , <nl> - diyfp M_minus , diyfp w , diyfp M_plus ) <nl> - { <nl> - static_assert ( kAlpha > = - 60 , " internal error " ) ; <nl> - static_assert ( kGamma < = - 32 , " internal error " ) ; <nl> - <nl> - / / Generates the digits ( and the exponent ) of a decimal floating - point <nl> - / / number V = buffer * 10 ^ decimal_exponent in the range [ M - , M + ] . The diyfp ' s <nl> - / / w , M - and M + share the same exponent e , which satisfies alpha < = e < = gamma . <nl> - / / <nl> - / / < mmmmmmmmmmmmmmmmmmmmmmmmmmm delta mmm - > <nl> - / / < mmm - dist mmmmmmmmm > <nl> - / / mmmmmmmmmmmm - - [ mmmmmmmmmmmmmmmmmm + mmmmmmmmmmmmmmmmmm - ] mmmmmmmmmmmm - - <nl> - / / M - w M + <nl> - / / <nl> - / / Grisu2 generates the digits of M + from left to right and stops as soon as <nl> - / / V is in [ M - , M + ] . <nl> - <nl> - assert ( M_plus . e > = kAlpha ) ; <nl> - assert ( M_plus . e < = kGamma ) ; <nl> - <nl> - uint64_t delta = diyfp : : sub ( M_plus , M_minus ) . f ; / / ( significand of ( M + - M - ) , implicit exponent is e ) <nl> - uint64_t dist = diyfp : : sub ( M_plus , w ) . f ; / / ( significand of ( M + - w ) , implicit exponent is e ) <nl> - <nl> - / / Split M + = f * 2 ^ e into two parts p1 and p2 ( note : e < 0 ) : <nl> - / / <nl> - / / M + = f * 2 ^ e <nl> - / / = ( ( f div 2 ^ - e ) * 2 ^ - e + ( f mod 2 ^ - e ) ) * 2 ^ e <nl> - / / = ( ( p1 ) * 2 ^ - e + ( p2 ) ) * 2 ^ e <nl> - / / = p1 + p2 * 2 ^ e <nl> - <nl> - const diyfp one ( uint64_t { 1 } < < - M_plus . e , M_plus . e ) ; <nl> - <nl> - uint32_t p1 = static_cast < uint32_t > ( M_plus . f > > - one . e ) ; / / p1 = f div 2 ^ - e ( Since - e > = 32 , p1 fits into a 32 - bit int . ) <nl> - uint64_t p2 = M_plus . f & ( one . f - 1 ) ; / / p2 = f mod 2 ^ - e <nl> - <nl> - / / 1 ) <nl> - / / <nl> - / / Generate the digits of the integral part p1 = d [ n - 1 ] . . . d [ 1 ] d [ 0 ] <nl> - <nl> - assert ( p1 > 0 ) ; <nl> - <nl> - uint32_t pow10 ; <nl> - const int k = find_largest_pow10 ( p1 , pow10 ) ; <nl> - <nl> - / / 10 ^ ( k - 1 ) < = p1 < 10 ^ k , pow10 = 10 ^ ( k - 1 ) <nl> - / / <nl> - / / p1 = ( p1 div 10 ^ ( k - 1 ) ) * 10 ^ ( k - 1 ) + ( p1 mod 10 ^ ( k - 1 ) ) <nl> - / / = ( d [ k - 1 ] ) * 10 ^ ( k - 1 ) + ( p1 mod 10 ^ ( k - 1 ) ) <nl> - / / <nl> - / / M + = p1 + p2 * 2 ^ e <nl> - / / = d [ k - 1 ] * 10 ^ ( k - 1 ) + ( p1 mod 10 ^ ( k - 1 ) ) + p2 * 2 ^ e <nl> - / / = d [ k - 1 ] * 10 ^ ( k - 1 ) + ( ( p1 mod 10 ^ ( k - 1 ) ) * 2 ^ - e + p2 ) * 2 ^ e <nl> - / / = d [ k - 1 ] * 10 ^ ( k - 1 ) + ( rest ) * 2 ^ e <nl> - / / <nl> - / / Now generate the digits d [ n ] of p1 from left to right ( n = k - 1 , . . . , 0 ) <nl> - / / <nl> - / / p1 = d [ k - 1 ] . . . d [ n ] * 10 ^ n + d [ n - 1 ] . . . d [ 0 ] <nl> - / / <nl> - / / but stop as soon as <nl> - / / <nl> - / / rest * 2 ^ e = ( d [ n - 1 ] . . . d [ 0 ] * 2 ^ - e + p2 ) * 2 ^ e < = delta * 2 ^ e <nl> - <nl> - int n = k ; <nl> - while ( n > 0 ) <nl> - { <nl> - / / Invariants : <nl> - / / M + = buffer * 10 ^ n + ( p1 + p2 * 2 ^ e ) ( buffer = 0 for n = k ) <nl> - / / pow10 = 10 ^ ( n - 1 ) < = p1 < 10 ^ n <nl> - / / <nl> - const uint32_t d = p1 / pow10 ; / / d = p1 div 10 ^ ( n - 1 ) <nl> - const uint32_t r = p1 % pow10 ; / / r = p1 mod 10 ^ ( n - 1 ) <nl> - / / <nl> - / / M + = buffer * 10 ^ n + ( d * 10 ^ ( n - 1 ) + r ) + p2 * 2 ^ e <nl> - / / = ( buffer * 10 + d ) * 10 ^ ( n - 1 ) + ( r + p2 * 2 ^ e ) <nl> - / / <nl> - assert ( d < = 9 ) ; <nl> - buffer [ length + + ] = static_cast < char > ( ' 0 ' + d ) ; / / buffer : = buffer * 10 + d <nl> - / / <nl> - / / M + = buffer * 10 ^ ( n - 1 ) + ( r + p2 * 2 ^ e ) <nl> - / / <nl> - p1 = r ; <nl> - n - - ; <nl> - / / <nl> - / / M + = buffer * 10 ^ n + ( p1 + p2 * 2 ^ e ) <nl> - / / pow10 = 10 ^ n <nl> - / / <nl> - <nl> - / / Now check if enough digits have been generated . <nl> - / / Compute <nl> - / / <nl> - / / p1 + p2 * 2 ^ e = ( p1 * 2 ^ - e + p2 ) * 2 ^ e = rest * 2 ^ e <nl> - / / <nl> - / / Note : <nl> - / / Since rest and delta share the same exponent e , it suffices to <nl> - / / compare the significands . <nl> - const uint64_t rest = ( uint64_t { p1 } < < - one . e ) + p2 ; <nl> - if ( rest < = delta ) <nl> - { <nl> - / / V = buffer * 10 ^ n , with M - < = V < = M + . <nl> - <nl> - decimal_exponent + = n ; <nl> - <nl> - / / We may now just stop . But instead look if the buffer could be <nl> - / / decremented to bring V closer to w . <nl> - / / <nl> - / / pow10 = 10 ^ n is now 1 ulp in the decimal representation V . <nl> - / / The rounding procedure works with diyfp ' s with an implicit <nl> - / / exponent of e . <nl> - / / <nl> - / / 10 ^ n = ( 10 ^ n * 2 ^ - e ) * 2 ^ e = ulp * 2 ^ e <nl> - / / <nl> - const uint64_t ten_n = uint64_t { pow10 } < < - one . e ; <nl> - grisu2_round ( buffer , length , dist , delta , rest , ten_n ) ; <nl> - <nl> - return ; <nl> - } <nl> - <nl> - pow10 / = 10 ; <nl> - / / <nl> - / / pow10 = 10 ^ ( n - 1 ) < = p1 < 10 ^ n <nl> - / / Invariants restored . <nl> - } <nl> - <nl> - / / 2 ) <nl> - / / <nl> - / / The digits of the integral part have been generated : <nl> - / / <nl> - / / M + = d [ k - 1 ] . . . d [ 1 ] d [ 0 ] + p2 * 2 ^ e <nl> - / / = buffer + p2 * 2 ^ e <nl> - / / <nl> - / / Now generate the digits of the fractional part p2 * 2 ^ e . <nl> - / / <nl> - / / Note : <nl> - / / No decimal point is generated : the exponent is adjusted instead . <nl> - / / <nl> - / / p2 actually represents the fraction <nl> - / / <nl> - / / p2 * 2 ^ e <nl> - / / = p2 / 2 ^ - e <nl> - / / = d [ - 1 ] / 10 ^ 1 + d [ - 2 ] / 10 ^ 2 + . . . <nl> - / / <nl> - / / Now generate the digits d [ - m ] of p1 from left to right ( m = 1 , 2 , . . . ) <nl> - / / <nl> - / / p2 * 2 ^ e = d [ - 1 ] d [ - 2 ] . . . d [ - m ] * 10 ^ - m <nl> - / / + 10 ^ - m * ( d [ - m - 1 ] / 10 ^ 1 + d [ - m - 2 ] / 10 ^ 2 + . . . ) <nl> - / / <nl> - / / using <nl> - / / <nl> - / / 10 ^ m * p2 = ( ( 10 ^ m * p2 ) div 2 ^ - e ) * 2 ^ - e + ( ( 10 ^ m * p2 ) mod 2 ^ - e ) <nl> - / / = ( d ) * 2 ^ - e + ( r ) <nl> - / / <nl> - / / or <nl> - / / 10 ^ m * p2 * 2 ^ e = d + r * 2 ^ e <nl> - / / <nl> - / / i . e . <nl> - / / <nl> - / / M + = buffer + p2 * 2 ^ e <nl> - / / = buffer + 10 ^ - m * ( d + r * 2 ^ e ) <nl> - / / = ( buffer * 10 ^ m + d ) * 10 ^ - m + 10 ^ - m * r * 2 ^ e <nl> - / / <nl> - / / and stop as soon as 10 ^ - m * r * 2 ^ e < = delta * 2 ^ e <nl> - <nl> - assert ( p2 > delta ) ; <nl> - <nl> - int m = 0 ; <nl> - for ( ; ; ) <nl> - { <nl> - / / Invariant : <nl> - / / M + = buffer * 10 ^ - m + 10 ^ - m * ( d [ - m - 1 ] / 10 + d [ - m - 2 ] / 10 ^ 2 + . . . ) * 2 ^ e <nl> - / / = buffer * 10 ^ - m + 10 ^ - m * ( p2 ) * 2 ^ e <nl> - / / = buffer * 10 ^ - m + 10 ^ - m * ( 1 / 10 * ( 10 * p2 ) ) * 2 ^ e <nl> - / / = buffer * 10 ^ - m + 10 ^ - m * ( 1 / 10 * ( ( 10 * p2 div 2 ^ - e ) * 2 ^ - e + ( 10 * p2 mod 2 ^ - e ) ) * 2 ^ e <nl> - / / <nl> - assert ( p2 < = UINT64_MAX / 10 ) ; <nl> - p2 * = 10 ; <nl> - const uint64_t d = p2 > > - one . e ; / / d = ( 10 * p2 ) div 2 ^ - e <nl> - const uint64_t r = p2 & ( one . f - 1 ) ; / / r = ( 10 * p2 ) mod 2 ^ - e <nl> - / / <nl> - / / M + = buffer * 10 ^ - m + 10 ^ - m * ( 1 / 10 * ( d * 2 ^ - e + r ) * 2 ^ e <nl> - / / = buffer * 10 ^ - m + 10 ^ - m * ( 1 / 10 * ( d + r * 2 ^ e ) ) <nl> - / / = ( buffer * 10 + d ) * 10 ^ ( - m - 1 ) + 10 ^ ( - m - 1 ) * r * 2 ^ e <nl> - / / <nl> - assert ( d < = 9 ) ; <nl> - buffer [ length + + ] = static_cast < char > ( ' 0 ' + d ) ; / / buffer : = buffer * 10 + d <nl> - / / <nl> - / / M + = buffer * 10 ^ ( - m - 1 ) + 10 ^ ( - m - 1 ) * r * 2 ^ e <nl> - / / <nl> - p2 = r ; <nl> - m + + ; <nl> - / / <nl> - / / M + = buffer * 10 ^ - m + 10 ^ - m * p2 * 2 ^ e <nl> - / / Invariant restored . <nl> - <nl> - / / Check if enough digits have been generated . <nl> - / / <nl> - / / 10 ^ - m * p2 * 2 ^ e < = delta * 2 ^ e <nl> - / / p2 * 2 ^ e < = 10 ^ m * delta * 2 ^ e <nl> - / / p2 < = 10 ^ m * delta <nl> - delta * = 10 ; <nl> - dist * = 10 ; <nl> - if ( p2 < = delta ) <nl> - { <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / V = buffer * 10 ^ - m , with M - < = V < = M + . <nl> - <nl> - decimal_exponent - = m ; <nl> - <nl> - / / 1 ulp in the decimal representation is now 10 ^ - m . <nl> - / / Since delta and dist are now scaled by 10 ^ m , we need to do the <nl> - / / same with ulp in order to keep the units in sync . <nl> - / / <nl> - / / 10 ^ m * 10 ^ - m = 1 = 2 ^ - e * 2 ^ e = ten_m * 2 ^ e <nl> - / / <nl> - const uint64_t ten_m = one . f ; <nl> - grisu2_round ( buffer , length , dist , delta , p2 , ten_m ) ; <nl> - <nl> - / / By construction this algorithm generates the shortest possible decimal <nl> - / / number ( Loitsch , Theorem 6 . 2 ) which rounds back to w . <nl> - / / For an input number of precision p , at least <nl> - / / <nl> - / / N = 1 + ceil ( p * log_10 ( 2 ) ) <nl> - / / <nl> - / / decimal digits are sufficient to identify all binary floating - point <nl> - / / numbers ( Matula , " In - and - Out conversions " ) . <nl> - / / This implies that the algorithm does not produce more than N decimal <nl> - / / digits . <nl> - / / <nl> - / / N = 17 for p = 53 ( IEEE double precision ) <nl> - / / N = 9 for p = 24 ( IEEE single precision ) <nl> - } <nl> - <nl> - / * ! <nl> - v = buf * 10 ^ decimal_exponent <nl> - len is the length of the buffer ( number of decimal digits ) <nl> - The buffer must be large enough , i . e . > = max_digits10 . <nl> - * / <nl> - inline void grisu2 ( char * buf , int & len , int & decimal_exponent , <nl> - diyfp m_minus , diyfp v , diyfp m_plus ) <nl> - { <nl> - assert ( m_plus . e = = m_minus . e ) ; <nl> - assert ( m_plus . e = = v . e ) ; <nl> - <nl> - / / mmmmmm - - ( mmmmmmmmmmmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmm - - ) mmmmmm - - ( A ) <nl> - / / m - v m + <nl> - / / <nl> - / / mmmmmmmmmmmmmmmmmm - - ( mmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmm - - ) mmmmmm - - ( B ) <nl> - / / m - v m + <nl> - / / <nl> - / / First scale v ( and m - and m + ) such that the exponent is in the range <nl> - / / [ alpha , gamma ] . <nl> - <nl> - const cached_power cached = get_cached_power_for_binary_exponent ( m_plus . e ) ; <nl> - <nl> - const diyfp c_minus_k ( cached . f , cached . e ) ; / / = c ~ = 10 ^ - k <nl> - <nl> - / / The exponent of the products is = v . e + c_minus_k . e + q and is in the range [ alpha , gamma ] <nl> - const diyfp w = diyfp : : mul ( v , c_minus_k ) ; <nl> - const diyfp w_minus = diyfp : : mul ( m_minus , c_minus_k ) ; <nl> - const diyfp w_plus = diyfp : : mul ( m_plus , c_minus_k ) ; <nl> - <nl> - / / mmm - ( mmm + mmm ) mmmmmmmmmmmmmmm ( mmm + mmm ) mmmmmmmmmmmmmmm ( mmm + mmm ) mmm - <nl> - / / w - w w + <nl> - / / = c * m - = c * v = c * m + <nl> - / / <nl> - / / diyfp : : mul rounds its result and c_minus_k is approximated too . w , w - and <nl> - / / w + are now off by a small amount . <nl> - / / In fact : <nl> - / / <nl> - / / w - v * 10 ^ k < 1 ulp <nl> - / / <nl> - / / To account for this inaccuracy , add resp . subtract 1 ulp . <nl> - / / <nl> - / / mmmmmm - - + mmm [ mmmmmmmmmmmmmmm ( mmm + mmm ) mmmmmmmmmmmmmmm ] mmm + mmmmmm - - <nl> - / / w - M - w M + w + <nl> - / / <nl> - / / Now any number in [ M - , M + ] ( bounds included ) will round to w when input , <nl> - / / regardless of how the input rounding algorithm breaks ties . <nl> - / / <nl> - / / And digit_gen generates the shortest possible such number in [ M - , M + ] . <nl> - / / Note that this does not mean that Grisu2 always generates the shortest <nl> - / / possible number in the interval ( m - , m + ) . <nl> - const diyfp M_minus ( w_minus . f + 1 , w_minus . e ) ; <nl> - const diyfp M_plus ( w_plus . f - 1 , w_plus . e ) ; <nl> - <nl> - decimal_exponent = - cached . k ; / / = - ( - k ) = k <nl> - <nl> - grisu2_digit_gen ( buf , len , decimal_exponent , M_minus , w , M_plus ) ; <nl> - } <nl> - <nl> - / * ! <nl> - v = buf * 10 ^ decimal_exponent <nl> - len is the length of the buffer ( number of decimal digits ) <nl> - The buffer must be large enough , i . e . > = max_digits10 . <nl> - * / <nl> - template < typename FloatType > <nl> - void grisu2 ( char * buf , int & len , int & decimal_exponent , FloatType value ) <nl> - { <nl> - static_assert ( diyfp : : kPrecision > = std : : numeric_limits < FloatType > : : digits + 3 , <nl> - " internal error : not enough precision " ) ; <nl> - <nl> - assert ( std : : isfinite ( value ) ) ; <nl> - assert ( value > 0 ) ; <nl> - <nl> - / / If the neighbors ( and boundaries ) of ' value ' are always computed for double - precision <nl> - / / numbers , all float ' s can be recovered using strtod ( and strtof ) . However , the resulting <nl> - / / decimal representations are not exactly " short " . <nl> - / / <nl> - / / The documentation for ' std : : to_chars ' ( https : / / en . cppreference . com / w / cpp / utility / to_chars ) <nl> - / / says " value is converted to a string as if by std : : sprintf in the default ( " C " ) locale " <nl> - / / and since sprintf promotes float ' s to double ' s , I think this is exactly what ' std : : to_chars ' <nl> - / / does . <nl> - / / On the other hand , the documentation for ' std : : to_chars ' requires that " parsing the <nl> - / / representation using the corresponding std : : from_chars function recovers value exactly " . That <nl> - / / indicates that single precision floating - point numbers should be recovered using <nl> - / / ' std : : strtof ' . <nl> - / / <nl> - / / NB : If the neighbors are computed for single - precision numbers , there is a single float <nl> - / / ( 7 . 0385307e - 26f ) which can ' t be recovered using strtod . The resulting double precision <nl> - / / value is off by 1 ulp . <nl> - # if 0 <nl> - const boundaries w = compute_boundaries ( static_cast < double > ( value ) ) ; <nl> - # else <nl> - const boundaries w = compute_boundaries ( value ) ; <nl> - # endif <nl> - <nl> - grisu2 ( buf , len , decimal_exponent , w . minus , w . w , w . plus ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief appends a decimal representation of e to buf <nl> - @ return a pointer to the element following the exponent . <nl> - @ pre - 1000 < e < 1000 <nl> - * / <nl> - inline char * append_exponent ( char * buf , int e ) <nl> - { <nl> - assert ( e > - 1000 ) ; <nl> - assert ( e < 1000 ) ; <nl> - <nl> - if ( e < 0 ) <nl> - { <nl> - e = - e ; <nl> - * buf + + = ' - ' ; <nl> - } <nl> - else <nl> - { <nl> - * buf + + = ' + ' ; <nl> - } <nl> - <nl> - uint32_t k = static_cast < uint32_t > ( e ) ; <nl> - if ( k < 10 ) <nl> - { <nl> - / / Always print at least two digits in the exponent . <nl> - / / This is for compatibility with printf ( " % g " ) . <nl> - * buf + + = ' 0 ' ; <nl> - * buf + + = static_cast < char > ( ' 0 ' + k ) ; <nl> - } <nl> - else if ( k < 100 ) <nl> - { <nl> - * buf + + = static_cast < char > ( ' 0 ' + k / 10 ) ; <nl> - k % = 10 ; <nl> - * buf + + = static_cast < char > ( ' 0 ' + k ) ; <nl> - } <nl> - else <nl> - { <nl> - * buf + + = static_cast < char > ( ' 0 ' + k / 100 ) ; <nl> - k % = 100 ; <nl> - * buf + + = static_cast < char > ( ' 0 ' + k / 10 ) ; <nl> - k % = 10 ; <nl> - * buf + + = static_cast < char > ( ' 0 ' + k ) ; <nl> - } <nl> - <nl> - return buf ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief prettify v = buf * 10 ^ decimal_exponent <nl> - <nl> - If v is in the range [ 10 ^ min_exp , 10 ^ max_exp ) it will be printed in fixed - point <nl> - notation . Otherwise it will be printed in exponential notation . <nl> - <nl> - @ pre min_exp < 0 <nl> - @ pre max_exp > 0 <nl> - * / <nl> - inline char * format_buffer ( char * buf , int len , int decimal_exponent , <nl> - int min_exp , int max_exp ) <nl> - { <nl> - assert ( min_exp < 0 ) ; <nl> - assert ( max_exp > 0 ) ; <nl> - <nl> - const int k = len ; <nl> - const int n = len + decimal_exponent ; <nl> - <nl> - / / v = buf * 10 ^ ( n - k ) <nl> - / / k is the length of the buffer ( number of decimal digits ) <nl> - / / n is the position of the decimal point relative to the start of the buffer . <nl> - <nl> - if ( k < = n and n < = max_exp ) <nl> - { <nl> - / / digits [ 000 ] <nl> - / / len < = max_exp + 2 <nl> - <nl> - std : : memset ( buf + k , ' 0 ' , static_cast < size_t > ( n - k ) ) ; <nl> - / / Make it look like a floating - point number ( # 362 , # 378 ) <nl> - buf [ n + 0 ] = ' . ' ; <nl> - buf [ n + 1 ] = ' 0 ' ; <nl> - return buf + ( n + 2 ) ; <nl> - } <nl> - <nl> - if ( 0 < n and n < = max_exp ) <nl> - { <nl> - / / dig . its <nl> - / / len < = max_digits10 + 1 <nl> - <nl> - assert ( k > n ) ; <nl> - <nl> - std : : memmove ( buf + ( n + 1 ) , buf + n , static_cast < size_t > ( k - n ) ) ; <nl> - buf [ n ] = ' . ' ; <nl> - return buf + ( k + 1 ) ; <nl> - } <nl> - <nl> - if ( min_exp < n and n < = 0 ) <nl> - { <nl> - / / 0 . [ 000 ] digits <nl> - / / len < = 2 + ( - min_exp - 1 ) + max_digits10 <nl> - <nl> - std : : memmove ( buf + ( 2 + - n ) , buf , static_cast < size_t > ( k ) ) ; <nl> - buf [ 0 ] = ' 0 ' ; <nl> - buf [ 1 ] = ' . ' ; <nl> - std : : memset ( buf + 2 , ' 0 ' , static_cast < size_t > ( - n ) ) ; <nl> - return buf + ( 2 + ( - n ) + k ) ; <nl> - } <nl> - <nl> - if ( k = = 1 ) <nl> - { <nl> - / / dE + 123 <nl> - / / len < = 1 + 5 <nl> - <nl> - buf + = 1 ; <nl> - } <nl> - else <nl> - { <nl> - / / d . igitsE + 123 <nl> - / / len < = max_digits10 + 1 + 5 <nl> - <nl> - std : : memmove ( buf + 2 , buf + 1 , static_cast < size_t > ( k - 1 ) ) ; <nl> - buf [ 1 ] = ' . ' ; <nl> - buf + = 1 + k ; <nl> - } <nl> - <nl> - * buf + + = ' e ' ; <nl> - return append_exponent ( buf , n - 1 ) ; <nl> - } <nl> - <nl> - } / / namespace dtoa_impl <nl> - <nl> - / * ! <nl> - @ brief generates a decimal representation of the floating - point number value in [ first , last ) . <nl> - <nl> - The format of the resulting decimal representation is similar to printf ' s % g <nl> - format . Returns an iterator pointing past - the - end of the decimal representation . <nl> - <nl> - @ note The input number must be finite , i . e . NaN ' s and Inf ' s are not supported . <nl> - @ note The buffer must be large enough . <nl> - @ note The result is NOT null - terminated . <nl> - * / <nl> - template < typename FloatType > <nl> - char * to_chars ( char * first , char * last , FloatType value ) <nl> - { <nl> - static_cast < void > ( last ) ; / / maybe unused - fix warning <nl> - assert ( std : : isfinite ( value ) ) ; <nl> - <nl> - / / Use signbit ( value ) instead of ( value < 0 ) since signbit works for - 0 . <nl> - if ( std : : signbit ( value ) ) <nl> - { <nl> - value = - value ; <nl> - * first + + = ' - ' ; <nl> - } <nl> - <nl> - if ( value = = 0 ) / / + - 0 <nl> - { <nl> - * first + + = ' 0 ' ; <nl> - / / Make it look like a floating - point number ( # 362 , # 378 ) <nl> - * first + + = ' . ' ; <nl> - * first + + = ' 0 ' ; <nl> - return first ; <nl> - } <nl> - <nl> - assert ( last - first > = std : : numeric_limits < FloatType > : : max_digits10 ) ; <nl> - <nl> - / / Compute v = buffer * 10 ^ decimal_exponent . <nl> - / / The decimal digits are stored in the buffer , which needs to be interpreted <nl> - / / as an unsigned decimal integer . <nl> - / / len is the length of the buffer , i . e . the number of decimal digits . <nl> - int len = 0 ; <nl> - int decimal_exponent = 0 ; <nl> - dtoa_impl : : grisu2 ( first , len , decimal_exponent , value ) ; <nl> - <nl> - assert ( len < = std : : numeric_limits < FloatType > : : max_digits10 ) ; <nl> - <nl> - / / Format the buffer like printf ( " % . * g " , prec , value ) <nl> - constexpr int kMinExp = - 4 ; <nl> - / / Use digits10 here to increase compatibility with version 2 . <nl> - constexpr int kMaxExp = std : : numeric_limits < FloatType > : : digits10 ; <nl> - <nl> - assert ( last - first > = kMaxExp + 2 ) ; <nl> - assert ( last - first > = 2 + ( - kMinExp - 1 ) + std : : numeric_limits < FloatType > : : max_digits10 ) ; <nl> - assert ( last - first > = std : : numeric_limits < FloatType > : : max_digits10 + 6 ) ; <nl> - <nl> - return dtoa_impl : : format_buffer ( first , len , decimal_exponent , kMinExp , kMaxExp ) ; <nl> - } <nl> - <nl> - } / / namespace detail <nl> - } / / namespace nlohmann <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / meta / cpp_future . hpp > <nl> - <nl> - / / # include < nlohmann / detail / output / output_adapters . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / <nl> - / / serialization / / <nl> - / / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < typename BasicJsonType > <nl> - class serializer <nl> - { <nl> - using string_t = typename BasicJsonType : : string_t ; <nl> - using number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - static constexpr uint8_t UTF8_ACCEPT = 0 ; <nl> - static constexpr uint8_t UTF8_REJECT = 1 ; <nl> - <nl> - public : <nl> - / * ! <nl> - @ param [ in ] s output stream to serialize to <nl> - @ param [ in ] ichar indentation character to use <nl> - * / <nl> - serializer ( output_adapter_t < char > s , const char ichar ) <nl> - : o ( std : : move ( s ) ) , loc ( std : : localeconv ( ) ) , <nl> - thousands_sep ( loc - > thousands_sep = = nullptr ? ' \ 0 ' : * ( loc - > thousands_sep ) ) , <nl> - decimal_point ( loc - > decimal_point = = nullptr ? ' \ 0 ' : * ( loc - > decimal_point ) ) , <nl> - indent_char ( ichar ) , indent_string ( 512 , indent_char ) <nl> - { } <nl> - <nl> - / / delete because of pointer members <nl> - serializer ( const serializer & ) = delete ; <nl> - serializer & operator = ( const serializer & ) = delete ; <nl> - <nl> - / * ! <nl> - @ brief internal implementation of the serialization function <nl> - <nl> - This function is called by the public member function dump and organizes <nl> - the serialization internally . The indentation level is propagated as <nl> - additional parameter . In case of arrays and objects , the function is <nl> - called recursively . <nl> - <nl> - - strings and object keys are escaped using ` escape_string ( ) ` <nl> - - integer numbers are converted implicitly via ` operator < < ` <nl> - - floating - point numbers are converted to a string using ` " % g " ` format <nl> - <nl> - @ param [ in ] val value to serialize <nl> - @ param [ in ] pretty_print whether the output shall be pretty - printed <nl> - @ param [ in ] indent_step the indent level <nl> - @ param [ in ] current_indent the current indent level ( only used internally ) <nl> - * / <nl> - void dump ( const BasicJsonType & val , const bool pretty_print , <nl> - const bool ensure_ascii , <nl> - const unsigned int indent_step , <nl> - const unsigned int current_indent = 0 ) <nl> - { <nl> - switch ( val . m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - if ( val . m_value . object - > empty ( ) ) <nl> - { <nl> - o - > write_characters ( " { } " , 2 ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( pretty_print ) <nl> - { <nl> - o - > write_characters ( " { \ n " , 2 ) ; <nl> - <nl> - / / variable to hold indentation for recursive calls <nl> - const auto new_indent = current_indent + indent_step ; <nl> - if ( JSON_UNLIKELY ( indent_string . size ( ) < new_indent ) ) <nl> - { <nl> - indent_string . resize ( indent_string . size ( ) * 2 , ' ' ) ; <nl> - } <nl> - <nl> - / / first n - 1 elements <nl> - auto i = val . m_value . object - > cbegin ( ) ; <nl> - for ( std : : size_t cnt = 0 ; cnt < val . m_value . object - > size ( ) - 1 ; + + cnt , + + i ) <nl> - { <nl> - o - > write_characters ( indent_string . c_str ( ) , new_indent ) ; <nl> - o - > write_character ( ' \ " ' ) ; <nl> - dump_escaped ( i - > first , ensure_ascii ) ; <nl> - o - > write_characters ( " \ " : " , 3 ) ; <nl> - dump ( i - > second , true , ensure_ascii , indent_step , new_indent ) ; <nl> - o - > write_characters ( " , \ n " , 2 ) ; <nl> - } <nl> - <nl> - / / last element <nl> - assert ( i ! = val . m_value . object - > cend ( ) ) ; <nl> - assert ( std : : next ( i ) = = val . m_value . object - > cend ( ) ) ; <nl> - o - > write_characters ( indent_string . c_str ( ) , new_indent ) ; <nl> - o - > write_character ( ' \ " ' ) ; <nl> - dump_escaped ( i - > first , ensure_ascii ) ; <nl> - o - > write_characters ( " \ " : " , 3 ) ; <nl> - dump ( i - > second , true , ensure_ascii , indent_step , new_indent ) ; <nl> - <nl> - o - > write_character ( ' \ n ' ) ; <nl> - o - > write_characters ( indent_string . c_str ( ) , current_indent ) ; <nl> - o - > write_character ( ' } ' ) ; <nl> - } <nl> - else <nl> - { <nl> - o - > write_character ( ' { ' ) ; <nl> - <nl> - / / first n - 1 elements <nl> - auto i = val . m_value . object - > cbegin ( ) ; <nl> - for ( std : : size_t cnt = 0 ; cnt < val . m_value . object - > size ( ) - 1 ; + + cnt , + + i ) <nl> - { <nl> - o - > write_character ( ' \ " ' ) ; <nl> - dump_escaped ( i - > first , ensure_ascii ) ; <nl> - o - > write_characters ( " \ " : " , 2 ) ; <nl> - dump ( i - > second , false , ensure_ascii , indent_step , current_indent ) ; <nl> - o - > write_character ( ' , ' ) ; <nl> - } <nl> - <nl> - / / last element <nl> - assert ( i ! = val . m_value . object - > cend ( ) ) ; <nl> - assert ( std : : next ( i ) = = val . m_value . object - > cend ( ) ) ; <nl> - o - > write_character ( ' \ " ' ) ; <nl> - dump_escaped ( i - > first , ensure_ascii ) ; <nl> - o - > write_characters ( " \ " : " , 2 ) ; <nl> - dump ( i - > second , false , ensure_ascii , indent_step , current_indent ) ; <nl> - <nl> - o - > write_character ( ' } ' ) ; <nl> - } <nl> - <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - if ( val . m_value . array - > empty ( ) ) <nl> - { <nl> - o - > write_characters ( " [ ] " , 2 ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( pretty_print ) <nl> - { <nl> - o - > write_characters ( " [ \ n " , 2 ) ; <nl> - <nl> - / / variable to hold indentation for recursive calls <nl> - const auto new_indent = current_indent + indent_step ; <nl> - if ( JSON_UNLIKELY ( indent_string . size ( ) < new_indent ) ) <nl> - { <nl> - indent_string . resize ( indent_string . size ( ) * 2 , ' ' ) ; <nl> - } <nl> - <nl> - / / first n - 1 elements <nl> - for ( auto i = val . m_value . array - > cbegin ( ) ; <nl> - i ! = val . m_value . array - > cend ( ) - 1 ; + + i ) <nl> - { <nl> - o - > write_characters ( indent_string . c_str ( ) , new_indent ) ; <nl> - dump ( * i , true , ensure_ascii , indent_step , new_indent ) ; <nl> - o - > write_characters ( " , \ n " , 2 ) ; <nl> - } <nl> - <nl> - / / last element <nl> - assert ( not val . m_value . array - > empty ( ) ) ; <nl> - o - > write_characters ( indent_string . c_str ( ) , new_indent ) ; <nl> - dump ( val . m_value . array - > back ( ) , true , ensure_ascii , indent_step , new_indent ) ; <nl> - <nl> - o - > write_character ( ' \ n ' ) ; <nl> - o - > write_characters ( indent_string . c_str ( ) , current_indent ) ; <nl> - o - > write_character ( ' ] ' ) ; <nl> - } <nl> - else <nl> - { <nl> - o - > write_character ( ' [ ' ) ; <nl> - <nl> - / / first n - 1 elements <nl> - for ( auto i = val . m_value . array - > cbegin ( ) ; <nl> - i ! = val . m_value . array - > cend ( ) - 1 ; + + i ) <nl> - { <nl> - dump ( * i , false , ensure_ascii , indent_step , current_indent ) ; <nl> - o - > write_character ( ' , ' ) ; <nl> - } <nl> - <nl> - / / last element <nl> - assert ( not val . m_value . array - > empty ( ) ) ; <nl> - dump ( val . m_value . array - > back ( ) , false , ensure_ascii , indent_step , current_indent ) ; <nl> - <nl> - o - > write_character ( ' ] ' ) ; <nl> - } <nl> - <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - o - > write_character ( ' \ " ' ) ; <nl> - dump_escaped ( * val . m_value . string , ensure_ascii ) ; <nl> - o - > write_character ( ' \ " ' ) ; <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - if ( val . m_value . boolean ) <nl> - { <nl> - o - > write_characters ( " true " , 4 ) ; <nl> - } <nl> - else <nl> - { <nl> - o - > write_characters ( " false " , 5 ) ; <nl> - } <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - dump_integer ( val . m_value . number_integer ) ; <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - dump_integer ( val . m_value . number_unsigned ) ; <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - dump_float ( val . m_value . number_float ) ; <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : discarded : <nl> - { <nl> - o - > write_characters ( " < discarded > " , 11 ) ; <nl> - return ; <nl> - } <nl> - <nl> - case value_t : : null : <nl> - { <nl> - o - > write_characters ( " null " , 4 ) ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ brief dump escaped string <nl> - <nl> - Escape a string by replacing certain special characters by a sequence of an <nl> - escape character ( backslash ) and another character and other control <nl> - characters by a sequence of " \ u " followed by a four - digit hex <nl> - representation . The escaped string is written to output stream @ a o . <nl> - <nl> - @ param [ in ] s the string to escape <nl> - @ param [ in ] ensure_ascii whether to escape non - ASCII characters with <nl> - \ uXXXX sequences <nl> - <nl> - @ complexity Linear in the length of string @ a s . <nl> - * / <nl> - void dump_escaped ( const string_t & s , const bool ensure_ascii ) <nl> - { <nl> - uint32_t codepoint ; <nl> - uint8_t state = UTF8_ACCEPT ; <nl> - std : : size_t bytes = 0 ; / / number of bytes written to string_buffer <nl> - <nl> - for ( std : : size_t i = 0 ; i < s . size ( ) ; + + i ) <nl> - { <nl> - const auto byte = static_cast < uint8_t > ( s [ i ] ) ; <nl> - <nl> - switch ( decode ( state , codepoint , byte ) ) <nl> - { <nl> - case UTF8_ACCEPT : / / decode found a new code point <nl> - { <nl> - switch ( codepoint ) <nl> - { <nl> - case 0x08 : / / backspace <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' b ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x09 : / / horizontal tab <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' t ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x0A : / / newline <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' n ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x0C : / / formfeed <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' f ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x0D : / / carriage return <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' r ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x22 : / / quotation mark <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' \ " ' ; <nl> - break ; <nl> - } <nl> - <nl> - case 0x5C : / / reverse solidus <nl> - { <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - string_buffer [ bytes + + ] = ' \ \ ' ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / escape control characters ( 0x00 . . 0x1F ) or , if <nl> - / / ensure_ascii parameter is used , non - ASCII characters <nl> - if ( ( codepoint < = 0x1F ) or ( ensure_ascii and ( codepoint > = 0x7F ) ) ) <nl> - { <nl> - if ( codepoint < = 0xFFFF ) <nl> - { <nl> - std : : snprintf ( string_buffer . data ( ) + bytes , 7 , " \ \ u % 04x " , <nl> - static_cast < uint16_t > ( codepoint ) ) ; <nl> - bytes + = 6 ; <nl> - } <nl> - else <nl> - { <nl> - std : : snprintf ( string_buffer . data ( ) + bytes , 13 , " \ \ u % 04x \ \ u % 04x " , <nl> - static_cast < uint16_t > ( 0xD7C0 + ( codepoint > > 10 ) ) , <nl> - static_cast < uint16_t > ( 0xDC00 + ( codepoint & 0x3FF ) ) ) ; <nl> - bytes + = 12 ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / copy byte to buffer ( all previous bytes <nl> - / / been copied have in default case above ) <nl> - string_buffer [ bytes + + ] = s [ i ] ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / write buffer and reset index ; there must be 13 bytes <nl> - / / left , as this is the maximal number of bytes to be <nl> - / / written ( " \ uxxxx \ uxxxx \ 0 " ) for one code point <nl> - if ( string_buffer . size ( ) - bytes < 13 ) <nl> - { <nl> - o - > write_characters ( string_buffer . data ( ) , bytes ) ; <nl> - bytes = 0 ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case UTF8_REJECT : / / decode found invalid UTF - 8 byte <nl> - { <nl> - std : : string sn ( 3 , ' \ 0 ' ) ; <nl> - snprintf ( & sn [ 0 ] , sn . size ( ) , " % . 2X " , byte ) ; <nl> - JSON_THROW ( type_error : : create ( 316 , " invalid UTF - 8 byte at index " + std : : to_string ( i ) + " : 0x " + sn ) ) ; <nl> - } <nl> - <nl> - default : / / decode found yet incomplete multi - byte code point <nl> - { <nl> - if ( not ensure_ascii ) <nl> - { <nl> - / / code point will not be escaped - copy byte to buffer <nl> - string_buffer [ bytes + + ] = s [ i ] ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( JSON_LIKELY ( state = = UTF8_ACCEPT ) ) <nl> - { <nl> - / / write buffer <nl> - if ( bytes > 0 ) <nl> - { <nl> - o - > write_characters ( string_buffer . data ( ) , bytes ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / we finish reading , but do not accept : string was incomplete <nl> - std : : string sn ( 3 , ' \ 0 ' ) ; <nl> - snprintf ( & sn [ 0 ] , sn . size ( ) , " % . 2X " , static_cast < uint8_t > ( s . back ( ) ) ) ; <nl> - JSON_THROW ( type_error : : create ( 316 , " incomplete UTF - 8 string ; last byte : 0x " + sn ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief dump an integer <nl> - <nl> - Dump a given integer to output stream @ a o . Works internally with <nl> - @ a number_buffer . <nl> - <nl> - @ param [ in ] x integer number ( signed or unsigned ) to dump <nl> - @ tparam NumberType either @ a number_integer_t or @ a number_unsigned_t <nl> - * / <nl> - template < typename NumberType , detail : : enable_if_t < <nl> - std : : is_same < NumberType , number_unsigned_t > : : value or <nl> - std : : is_same < NumberType , number_integer_t > : : value , <nl> - int > = 0 > <nl> - void dump_integer ( NumberType x ) <nl> - { <nl> - / / special case for " 0 " <nl> - if ( x = = 0 ) <nl> - { <nl> - o - > write_character ( ' 0 ' ) ; <nl> - return ; <nl> - } <nl> - <nl> - const bool is_negative = ( x < = 0 ) and ( x ! = 0 ) ; / / see issue # 755 <nl> - std : : size_t i = 0 ; <nl> - <nl> - while ( x ! = 0 ) <nl> - { <nl> - / / spare 1 byte for ' \ 0 ' <nl> - assert ( i < number_buffer . size ( ) - 1 ) ; <nl> - <nl> - const auto digit = std : : labs ( static_cast < long > ( x % 10 ) ) ; <nl> - number_buffer [ i + + ] = static_cast < char > ( ' 0 ' + digit ) ; <nl> - x / = 10 ; <nl> - } <nl> - <nl> - if ( is_negative ) <nl> - { <nl> - / / make sure there is capacity for the ' - ' <nl> - assert ( i < number_buffer . size ( ) - 2 ) ; <nl> - number_buffer [ i + + ] = ' - ' ; <nl> - } <nl> - <nl> - std : : reverse ( number_buffer . begin ( ) , number_buffer . begin ( ) + i ) ; <nl> - o - > write_characters ( number_buffer . data ( ) , i ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief dump a floating - point number <nl> - <nl> - Dump a given floating - point number to output stream @ a o . Works internally <nl> - with @ a number_buffer . <nl> - <nl> - @ param [ in ] x floating - point number to dump <nl> - * / <nl> - void dump_float ( number_float_t x ) <nl> - { <nl> - / / NaN / inf <nl> - if ( not std : : isfinite ( x ) ) <nl> - { <nl> - o - > write_characters ( " null " , 4 ) ; <nl> - return ; <nl> - } <nl> - <nl> - / / If number_float_t is an IEEE - 754 single or double precision number , <nl> - / / use the Grisu2 algorithm to produce short numbers which are <nl> - / / guaranteed to round - trip , using strtof and strtod , resp . <nl> - / / <nl> - / / NB : The test below works if < long double > = = < double > . <nl> - static constexpr bool is_ieee_single_or_double <nl> - = ( std : : numeric_limits < number_float_t > : : is_iec559 and std : : numeric_limits < number_float_t > : : digits = = 24 and std : : numeric_limits < number_float_t > : : max_exponent = = 128 ) or <nl> - ( std : : numeric_limits < number_float_t > : : is_iec559 and std : : numeric_limits < number_float_t > : : digits = = 53 and std : : numeric_limits < number_float_t > : : max_exponent = = 1024 ) ; <nl> - <nl> - dump_float ( x , std : : integral_constant < bool , is_ieee_single_or_double > ( ) ) ; <nl> - } <nl> - <nl> - void dump_float ( number_float_t x , std : : true_type / * is_ieee_single_or_double * / ) <nl> - { <nl> - char * begin = number_buffer . data ( ) ; <nl> - char * end = : : nlohmann : : detail : : to_chars ( begin , begin + number_buffer . size ( ) , x ) ; <nl> - <nl> - o - > write_characters ( begin , static_cast < size_t > ( end - begin ) ) ; <nl> - } <nl> - <nl> - void dump_float ( number_float_t x , std : : false_type / * is_ieee_single_or_double * / ) <nl> - { <nl> - / / get number of digits for a float - > text - > float round - trip <nl> - static constexpr auto d = std : : numeric_limits < number_float_t > : : max_digits10 ; <nl> - <nl> - / / the actual conversion <nl> - std : : ptrdiff_t len = snprintf ( number_buffer . data ( ) , number_buffer . size ( ) , " % . * g " , d , x ) ; <nl> - <nl> - / / negative value indicates an error <nl> - assert ( len > 0 ) ; <nl> - / / check if buffer was large enough <nl> - assert ( static_cast < std : : size_t > ( len ) < number_buffer . size ( ) ) ; <nl> - <nl> - / / erase thousands separator <nl> - if ( thousands_sep ! = ' \ 0 ' ) <nl> - { <nl> - const auto end = std : : remove ( number_buffer . begin ( ) , <nl> - number_buffer . begin ( ) + len , thousands_sep ) ; <nl> - std : : fill ( end , number_buffer . end ( ) , ' \ 0 ' ) ; <nl> - assert ( ( end - number_buffer . begin ( ) ) < = len ) ; <nl> - len = ( end - number_buffer . begin ( ) ) ; <nl> - } <nl> - <nl> - / / convert decimal point to ' . ' <nl> - if ( decimal_point ! = ' \ 0 ' and decimal_point ! = ' . ' ) <nl> - { <nl> - const auto dec_pos = std : : find ( number_buffer . begin ( ) , number_buffer . end ( ) , decimal_point ) ; <nl> - if ( dec_pos ! = number_buffer . end ( ) ) <nl> - { <nl> - * dec_pos = ' . ' ; <nl> - } <nl> - } <nl> - <nl> - o - > write_characters ( number_buffer . data ( ) , static_cast < std : : size_t > ( len ) ) ; <nl> - <nl> - / / determine if need to append " . 0 " <nl> - const bool value_is_int_like = <nl> - std : : none_of ( number_buffer . begin ( ) , number_buffer . begin ( ) + len + 1 , <nl> - [ ] ( char c ) <nl> - { <nl> - return ( c = = ' . ' or c = = ' e ' ) ; <nl> - } ) ; <nl> - <nl> - if ( value_is_int_like ) <nl> - { <nl> - o - > write_characters ( " . 0 " , 2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief check whether a string is UTF - 8 encoded <nl> - <nl> - The function checks each byte of a string whether it is UTF - 8 encoded . The <nl> - result of the check is stored in the @ a state parameter . The function must <nl> - be called initially with state 0 ( accept ) . State 1 means the string must <nl> - be rejected , because the current byte is not allowed . If the string is <nl> - completely processed , but the state is non - zero , the string ended <nl> - prematurely ; that is , the last byte indicated more bytes should have <nl> - followed . <nl> - <nl> - @ param [ in , out ] state the state of the decoding <nl> - @ param [ in , out ] codep codepoint ( valid only if resulting state is UTF8_ACCEPT ) <nl> - @ param [ in ] byte next byte to decode <nl> - @ return new state <nl> - <nl> - @ note The function has been edited : a std : : array is used . <nl> - <nl> - @ copyright Copyright ( c ) 2008 - 2009 Bjoern Hoehrmann < bjoern @ hoehrmann . de > <nl> - @ sa http : / / bjoern . hoehrmann . de / utf - 8 / decoder / dfa / <nl> - * / <nl> - static uint8_t decode ( uint8_t & state , uint32_t & codep , const uint8_t byte ) noexcept <nl> - { <nl> - static const std : : array < uint8_t , 400 > utf8d = <nl> - { <nl> - { <nl> - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , / / 00 . . 1F <nl> - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , / / 20 . . 3F <nl> - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , / / 40 . . 5F <nl> - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , / / 60 . . 7F <nl> - 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , / / 80 . . 9F <nl> - 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , / / A0 . . BF <nl> - 8 , 8 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , / / C0 . . DF <nl> - 0xA , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x3 , 0x4 , 0x3 , 0x3 , / / E0 . . EF <nl> - 0xB , 0x6 , 0x6 , 0x6 , 0x5 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , 0x8 , / / F0 . . FF <nl> - 0x0 , 0x1 , 0x2 , 0x3 , 0x5 , 0x8 , 0x7 , 0x1 , 0x1 , 0x1 , 0x4 , 0x6 , 0x1 , 0x1 , 0x1 , 0x1 , / / s0 . . s0 <nl> - 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , / / s1 . . s2 <nl> - 1 , 2 , 1 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , / / s3 . . s4 <nl> - 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 3 , 1 , 3 , 1 , 1 , 1 , 1 , 1 , 1 , / / s5 . . s6 <nl> - 1 , 3 , 1 , 1 , 1 , 1 , 1 , 3 , 1 , 3 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 3 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 / / s7 . . s8 <nl> - } <nl> - } ; <nl> - <nl> - const uint8_t type = utf8d [ byte ] ; <nl> - <nl> - codep = ( state ! = UTF8_ACCEPT ) <nl> - ? ( byte & 0x3fu ) | ( codep < < 6 ) <nl> - : static_cast < uint32_t > ( 0xff > > type ) & ( byte ) ; <nl> - <nl> - state = utf8d [ 256u + state * 16u + type ] ; <nl> - return state ; <nl> - } <nl> - <nl> - private : <nl> - / / / the output of the serializer <nl> - output_adapter_t < char > o = nullptr ; <nl> - <nl> - / / / a ( hopefully ) large enough character buffer <nl> - std : : array < char , 64 > number_buffer { { } } ; <nl> - <nl> - / / / the locale <nl> - const std : : lconv * loc = nullptr ; <nl> - / / / the locale ' s thousand separator character <nl> - const char thousands_sep = ' \ 0 ' ; <nl> - / / / the locale ' s decimal point character <nl> - const char decimal_point = ' \ 0 ' ; <nl> - <nl> - / / / string buffer <nl> - std : : array < char , 512 > string_buffer { { } } ; <nl> - <nl> - / / / the indentation character <nl> - const char indent_char ; <nl> - / / / the indentation string <nl> - string_t indent_string ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / json_ref . hpp > <nl> - <nl> - <nl> - # include < initializer_list > <nl> - # include < utility > <nl> - <nl> - namespace nlohmann <nl> - { <nl> - namespace detail <nl> - { <nl> - template < typename BasicJsonType > <nl> - class json_ref <nl> - { <nl> - public : <nl> - using value_type = BasicJsonType ; <nl> - <nl> - json_ref ( value_type & & value ) <nl> - : owned_value ( std : : move ( value ) ) , value_ref ( & owned_value ) , is_rvalue ( true ) <nl> - { } <nl> - <nl> - json_ref ( const value_type & value ) <nl> - : value_ref ( const_cast < value_type * > ( & value ) ) , is_rvalue ( false ) <nl> - { } <nl> - <nl> - json_ref ( std : : initializer_list < json_ref > init ) <nl> - : owned_value ( init ) , value_ref ( & owned_value ) , is_rvalue ( true ) <nl> - { } <nl> - <nl> - template < class . . . Args > <nl> - json_ref ( Args & & . . . args ) <nl> - : owned_value ( std : : forward < Args > ( args ) . . . ) , value_ref ( & owned_value ) , is_rvalue ( true ) <nl> - { } <nl> - <nl> - / / class should be movable only <nl> - json_ref ( json_ref & & ) = default ; <nl> - json_ref ( const json_ref & ) = delete ; <nl> - json_ref & operator = ( const json_ref & ) = delete ; <nl> - <nl> - value_type moved_or_copied ( ) const <nl> - { <nl> - if ( is_rvalue ) <nl> - { <nl> - return std : : move ( * value_ref ) ; <nl> - } <nl> - return * value_ref ; <nl> - } <nl> - <nl> - value_type const & operator * ( ) const <nl> - { <nl> - return * static_cast < value_type const * > ( value_ref ) ; <nl> - } <nl> - <nl> - value_type const * operator - > ( ) const <nl> - { <nl> - return static_cast < value_type const * > ( value_ref ) ; <nl> - } <nl> - <nl> - private : <nl> - mutable value_type owned_value = nullptr ; <nl> - value_type * value_ref = nullptr ; <nl> - const bool is_rvalue ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / json_pointer . hpp > <nl> - <nl> - <nl> - # include < cassert > / / assert <nl> - # include < numeric > / / accumulate <nl> - # include < string > / / string <nl> - # include < vector > / / vector <nl> - <nl> - / / # include < nlohmann / detail / macro_scope . hpp > <nl> - <nl> - / / # include < nlohmann / detail / exceptions . hpp > <nl> - <nl> - / / # include < nlohmann / detail / value_t . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - template < typename BasicJsonType > <nl> - class json_pointer <nl> - { <nl> - / / allow basic_json to access private members <nl> - NLOHMANN_BASIC_JSON_TPL_DECLARATION <nl> - friend class basic_json ; <nl> - <nl> - public : <nl> - / * ! <nl> - @ brief create JSON pointer <nl> - <nl> - Create a JSON pointer according to the syntax described in <nl> - [ Section 3 of RFC6901 ] ( https : / / tools . ietf . org / html / rfc6901 # section - 3 ) . <nl> - <nl> - @ param [ in ] s string representing the JSON pointer ; if omitted , the empty <nl> - string is assumed which references the whole JSON value <nl> - <nl> - @ throw parse_error . 107 if the given JSON pointer @ a s is nonempty and does <nl> - not begin with a slash ( ` / ` ) ; see example below <nl> - <nl> - @ throw parse_error . 108 if a tilde ( ` ~ ` ) in the given JSON pointer @ a s is <nl> - not followed by ` 0 ` ( representing ` ~ ` ) or ` 1 ` ( representing ` / ` ) ; see <nl> - example below <nl> - <nl> - @ liveexample { The example shows the construction several valid JSON pointers <nl> - as well as the exceptional behavior . , json_pointer } <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - explicit json_pointer ( const std : : string & s = " " ) <nl> - : reference_tokens ( split ( s ) ) <nl> - { } <nl> - <nl> - / * ! <nl> - @ brief return a string representation of the JSON pointer <nl> - <nl> - @ invariant For each JSON pointer ` ptr ` , it holds : <nl> - @ code { . cpp } <nl> - ptr = = json_pointer ( ptr . to_string ( ) ) ; <nl> - @ endcode <nl> - <nl> - @ return a string representation of the JSON pointer <nl> - <nl> - @ liveexample { The example shows the result of ` to_string ` . , <nl> - json_pointer__to_string } <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - std : : string to_string ( ) const noexcept <nl> - { <nl> - return std : : accumulate ( reference_tokens . begin ( ) , reference_tokens . end ( ) , <nl> - std : : string { } , <nl> - [ ] ( const std : : string & a , const std : : string & b ) <nl> - { <nl> - return a + " / " + escape ( b ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - / / / @ copydoc to_string ( ) <nl> - operator std : : string ( ) const <nl> - { <nl> - return to_string ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] s reference token to be converted into an array index <nl> - <nl> - @ return integer representation of @ a s <nl> - <nl> - @ throw out_of_range . 404 if string @ a s could not be converted to an integer <nl> - * / <nl> - static int array_index ( const std : : string & s ) <nl> - { <nl> - std : : size_t processed_chars = 0 ; <nl> - const int res = std : : stoi ( s , & processed_chars ) ; <nl> - <nl> - / / check if the string was completely read <nl> - if ( JSON_UNLIKELY ( processed_chars ! = s . size ( ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : out_of_range : : create ( 404 , " unresolved reference token ' " + s + " ' " ) ) ; <nl> - } <nl> - <nl> - return res ; <nl> - } <nl> - <nl> - private : <nl> - / * ! <nl> - @ brief remove and return last reference pointer <nl> - @ throw out_of_range . 405 if JSON pointer has no parent <nl> - * / <nl> - std : : string pop_back ( ) <nl> - { <nl> - if ( JSON_UNLIKELY ( is_root ( ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : out_of_range : : create ( 405 , " JSON pointer has no parent " ) ) ; <nl> - } <nl> - <nl> - auto last = reference_tokens . back ( ) ; <nl> - reference_tokens . pop_back ( ) ; <nl> - return last ; <nl> - } <nl> - <nl> - / / / return whether pointer points to the root document <nl> - bool is_root ( ) const <nl> - { <nl> - return reference_tokens . empty ( ) ; <nl> - } <nl> - <nl> - json_pointer top ( ) const <nl> - { <nl> - if ( JSON_UNLIKELY ( is_root ( ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : out_of_range : : create ( 405 , " JSON pointer has no parent " ) ) ; <nl> - } <nl> - <nl> - json_pointer result = * this ; <nl> - result . reference_tokens = { reference_tokens [ 0 ] } ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create and return a reference to the pointed to value <nl> - <nl> - @ complexity Linear in the number of reference tokens . <nl> - <nl> - @ throw parse_error . 109 if array index is not a number <nl> - @ throw type_error . 313 if value cannot be unflattened <nl> - * / <nl> - BasicJsonType & get_and_create ( BasicJsonType & j ) const <nl> - { <nl> - using size_type = typename BasicJsonType : : size_type ; <nl> - auto result = & j ; <nl> - <nl> - / / in case no reference tokens exist , return a reference to the JSON value <nl> - / / j which will be overwritten by a primitive value <nl> - for ( const auto & reference_token : reference_tokens ) <nl> - { <nl> - switch ( result - > m_type ) <nl> - { <nl> - case detail : : value_t : : null : <nl> - { <nl> - if ( reference_token = = " 0 " ) <nl> - { <nl> - / / start a new array if reference token is 0 <nl> - result = & result - > operator [ ] ( 0 ) ; <nl> - } <nl> - else <nl> - { <nl> - / / start a new object otherwise <nl> - result = & result - > operator [ ] ( reference_token ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : object : <nl> - { <nl> - / / create an entry in the object <nl> - result = & result - > operator [ ] ( reference_token ) ; <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : array : <nl> - { <nl> - / / create an entry in the array <nl> - JSON_TRY <nl> - { <nl> - result = & result - > operator [ ] ( static_cast < size_type > ( array_index ( reference_token ) ) ) ; <nl> - } <nl> - JSON_CATCH ( std : : invalid_argument & ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 109 , 0 , " array index ' " + reference_token + " ' is not a number " ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / * <nl> - The following code is only reached if there exists a reference <nl> - token _and_ the current value is primitive . In this case , we have <nl> - an error situation , because primitive values may only occur as <nl> - single value ; that is , with an empty list of reference tokens . <nl> - * / <nl> - default : <nl> - JSON_THROW ( detail : : type_error : : create ( 313 , " invalid value to unflatten " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return * result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return a reference to the pointed to value <nl> - <nl> - @ note This version does not throw if a value is not present , but tries to <nl> - create nested values instead . For instance , calling this function <nl> - with pointer ` " / this / that " ` on a null value is equivalent to calling <nl> - ` operator [ ] ( " this " ) . operator [ ] ( " that " ) ` on that value , effectively <nl> - changing the null value to an object . <nl> - <nl> - @ param [ in ] ptr a JSON value <nl> - <nl> - @ return reference to the JSON value pointed to by the JSON pointer <nl> - <nl> - @ complexity Linear in the length of the JSON pointer . <nl> - <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - * / <nl> - BasicJsonType & get_unchecked ( BasicJsonType * ptr ) const <nl> - { <nl> - using size_type = typename BasicJsonType : : size_type ; <nl> - for ( const auto & reference_token : reference_tokens ) <nl> - { <nl> - / / convert null values to arrays or objects before continuing <nl> - if ( ptr - > m_type = = detail : : value_t : : null ) <nl> - { <nl> - / / check if reference token is a number <nl> - const bool nums = <nl> - std : : all_of ( reference_token . begin ( ) , reference_token . end ( ) , <nl> - [ ] ( const char x ) <nl> - { <nl> - return ( x > = ' 0 ' and x < = ' 9 ' ) ; <nl> - } ) ; <nl> - <nl> - / / change value to array for numbers or " - " or to object otherwise <nl> - * ptr = ( nums or reference_token = = " - " ) <nl> - ? detail : : value_t : : array <nl> - : detail : : value_t : : object ; <nl> - } <nl> - <nl> - switch ( ptr - > m_type ) <nl> - { <nl> - case detail : : value_t : : object : <nl> - { <nl> - / / use unchecked object access <nl> - ptr = & ptr - > operator [ ] ( reference_token ) ; <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : array : <nl> - { <nl> - / / error condition ( cf . RFC 6901 , Sect . 4 ) <nl> - if ( JSON_UNLIKELY ( reference_token . size ( ) > 1 and reference_token [ 0 ] = = ' 0 ' ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 106 , 0 , <nl> - " array index ' " + reference_token + <nl> - " ' must not begin with ' 0 ' " ) ) ; <nl> - } <nl> - <nl> - if ( reference_token = = " - " ) <nl> - { <nl> - / / explicitly treat " - " as index beyond the end <nl> - ptr = & ptr - > operator [ ] ( ptr - > m_value . array - > size ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - / / convert array index to number ; unchecked access <nl> - JSON_TRY <nl> - { <nl> - ptr = & ptr - > operator [ ] ( <nl> - static_cast < size_type > ( array_index ( reference_token ) ) ) ; <nl> - } <nl> - JSON_CATCH ( std : : invalid_argument & ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 109 , 0 , " array index ' " + reference_token + " ' is not a number " ) ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( detail : : out_of_range : : create ( 404 , " unresolved reference token ' " + reference_token + " ' " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return * ptr ; <nl> - } <nl> - <nl> - / * ! <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 402 if the array index ' - ' is used <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - * / <nl> - BasicJsonType & get_checked ( BasicJsonType * ptr ) const <nl> - { <nl> - using size_type = typename BasicJsonType : : size_type ; <nl> - for ( const auto & reference_token : reference_tokens ) <nl> - { <nl> - switch ( ptr - > m_type ) <nl> - { <nl> - case detail : : value_t : : object : <nl> - { <nl> - / / note : at performs range check <nl> - ptr = & ptr - > at ( reference_token ) ; <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : array : <nl> - { <nl> - if ( JSON_UNLIKELY ( reference_token = = " - " ) ) <nl> - { <nl> - / / " - " always fails the range check <nl> - JSON_THROW ( detail : : out_of_range : : create ( 402 , <nl> - " array index ' - ' ( " + std : : to_string ( ptr - > m_value . array - > size ( ) ) + <nl> - " ) is out of range " ) ) ; <nl> - } <nl> - <nl> - / / error condition ( cf . RFC 6901 , Sect . 4 ) <nl> - if ( JSON_UNLIKELY ( reference_token . size ( ) > 1 and reference_token [ 0 ] = = ' 0 ' ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 106 , 0 , <nl> - " array index ' " + reference_token + <nl> - " ' must not begin with ' 0 ' " ) ) ; <nl> - } <nl> - <nl> - / / note : at performs range check <nl> - JSON_TRY <nl> - { <nl> - ptr = & ptr - > at ( static_cast < size_type > ( array_index ( reference_token ) ) ) ; <nl> - } <nl> - JSON_CATCH ( std : : invalid_argument & ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 109 , 0 , " array index ' " + reference_token + " ' is not a number " ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( detail : : out_of_range : : create ( 404 , " unresolved reference token ' " + reference_token + " ' " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return * ptr ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return a const reference to the pointed to value <nl> - <nl> - @ param [ in ] ptr a JSON value <nl> - <nl> - @ return const reference to the JSON value pointed to by the JSON <nl> - pointer <nl> - <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 402 if the array index ' - ' is used <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - * / <nl> - const BasicJsonType & get_unchecked ( const BasicJsonType * ptr ) const <nl> - { <nl> - using size_type = typename BasicJsonType : : size_type ; <nl> - for ( const auto & reference_token : reference_tokens ) <nl> - { <nl> - switch ( ptr - > m_type ) <nl> - { <nl> - case detail : : value_t : : object : <nl> - { <nl> - / / use unchecked object access <nl> - ptr = & ptr - > operator [ ] ( reference_token ) ; <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : array : <nl> - { <nl> - if ( JSON_UNLIKELY ( reference_token = = " - " ) ) <nl> - { <nl> - / / " - " cannot be used for const access <nl> - JSON_THROW ( detail : : out_of_range : : create ( 402 , <nl> - " array index ' - ' ( " + std : : to_string ( ptr - > m_value . array - > size ( ) ) + <nl> - " ) is out of range " ) ) ; <nl> - } <nl> - <nl> - / / error condition ( cf . RFC 6901 , Sect . 4 ) <nl> - if ( JSON_UNLIKELY ( reference_token . size ( ) > 1 and reference_token [ 0 ] = = ' 0 ' ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 106 , 0 , <nl> - " array index ' " + reference_token + <nl> - " ' must not begin with ' 0 ' " ) ) ; <nl> - } <nl> - <nl> - / / use unchecked array access <nl> - JSON_TRY <nl> - { <nl> - ptr = & ptr - > operator [ ] ( <nl> - static_cast < size_type > ( array_index ( reference_token ) ) ) ; <nl> - } <nl> - JSON_CATCH ( std : : invalid_argument & ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 109 , 0 , " array index ' " + reference_token + " ' is not a number " ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( detail : : out_of_range : : create ( 404 , " unresolved reference token ' " + reference_token + " ' " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return * ptr ; <nl> - } <nl> - <nl> - / * ! <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 402 if the array index ' - ' is used <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - * / <nl> - const BasicJsonType & get_checked ( const BasicJsonType * ptr ) const <nl> - { <nl> - using size_type = typename BasicJsonType : : size_type ; <nl> - for ( const auto & reference_token : reference_tokens ) <nl> - { <nl> - switch ( ptr - > m_type ) <nl> - { <nl> - case detail : : value_t : : object : <nl> - { <nl> - / / note : at performs range check <nl> - ptr = & ptr - > at ( reference_token ) ; <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : array : <nl> - { <nl> - if ( JSON_UNLIKELY ( reference_token = = " - " ) ) <nl> - { <nl> - / / " - " always fails the range check <nl> - JSON_THROW ( detail : : out_of_range : : create ( 402 , <nl> - " array index ' - ' ( " + std : : to_string ( ptr - > m_value . array - > size ( ) ) + <nl> - " ) is out of range " ) ) ; <nl> - } <nl> - <nl> - / / error condition ( cf . RFC 6901 , Sect . 4 ) <nl> - if ( JSON_UNLIKELY ( reference_token . size ( ) > 1 and reference_token [ 0 ] = = ' 0 ' ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 106 , 0 , <nl> - " array index ' " + reference_token + <nl> - " ' must not begin with ' 0 ' " ) ) ; <nl> - } <nl> - <nl> - / / note : at performs range check <nl> - JSON_TRY <nl> - { <nl> - ptr = & ptr - > at ( static_cast < size_type > ( array_index ( reference_token ) ) ) ; <nl> - } <nl> - JSON_CATCH ( std : : invalid_argument & ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 109 , 0 , " array index ' " + reference_token + " ' is not a number " ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( detail : : out_of_range : : create ( 404 , " unresolved reference token ' " + reference_token + " ' " ) ) ; <nl> - } <nl> - } <nl> - <nl> - return * ptr ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief split the string input to reference tokens <nl> - <nl> - @ note This function is only called by the json_pointer constructor . <nl> - All exceptions below are documented there . <nl> - <nl> - @ throw parse_error . 107 if the pointer is not empty or begins with ' / ' <nl> - @ throw parse_error . 108 if character ' ~ ' is not followed by ' 0 ' or ' 1 ' <nl> - * / <nl> - static std : : vector < std : : string > split ( const std : : string & reference_string ) <nl> - { <nl> - std : : vector < std : : string > result ; <nl> - <nl> - / / special case : empty reference string - > no reference tokens <nl> - if ( reference_string . empty ( ) ) <nl> - { <nl> - return result ; <nl> - } <nl> - <nl> - / / check if nonempty reference string begins with slash <nl> - if ( JSON_UNLIKELY ( reference_string [ 0 ] ! = ' / ' ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 107 , 1 , <nl> - " JSON pointer must be empty or begin with ' / ' - was : ' " + <nl> - reference_string + " ' " ) ) ; <nl> - } <nl> - <nl> - / / extract the reference tokens : <nl> - / / - slash : position of the last read slash ( or end of string ) <nl> - / / - start : position after the previous slash <nl> - for ( <nl> - / / search for the first slash after the first character <nl> - std : : size_t slash = reference_string . find_first_of ( ' / ' , 1 ) , <nl> - / / set the beginning of the first reference token <nl> - start = 1 ; <nl> - / / we can stop if start = = string : : npos + 1 = 0 <nl> - start ! = 0 ; <nl> - / / set the beginning of the next reference token <nl> - / / ( will eventually be 0 if slash = = std : : string : : npos ) <nl> - start = slash + 1 , <nl> - / / find next slash <nl> - slash = reference_string . find_first_of ( ' / ' , start ) ) <nl> - { <nl> - / / use the text between the beginning of the reference token <nl> - / / ( start ) and the last slash ( slash ) . <nl> - auto reference_token = reference_string . substr ( start , slash - start ) ; <nl> - <nl> - / / check reference tokens are properly escaped <nl> - for ( std : : size_t pos = reference_token . find_first_of ( ' ~ ' ) ; <nl> - pos ! = std : : string : : npos ; <nl> - pos = reference_token . find_first_of ( ' ~ ' , pos + 1 ) ) <nl> - { <nl> - assert ( reference_token [ pos ] = = ' ~ ' ) ; <nl> - <nl> - / / ~ must be followed by 0 or 1 <nl> - if ( JSON_UNLIKELY ( pos = = reference_token . size ( ) - 1 or <nl> - ( reference_token [ pos + 1 ] ! = ' 0 ' and <nl> - reference_token [ pos + 1 ] ! = ' 1 ' ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : parse_error : : create ( 108 , 0 , " escape character ' ~ ' must be followed with ' 0 ' or ' 1 ' " ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / finally , store the reference token <nl> - unescape ( reference_token ) ; <nl> - result . push_back ( reference_token ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief replace all occurrences of a substring by another string <nl> - <nl> - @ param [ in , out ] s the string to manipulate ; changed so that all <nl> - occurrences of @ a f are replaced with @ a t <nl> - @ param [ in ] f the substring to replace with @ a t <nl> - @ param [ in ] t the string to replace @ a f <nl> - <nl> - @ pre The search string @ a f must not be empty . * * This precondition is <nl> - enforced with an assertion . * * <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - static void replace_substring ( std : : string & s , const std : : string & f , <nl> - const std : : string & t ) <nl> - { <nl> - assert ( not f . empty ( ) ) ; <nl> - for ( auto pos = s . find ( f ) ; / / find first occurrence of f <nl> - pos ! = std : : string : : npos ; / / make sure f was found <nl> - s . replace ( pos , f . size ( ) , t ) , / / replace with t , and <nl> - pos = s . find ( f , pos + t . size ( ) ) ) / / find next occurrence of f <nl> - { } <nl> - } <nl> - <nl> - / / / escape " ~ " " to " ~ 0 " and " / " to " ~ 1 " <nl> - static std : : string escape ( std : : string s ) <nl> - { <nl> - replace_substring ( s , " ~ " , " ~ 0 " ) ; <nl> - replace_substring ( s , " / " , " ~ 1 " ) ; <nl> - return s ; <nl> - } <nl> - <nl> - / / / unescape " ~ 1 " to tilde and " ~ 0 " to slash ( order is important ! ) <nl> - static void unescape ( std : : string & s ) <nl> - { <nl> - replace_substring ( s , " ~ 1 " , " / " ) ; <nl> - replace_substring ( s , " ~ 0 " , " ~ " ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] reference_string the reference string to the current value <nl> - @ param [ in ] value the value to consider <nl> - @ param [ in , out ] result the result object to insert values to <nl> - <nl> - @ note Empty objects or arrays are flattened to ` null ` . <nl> - * / <nl> - static void flatten ( const std : : string & reference_string , <nl> - const BasicJsonType & value , <nl> - BasicJsonType & result ) <nl> - { <nl> - switch ( value . m_type ) <nl> - { <nl> - case detail : : value_t : : array : <nl> - { <nl> - if ( value . m_value . array - > empty ( ) ) <nl> - { <nl> - / / flatten empty array as null <nl> - result [ reference_string ] = nullptr ; <nl> - } <nl> - else <nl> - { <nl> - / / iterate array and use index as reference string <nl> - for ( std : : size_t i = 0 ; i < value . m_value . array - > size ( ) ; + + i ) <nl> - { <nl> - flatten ( reference_string + " / " + std : : to_string ( i ) , <nl> - value . m_value . array - > operator [ ] ( i ) , result ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case detail : : value_t : : object : <nl> - { <nl> - if ( value . m_value . object - > empty ( ) ) <nl> - { <nl> - / / flatten empty object as null <nl> - result [ reference_string ] = nullptr ; <nl> - } <nl> - else <nl> - { <nl> - / / iterate object and use keys as reference string <nl> - for ( const auto & element : * value . m_value . object ) <nl> - { <nl> - flatten ( reference_string + " / " + escape ( element . first ) , element . second , result ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / add primitive value with its reference string <nl> - result [ reference_string ] = value ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ param [ in ] value flattened JSON <nl> - <nl> - @ return unflattened JSON <nl> - <nl> - @ throw parse_error . 109 if array index is not a number <nl> - @ throw type_error . 314 if value is not an object <nl> - @ throw type_error . 315 if object values are not primitive <nl> - @ throw type_error . 313 if value cannot be unflattened <nl> - * / <nl> - static BasicJsonType <nl> - unflatten ( const BasicJsonType & value ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not value . is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : type_error : : create ( 314 , " only objects can be unflattened " ) ) ; <nl> - } <nl> - <nl> - BasicJsonType result ; <nl> - <nl> - / / iterate the JSON object values <nl> - for ( const auto & element : * value . m_value . object ) <nl> - { <nl> - if ( JSON_UNLIKELY ( not element . second . is_primitive ( ) ) ) <nl> - { <nl> - JSON_THROW ( detail : : type_error : : create ( 315 , " values in object must be primitive " ) ) ; <nl> - } <nl> - <nl> - / / assign value to reference pointed to by JSON pointer ; Note that if <nl> - / / the JSON pointer is " " ( i . e . , points to the whole value ) , function <nl> - / / get_and_create returns a reference to result itself . An assignment <nl> - / / will then create a primitive value . <nl> - json_pointer ( element . first ) . get_and_create ( result ) = element . second ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - friend bool operator = = ( json_pointer const & lhs , <nl> - json_pointer const & rhs ) noexcept <nl> - { <nl> - return ( lhs . reference_tokens = = rhs . reference_tokens ) ; <nl> - } <nl> - <nl> - friend bool operator ! = ( json_pointer const & lhs , <nl> - json_pointer const & rhs ) noexcept <nl> - { <nl> - return not ( lhs = = rhs ) ; <nl> - } <nl> - <nl> - / / / the reference tokens <nl> - std : : vector < std : : string > reference_tokens ; <nl> - } ; <nl> - } <nl> - <nl> - / / # include < nlohmann / adl_serializer . hpp > <nl> - <nl> - <nl> - # include < utility > <nl> - <nl> - / / # include < nlohmann / detail / conversions / from_json . hpp > <nl> - <nl> - / / # include < nlohmann / detail / conversions / to_json . hpp > <nl> - <nl> - <nl> - namespace nlohmann <nl> - { <nl> - template < typename , typename > <nl> - struct adl_serializer <nl> - { <nl> - / * ! <nl> - @ brief convert a JSON value to any value type <nl> - <nl> - This function is usually called by the ` get ( ) ` function of the <nl> - @ ref basic_json class ( either explicit or via conversion operators ) . <nl> - <nl> - @ param [ in ] j JSON value to read from <nl> - @ param [ in , out ] val value to write to <nl> - * / <nl> - template < typename BasicJsonType , typename ValueType > <nl> - static void from_json ( BasicJsonType & & j , ValueType & val ) noexcept ( <nl> - noexcept ( : : nlohmann : : from_json ( std : : forward < BasicJsonType > ( j ) , val ) ) ) <nl> - { <nl> - : : nlohmann : : from_json ( std : : forward < BasicJsonType > ( j ) , val ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief convert any value type to a JSON value <nl> - <nl> - This function is usually called by the constructors of the @ ref basic_json <nl> - class . <nl> - <nl> - @ param [ in , out ] j JSON value to write to <nl> - @ param [ in ] val value to read from <nl> - * / <nl> - template < typename BasicJsonType , typename ValueType > <nl> - static void to_json ( BasicJsonType & j , ValueType & & val ) noexcept ( <nl> - noexcept ( : : nlohmann : : to_json ( j , std : : forward < ValueType > ( val ) ) ) ) <nl> - { <nl> - : : nlohmann : : to_json ( j , std : : forward < ValueType > ( val ) ) ; <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - <nl> - / * ! <nl> - @ brief namespace for Niels Lohmann <nl> - @ see https : / / github . com / nlohmann <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - namespace nlohmann <nl> - { <nl> - <nl> - / * ! <nl> - @ brief a class to store JSON values <nl> - <nl> - @ tparam ObjectType type for JSON objects ( ` std : : map ` by default ; will be used <nl> - in @ ref object_t ) <nl> - @ tparam ArrayType type for JSON arrays ( ` std : : vector ` by default ; will be used <nl> - in @ ref array_t ) <nl> - @ tparam StringType type for JSON strings and object keys ( ` std : : string ` by <nl> - default ; will be used in @ ref string_t ) <nl> - @ tparam BooleanType type for JSON booleans ( ` bool ` by default ; will be used <nl> - in @ ref boolean_t ) <nl> - @ tparam NumberIntegerType type for JSON integer numbers ( ` int64_t ` by <nl> - default ; will be used in @ ref number_integer_t ) <nl> - @ tparam NumberUnsignedType type for JSON unsigned integer numbers ( @ c <nl> - ` uint64_t ` by default ; will be used in @ ref number_unsigned_t ) <nl> - @ tparam NumberFloatType type for JSON floating - point numbers ( ` double ` by <nl> - default ; will be used in @ ref number_float_t ) <nl> - @ tparam AllocatorType type of the allocator to use ( ` std : : allocator ` by <nl> - default ) <nl> - @ tparam JSONSerializer the serializer to resolve internal calls to ` to_json ( ) ` <nl> - and ` from_json ( ) ` ( @ ref adl_serializer by default ) <nl> - <nl> - @ requirement The class satisfies the following concept requirements : <nl> - - Basic <nl> - - [ DefaultConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / DefaultConstructible ) : <nl> - JSON values can be default constructed . The result will be a JSON null <nl> - value . <nl> - - [ MoveConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / MoveConstructible ) : <nl> - A JSON value can be constructed from an rvalue argument . <nl> - - [ CopyConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / CopyConstructible ) : <nl> - A JSON value can be copy - constructed from an lvalue expression . <nl> - - [ MoveAssignable ] ( https : / / en . cppreference . com / w / cpp / named_req / MoveAssignable ) : <nl> - A JSON value van be assigned from an rvalue argument . <nl> - - [ CopyAssignable ] ( https : / / en . cppreference . com / w / cpp / named_req / CopyAssignable ) : <nl> - A JSON value can be copy - assigned from an lvalue expression . <nl> - - [ Destructible ] ( https : / / en . cppreference . com / w / cpp / named_req / Destructible ) : <nl> - JSON values can be destructed . <nl> - - Layout <nl> - - [ StandardLayoutType ] ( https : / / en . cppreference . com / w / cpp / named_req / StandardLayoutType ) : <nl> - JSON values have <nl> - [ standard layout ] ( https : / / en . cppreference . com / w / cpp / language / data_members # Standard_layout ) : <nl> - All non - static data members are private and standard layout types , the <nl> - class has no virtual functions or ( virtual ) base classes . <nl> - - Library - wide <nl> - - [ EqualityComparable ] ( https : / / en . cppreference . com / w / cpp / named_req / EqualityComparable ) : <nl> - JSON values can be compared with ` = = ` , see @ ref <nl> - operator = = ( const_reference , const_reference ) . <nl> - - [ LessThanComparable ] ( https : / / en . cppreference . com / w / cpp / named_req / LessThanComparable ) : <nl> - JSON values can be compared with ` < ` , see @ ref <nl> - operator < ( const_reference , const_reference ) . <nl> - - [ Swappable ] ( https : / / en . cppreference . com / w / cpp / named_req / Swappable ) : <nl> - Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of <nl> - other compatible types , using unqualified function call @ ref swap ( ) . <nl> - - [ NullablePointer ] ( https : / / en . cppreference . com / w / cpp / named_req / NullablePointer ) : <nl> - JSON values can be compared against ` std : : nullptr_t ` objects which are used <nl> - to model the ` null ` value . <nl> - - Container <nl> - - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) : <nl> - JSON values can be used like STL containers and provide iterator access . <nl> - - [ ReversibleContainer ] ( https : / / en . cppreference . com / w / cpp / named_req / ReversibleContainer ) ; <nl> - JSON values can be used like STL containers and provide reverse iterator <nl> - access . <nl> - <nl> - @ invariant The member variables @ a m_value and @ a m_type have the following <nl> - relationship : <nl> - - If ` m_type = = value_t : : object ` , then ` m_value . object ! = nullptr ` . <nl> - - If ` m_type = = value_t : : array ` , then ` m_value . array ! = nullptr ` . <nl> - - If ` m_type = = value_t : : string ` , then ` m_value . string ! = nullptr ` . <nl> - The invariants are checked by member function assert_invariant ( ) . <nl> - <nl> - @ internal <nl> - @ note ObjectType trick from http : / / stackoverflow . com / a / 9860911 <nl> - @ endinternal <nl> - <nl> - @ see [ RFC 7159 : The JavaScript Object Notation ( JSON ) Data Interchange <nl> - Format ] ( http : / / rfc7159 . net / rfc7159 ) <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ nosubgrouping <nl> - * / <nl> - NLOHMANN_BASIC_JSON_TPL_DECLARATION <nl> - class basic_json <nl> - { <nl> - private : <nl> - template < detail : : value_t > friend struct detail : : external_constructor ; <nl> - friend : : nlohmann : : json_pointer < basic_json > ; <nl> - friend : : nlohmann : : detail : : parser < basic_json > ; <nl> - friend : : nlohmann : : detail : : serializer < basic_json > ; <nl> - template < typename BasicJsonType > <nl> - friend class : : nlohmann : : detail : : iter_impl ; <nl> - template < typename BasicJsonType , typename CharType > <nl> - friend class : : nlohmann : : detail : : binary_writer ; <nl> - template < typename BasicJsonType , typename SAX > <nl> - friend class : : nlohmann : : detail : : binary_reader ; <nl> - template < typename BasicJsonType > <nl> - friend class : : nlohmann : : detail : : json_sax_dom_parser ; <nl> - template < typename BasicJsonType > <nl> - friend class : : nlohmann : : detail : : json_sax_dom_callback_parser ; <nl> - <nl> - / / / workaround type for MSVC <nl> - using basic_json_t = NLOHMANN_BASIC_JSON_TPL ; <nl> - <nl> - / / convenience aliases for types residing in namespace detail ; <nl> - using lexer = : : nlohmann : : detail : : lexer < basic_json > ; <nl> - using parser = : : nlohmann : : detail : : parser < basic_json > ; <nl> - <nl> - using primitive_iterator_t = : : nlohmann : : detail : : primitive_iterator_t ; <nl> - template < typename BasicJsonType > <nl> - using internal_iterator = : : nlohmann : : detail : : internal_iterator < BasicJsonType > ; <nl> - template < typename BasicJsonType > <nl> - using iter_impl = : : nlohmann : : detail : : iter_impl < BasicJsonType > ; <nl> - template < typename Iterator > <nl> - using iteration_proxy = : : nlohmann : : detail : : iteration_proxy < Iterator > ; <nl> - template < typename Base > using json_reverse_iterator = : : nlohmann : : detail : : json_reverse_iterator < Base > ; <nl> - <nl> - template < typename CharType > <nl> - using output_adapter_t = : : nlohmann : : detail : : output_adapter_t < CharType > ; <nl> - <nl> - using binary_reader = : : nlohmann : : detail : : binary_reader < basic_json > ; <nl> - template < typename CharType > using binary_writer = : : nlohmann : : detail : : binary_writer < basic_json , CharType > ; <nl> - <nl> - using serializer = : : nlohmann : : detail : : serializer < basic_json > ; <nl> - <nl> - public : <nl> - using value_t = detail : : value_t ; <nl> - / / / JSON Pointer , see @ ref nlohmann : : json_pointer <nl> - using json_pointer = : : nlohmann : : json_pointer < basic_json > ; <nl> - template < typename T , typename SFINAE > <nl> - using json_serializer = JSONSerializer < T , SFINAE > ; <nl> - / / / helper type for initializer lists of basic_json values <nl> - using initializer_list_t = std : : initializer_list < detail : : json_ref < basic_json > > ; <nl> - <nl> - using input_format_t = detail : : input_format_t ; <nl> - / / / SAX interface type , see @ ref nlohmann : : json_sax <nl> - using json_sax_t = json_sax < basic_json > ; <nl> - <nl> - / / / / / / / / / / / / / / / / <nl> - / / exceptions / / <nl> - / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name exceptions <nl> - / / / Classes to implement user - defined exceptions . <nl> - / / / @ { <nl> - <nl> - / / / @ copydoc detail : : exception <nl> - using exception = detail : : exception ; <nl> - / / / @ copydoc detail : : parse_error <nl> - using parse_error = detail : : parse_error ; <nl> - / / / @ copydoc detail : : invalid_iterator <nl> - using invalid_iterator = detail : : invalid_iterator ; <nl> - / / / @ copydoc detail : : type_error <nl> - using type_error = detail : : type_error ; <nl> - / / / @ copydoc detail : : out_of_range <nl> - using out_of_range = detail : : out_of_range ; <nl> - / / / @ copydoc detail : : other_error <nl> - using other_error = detail : : other_error ; <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / container types / / <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name container types <nl> - / / / The canonic container types to use @ ref basic_json like any other STL <nl> - / / / container . <nl> - / / / @ { <nl> - <nl> - / / / the type of elements in a basic_json container <nl> - using value_type = basic_json ; <nl> - <nl> - / / / the type of an element reference <nl> - using reference = value_type & ; <nl> - / / / the type of an element const reference <nl> - using const_reference = const value_type & ; <nl> - <nl> - / / / a type to represent differences between iterators <nl> - using difference_type = std : : ptrdiff_t ; <nl> - / / / a type to represent container sizes <nl> - using size_type = std : : size_t ; <nl> - <nl> - / / / the allocator type <nl> - using allocator_type = AllocatorType < basic_json > ; <nl> - <nl> - / / / the type of an element pointer <nl> - using pointer = typename std : : allocator_traits < allocator_type > : : pointer ; <nl> - / / / the type of an element const pointer <nl> - using const_pointer = typename std : : allocator_traits < allocator_type > : : const_pointer ; <nl> - <nl> - / / / an iterator for a basic_json container <nl> - using iterator = iter_impl < basic_json > ; <nl> - / / / a const iterator for a basic_json container <nl> - using const_iterator = iter_impl < const basic_json > ; <nl> - / / / a reverse iterator for a basic_json container <nl> - using reverse_iterator = json_reverse_iterator < typename basic_json : : iterator > ; <nl> - / / / a const reverse iterator for a basic_json container <nl> - using const_reverse_iterator = json_reverse_iterator < typename basic_json : : const_iterator > ; <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / * ! <nl> - @ brief returns the allocator associated with the container <nl> - * / <nl> - static allocator_type get_allocator ( ) <nl> - { <nl> - return allocator_type ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns version information on the library <nl> - <nl> - This function returns a JSON object with information about the library , <nl> - including the version number and information on the platform and compiler . <nl> - <nl> - @ return JSON object holding version information <nl> - key | description <nl> - mmmmmmmmm - - | mmmmmmmmmmmmmmm <nl> - ` compiler ` | Information on the used compiler . It is an object with the following keys : ` c + + ` ( the used C + + standard ) , ` family ` ( the compiler family ; possible values are ` clang ` , ` icc ` , ` gcc ` , ` ilecpp ` , ` msvc ` , ` pgcpp ` , ` sunpro ` , and ` unknown ` ) , and ` version ` ( the compiler version ) . <nl> - ` copyright ` | The copyright line for the library as string . <nl> - ` name ` | The name of the library as string . <nl> - ` platform ` | The used platform as string . Possible values are ` win32 ` , ` linux ` , ` apple ` , ` unix ` , and ` unknown ` . <nl> - ` url ` | The URL of the project as string . <nl> - ` version ` | The version of the library . It is an object with the following keys : ` major ` , ` minor ` , and ` patch ` as defined by [ Semantic Versioning ] ( http : / / semver . org ) , and ` string ` ( the version string ) . <nl> - <nl> - @ liveexample { The following code shows an example output of the ` meta ( ) ` <nl> - function . , meta } <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since 2 . 1 . 0 <nl> - * / <nl> - static basic_json meta ( ) <nl> - { <nl> - basic_json result ; <nl> - <nl> - result [ " copyright " ] = " ( C ) 2013 - 2017 Niels Lohmann " ; <nl> - result [ " name " ] = " JSON for Modern C + + " ; <nl> - result [ " url " ] = " https : / / github . com / nlohmann / json " ; <nl> - result [ " version " ] [ " string " ] = <nl> - std : : to_string ( NLOHMANN_JSON_VERSION_MAJOR ) + " . " + <nl> - std : : to_string ( NLOHMANN_JSON_VERSION_MINOR ) + " . " + <nl> - std : : to_string ( NLOHMANN_JSON_VERSION_PATCH ) ; <nl> - result [ " version " ] [ " major " ] = NLOHMANN_JSON_VERSION_MAJOR ; <nl> - result [ " version " ] [ " minor " ] = NLOHMANN_JSON_VERSION_MINOR ; <nl> - result [ " version " ] [ " patch " ] = NLOHMANN_JSON_VERSION_PATCH ; <nl> - <nl> - # ifdef _WIN32 <nl> - result [ " platform " ] = " win32 " ; <nl> - # elif defined __linux__ <nl> - result [ " platform " ] = " linux " ; <nl> - # elif defined __APPLE__ <nl> - result [ " platform " ] = " apple " ; <nl> - # elif defined __unix__ <nl> - result [ " platform " ] = " unix " ; <nl> - # else <nl> - result [ " platform " ] = " unknown " ; <nl> - # endif <nl> - <nl> - # if defined ( __ICC ) | | defined ( __INTEL_COMPILER ) <nl> - result [ " compiler " ] = { { " family " , " icc " } , { " version " , __INTEL_COMPILER } } ; <nl> - # elif defined ( __clang__ ) <nl> - result [ " compiler " ] = { { " family " , " clang " } , { " version " , __clang_version__ } } ; <nl> - # elif defined ( __GNUC__ ) | | defined ( __GNUG__ ) <nl> - result [ " compiler " ] = { { " family " , " gcc " } , { " version " , std : : to_string ( __GNUC__ ) + " . " + std : : to_string ( __GNUC_MINOR__ ) + " . " + std : : to_string ( __GNUC_PATCHLEVEL__ ) } } ; <nl> - # elif defined ( __HP_cc ) | | defined ( __HP_aCC ) <nl> - result [ " compiler " ] = " hp " <nl> - # elif defined ( __IBMCPP__ ) <nl> - result [ " compiler " ] = { { " family " , " ilecpp " } , { " version " , __IBMCPP__ } } ; <nl> - # elif defined ( _MSC_VER ) <nl> - result [ " compiler " ] = { { " family " , " msvc " } , { " version " , _MSC_VER } } ; <nl> - # elif defined ( __PGI ) <nl> - result [ " compiler " ] = { { " family " , " pgcpp " } , { " version " , __PGI } } ; <nl> - # elif defined ( __SUNPRO_CC ) <nl> - result [ " compiler " ] = { { " family " , " sunpro " } , { " version " , __SUNPRO_CC } } ; <nl> - # else <nl> - result [ " compiler " ] = { { " family " , " unknown " } , { " version " , " unknown " } } ; <nl> - # endif <nl> - <nl> - # ifdef __cplusplus <nl> - result [ " compiler " ] [ " c + + " ] = std : : to_string ( __cplusplus ) ; <nl> - # else <nl> - result [ " compiler " ] [ " c + + " ] = " unknown " ; <nl> - # endif <nl> - return result ; <nl> - } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON value data types / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name JSON value data types <nl> - / / / The data types to store a JSON value . These types are derived from <nl> - / / / the template arguments passed to class @ ref basic_json . <nl> - / / / @ { <nl> - <nl> - # if defined ( JSON_HAS_CPP_14 ) <nl> - / / Use transparent comparator if possible , combined with perfect forwarding <nl> - / / on find ( ) and count ( ) calls prevents unnecessary string construction . <nl> - using object_comparator_t = std : : less < > ; <nl> - # else <nl> - using object_comparator_t = std : : less < StringType > ; <nl> - # endif <nl> - <nl> - / * ! <nl> - @ brief a type for an object <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes JSON objects as follows : <nl> - > An object is an unordered collection of zero or more name / value pairs , <nl> - > where a name is a string and a value is a string , number , boolean , null , <nl> - > object , or array . <nl> - <nl> - To store objects in C + + , a type is defined by the template parameters <nl> - described below . <nl> - <nl> - @ tparam ObjectType the container to store objects ( e . g . , ` std : : map ` or <nl> - ` std : : unordered_map ` ) <nl> - @ tparam StringType the type of the keys or names ( e . g . , ` std : : string ` ) . <nl> - The comparison function ` std : : less < StringType > ` is used to order elements <nl> - inside the container . <nl> - @ tparam AllocatorType the allocator to use for objects ( e . g . , <nl> - ` std : : allocator ` ) <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a ObjectType ( ` std : : map ` ) , @ a StringType <nl> - ( ` std : : string ` ) , and @ a AllocatorType ( ` std : : allocator ` ) , the default <nl> - value for @ a object_t is : <nl> - <nl> - @ code { . cpp } <nl> - std : : map < <nl> - std : : string , / / key_type <nl> - basic_json , / / value_type <nl> - std : : less < std : : string > , / / key_compare <nl> - std : : allocator < std : : pair < const std : : string , basic_json > > / / allocator_type <nl> - > <nl> - @ endcode <nl> - <nl> - # # # # Behavior <nl> - <nl> - The choice of @ a object_t influences the behavior of the JSON class . With <nl> - the default type , objects have the following behavior : <nl> - <nl> - - When all names are unique , objects will be interoperable in the sense <nl> - that all software implementations receiving that object will agree on <nl> - the name - value mappings . <nl> - - When the names within an object are not unique , it is unspecified which <nl> - one of the values for a given key will be chosen . For instance , <nl> - ` { " key " : 2 , " key " : 1 } ` could be equal to either ` { " key " : 1 } ` or <nl> - ` { " key " : 2 } ` . <nl> - - Internally , name / value pairs are stored in lexicographical order of the <nl> - names . Objects will also be serialized ( see @ ref dump ) in this order . <nl> - For instance , ` { " b " : 1 , " a " : 2 } ` and ` { " a " : 2 , " b " : 1 } ` will be stored <nl> - and serialized as ` { " a " : 2 , " b " : 1 } ` . <nl> - - When comparing objects , the order of the name / value pairs is irrelevant . <nl> - This makes objects interoperable in the sense that they will not be <nl> - affected by these differences . For instance , ` { " b " : 1 , " a " : 2 } ` and <nl> - ` { " a " : 2 , " b " : 1 } ` will be treated as equal . <nl> - <nl> - # # # # Limits <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) specifies : <nl> - > An implementation may set limits on the maximum depth of nesting . <nl> - <nl> - In this class , the object ' s limit of nesting is not explicitly constrained . <nl> - However , a maximum depth of nesting may be introduced by the compiler or <nl> - runtime environment . A theoretical limit can be queried by calling the <nl> - @ ref max_size function of a JSON object . <nl> - <nl> - # # # # Storage <nl> - <nl> - Objects are stored as pointers in a @ ref basic_json type . That is , for any <nl> - access to object values , a pointer of type ` object_t * ` must be <nl> - dereferenced . <nl> - <nl> - @ sa @ ref array_t - - type for an array value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ note The order name / value pairs are added to the object is * not * <nl> - preserved by the library . Therefore , iterating an object may return <nl> - name / value pairs in a different order than they were originally stored . In <nl> - fact , keys will be traversed in alphabetical order as ` std : : map ` with <nl> - ` std : : less ` is used by default . Please note this behavior conforms to [ RFC <nl> - 7159 ] ( http : / / rfc7159 . net / rfc7159 ) , because any order implements the <nl> - specified " unordered " nature of JSON objects . <nl> - * / <nl> - using object_t = ObjectType < StringType , <nl> - basic_json , <nl> - object_comparator_t , <nl> - AllocatorType < std : : pair < const StringType , <nl> - basic_json > > > ; <nl> - <nl> - / * ! <nl> - @ brief a type for an array <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes JSON arrays as follows : <nl> - > An array is an ordered sequence of zero or more values . <nl> - <nl> - To store objects in C + + , a type is defined by the template parameters <nl> - explained below . <nl> - <nl> - @ tparam ArrayType container type to store arrays ( e . g . , ` std : : vector ` or <nl> - ` std : : list ` ) <nl> - @ tparam AllocatorType allocator to use for arrays ( e . g . , ` std : : allocator ` ) <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a ArrayType ( ` std : : vector ` ) and @ a <nl> - AllocatorType ( ` std : : allocator ` ) , the default value for @ a array_t is : <nl> - <nl> - @ code { . cpp } <nl> - std : : vector < <nl> - basic_json , / / value_type <nl> - std : : allocator < basic_json > / / allocator_type <nl> - > <nl> - @ endcode <nl> - <nl> - # # # # Limits <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) specifies : <nl> - > An implementation may set limits on the maximum depth of nesting . <nl> - <nl> - In this class , the array ' s limit of nesting is not explicitly constrained . <nl> - However , a maximum depth of nesting may be introduced by the compiler or <nl> - runtime environment . A theoretical limit can be queried by calling the <nl> - @ ref max_size function of a JSON array . <nl> - <nl> - # # # # Storage <nl> - <nl> - Arrays are stored as pointers in a @ ref basic_json type . That is , for any <nl> - access to array values , a pointer of type ` array_t * ` must be dereferenced . <nl> - <nl> - @ sa @ ref object_t - - type for an object value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using array_t = ArrayType < basic_json , AllocatorType < basic_json > > ; <nl> - <nl> - / * ! <nl> - @ brief a type for a string <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes JSON strings as follows : <nl> - > A string is a sequence of zero or more Unicode characters . <nl> - <nl> - To store objects in C + + , a type is defined by the template parameter <nl> - described below . Unicode values are split by the JSON class into <nl> - byte - sized characters during deserialization . <nl> - <nl> - @ tparam StringType the container to store strings ( e . g . , ` std : : string ` ) . <nl> - Note this container is used for keys / names in objects , see @ ref object_t . <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a StringType ( ` std : : string ` ) , the default <nl> - value for @ a string_t is : <nl> - <nl> - @ code { . cpp } <nl> - std : : string <nl> - @ endcode <nl> - <nl> - # # # # Encoding <nl> - <nl> - Strings are stored in UTF - 8 encoding . Therefore , functions like <nl> - ` std : : string : : size ( ) ` or ` std : : string : : length ( ) ` return the number of <nl> - bytes in the string rather than the number of characters or glyphs . <nl> - <nl> - # # # # String comparison <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) states : <nl> - > Software implementations are typically required to test names of object <nl> - > members for equality . Implementations that transform the textual <nl> - > representation into sequences of Unicode code units and then perform the <nl> - > comparison numerically , code unit by code unit , are interoperable in the <nl> - > sense that implementations will agree in all cases on equality or <nl> - > inequality of two strings . For example , implementations that compare <nl> - > strings with escaped characters unconverted may incorrectly find that <nl> - > ` " a \ \ b " ` and ` " a \ u005Cb " ` are not equal . <nl> - <nl> - This implementation is interoperable as it does compare strings code unit <nl> - by code unit . <nl> - <nl> - # # # # Storage <nl> - <nl> - String values are stored as pointers in a @ ref basic_json type . That is , <nl> - for any access to string values , a pointer of type ` string_t * ` must be <nl> - dereferenced . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using string_t = StringType ; <nl> - <nl> - / * ! <nl> - @ brief a type for a boolean <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) implicitly describes a boolean as a <nl> - type which differentiates the two literals ` true ` and ` false ` . <nl> - <nl> - To store objects in C + + , a type is defined by the template parameter @ a <nl> - BooleanType which chooses the type to use . <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a BooleanType ( ` bool ` ) , the default value for <nl> - @ a boolean_t is : <nl> - <nl> - @ code { . cpp } <nl> - bool <nl> - @ endcode <nl> - <nl> - # # # # Storage <nl> - <nl> - Boolean values are stored directly inside a @ ref basic_json type . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using boolean_t = BooleanType ; <nl> - <nl> - / * ! <nl> - @ brief a type for a number ( integer ) <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes numbers as follows : <nl> - > The representation of numbers is similar to that used in most <nl> - > programming languages . A number is represented in base 10 using decimal <nl> - > digits . It contains an integer component that may be prefixed with an <nl> - > optional minus sign , which may be followed by a fraction part and / or an <nl> - > exponent part . Leading zeros are not allowed . ( . . . ) Numeric values that <nl> - > cannot be represented in the grammar below ( such as Infinity and NaN ) <nl> - > are not permitted . <nl> - <nl> - This description includes both integer and floating - point numbers . <nl> - However , C + + allows more precise storage if it is known whether the number <nl> - is a signed integer , an unsigned integer or a floating - point number . <nl> - Therefore , three different types , @ ref number_integer_t , @ ref <nl> - number_unsigned_t and @ ref number_float_t are used . <nl> - <nl> - To store integer numbers in C + + , a type is defined by the template <nl> - parameter @ a NumberIntegerType which chooses the type to use . <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a NumberIntegerType ( ` int64_t ` ) , the default <nl> - value for @ a number_integer_t is : <nl> - <nl> - @ code { . cpp } <nl> - int64_t <nl> - @ endcode <nl> - <nl> - # # # # Default behavior <nl> - <nl> - - The restrictions about leading zeros is not enforced in C + + . Instead , <nl> - leading zeros in integer literals lead to an interpretation as octal <nl> - number . Internally , the value will be stored as decimal number . For <nl> - instance , the C + + integer literal ` 010 ` will be serialized to ` 8 ` . <nl> - During deserialization , leading zeros yield an error . <nl> - - Not - a - number ( NaN ) values will be serialized to ` null ` . <nl> - <nl> - # # # # Limits <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) specifies : <nl> - > An implementation may set limits on the range and precision of numbers . <nl> - <nl> - When the default type is used , the maximal integer number that can be <nl> - stored is ` 9223372036854775807 ` ( INT64_MAX ) and the minimal integer number <nl> - that can be stored is ` - 9223372036854775808 ` ( INT64_MIN ) . Integer numbers <nl> - that are out of range will yield over / underflow when used in a <nl> - constructor . During deserialization , too large or small integer numbers <nl> - will be automatically be stored as @ ref number_unsigned_t or @ ref <nl> - number_float_t . <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) further states : <nl> - > Note that when such software is used , numbers that are integers and are <nl> - > in the range \ f $ [ - 2 ^ { 53 } + 1 , 2 ^ { 53 } - 1 ] \ f $ are interoperable in the sense <nl> - > that implementations will agree exactly on their numeric values . <nl> - <nl> - As this range is a subrange of the exactly supported range [ INT64_MIN , <nl> - INT64_MAX ] , this class ' s integer type is interoperable . <nl> - <nl> - # # # # Storage <nl> - <nl> - Integer number values are stored directly inside a @ ref basic_json type . <nl> - <nl> - @ sa @ ref number_float_t - - type for number values ( floating - point ) <nl> - <nl> - @ sa @ ref number_unsigned_t - - type for number values ( unsigned integer ) <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using number_integer_t = NumberIntegerType ; <nl> - <nl> - / * ! <nl> - @ brief a type for a number ( unsigned ) <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes numbers as follows : <nl> - > The representation of numbers is similar to that used in most <nl> - > programming languages . A number is represented in base 10 using decimal <nl> - > digits . It contains an integer component that may be prefixed with an <nl> - > optional minus sign , which may be followed by a fraction part and / or an <nl> - > exponent part . Leading zeros are not allowed . ( . . . ) Numeric values that <nl> - > cannot be represented in the grammar below ( such as Infinity and NaN ) <nl> - > are not permitted . <nl> - <nl> - This description includes both integer and floating - point numbers . <nl> - However , C + + allows more precise storage if it is known whether the number <nl> - is a signed integer , an unsigned integer or a floating - point number . <nl> - Therefore , three different types , @ ref number_integer_t , @ ref <nl> - number_unsigned_t and @ ref number_float_t are used . <nl> - <nl> - To store unsigned integer numbers in C + + , a type is defined by the <nl> - template parameter @ a NumberUnsignedType which chooses the type to use . <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a NumberUnsignedType ( ` uint64_t ` ) , the <nl> - default value for @ a number_unsigned_t is : <nl> - <nl> - @ code { . cpp } <nl> - uint64_t <nl> - @ endcode <nl> - <nl> - # # # # Default behavior <nl> - <nl> - - The restrictions about leading zeros is not enforced in C + + . Instead , <nl> - leading zeros in integer literals lead to an interpretation as octal <nl> - number . Internally , the value will be stored as decimal number . For <nl> - instance , the C + + integer literal ` 010 ` will be serialized to ` 8 ` . <nl> - During deserialization , leading zeros yield an error . <nl> - - Not - a - number ( NaN ) values will be serialized to ` null ` . <nl> - <nl> - # # # # Limits <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) specifies : <nl> - > An implementation may set limits on the range and precision of numbers . <nl> - <nl> - When the default type is used , the maximal integer number that can be <nl> - stored is ` 18446744073709551615 ` ( UINT64_MAX ) and the minimal integer <nl> - number that can be stored is ` 0 ` . Integer numbers that are out of range <nl> - will yield over / underflow when used in a constructor . During <nl> - deserialization , too large or small integer numbers will be automatically <nl> - be stored as @ ref number_integer_t or @ ref number_float_t . <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) further states : <nl> - > Note that when such software is used , numbers that are integers and are <nl> - > in the range \ f $ [ - 2 ^ { 53 } + 1 , 2 ^ { 53 } - 1 ] \ f $ are interoperable in the sense <nl> - > that implementations will agree exactly on their numeric values . <nl> - <nl> - As this range is a subrange ( when considered in conjunction with the <nl> - number_integer_t type ) of the exactly supported range [ 0 , UINT64_MAX ] , <nl> - this class ' s integer type is interoperable . <nl> - <nl> - # # # # Storage <nl> - <nl> - Integer number values are stored directly inside a @ ref basic_json type . <nl> - <nl> - @ sa @ ref number_float_t - - type for number values ( floating - point ) <nl> - @ sa @ ref number_integer_t - - type for number values ( integer ) <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - using number_unsigned_t = NumberUnsignedType ; <nl> - <nl> - / * ! <nl> - @ brief a type for a number ( floating - point ) <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) describes numbers as follows : <nl> - > The representation of numbers is similar to that used in most <nl> - > programming languages . A number is represented in base 10 using decimal <nl> - > digits . It contains an integer component that may be prefixed with an <nl> - > optional minus sign , which may be followed by a fraction part and / or an <nl> - > exponent part . Leading zeros are not allowed . ( . . . ) Numeric values that <nl> - > cannot be represented in the grammar below ( such as Infinity and NaN ) <nl> - > are not permitted . <nl> - <nl> - This description includes both integer and floating - point numbers . <nl> - However , C + + allows more precise storage if it is known whether the number <nl> - is a signed integer , an unsigned integer or a floating - point number . <nl> - Therefore , three different types , @ ref number_integer_t , @ ref <nl> - number_unsigned_t and @ ref number_float_t are used . <nl> - <nl> - To store floating - point numbers in C + + , a type is defined by the template <nl> - parameter @ a NumberFloatType which chooses the type to use . <nl> - <nl> - # # # # Default type <nl> - <nl> - With the default values for @ a NumberFloatType ( ` double ` ) , the default <nl> - value for @ a number_float_t is : <nl> - <nl> - @ code { . cpp } <nl> - double <nl> - @ endcode <nl> - <nl> - # # # # Default behavior <nl> - <nl> - - The restrictions about leading zeros is not enforced in C + + . Instead , <nl> - leading zeros in floating - point literals will be ignored . Internally , <nl> - the value will be stored as decimal number . For instance , the C + + <nl> - floating - point literal ` 01 . 2 ` will be serialized to ` 1 . 2 ` . During <nl> - deserialization , leading zeros yield an error . <nl> - - Not - a - number ( NaN ) values will be serialized to ` null ` . <nl> - <nl> - # # # # Limits <nl> - <nl> - [ RFC 7159 ] ( http : / / rfc7159 . net / rfc7159 ) states : <nl> - > This specification allows implementations to set limits on the range and <nl> - > precision of numbers accepted . Since software that implements IEEE <nl> - > 754 - 2008 binary64 ( double precision ) numbers is generally available and <nl> - > widely used , good interoperability can be achieved by implementations <nl> - > that expect no more precision or range than these provide , in the sense <nl> - > that implementations will approximate JSON numbers within the expected <nl> - > precision . <nl> - <nl> - This implementation does exactly follow this approach , as it uses double <nl> - precision floating - point numbers . Note values smaller than <nl> - ` - 1 . 79769313486232e + 308 ` and values greater than ` 1 . 79769313486232e + 308 ` <nl> - will be stored as NaN internally and be serialized to ` null ` . <nl> - <nl> - # # # # Storage <nl> - <nl> - Floating - point number values are stored directly inside a @ ref basic_json <nl> - type . <nl> - <nl> - @ sa @ ref number_integer_t - - type for number values ( integer ) <nl> - <nl> - @ sa @ ref number_unsigned_t - - type for number values ( unsigned integer ) <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using number_float_t = NumberFloatType ; <nl> - <nl> - / / / @ } <nl> - <nl> - private : <nl> - <nl> - / / / helper for exception - safe object creation <nl> - template < typename T , typename . . . Args > <nl> - static T * create ( Args & & . . . args ) <nl> - { <nl> - AllocatorType < T > alloc ; <nl> - using AllocatorTraits = std : : allocator_traits < AllocatorType < T > > ; <nl> - <nl> - auto deleter = [ & ] ( T * object ) <nl> - { <nl> - AllocatorTraits : : deallocate ( alloc , object , 1 ) ; <nl> - } ; <nl> - std : : unique_ptr < T , decltype ( deleter ) > object ( AllocatorTraits : : allocate ( alloc , 1 ) , deleter ) ; <nl> - AllocatorTraits : : construct ( alloc , object . get ( ) , std : : forward < Args > ( args ) . . . ) ; <nl> - assert ( object ! = nullptr ) ; <nl> - return object . release ( ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON value storage / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief a JSON value <nl> - <nl> - The actual storage for a JSON value of the @ ref basic_json class . This <nl> - union combines the different storage types for the JSON value types <nl> - defined in @ ref value_t . <nl> - <nl> - JSON type | value_t type | used type <nl> - mmmmmmmmm | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm <nl> - object | object | pointer to @ ref object_t <nl> - array | array | pointer to @ ref array_t <nl> - string | string | pointer to @ ref string_t <nl> - boolean | boolean | @ ref boolean_t <nl> - number | number_integer | @ ref number_integer_t <nl> - number | number_unsigned | @ ref number_unsigned_t <nl> - number | number_float | @ ref number_float_t <nl> - null | null | * no value is stored * <nl> - <nl> - @ note Variable - length types ( objects , arrays , and strings ) are stored as <nl> - pointers . The size of the union should not exceed 64 bits if the default <nl> - value types are used . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - union json_value <nl> - { <nl> - / / / object ( stored with pointer to save storage ) <nl> - object_t * object ; <nl> - / / / array ( stored with pointer to save storage ) <nl> - array_t * array ; <nl> - / / / string ( stored with pointer to save storage ) <nl> - string_t * string ; <nl> - / / / boolean <nl> - boolean_t boolean ; <nl> - / / / number ( integer ) <nl> - number_integer_t number_integer ; <nl> - / / / number ( unsigned integer ) <nl> - number_unsigned_t number_unsigned ; <nl> - / / / number ( floating - point ) <nl> - number_float_t number_float ; <nl> - <nl> - / / / default constructor ( for null values ) <nl> - json_value ( ) = default ; <nl> - / / / constructor for booleans <nl> - json_value ( boolean_t v ) noexcept : boolean ( v ) { } <nl> - / / / constructor for numbers ( integer ) <nl> - json_value ( number_integer_t v ) noexcept : number_integer ( v ) { } <nl> - / / / constructor for numbers ( unsigned ) <nl> - json_value ( number_unsigned_t v ) noexcept : number_unsigned ( v ) { } <nl> - / / / constructor for numbers ( floating - point ) <nl> - json_value ( number_float_t v ) noexcept : number_float ( v ) { } <nl> - / / / constructor for empty values of a given type <nl> - json_value ( value_t t ) <nl> - { <nl> - switch ( t ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - object = create < object_t > ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - array = create < array_t > ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - string = create < string_t > ( " " ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - boolean = boolean_t ( false ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - number_integer = number_integer_t ( 0 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - number_unsigned = number_unsigned_t ( 0 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - number_float = number_float_t ( 0 . 0 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : null : <nl> - { <nl> - object = nullptr ; / / silence warning , see # 821 <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - object = nullptr ; / / silence warning , see # 821 <nl> - if ( JSON_UNLIKELY ( t = = value_t : : null ) ) <nl> - { <nl> - JSON_THROW ( other_error : : create ( 500 , " 961c151d2e87f2686a955a9be24d316f1362bf21 3 . 1 . 2 " ) ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / constructor for strings <nl> - json_value ( const string_t & value ) <nl> - { <nl> - string = create < string_t > ( value ) ; <nl> - } <nl> - <nl> - / / / constructor for rvalue strings <nl> - json_value ( string_t & & value ) <nl> - { <nl> - string = create < string_t > ( std : : move ( value ) ) ; <nl> - } <nl> - <nl> - / / / constructor for objects <nl> - json_value ( const object_t & value ) <nl> - { <nl> - object = create < object_t > ( value ) ; <nl> - } <nl> - <nl> - / / / constructor for rvalue objects <nl> - json_value ( object_t & & value ) <nl> - { <nl> - object = create < object_t > ( std : : move ( value ) ) ; <nl> - } <nl> - <nl> - / / / constructor for arrays <nl> - json_value ( const array_t & value ) <nl> - { <nl> - array = create < array_t > ( value ) ; <nl> - } <nl> - <nl> - / / / constructor for rvalue arrays <nl> - json_value ( array_t & & value ) <nl> - { <nl> - array = create < array_t > ( std : : move ( value ) ) ; <nl> - } <nl> - <nl> - void destroy ( value_t t ) noexcept <nl> - { <nl> - switch ( t ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - AllocatorType < object_t > alloc ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : destroy ( alloc , object ) ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : deallocate ( alloc , object , 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - AllocatorType < array_t > alloc ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : destroy ( alloc , array ) ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : deallocate ( alloc , array , 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - AllocatorType < string_t > alloc ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : destroy ( alloc , string ) ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : deallocate ( alloc , string , 1 ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } ; <nl> - <nl> - / * ! <nl> - @ brief checks the class invariants <nl> - <nl> - This function asserts the class invariants . It needs to be called at the <nl> - end of every constructor to make sure that created objects respect the <nl> - invariant . Furthermore , it has to be called each time the type of a JSON <nl> - value is changed , because the invariant expresses a relationship between <nl> - @ a m_type and @ a m_value . <nl> - * / <nl> - void assert_invariant ( ) const noexcept <nl> - { <nl> - assert ( m_type ! = value_t : : object or m_value . object ! = nullptr ) ; <nl> - assert ( m_type ! = value_t : : array or m_value . array ! = nullptr ) ; <nl> - assert ( m_type ! = value_t : : string or m_value . string ! = nullptr ) ; <nl> - } <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON parser callback / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief parser event types <nl> - <nl> - The parser callback distinguishes the following events : <nl> - - ` object_start ` : the parser read ` { ` and started to process a JSON object <nl> - - ` key ` : the parser read a key of a value in an object <nl> - - ` object_end ` : the parser read ` } ` and finished processing a JSON object <nl> - - ` array_start ` : the parser read ` [ ` and started to process a JSON array <nl> - - ` array_end ` : the parser read ` ] ` and finished processing a JSON array <nl> - - ` value ` : the parser finished reading a JSON value <nl> - <nl> - @ image html callback_events . png " Example when certain parse events are triggered " <nl> - <nl> - @ sa @ ref parser_callback_t for more information and examples <nl> - * / <nl> - using parse_event_t = typename parser : : parse_event_t ; <nl> - <nl> - / * ! <nl> - @ brief per - element parser callback type <nl> - <nl> - With a parser callback function , the result of parsing a JSON text can be <nl> - influenced . When passed to @ ref parse , it is called on certain events <nl> - ( passed as @ ref parse_event_t via parameter @ a event ) with a set recursion <nl> - depth @ a depth and context JSON value @ a parsed . The return value of the <nl> - callback function is a boolean indicating whether the element that emitted <nl> - the callback shall be kept or not . <nl> - <nl> - We distinguish six scenarios ( determined by the event type ) in which the <nl> - callback function can be called . The following table describes the values <nl> - of the parameters @ a depth , @ a event , and @ a parsed . <nl> - <nl> - parameter @ a event | description | parameter @ a depth | parameter @ a parsed <nl> - mmmmmmmmmmmmmmmmmm | mmmmmmmmm - - | mmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmm - <nl> - parse_event_t : : object_start | the parser read ` { ` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded <nl> - parse_event_t : : key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key <nl> - parse_event_t : : object_end | the parser read ` } ` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object <nl> - parse_event_t : : array_start | the parser read ` [ ` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded <nl> - parse_event_t : : array_end | the parser read ` ] ` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array <nl> - parse_event_t : : value | the parser finished reading a JSON value | depth of the value | the parsed JSON value <nl> - <nl> - @ image html callback_events . png " Example when certain parse events are triggered " <nl> - <nl> - Discarding a value ( i . e . , returning ` false ` ) has different effects <nl> - depending on the context in which function was called : <nl> - <nl> - - Discarded values in structured types are skipped . That is , the parser <nl> - will behave as if the discarded value was never read . <nl> - - In case a value outside a structured type is skipped , it is replaced <nl> - with ` null ` . This case happens if the top - level element is skipped . <nl> - <nl> - @ param [ in ] depth the depth of the recursion during parsing <nl> - <nl> - @ param [ in ] event an event of type parse_event_t indicating the context in <nl> - the callback function has been called <nl> - <nl> - @ param [ in , out ] parsed the current intermediate parse result ; note that <nl> - writing to this value has no effect for parse_event_t : : key events <nl> - <nl> - @ return Whether the JSON value which called the function during parsing <nl> - should be kept ( ` true ` ) or not ( ` false ` ) . In the latter case , it is either <nl> - skipped completely or replaced by an empty discarded object . <nl> - <nl> - @ sa @ ref parse for examples <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - using parser_callback_t = typename parser : : parser_callback_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / <nl> - / / constructors / / <nl> - / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name constructors and destructors <nl> - / / / Constructors of class @ ref basic_json , copy / move constructor , copy <nl> - / / / assignment , static functions creating objects , and the destructor . <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief create an empty value with a given type <nl> - <nl> - Create an empty JSON value with a given type . The value will be default <nl> - initialized with an empty value which depends on the type : <nl> - <nl> - Value type | initial value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` null ` <nl> - boolean | ` false ` <nl> - string | ` " " ` <nl> - number | ` 0 ` <nl> - object | ` { } ` <nl> - array | ` [ ] ` <nl> - <nl> - @ param [ in ] v the type of the value to create <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The following code shows the constructor for different @ ref <nl> - value_t values , basic_json__value_t } <nl> - <nl> - @ sa @ ref clear ( ) - - restores the postcondition of this constructor <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( const value_t v ) <nl> - : m_type ( v ) , m_value ( v ) <nl> - { <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a null object <nl> - <nl> - Create a ` null ` JSON value . It either takes a null pointer as parameter <nl> - ( explicitly creating ` null ` ) or no parameter ( implicitly creating ` null ` ) . <nl> - The passed null pointer itself is not read - - it is only used to choose <nl> - the right constructor . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this constructor never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code shows the constructor with and without a <nl> - null pointer parameter . , basic_json__nullptr_t } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( std : : nullptr_t = nullptr ) noexcept <nl> - : basic_json ( value_t : : null ) <nl> - { <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a JSON value <nl> - <nl> - This is a " catch all " constructor for all compatible JSON types ; that is , <nl> - types for which a ` to_json ( ) ` method exists . The constructor forwards the <nl> - parameter @ a val to that method ( to ` json_serializer < U > : : to_json ` method <nl> - with ` U = uncvref_t < CompatibleType > ` , to be exact ) . <nl> - <nl> - Template type @ a CompatibleType includes , but is not limited to , the <nl> - following types : <nl> - - * * arrays * * : @ ref array_t and all kinds of compatible containers such as <nl> - ` std : : vector ` , ` std : : deque ` , ` std : : list ` , ` std : : forward_list ` , <nl> - ` std : : array ` , ` std : : valarray ` , ` std : : set ` , ` std : : unordered_set ` , <nl> - ` std : : multiset ` , and ` std : : unordered_multiset ` with a ` value_type ` from <nl> - which a @ ref basic_json value can be constructed . <nl> - - * * objects * * : @ ref object_t and all kinds of compatible associative <nl> - containers such as ` std : : map ` , ` std : : unordered_map ` , ` std : : multimap ` , <nl> - and ` std : : unordered_multimap ` with a ` key_type ` compatible to <nl> - @ ref string_t and a ` value_type ` from which a @ ref basic_json value can <nl> - be constructed . <nl> - - * * strings * * : @ ref string_t , string literals , and all compatible string <nl> - containers can be used . <nl> - - * * numbers * * : @ ref number_integer_t , @ ref number_unsigned_t , <nl> - @ ref number_float_t , and all convertible number types such as ` int ` , <nl> - ` size_t ` , ` int64_t ` , ` float ` or ` double ` can be used . <nl> - - * * boolean * * : @ ref boolean_t / ` bool ` can be used . <nl> - <nl> - See the examples below . <nl> - <nl> - @ tparam CompatibleType a type such that : <nl> - - @ a CompatibleType is not derived from ` std : : istream ` , <nl> - - @ a CompatibleType is not @ ref basic_json ( to avoid hijacking copy / move <nl> - constructors ) , <nl> - - @ a CompatibleType is not a different @ ref basic_json type ( i . e . with different template arguments ) <nl> - - @ a CompatibleType is not a @ ref basic_json nested type ( e . g . , <nl> - @ ref json_pointer , @ ref iterator , etc . . . ) <nl> - - @ ref @ ref json_serializer < U > has a <nl> - ` to_json ( basic_json_t & , CompatibleType & & ) ` method <nl> - <nl> - @ tparam U = ` uncvref_t < CompatibleType > ` <nl> - <nl> - @ param [ in ] val the value to be forwarded to the respective constructor <nl> - <nl> - @ complexity Usually linear in the size of the passed @ a val , also <nl> - depending on the implementation of the called ` to_json ( ) ` <nl> - method . <nl> - <nl> - @ exceptionsafety Depends on the called constructor . For types directly <nl> - supported by the library ( i . e . , all types for which no ` to_json ( ) ` function <nl> - was provided ) , strong guarantee holds : if an exception is thrown , there are <nl> - no changes to any JSON value . <nl> - <nl> - @ liveexample { The following code shows the constructor with several <nl> - compatible types . , basic_json__CompatibleType } <nl> - <nl> - @ since version 2 . 1 . 0 <nl> - * / <nl> - template < typename CompatibleType , <nl> - typename U = detail : : uncvref_t < CompatibleType > , <nl> - detail : : enable_if_t < <nl> - detail : : is_compatible_type < basic_json_t , U > : : value , int > = 0 > <nl> - basic_json ( CompatibleType & & val ) noexcept ( noexcept ( <nl> - JSONSerializer < U > : : to_json ( std : : declval < basic_json_t & > ( ) , <nl> - std : : forward < CompatibleType > ( val ) ) ) ) <nl> - { <nl> - JSONSerializer < U > : : to_json ( * this , std : : forward < CompatibleType > ( val ) ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a JSON value from an existing one <nl> - <nl> - This is a constructor for existing @ ref basic_json types . <nl> - It does not hijack copy / move constructors , since the parameter has different <nl> - template arguments than the current ones . <nl> - <nl> - The constructor tries to convert the internal @ ref m_value of the parameter . <nl> - <nl> - @ tparam BasicJsonType a type such that : <nl> - - @ a BasicJsonType is a @ ref basic_json type . <nl> - - @ a BasicJsonType has different template arguments than @ ref basic_json_t . <nl> - <nl> - @ param [ in ] val the @ ref basic_json value to be converted . <nl> - <nl> - @ complexity Usually linear in the size of the passed @ a val , also <nl> - depending on the implementation of the called ` to_json ( ) ` <nl> - method . <nl> - <nl> - @ exceptionsafety Depends on the called constructor . For types directly <nl> - supported by the library ( i . e . , all types for which no ` to_json ( ) ` function <nl> - was provided ) , strong guarantee holds : if an exception is thrown , there are <nl> - no changes to any JSON value . <nl> - <nl> - @ since version 3 . 1 . 2 <nl> - * / <nl> - template < typename BasicJsonType , <nl> - detail : : enable_if_t < <nl> - detail : : is_basic_json < BasicJsonType > : : value and not std : : is_same < basic_json , BasicJsonType > : : value , int > = 0 > <nl> - basic_json ( const BasicJsonType & val ) <nl> - { <nl> - using other_boolean_t = typename BasicJsonType : : boolean_t ; <nl> - using other_number_float_t = typename BasicJsonType : : number_float_t ; <nl> - using other_number_integer_t = typename BasicJsonType : : number_integer_t ; <nl> - using other_number_unsigned_t = typename BasicJsonType : : number_unsigned_t ; <nl> - using other_string_t = typename BasicJsonType : : string_t ; <nl> - using other_object_t = typename BasicJsonType : : object_t ; <nl> - using other_array_t = typename BasicJsonType : : array_t ; <nl> - <nl> - switch ( val . type ( ) ) <nl> - { <nl> - case value_t : : boolean : <nl> - JSONSerializer < other_boolean_t > : : to_json ( * this , val . template get < other_boolean_t > ( ) ) ; <nl> - break ; <nl> - case value_t : : number_float : <nl> - JSONSerializer < other_number_float_t > : : to_json ( * this , val . template get < other_number_float_t > ( ) ) ; <nl> - break ; <nl> - case value_t : : number_integer : <nl> - JSONSerializer < other_number_integer_t > : : to_json ( * this , val . template get < other_number_integer_t > ( ) ) ; <nl> - break ; <nl> - case value_t : : number_unsigned : <nl> - JSONSerializer < other_number_unsigned_t > : : to_json ( * this , val . template get < other_number_unsigned_t > ( ) ) ; <nl> - break ; <nl> - case value_t : : string : <nl> - JSONSerializer < other_string_t > : : to_json ( * this , val . template get_ref < const other_string_t & > ( ) ) ; <nl> - break ; <nl> - case value_t : : object : <nl> - JSONSerializer < other_object_t > : : to_json ( * this , val . template get_ref < const other_object_t & > ( ) ) ; <nl> - break ; <nl> - case value_t : : array : <nl> - JSONSerializer < other_array_t > : : to_json ( * this , val . template get_ref < const other_array_t & > ( ) ) ; <nl> - break ; <nl> - case value_t : : null : <nl> - * this = nullptr ; <nl> - break ; <nl> - case value_t : : discarded : <nl> - m_type = value_t : : discarded ; <nl> - break ; <nl> - } <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a container ( array or object ) from an initializer list <nl> - <nl> - Creates a JSON value of type array or object from the passed initializer <nl> - list @ a init . In case @ a type_deduction is ` true ` ( default ) , the type of <nl> - the JSON value to be created is deducted from the initializer list @ a init <nl> - according to the following rules : <nl> - <nl> - 1 . If the list is empty , an empty JSON object value ` { } ` is created . <nl> - 2 . If the list consists of pairs whose first element is a string , a JSON <nl> - object value is created where the first elements of the pairs are <nl> - treated as keys and the second elements are as values . <nl> - 3 . In all other cases , an array is created . <nl> - <nl> - The rules aim to create the best fit between a C + + initializer list and <nl> - JSON values . The rationale is as follows : <nl> - <nl> - 1 . The empty initializer list is written as ` { } ` which is exactly an empty <nl> - JSON object . <nl> - 2 . C + + has no way of describing mapped types other than to list a list of <nl> - pairs . As JSON requires that keys must be of type string , rule 2 is the <nl> - weakest constraint one can pose on initializer lists to interpret them <nl> - as an object . <nl> - 3 . In all other cases , the initializer list could not be interpreted as <nl> - JSON object type , so interpreting it as JSON array type is safe . <nl> - <nl> - With the rules described above , the following JSON values cannot be <nl> - expressed by an initializer list : <nl> - <nl> - - the empty array ( ` [ ] ` ) : use @ ref array ( initializer_list_t ) <nl> - with an empty initializer list in this case <nl> - - arrays whose elements satisfy rule 2 : use @ ref <nl> - array ( initializer_list_t ) with the same initializer list <nl> - in this case <nl> - <nl> - @ note When used without parentheses around an empty initializer list , @ ref <nl> - basic_json ( ) is called instead of this function , yielding the JSON null <nl> - value . <nl> - <nl> - @ param [ in ] init initializer list with JSON values <nl> - <nl> - @ param [ in ] type_deduction internal parameter ; when set to ` true ` , the type <nl> - of the JSON value is deducted from the initializer list @ a init ; when set <nl> - to ` false ` , the type provided via @ a manual_type is forced . This mode is <nl> - used by the functions @ ref array ( initializer_list_t ) and <nl> - @ ref object ( initializer_list_t ) . <nl> - <nl> - @ param [ in ] manual_type internal parameter ; when @ a type_deduction is set <nl> - to ` false ` , the created JSON value will use the provided type ( only @ ref <nl> - value_t : : array and @ ref value_t : : object are valid ) ; when @ a type_deduction <nl> - is set to ` true ` , this parameter has no effect <nl> - <nl> - @ throw type_error . 301 if @ a type_deduction is ` false ` , @ a manual_type is <nl> - ` value_t : : object ` , but @ a init contains an element which is not a pair <nl> - whose first element is a string . In this case , the constructor could not <nl> - create an object . If @ a type_deduction would have be ` true ` , an array <nl> - would have been created . See @ ref object ( initializer_list_t ) <nl> - for an example . <nl> - <nl> - @ complexity Linear in the size of the initializer list @ a init . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The example below shows how JSON values are created from <nl> - initializer lists . , basic_json__list_init_t } <nl> - <nl> - @ sa @ ref array ( initializer_list_t ) - - create a JSON array <nl> - value from an initializer list <nl> - @ sa @ ref object ( initializer_list_t ) - - create a JSON object <nl> - value from an initializer list <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( initializer_list_t init , <nl> - bool type_deduction = true , <nl> - value_t manual_type = value_t : : array ) <nl> - { <nl> - / / check if each element is an array with two elements whose first <nl> - / / element is a string <nl> - bool is_an_object = std : : all_of ( init . begin ( ) , init . end ( ) , <nl> - [ ] ( const detail : : json_ref < basic_json > & element_ref ) <nl> - { <nl> - return ( element_ref - > is_array ( ) and element_ref - > size ( ) = = 2 and ( * element_ref ) [ 0 ] . is_string ( ) ) ; <nl> - } ) ; <nl> - <nl> - / / adjust type if type deduction is not wanted <nl> - if ( not type_deduction ) <nl> - { <nl> - / / if array is wanted , do not create an object though possible <nl> - if ( manual_type = = value_t : : array ) <nl> - { <nl> - is_an_object = false ; <nl> - } <nl> - <nl> - / / if object is wanted but impossible , throw an exception <nl> - if ( JSON_UNLIKELY ( manual_type = = value_t : : object and not is_an_object ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 301 , " cannot create object from initializer list " ) ) ; <nl> - } <nl> - } <nl> - <nl> - if ( is_an_object ) <nl> - { <nl> - / / the initializer list is a list of pairs - > create object <nl> - m_type = value_t : : object ; <nl> - m_value = value_t : : object ; <nl> - <nl> - std : : for_each ( init . begin ( ) , init . end ( ) , [ this ] ( const detail : : json_ref < basic_json > & element_ref ) <nl> - { <nl> - auto element = element_ref . moved_or_copied ( ) ; <nl> - m_value . object - > emplace ( <nl> - std : : move ( * ( ( * element . m_value . array ) [ 0 ] . m_value . string ) ) , <nl> - std : : move ( ( * element . m_value . array ) [ 1 ] ) ) ; <nl> - } ) ; <nl> - } <nl> - else <nl> - { <nl> - / / the initializer list describes an array - > create array <nl> - m_type = value_t : : array ; <nl> - m_value . array = create < array_t > ( init . begin ( ) , init . end ( ) ) ; <nl> - } <nl> - <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief explicitly create an array from an initializer list <nl> - <nl> - Creates a JSON array value from a given initializer list . That is , given a <nl> - list of values ` a , b , c ` , creates the JSON value ` [ a , b , c ] ` . If the <nl> - initializer list is empty , the empty array ` [ ] ` is created . <nl> - <nl> - @ note This function is only needed to express two edge cases that cannot <nl> - be realized with the initializer list constructor ( @ ref <nl> - basic_json ( initializer_list_t , bool , value_t ) ) . These cases <nl> - are : <nl> - 1 . creating an array whose elements are all pairs whose first element is a <nl> - string - - in this case , the initializer list constructor would create an <nl> - object , taking the first elements as keys <nl> - 2 . creating an empty array - - passing the empty initializer list to the <nl> - initializer list constructor yields an empty object <nl> - <nl> - @ param [ in ] init initializer list with JSON values to create an array from <nl> - ( optional ) <nl> - <nl> - @ return JSON array value <nl> - <nl> - @ complexity Linear in the size of @ a init . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The following code shows an example for the ` array ` <nl> - function . , array } <nl> - <nl> - @ sa @ ref basic_json ( initializer_list_t , bool , value_t ) - - <nl> - create a JSON value from an initializer list <nl> - @ sa @ ref object ( initializer_list_t ) - - create a JSON object <nl> - value from an initializer list <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - static basic_json array ( initializer_list_t init = { } ) <nl> - { <nl> - return basic_json ( init , false , value_t : : array ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief explicitly create an object from an initializer list <nl> - <nl> - Creates a JSON object value from a given initializer list . The initializer <nl> - lists elements must be pairs , and their first elements must be strings . If <nl> - the initializer list is empty , the empty object ` { } ` is created . <nl> - <nl> - @ note This function is only added for symmetry reasons . In contrast to the <nl> - related function @ ref array ( initializer_list_t ) , there are <nl> - no cases which can only be expressed by this function . That is , any <nl> - initializer list @ a init can also be passed to the initializer list <nl> - constructor @ ref basic_json ( initializer_list_t , bool , value_t ) . <nl> - <nl> - @ param [ in ] init initializer list to create an object from ( optional ) <nl> - <nl> - @ return JSON object value <nl> - <nl> - @ throw type_error . 301 if @ a init is not a list of pairs whose first <nl> - elements are strings . In this case , no object can be created . When such a <nl> - value is passed to @ ref basic_json ( initializer_list_t , bool , value_t ) , <nl> - an array would have been created from the passed initializer list @ a init . <nl> - See example below . <nl> - <nl> - @ complexity Linear in the size of @ a init . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The following code shows an example for the ` object ` <nl> - function . , object } <nl> - <nl> - @ sa @ ref basic_json ( initializer_list_t , bool , value_t ) - - <nl> - create a JSON value from an initializer list <nl> - @ sa @ ref array ( initializer_list_t ) - - create a JSON array <nl> - value from an initializer list <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - static basic_json object ( initializer_list_t init = { } ) <nl> - { <nl> - return basic_json ( init , false , value_t : : object ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief construct an array with count copies of given value <nl> - <nl> - Constructs a JSON array value by creating @ a cnt copies of a passed value . <nl> - In case @ a cnt is ` 0 ` , an empty array is created . <nl> - <nl> - @ param [ in ] cnt the number of JSON copies of @ a val to create <nl> - @ param [ in ] val the JSON value to copy <nl> - <nl> - @ post ` std : : distance ( begin ( ) , end ( ) ) = = cnt ` holds . <nl> - <nl> - @ complexity Linear in @ a cnt . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The following code shows examples for the @ ref <nl> - basic_json ( size_type \ , const basic_json & ) <nl> - constructor . , basic_json__size_type_basic_json } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( size_type cnt , const basic_json & val ) <nl> - : m_type ( value_t : : array ) <nl> - { <nl> - m_value . array = create < array_t > ( cnt , val ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief construct a JSON container given an iterator range <nl> - <nl> - Constructs the JSON value with the contents of the range ` [ first , last ) ` . <nl> - The semantics depends on the different types a JSON value can have : <nl> - - In case of a null type , invalid_iterator . 206 is thrown . <nl> - - In case of other primitive types ( number , boolean , or string ) , @ a first <nl> - must be ` begin ( ) ` and @ a last must be ` end ( ) ` . In this case , the value is <nl> - copied . Otherwise , invalid_iterator . 204 is thrown . <nl> - - In case of structured types ( array , object ) , the constructor behaves as <nl> - similar versions for ` std : : vector ` or ` std : : map ` ; that is , a JSON array <nl> - or object is constructed from the values in the range . <nl> - <nl> - @ tparam InputIT an input iterator type ( @ ref iterator or @ ref <nl> - const_iterator ) <nl> - <nl> - @ param [ in ] first begin of the range to copy from ( included ) <nl> - @ param [ in ] last end of the range to copy from ( excluded ) <nl> - <nl> - @ pre Iterators @ a first and @ a last must be initialized . * * This <nl> - precondition is enforced with an assertion ( see warning ) . * * If <nl> - assertions are switched off , a violation of this precondition yields <nl> - undefined behavior . <nl> - <nl> - @ pre Range ` [ first , last ) ` is valid . Usually , this precondition cannot be <nl> - checked efficiently . Only certain edge cases are detected ; see the <nl> - description of the exceptions below . A violation of this precondition <nl> - yields undefined behavior . <nl> - <nl> - @ warning A precondition is enforced with a runtime assertion that will <nl> - result in calling ` std : : abort ` if this precondition is not met . <nl> - Assertions can be disabled by defining ` NDEBUG ` at compile time . <nl> - See https : / / en . cppreference . com / w / cpp / error / assert for more <nl> - information . <nl> - <nl> - @ throw invalid_iterator . 201 if iterators @ a first and @ a last are not <nl> - compatible ( i . e . , do not belong to the same JSON value ) . In this case , <nl> - the range ` [ first , last ) ` is undefined . <nl> - @ throw invalid_iterator . 204 if iterators @ a first and @ a last belong to a <nl> - primitive type ( number , boolean , or string ) , but @ a first does not point <nl> - to the first element any more . In this case , the range ` [ first , last ) ` is <nl> - undefined . See example code below . <nl> - @ throw invalid_iterator . 206 if iterators @ a first and @ a last belong to a <nl> - null value . In this case , the range ` [ first , last ) ` is undefined . <nl> - <nl> - @ complexity Linear in distance between @ a first and @ a last . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ liveexample { The example below shows several ways to create JSON values by <nl> - specifying a subrange with iterators . , basic_json__InputIt_InputIt } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < class InputIT , typename std : : enable_if < <nl> - std : : is_same < InputIT , typename basic_json_t : : iterator > : : value or <nl> - std : : is_same < InputIT , typename basic_json_t : : const_iterator > : : value , int > : : type = 0 > <nl> - basic_json ( InputIT first , InputIT last ) <nl> - { <nl> - assert ( first . m_object ! = nullptr ) ; <nl> - assert ( last . m_object ! = nullptr ) ; <nl> - <nl> - / / make sure iterator fits the current value <nl> - if ( JSON_UNLIKELY ( first . m_object ! = last . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 201 , " iterators are not compatible " ) ) ; <nl> - } <nl> - <nl> - / / copy type from first iterator <nl> - m_type = first . m_object - > m_type ; <nl> - <nl> - / / check if iterator range is complete for primitive values <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : boolean : <nl> - case value_t : : number_float : <nl> - case value_t : : number_integer : <nl> - case value_t : : number_unsigned : <nl> - case value_t : : string : <nl> - { <nl> - if ( JSON_UNLIKELY ( not first . m_it . primitive_iterator . is_begin ( ) <nl> - or not last . m_it . primitive_iterator . is_end ( ) ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 204 , " iterators out of range " ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : number_integer : <nl> - { <nl> - m_value . number_integer = first . m_object - > m_value . number_integer ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - m_value . number_unsigned = first . m_object - > m_value . number_unsigned ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - m_value . number_float = first . m_object - > m_value . number_float ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - m_value . boolean = first . m_object - > m_value . boolean ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - m_value = * first . m_object - > m_value . string ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - m_value . object = create < object_t > ( first . m_it . object_iterator , <nl> - last . m_it . object_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_value . array = create < array_t > ( first . m_it . array_iterator , <nl> - last . m_it . array_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( invalid_iterator : : create ( 206 , " cannot construct with iterators from " + <nl> - std : : string ( first . m_object - > type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / other constructors and destructor / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ private <nl> - basic_json ( const detail : : json_ref < basic_json > & ref ) <nl> - : basic_json ( ref . moved_or_copied ( ) ) <nl> - { } <nl> - <nl> - / * ! <nl> - @ brief copy constructor <nl> - <nl> - Creates a copy of a given JSON value . <nl> - <nl> - @ param [ in ] other the JSON value to copy <nl> - <nl> - @ post ` * this = = other ` <nl> - <nl> - @ complexity Linear in the size of @ a other . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes to any JSON value . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is linear . <nl> - - As postcondition , it holds : ` other = = basic_json ( other ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for the copy <nl> - constructor . , basic_json__basic_json } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( const basic_json & other ) <nl> - : m_type ( other . m_type ) <nl> - { <nl> - / / check of passed value is valid <nl> - other . assert_invariant ( ) ; <nl> - <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : object : <nl> - { <nl> - m_value = * other . m_value . object ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_value = * other . m_value . array ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - m_value = * other . m_value . string ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - m_value = other . m_value . boolean ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_integer : <nl> - { <nl> - m_value = other . m_value . number_integer ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - m_value = other . m_value . number_unsigned ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - m_value = other . m_value . number_float ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief move constructor <nl> - <nl> - Move constructor . Constructs a JSON value with the contents of the given <nl> - value @ a other using move semantics . It " steals " the resources from @ a <nl> - other and leaves it as JSON null value . <nl> - <nl> - @ param [ in , out ] other value to move to this object <nl> - <nl> - @ post ` * this ` has the same value as @ a other before the call . <nl> - @ post @ a other is a JSON null value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this constructor never throws <nl> - exceptions . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ MoveConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / MoveConstructible ) <nl> - requirements . <nl> - <nl> - @ liveexample { The code below shows the move constructor explicitly called <nl> - via std : : move . , basic_json__moveconstructor } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - basic_json ( basic_json & & other ) noexcept <nl> - : m_type ( std : : move ( other . m_type ) ) , <nl> - m_value ( std : : move ( other . m_value ) ) <nl> - { <nl> - / / check that passed value is valid <nl> - other . assert_invariant ( ) ; <nl> - <nl> - / / invalidate payload <nl> - other . m_type = value_t : : null ; <nl> - other . m_value = { } ; <nl> - <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief copy assignment <nl> - <nl> - Copy assignment operator . Copies a JSON value via the " copy and swap " <nl> - strategy : It is expressed in terms of the copy constructor , destructor , <nl> - and the ` swap ( ) ` member function . <nl> - <nl> - @ param [ in ] other value to copy from <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is linear . <nl> - <nl> - @ liveexample { The code below shows and example for the copy assignment . It <nl> - creates a copy of value ` a ` which is then swapped with ` b ` . Finally \ , the <nl> - copy of ` a ` ( which is the null value after the swap ) is <nl> - destroyed . , basic_json__copyassignment } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reference & operator = ( basic_json other ) noexcept ( <nl> - std : : is_nothrow_move_constructible < value_t > : : value and <nl> - std : : is_nothrow_move_assignable < value_t > : : value and <nl> - std : : is_nothrow_move_constructible < json_value > : : value and <nl> - std : : is_nothrow_move_assignable < json_value > : : value <nl> - ) <nl> - { <nl> - / / check that passed value is valid <nl> - other . assert_invariant ( ) ; <nl> - <nl> - using std : : swap ; <nl> - swap ( m_type , other . m_type ) ; <nl> - swap ( m_value , other . m_value ) ; <nl> - <nl> - assert_invariant ( ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief destructor <nl> - <nl> - Destroys the JSON value and frees all allocated memory . <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is linear . <nl> - - All stored elements are destroyed and all memory is freed . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - ~ basic_json ( ) noexcept <nl> - { <nl> - assert_invariant ( ) ; <nl> - m_value . destroy ( m_type ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / object inspection / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name object inspection <nl> - / / / Functions to inspect the type of a JSON value . <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief serialization <nl> - <nl> - Serialization function for JSON values . The function tries to mimic <nl> - Python ' s ` json . dumps ( ) ` function , and currently supports its @ a indent <nl> - and @ a ensure_ascii parameters . <nl> - <nl> - @ param [ in ] indent If indent is nonnegative , then array elements and object <nl> - members will be pretty - printed with that indent level . An indent level of <nl> - ` 0 ` will only insert newlines . ` - 1 ` ( the default ) selects the most compact <nl> - representation . <nl> - @ param [ in ] indent_char The character to use for indentation if @ a indent is <nl> - greater than ` 0 ` . The default is ` ` ( space ) . <nl> - @ param [ in ] ensure_ascii If @ a ensure_ascii is true , all non - ASCII characters <nl> - in the output are escaped with ` \ uXXXX ` sequences , and the result consists <nl> - of ASCII characters only . <nl> - <nl> - @ return string containing the serialization of the JSON value <nl> - <nl> - @ throw type_error . 316 if a string stored inside the JSON value is not <nl> - UTF - 8 encoded <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ liveexample { The following example shows the effect of different @ a indent \ , <nl> - @ a indent_char \ , and @ a ensure_ascii parameters to the result of the <nl> - serialization . , dump } <nl> - <nl> - @ see https : / / docs . python . org / 2 / library / json . html # json . dump <nl> - <nl> - @ since version 1 . 0 . 0 ; indentation character @ a indent_char , option <nl> - @ a ensure_ascii and exceptions added in version 3 . 0 . 0 <nl> - * / <nl> - string_t dump ( const int indent = - 1 , const char indent_char = ' ' , <nl> - const bool ensure_ascii = false ) const <nl> - { <nl> - string_t result ; <nl> - serializer s ( detail : : output_adapter < char , string_t > ( result ) , indent_char ) ; <nl> - <nl> - if ( indent > = 0 ) <nl> - { <nl> - s . dump ( * this , true , ensure_ascii , static_cast < unsigned int > ( indent ) ) ; <nl> - } <nl> - else <nl> - { <nl> - s . dump ( * this , false , ensure_ascii , 0 ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return the type of the JSON value ( explicit ) <nl> - <nl> - Return the type of the JSON value as a value from the @ ref value_t <nl> - enumeration . <nl> - <nl> - @ return the type of the JSON value <nl> - Value type | return value <nl> - mmmmmmmmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmmmmmmmmmmm - <nl> - null | value_t : : null <nl> - boolean | value_t : : boolean <nl> - string | value_t : : string <nl> - number ( integer ) | value_t : : number_integer <nl> - number ( unsigned integer ) | value_t : : number_unsigned <nl> - number ( floating - point ) | value_t : : number_float <nl> - object | value_t : : object <nl> - array | value_t : : array <nl> - discarded | value_t : : discarded <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` type ( ) ` for all JSON <nl> - types . , type } <nl> - <nl> - @ sa @ ref operator value_t ( ) - - return the type of the JSON value ( implicit ) <nl> - @ sa @ ref type_name ( ) - - return the type as string <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr value_t type ( ) const noexcept <nl> - { <nl> - return m_type ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether type is primitive <nl> - <nl> - This function returns true if and only if the JSON type is primitive <nl> - ( string , number , boolean , or null ) . <nl> - <nl> - @ return ` true ` if type is primitive ( string , number , boolean , or null ) , <nl> - ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_primitive ( ) ` for all JSON <nl> - types . , is_primitive } <nl> - <nl> - @ sa @ ref is_structured ( ) - - returns whether JSON value is structured <nl> - @ sa @ ref is_null ( ) - - returns whether JSON value is ` null ` <nl> - @ sa @ ref is_string ( ) - - returns whether JSON value is a string <nl> - @ sa @ ref is_boolean ( ) - - returns whether JSON value is a boolean <nl> - @ sa @ ref is_number ( ) - - returns whether JSON value is a number <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_primitive ( ) const noexcept <nl> - { <nl> - return is_null ( ) or is_string ( ) or is_boolean ( ) or is_number ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether type is structured <nl> - <nl> - This function returns true if and only if the JSON type is structured <nl> - ( array or object ) . <nl> - <nl> - @ return ` true ` if type is structured ( array or object ) , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_structured ( ) ` for all JSON <nl> - types . , is_structured } <nl> - <nl> - @ sa @ ref is_primitive ( ) - - returns whether value is primitive <nl> - @ sa @ ref is_array ( ) - - returns whether value is an array <nl> - @ sa @ ref is_object ( ) - - returns whether value is an object <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_structured ( ) const noexcept <nl> - { <nl> - return is_array ( ) or is_object ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is null <nl> - <nl> - This function returns true if and only if the JSON value is null . <nl> - <nl> - @ return ` true ` if type is null , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_null ( ) ` for all JSON <nl> - types . , is_null } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_null ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : null ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is a boolean <nl> - <nl> - This function returns true if and only if the JSON value is a boolean . <nl> - <nl> - @ return ` true ` if type is boolean , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_boolean ( ) ` for all JSON <nl> - types . , is_boolean } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_boolean ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : boolean ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is a number <nl> - <nl> - This function returns true if and only if the JSON value is a number . This <nl> - includes both integer ( signed and unsigned ) and floating - point values . <nl> - <nl> - @ return ` true ` if type is number ( regardless whether integer , unsigned <nl> - integer or floating - type ) , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_number ( ) ` for all JSON <nl> - types . , is_number } <nl> - <nl> - @ sa @ ref is_number_integer ( ) - - check if value is an integer or unsigned <nl> - integer number <nl> - @ sa @ ref is_number_unsigned ( ) - - check if value is an unsigned integer <nl> - number <nl> - @ sa @ ref is_number_float ( ) - - check if value is a floating - point number <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_number ( ) const noexcept <nl> - { <nl> - return is_number_integer ( ) or is_number_float ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is an integer number <nl> - <nl> - This function returns true if and only if the JSON value is a signed or <nl> - unsigned integer number . This excludes floating - point values . <nl> - <nl> - @ return ` true ` if type is an integer or unsigned integer number , ` false ` <nl> - otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_number_integer ( ) ` for all <nl> - JSON types . , is_number_integer } <nl> - <nl> - @ sa @ ref is_number ( ) - - check if value is a number <nl> - @ sa @ ref is_number_unsigned ( ) - - check if value is an unsigned integer <nl> - number <nl> - @ sa @ ref is_number_float ( ) - - check if value is a floating - point number <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_number_integer ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : number_integer or m_type = = value_t : : number_unsigned ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is an unsigned integer number <nl> - <nl> - This function returns true if and only if the JSON value is an unsigned <nl> - integer number . This excludes floating - point and signed integer values . <nl> - <nl> - @ return ` true ` if type is an unsigned integer number , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_number_unsigned ( ) ` for all <nl> - JSON types . , is_number_unsigned } <nl> - <nl> - @ sa @ ref is_number ( ) - - check if value is a number <nl> - @ sa @ ref is_number_integer ( ) - - check if value is an integer or unsigned <nl> - integer number <nl> - @ sa @ ref is_number_float ( ) - - check if value is a floating - point number <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - constexpr bool is_number_unsigned ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : number_unsigned ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is a floating - point number <nl> - <nl> - This function returns true if and only if the JSON value is a <nl> - floating - point number . This excludes signed and unsigned integer values . <nl> - <nl> - @ return ` true ` if type is a floating - point number , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_number_float ( ) ` for all <nl> - JSON types . , is_number_float } <nl> - <nl> - @ sa @ ref is_number ( ) - - check if value is number <nl> - @ sa @ ref is_number_integer ( ) - - check if value is an integer number <nl> - @ sa @ ref is_number_unsigned ( ) - - check if value is an unsigned integer <nl> - number <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_number_float ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : number_float ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is an object <nl> - <nl> - This function returns true if and only if the JSON value is an object . <nl> - <nl> - @ return ` true ` if type is object , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_object ( ) ` for all JSON <nl> - types . , is_object } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_object ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : object ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is an array <nl> - <nl> - This function returns true if and only if the JSON value is an array . <nl> - <nl> - @ return ` true ` if type is array , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_array ( ) ` for all JSON <nl> - types . , is_array } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_array ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : array ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is a string <nl> - <nl> - This function returns true if and only if the JSON value is a string . <nl> - <nl> - @ return ` true ` if type is string , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_string ( ) ` for all JSON <nl> - types . , is_string } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_string ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : string ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return whether value is discarded <nl> - <nl> - This function returns true if and only if the JSON value was discarded <nl> - during parsing with a callback function ( see @ ref parser_callback_t ) . <nl> - <nl> - @ note This function will always be ` false ` for JSON values after parsing . <nl> - That is , discarded values can only occur during parsing , but will be <nl> - removed when inside a structured value or replaced by null in other cases . <nl> - <nl> - @ return ` true ` if type is discarded , ` false ` otherwise . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies ` is_discarded ( ) ` for all JSON <nl> - types . , is_discarded } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr bool is_discarded ( ) const noexcept <nl> - { <nl> - return ( m_type = = value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return the type of the JSON value ( implicit ) <nl> - <nl> - Implicitly return the type of the JSON value as a value from the @ ref <nl> - value_t enumeration . <nl> - <nl> - @ return the type of the JSON value <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this member function never throws <nl> - exceptions . <nl> - <nl> - @ liveexample { The following code exemplifies the @ ref value_t operator for <nl> - all JSON types . , operator__value_t } <nl> - <nl> - @ sa @ ref type ( ) - - return the type of the JSON value ( explicit ) <nl> - @ sa @ ref type_name ( ) - - return the type as string <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - constexpr operator value_t ( ) const noexcept <nl> - { <nl> - return m_type ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - private : <nl> - / / / / / / / / / / / / / / / / / / <nl> - / / value access / / <nl> - / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / get a boolean ( explicit ) <nl> - boolean_t get_impl ( boolean_t * / * unused * / ) const <nl> - { <nl> - if ( JSON_LIKELY ( is_boolean ( ) ) ) <nl> - { <nl> - return m_value . boolean ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 302 , " type must be boolean , but is " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( object ) <nl> - object_t * get_impl_ptr ( object_t * / * unused * / ) noexcept <nl> - { <nl> - return is_object ( ) ? m_value . object : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( object ) <nl> - constexpr const object_t * get_impl_ptr ( const object_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_object ( ) ? m_value . object : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( array ) <nl> - array_t * get_impl_ptr ( array_t * / * unused * / ) noexcept <nl> - { <nl> - return is_array ( ) ? m_value . array : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( array ) <nl> - constexpr const array_t * get_impl_ptr ( const array_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_array ( ) ? m_value . array : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( string ) <nl> - string_t * get_impl_ptr ( string_t * / * unused * / ) noexcept <nl> - { <nl> - return is_string ( ) ? m_value . string : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( string ) <nl> - constexpr const string_t * get_impl_ptr ( const string_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_string ( ) ? m_value . string : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( boolean ) <nl> - boolean_t * get_impl_ptr ( boolean_t * / * unused * / ) noexcept <nl> - { <nl> - return is_boolean ( ) ? & m_value . boolean : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( boolean ) <nl> - constexpr const boolean_t * get_impl_ptr ( const boolean_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_boolean ( ) ? & m_value . boolean : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( integer number ) <nl> - number_integer_t * get_impl_ptr ( number_integer_t * / * unused * / ) noexcept <nl> - { <nl> - return is_number_integer ( ) ? & m_value . number_integer : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( integer number ) <nl> - constexpr const number_integer_t * get_impl_ptr ( const number_integer_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_number_integer ( ) ? & m_value . number_integer : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( unsigned number ) <nl> - number_unsigned_t * get_impl_ptr ( number_unsigned_t * / * unused * / ) noexcept <nl> - { <nl> - return is_number_unsigned ( ) ? & m_value . number_unsigned : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( unsigned number ) <nl> - constexpr const number_unsigned_t * get_impl_ptr ( const number_unsigned_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_number_unsigned ( ) ? & m_value . number_unsigned : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( floating - point number ) <nl> - number_float_t * get_impl_ptr ( number_float_t * / * unused * / ) noexcept <nl> - { <nl> - return is_number_float ( ) ? & m_value . number_float : nullptr ; <nl> - } <nl> - <nl> - / / / get a pointer to the value ( floating - point number ) <nl> - constexpr const number_float_t * get_impl_ptr ( const number_float_t * / * unused * / ) const noexcept <nl> - { <nl> - return is_number_float ( ) ? & m_value . number_float : nullptr ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief helper function to implement get_ref ( ) <nl> - <nl> - This function helps to implement get_ref ( ) without code duplication for <nl> - const and non - const overloads <nl> - <nl> - @ tparam ThisType will be deduced as ` basic_json ` or ` const basic_json ` <nl> - <nl> - @ throw type_error . 303 if ReferenceType does not match underlying value <nl> - type of the current JSON <nl> - * / <nl> - template < typename ReferenceType , typename ThisType > <nl> - static ReferenceType get_ref_impl ( ThisType & obj ) <nl> - { <nl> - / / delegate the call to get_ptr < > ( ) <nl> - auto ptr = obj . template get_ptr < typename std : : add_pointer < ReferenceType > : : type > ( ) ; <nl> - <nl> - if ( JSON_LIKELY ( ptr ! = nullptr ) ) <nl> - { <nl> - return * ptr ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 303 , " incompatible ReferenceType for get_ref , actual type is " + std : : string ( obj . type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - public : <nl> - / / / @ name value access <nl> - / / / Direct access to the stored value of a JSON value . <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief get special - case overload <nl> - <nl> - This overloads avoids a lot of template boilerplate , it can be seen as the <nl> - identity method <nl> - <nl> - @ tparam BasicJsonType = = @ ref basic_json <nl> - <nl> - @ return a copy of * this <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 2 . 1 . 0 <nl> - * / <nl> - template < typename BasicJsonType , detail : : enable_if_t < <nl> - std : : is_same < typename std : : remove_const < BasicJsonType > : : type , basic_json_t > : : value , <nl> - int > = 0 > <nl> - basic_json get ( ) const <nl> - { <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get special - case overload <nl> - <nl> - This overloads converts the current @ ref basic_json in a different <nl> - @ ref basic_json type <nl> - <nl> - @ tparam BasicJsonType = = @ ref basic_json <nl> - <nl> - @ return a copy of * this , converted into @ tparam BasicJsonType <nl> - <nl> - @ complexity Depending on the implementation of the called ` from_json ( ) ` <nl> - method . <nl> - <nl> - @ since version 3 . 1 . 2 <nl> - * / <nl> - template < typename BasicJsonType , detail : : enable_if_t < <nl> - not std : : is_same < BasicJsonType , basic_json > : : value and <nl> - detail : : is_basic_json < BasicJsonType > : : value , int > = 0 > <nl> - BasicJsonType get ( ) const <nl> - { <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a value ( explicit ) <nl> - <nl> - Explicit type conversion between the JSON value and a compatible value <nl> - which is [ CopyConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / CopyConstructible ) <nl> - and [ DefaultConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / DefaultConstructible ) . <nl> - The value is converted by calling the @ ref json_serializer < ValueType > <nl> - ` from_json ( ) ` method . <nl> - <nl> - The function is equivalent to executing <nl> - @ code { . cpp } <nl> - ValueType ret ; <nl> - JSONSerializer < ValueType > : : from_json ( * this , ret ) ; <nl> - return ret ; <nl> - @ endcode <nl> - <nl> - This overloads is chosen if : <nl> - - @ a ValueType is not @ ref basic_json , <nl> - - @ ref json_serializer < ValueType > has a ` from_json ( ) ` method of the form <nl> - ` void from_json ( const basic_json & , ValueType & ) ` , and <nl> - - @ ref json_serializer < ValueType > does not have a ` from_json ( ) ` method of <nl> - the form ` ValueType from_json ( const basic_json & ) ` <nl> - <nl> - @ tparam ValueTypeCV the provided value type <nl> - @ tparam ValueType the returned value type <nl> - <nl> - @ return copy of the JSON value , converted to @ a ValueType <nl> - <nl> - @ throw what @ ref json_serializer < ValueType > ` from_json ( ) ` method throws <nl> - <nl> - @ liveexample { The example below shows several conversions from JSON values <nl> - to other types . There a few things to note : ( 1 ) Floating - point numbers can <nl> - be converted to integers \ , ( 2 ) A JSON array can be converted to a standard <nl> - ` std : : vector < short > ` \ , ( 3 ) A JSON object can be converted to C + + <nl> - associative containers such as ` std : : unordered_map < std : : string \ , <nl> - json > ` . , get__ValueType_const } <nl> - <nl> - @ since version 2 . 1 . 0 <nl> - * / <nl> - template < typename ValueTypeCV , typename ValueType = detail : : uncvref_t < ValueTypeCV > , <nl> - detail : : enable_if_t < <nl> - not detail : : is_basic_json < ValueType > : : value and <nl> - detail : : has_from_json < basic_json_t , ValueType > : : value and <nl> - not detail : : has_non_default_from_json < basic_json_t , ValueType > : : value , <nl> - int > = 0 > <nl> - ValueType get ( ) const noexcept ( noexcept ( <nl> - JSONSerializer < ValueType > : : from_json ( std : : declval < const basic_json_t & > ( ) , std : : declval < ValueType & > ( ) ) ) ) <nl> - { <nl> - / / we cannot static_assert on ValueTypeCV being non - const , because <nl> - / / there is support for get < const basic_json_t > ( ) , which is why we <nl> - / / still need the uncvref <nl> - static_assert ( not std : : is_reference < ValueTypeCV > : : value , <nl> - " get ( ) cannot be used with reference types , you might want to use get_ref ( ) " ) ; <nl> - static_assert ( std : : is_default_constructible < ValueType > : : value , <nl> - " types must be DefaultConstructible when used with get ( ) " ) ; <nl> - <nl> - ValueType ret ; <nl> - JSONSerializer < ValueType > : : from_json ( * this , ret ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a value ( explicit ) ; special case <nl> - <nl> - Explicit type conversion between the JSON value and a compatible value <nl> - which is * * not * * [ CopyConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / CopyConstructible ) <nl> - and * * not * * [ DefaultConstructible ] ( https : / / en . cppreference . com / w / cpp / named_req / DefaultConstructible ) . <nl> - The value is converted by calling the @ ref json_serializer < ValueType > <nl> - ` from_json ( ) ` method . <nl> - <nl> - The function is equivalent to executing <nl> - @ code { . cpp } <nl> - return JSONSerializer < ValueTypeCV > : : from_json ( * this ) ; <nl> - @ endcode <nl> - <nl> - This overloads is chosen if : <nl> - - @ a ValueType is not @ ref basic_json and <nl> - - @ ref json_serializer < ValueType > has a ` from_json ( ) ` method of the form <nl> - ` ValueType from_json ( const basic_json & ) ` <nl> - <nl> - @ note If @ ref json_serializer < ValueType > has both overloads of <nl> - ` from_json ( ) ` , this one is chosen . <nl> - <nl> - @ tparam ValueTypeCV the provided value type <nl> - @ tparam ValueType the returned value type <nl> - <nl> - @ return copy of the JSON value , converted to @ a ValueType <nl> - <nl> - @ throw what @ ref json_serializer < ValueType > ` from_json ( ) ` method throws <nl> - <nl> - @ since version 2 . 1 . 0 <nl> - * / <nl> - template < typename ValueTypeCV , typename ValueType = detail : : uncvref_t < ValueTypeCV > , <nl> - detail : : enable_if_t < not std : : is_same < basic_json_t , ValueType > : : value and <nl> - detail : : has_non_default_from_json < basic_json_t , ValueType > : : value , <nl> - int > = 0 > <nl> - ValueType get ( ) const noexcept ( noexcept ( <nl> - JSONSerializer < ValueTypeCV > : : from_json ( std : : declval < const basic_json_t & > ( ) ) ) ) <nl> - { <nl> - static_assert ( not std : : is_reference < ValueTypeCV > : : value , <nl> - " get ( ) cannot be used with reference types , you might want to use get_ref ( ) " ) ; <nl> - return JSONSerializer < ValueTypeCV > : : from_json ( * this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a pointer value ( explicit ) <nl> - <nl> - Explicit pointer access to the internally stored JSON value . No copies are <nl> - made . <nl> - <nl> - @ warning The pointer becomes invalid if the underlying JSON object <nl> - changes . <nl> - <nl> - @ tparam PointerType pointer type ; must be a pointer to @ ref array_t , @ ref <nl> - object_t , @ ref string_t , @ ref boolean_t , @ ref number_integer_t , <nl> - @ ref number_unsigned_t , or @ ref number_float_t . <nl> - <nl> - @ return pointer to the internally stored JSON value if the requested <nl> - pointer type @ a PointerType fits to the JSON value ; ` nullptr ` otherwise <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how pointers to internal values of a <nl> - JSON value can be requested . Note that no type conversions are made and a <nl> - ` nullptr ` is returned if the value and the requested pointer type does not <nl> - match . , get__PointerType } <nl> - <nl> - @ sa @ ref get_ptr ( ) for explicit pointer - member access <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename PointerType , typename std : : enable_if < <nl> - std : : is_pointer < PointerType > : : value , int > : : type = 0 > <nl> - PointerType get ( ) noexcept <nl> - { <nl> - / / delegate the call to get_ptr <nl> - return get_ptr < PointerType > ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a pointer value ( explicit ) <nl> - @ copydoc get ( ) <nl> - * / <nl> - template < typename PointerType , typename std : : enable_if < <nl> - std : : is_pointer < PointerType > : : value , int > : : type = 0 > <nl> - constexpr const PointerType get ( ) const noexcept <nl> - { <nl> - / / delegate the call to get_ptr <nl> - return get_ptr < PointerType > ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a pointer value ( implicit ) <nl> - <nl> - Implicit pointer access to the internally stored JSON value . No copies are <nl> - made . <nl> - <nl> - @ warning Writing data to the pointee of the result yields an undefined <nl> - state . <nl> - <nl> - @ tparam PointerType pointer type ; must be a pointer to @ ref array_t , @ ref <nl> - object_t , @ ref string_t , @ ref boolean_t , @ ref number_integer_t , <nl> - @ ref number_unsigned_t , or @ ref number_float_t . Enforced by a static <nl> - assertion . <nl> - <nl> - @ return pointer to the internally stored JSON value if the requested <nl> - pointer type @ a PointerType fits to the JSON value ; ` nullptr ` otherwise <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how pointers to internal values of a <nl> - JSON value can be requested . Note that no type conversions are made and a <nl> - ` nullptr ` is returned if the value and the requested pointer type does not <nl> - match . , get_ptr } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename PointerType , typename std : : enable_if < <nl> - std : : is_pointer < PointerType > : : value , int > : : type = 0 > <nl> - PointerType get_ptr ( ) noexcept <nl> - { <nl> - / / get the type of the PointerType ( remove pointer and const ) <nl> - using pointee_t = typename std : : remove_const < typename <nl> - std : : remove_pointer < typename <nl> - std : : remove_const < PointerType > : : type > : : type > : : type ; <nl> - / / make sure the type matches the allowed types <nl> - static_assert ( <nl> - std : : is_same < object_t , pointee_t > : : value <nl> - or std : : is_same < array_t , pointee_t > : : value <nl> - or std : : is_same < string_t , pointee_t > : : value <nl> - or std : : is_same < boolean_t , pointee_t > : : value <nl> - or std : : is_same < number_integer_t , pointee_t > : : value <nl> - or std : : is_same < number_unsigned_t , pointee_t > : : value <nl> - or std : : is_same < number_float_t , pointee_t > : : value <nl> - , " incompatible pointer type " ) ; <nl> - <nl> - / / delegate the call to get_impl_ptr < > ( ) <nl> - return get_impl_ptr ( static_cast < PointerType > ( nullptr ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a pointer value ( implicit ) <nl> - @ copydoc get_ptr ( ) <nl> - * / <nl> - template < typename PointerType , typename std : : enable_if < <nl> - std : : is_pointer < PointerType > : : value and <nl> - std : : is_const < typename std : : remove_pointer < PointerType > : : type > : : value , int > : : type = 0 > <nl> - constexpr const PointerType get_ptr ( ) const noexcept <nl> - { <nl> - / / get the type of the PointerType ( remove pointer and const ) <nl> - using pointee_t = typename std : : remove_const < typename <nl> - std : : remove_pointer < typename <nl> - std : : remove_const < PointerType > : : type > : : type > : : type ; <nl> - / / make sure the type matches the allowed types <nl> - static_assert ( <nl> - std : : is_same < object_t , pointee_t > : : value <nl> - or std : : is_same < array_t , pointee_t > : : value <nl> - or std : : is_same < string_t , pointee_t > : : value <nl> - or std : : is_same < boolean_t , pointee_t > : : value <nl> - or std : : is_same < number_integer_t , pointee_t > : : value <nl> - or std : : is_same < number_unsigned_t , pointee_t > : : value <nl> - or std : : is_same < number_float_t , pointee_t > : : value <nl> - , " incompatible pointer type " ) ; <nl> - <nl> - / / delegate the call to get_impl_ptr < > ( ) const <nl> - return get_impl_ptr ( static_cast < PointerType > ( nullptr ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a reference value ( implicit ) <nl> - <nl> - Implicit reference access to the internally stored JSON value . No copies <nl> - are made . <nl> - <nl> - @ warning Writing data to the referee of the result yields an undefined <nl> - state . <nl> - <nl> - @ tparam ReferenceType reference type ; must be a reference to @ ref array_t , <nl> - @ ref object_t , @ ref string_t , @ ref boolean_t , @ ref number_integer_t , or <nl> - @ ref number_float_t . Enforced by static assertion . <nl> - <nl> - @ return reference to the internally stored JSON value if the requested <nl> - reference type @ a ReferenceType fits to the JSON value ; throws <nl> - type_error . 303 otherwise <nl> - <nl> - @ throw type_error . 303 in case passed type @ a ReferenceType is incompatible <nl> - with the stored JSON value ; see example below <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example shows several calls to ` get_ref ( ) ` . , get_ref } <nl> - <nl> - @ since version 1 . 1 . 0 <nl> - * / <nl> - template < typename ReferenceType , typename std : : enable_if < <nl> - std : : is_reference < ReferenceType > : : value , int > : : type = 0 > <nl> - ReferenceType get_ref ( ) <nl> - { <nl> - / / delegate call to get_ref_impl <nl> - return get_ref_impl < ReferenceType > ( * this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a reference value ( implicit ) <nl> - @ copydoc get_ref ( ) <nl> - * / <nl> - template < typename ReferenceType , typename std : : enable_if < <nl> - std : : is_reference < ReferenceType > : : value and <nl> - std : : is_const < typename std : : remove_reference < ReferenceType > : : type > : : value , int > : : type = 0 > <nl> - ReferenceType get_ref ( ) const <nl> - { <nl> - / / delegate call to get_ref_impl <nl> - return get_ref_impl < ReferenceType > ( * this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief get a value ( implicit ) <nl> - <nl> - Implicit type conversion between the JSON value and a compatible value . <nl> - The call is realized by calling @ ref get ( ) const . <nl> - <nl> - @ tparam ValueType non - pointer type compatible to the JSON value , for <nl> - instance ` int ` for JSON integer numbers , ` bool ` for JSON booleans , or <nl> - ` std : : vector ` types for JSON arrays . The character type of @ ref string_t <nl> - as well as an initializer list of this type is excluded to avoid <nl> - ambiguities as these types implicitly convert to ` std : : string ` . <nl> - <nl> - @ return copy of the JSON value , converted to type @ a ValueType <nl> - <nl> - @ throw type_error . 302 in case passed type @ a ValueType is incompatible <nl> - to the JSON value type ( e . g . , the JSON value is of type boolean , but a <nl> - string is requested ) ; see example below <nl> - <nl> - @ complexity Linear in the size of the JSON value . <nl> - <nl> - @ liveexample { The example below shows several conversions from JSON values <nl> - to other types . There a few things to note : ( 1 ) Floating - point numbers can <nl> - be converted to integers \ , ( 2 ) A JSON array can be converted to a standard <nl> - ` std : : vector < short > ` \ , ( 3 ) A JSON object can be converted to C + + <nl> - associative containers such as ` std : : unordered_map < std : : string \ , <nl> - json > ` . , operator__ValueType } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename ValueType , typename std : : enable_if < <nl> - not std : : is_pointer < ValueType > : : value and <nl> - not std : : is_same < ValueType , detail : : json_ref < basic_json > > : : value and <nl> - not std : : is_same < ValueType , typename string_t : : value_type > : : value and <nl> - not detail : : is_basic_json < ValueType > : : value <nl> - # ifndef _MSC_VER / / fix for issue # 167 operator < < ambiguity under VS2015 <nl> - and not std : : is_same < ValueType , std : : initializer_list < typename string_t : : value_type > > : : value <nl> - # if defined ( JSON_HAS_CPP_17 ) & & defined ( _MSC_VER ) and _MSC_VER < = 1914 <nl> - and not std : : is_same < ValueType , typename std : : string_view > : : value <nl> - # endif <nl> - # endif <nl> - , int > : : type = 0 > <nl> - operator ValueType ( ) const <nl> - { <nl> - / / delegate the call to get < > ( ) const <nl> - return get < ValueType > ( ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / <nl> - / / element access / / <nl> - / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name element access <nl> - / / / Access to the JSON value . <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief access specified array element with bounds checking <nl> - <nl> - Returns a reference to the element at specified location @ a idx , with <nl> - bounds checking . <nl> - <nl> - @ param [ in ] idx index of the element to access <nl> - <nl> - @ return reference to the element at index @ a idx <nl> - <nl> - @ throw type_error . 304 if the JSON value is not an array ; in this case , <nl> - calling ` at ` with an index makes no sense . See example below . <nl> - @ throw out_of_range . 401 if the index @ a idx is out of range of the array ; <nl> - that is , ` idx > = size ( ) ` . See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ liveexample { The example below shows how array elements can be read and <nl> - written using ` at ( ) ` . It also demonstrates the different exceptions that <nl> - can be thrown . , at__size_type } <nl> - * / <nl> - reference at ( size_type idx ) <nl> - { <nl> - / / at only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - JSON_TRY <nl> - { <nl> - return m_value . array - > at ( idx ) ; <nl> - } <nl> - JSON_CATCH ( std : : out_of_range & ) <nl> - { <nl> - / / create better exception explanation <nl> - JSON_THROW ( out_of_range : : create ( 401 , " array index " + std : : to_string ( idx ) + " is out of range " ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 304 , " cannot use at ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified array element with bounds checking <nl> - <nl> - Returns a const reference to the element at specified location @ a idx , <nl> - with bounds checking . <nl> - <nl> - @ param [ in ] idx index of the element to access <nl> - <nl> - @ return const reference to the element at index @ a idx <nl> - <nl> - @ throw type_error . 304 if the JSON value is not an array ; in this case , <nl> - calling ` at ` with an index makes no sense . See example below . <nl> - @ throw out_of_range . 401 if the index @ a idx is out of range of the array ; <nl> - that is , ` idx > = size ( ) ` . See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ liveexample { The example below shows how array elements can be read using <nl> - ` at ( ) ` . It also demonstrates the different exceptions that can be thrown . , <nl> - at__size_type_const } <nl> - * / <nl> - const_reference at ( size_type idx ) const <nl> - { <nl> - / / at only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - JSON_TRY <nl> - { <nl> - return m_value . array - > at ( idx ) ; <nl> - } <nl> - JSON_CATCH ( std : : out_of_range & ) <nl> - { <nl> - / / create better exception explanation <nl> - JSON_THROW ( out_of_range : : create ( 401 , " array index " + std : : to_string ( idx ) + " is out of range " ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 304 , " cannot use at ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element with bounds checking <nl> - <nl> - Returns a reference to the element at with specified key @ a key , with <nl> - bounds checking . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return reference to the element at key @ a key <nl> - <nl> - @ throw type_error . 304 if the JSON value is not an object ; in this case , <nl> - calling ` at ` with a key makes no sense . See example below . <nl> - @ throw out_of_range . 403 if the key @ a key is is not stored in the object ; <nl> - that is , ` find ( key ) = = end ( ) ` . See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ sa @ ref operator [ ] ( const typename object_t : : key_type & ) for unchecked <nl> - access by reference <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ liveexample { The example below shows how object elements can be read and <nl> - written using ` at ( ) ` . It also demonstrates the different exceptions that <nl> - can be thrown . , at__object_t_key_type } <nl> - * / <nl> - reference at ( const typename object_t : : key_type & key ) <nl> - { <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - JSON_TRY <nl> - { <nl> - return m_value . object - > at ( key ) ; <nl> - } <nl> - JSON_CATCH ( std : : out_of_range & ) <nl> - { <nl> - / / create better exception explanation <nl> - JSON_THROW ( out_of_range : : create ( 403 , " key ' " + key + " ' not found " ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 304 , " cannot use at ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element with bounds checking <nl> - <nl> - Returns a const reference to the element at with specified key @ a key , <nl> - with bounds checking . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return const reference to the element at key @ a key <nl> - <nl> - @ throw type_error . 304 if the JSON value is not an object ; in this case , <nl> - calling ` at ` with a key makes no sense . See example below . <nl> - @ throw out_of_range . 403 if the key @ a key is is not stored in the object ; <nl> - that is , ` find ( key ) = = end ( ) ` . See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ sa @ ref operator [ ] ( const typename object_t : : key_type & ) for unchecked <nl> - access by reference <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - <nl> - @ liveexample { The example below shows how object elements can be read using <nl> - ` at ( ) ` . It also demonstrates the different exceptions that can be thrown . , <nl> - at__object_t_key_type_const } <nl> - * / <nl> - const_reference at ( const typename object_t : : key_type & key ) const <nl> - { <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - JSON_TRY <nl> - { <nl> - return m_value . object - > at ( key ) ; <nl> - } <nl> - JSON_CATCH ( std : : out_of_range & ) <nl> - { <nl> - / / create better exception explanation <nl> - JSON_THROW ( out_of_range : : create ( 403 , " key ' " + key + " ' not found " ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 304 , " cannot use at ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified array element <nl> - <nl> - Returns a reference to the element at specified location @ a idx . <nl> - <nl> - @ note If @ a idx is beyond the range of the array ( i . e . , ` idx > = size ( ) ` ) , <nl> - then the array is silently filled up with ` null ` values to make ` idx ` a <nl> - valid reference to the last stored element . <nl> - <nl> - @ param [ in ] idx index of the element to access <nl> - <nl> - @ return reference to the element at index @ a idx <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an array or null ; in that <nl> - cases , using the [ ] operator with an index makes no sense . <nl> - <nl> - @ complexity Constant if @ a idx is in the range of the array . Otherwise <nl> - linear in ` idx - size ( ) ` . <nl> - <nl> - @ liveexample { The example below shows how array elements can be read and <nl> - written using ` [ ] ` operator . Note the addition of ` null ` <nl> - values . , operatorarray__size_type } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reference operator [ ] ( size_type idx ) <nl> - { <nl> - / / implicitly convert null value to an empty array <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : array ; <nl> - m_value . array = create < array_t > ( ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / operator [ ] only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - / / fill up array with null values if given idx is outside range <nl> - if ( idx > = m_value . array - > size ( ) ) <nl> - { <nl> - m_value . array - > insert ( m_value . array - > end ( ) , <nl> - idx - m_value . array - > size ( ) + 1 , <nl> - basic_json ( ) ) ; <nl> - } <nl> - <nl> - return m_value . array - > operator [ ] ( idx ) ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified array element <nl> - <nl> - Returns a const reference to the element at specified location @ a idx . <nl> - <nl> - @ param [ in ] idx index of the element to access <nl> - <nl> - @ return const reference to the element at index @ a idx <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an array ; in that case , <nl> - using the [ ] operator with an index makes no sense . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how array elements can be read using <nl> - the ` [ ] ` operator . , operatorarray__size_type_const } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_reference operator [ ] ( size_type idx ) const <nl> - { <nl> - / / const operator [ ] only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - return m_value . array - > operator [ ] ( idx ) ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element <nl> - <nl> - Returns a reference to the element at with specified key @ a key . <nl> - <nl> - @ note If @ a key is not found in the object , then it is silently added to <nl> - the object and filled with a ` null ` value to make ` key ` a valid reference . <nl> - In case the value was ` null ` before , it is converted to an object . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return reference to the element at key @ a key <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an object or null ; in that <nl> - cases , using the [ ] operator with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be read and <nl> - written using the ` [ ] ` operator . , operatorarray__key_type } <nl> - <nl> - @ sa @ ref at ( const typename object_t : : key_type & ) for access by reference <nl> - with range checking <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reference operator [ ] ( const typename object_t : : key_type & key ) <nl> - { <nl> - / / implicitly convert null value to an empty object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value . object = create < object_t > ( ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / operator [ ] only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - return m_value . object - > operator [ ] ( key ) ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief read - only access specified object element <nl> - <nl> - Returns a const reference to the element at with specified key @ a key . No <nl> - bounds checking is performed . <nl> - <nl> - @ warning If the element with key @ a key does not exist , the behavior is <nl> - undefined . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return const reference to the element at key @ a key <nl> - <nl> - @ pre The element with key @ a key must exist . * * This precondition is <nl> - enforced with an assertion . * * <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an object ; in that case , <nl> - using the [ ] operator with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be read using <nl> - the ` [ ] ` operator . , operatorarray__key_type_const } <nl> - <nl> - @ sa @ ref at ( const typename object_t : : key_type & ) for access by reference <nl> - with range checking <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_reference operator [ ] ( const typename object_t : : key_type & key ) const <nl> - { <nl> - / / const operator [ ] only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - assert ( m_value . object - > find ( key ) ! = m_value . object - > end ( ) ) ; <nl> - return m_value . object - > find ( key ) - > second ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element <nl> - <nl> - Returns a reference to the element at with specified key @ a key . <nl> - <nl> - @ note If @ a key is not found in the object , then it is silently added to <nl> - the object and filled with a ` null ` value to make ` key ` a valid reference . <nl> - In case the value was ` null ` before , it is converted to an object . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return reference to the element at key @ a key <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an object or null ; in that <nl> - cases , using the [ ] operator with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be read and <nl> - written using the ` [ ] ` operator . , operatorarray__key_type } <nl> - <nl> - @ sa @ ref at ( const typename object_t : : key_type & ) for access by reference <nl> - with range checking <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 1 . 0 <nl> - * / <nl> - template < typename T > <nl> - reference operator [ ] ( T * key ) <nl> - { <nl> - / / implicitly convert null to object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value = value_t : : object ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - return m_value . object - > operator [ ] ( key ) ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief read - only access specified object element <nl> - <nl> - Returns a const reference to the element at with specified key @ a key . No <nl> - bounds checking is performed . <nl> - <nl> - @ warning If the element with key @ a key does not exist , the behavior is <nl> - undefined . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - <nl> - @ return const reference to the element at key @ a key <nl> - <nl> - @ pre The element with key @ a key must exist . * * This precondition is <nl> - enforced with an assertion . * * <nl> - <nl> - @ throw type_error . 305 if the JSON value is not an object ; in that case , <nl> - using the [ ] operator with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be read using <nl> - the ` [ ] ` operator . , operatorarray__key_type_const } <nl> - <nl> - @ sa @ ref at ( const typename object_t : : key_type & ) for access by reference <nl> - with range checking <nl> - @ sa @ ref value ( ) for access by value with a default value <nl> - <nl> - @ since version 1 . 1 . 0 <nl> - * / <nl> - template < typename T > <nl> - const_reference operator [ ] ( T * key ) const <nl> - { <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - assert ( m_value . object - > find ( key ) ! = m_value . object - > end ( ) ) ; <nl> - return m_value . object - > find ( key ) - > second ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 305 , " cannot use operator [ ] with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element with default value <nl> - <nl> - Returns either a copy of an object ' s element at the specified key @ a key <nl> - or a given default value if no element with key @ a key exists . <nl> - <nl> - The function is basically equivalent to executing <nl> - @ code { . cpp } <nl> - try { <nl> - return at ( key ) ; <nl> - } catch ( out_of_range ) { <nl> - return default_value ; <nl> - } <nl> - @ endcode <nl> - <nl> - @ note Unlike @ ref at ( const typename object_t : : key_type & ) , this function <nl> - does not throw if the given key @ a key was not found . <nl> - <nl> - @ note Unlike @ ref operator [ ] ( const typename object_t : : key_type & key ) , this <nl> - function does not implicitly add an element to the position defined by @ a <nl> - key . This function is furthermore also applicable to const objects . <nl> - <nl> - @ param [ in ] key key of the element to access <nl> - @ param [ in ] default_value the value to return if @ a key is not found <nl> - <nl> - @ tparam ValueType type compatible to JSON values , for instance ` int ` for <nl> - JSON integer numbers , ` bool ` for JSON booleans , or ` std : : vector ` types for <nl> - JSON arrays . Note the type of the expected value at @ a key and the default <nl> - value @ a default_value must be compatible . <nl> - <nl> - @ return copy of the element at key @ a key or @ a default_value if @ a key <nl> - is not found <nl> - <nl> - @ throw type_error . 306 if the JSON value is not an object ; in that case , <nl> - using ` value ( ) ` with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be queried <nl> - with a default value . , basic_json__value } <nl> - <nl> - @ sa @ ref at ( const typename object_t : : key_type & ) for access by reference <nl> - with range checking <nl> - @ sa @ ref operator [ ] ( const typename object_t : : key_type & ) for unchecked <nl> - access by reference <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < class ValueType , typename std : : enable_if < <nl> - std : : is_convertible < basic_json_t , ValueType > : : value , int > : : type = 0 > <nl> - ValueType value ( const typename object_t : : key_type & key , const ValueType & default_value ) const <nl> - { <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - / / if key is found , return value and given default value otherwise <nl> - const auto it = find ( key ) ; <nl> - if ( it ! = end ( ) ) <nl> - { <nl> - return * it ; <nl> - } <nl> - <nl> - return default_value ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 306 , " cannot use value ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief overload for a default value of type const char * <nl> - @ copydoc basic_json : : value ( const typename object_t : : key_type & , ValueType ) const <nl> - * / <nl> - string_t value ( const typename object_t : : key_type & key , const char * default_value ) const <nl> - { <nl> - return value ( key , string_t ( default_value ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified object element via JSON Pointer with default value <nl> - <nl> - Returns either a copy of an object ' s element at the specified key @ a key <nl> - or a given default value if no element with key @ a key exists . <nl> - <nl> - The function is basically equivalent to executing <nl> - @ code { . cpp } <nl> - try { <nl> - return at ( ptr ) ; <nl> - } catch ( out_of_range ) { <nl> - return default_value ; <nl> - } <nl> - @ endcode <nl> - <nl> - @ note Unlike @ ref at ( const json_pointer & ) , this function does not throw <nl> - if the given key @ a key was not found . <nl> - <nl> - @ param [ in ] ptr a JSON pointer to the element to access <nl> - @ param [ in ] default_value the value to return if @ a ptr found no value <nl> - <nl> - @ tparam ValueType type compatible to JSON values , for instance ` int ` for <nl> - JSON integer numbers , ` bool ` for JSON booleans , or ` std : : vector ` types for <nl> - JSON arrays . Note the type of the expected value at @ a key and the default <nl> - value @ a default_value must be compatible . <nl> - <nl> - @ return copy of the element at key @ a key or @ a default_value if @ a key <nl> - is not found <nl> - <nl> - @ throw type_error . 306 if the JSON value is not an object ; in that case , <nl> - using ` value ( ) ` with a key makes no sense . <nl> - <nl> - @ complexity Logarithmic in the size of the container . <nl> - <nl> - @ liveexample { The example below shows how object elements can be queried <nl> - with a default value . , basic_json__value_ptr } <nl> - <nl> - @ sa @ ref operator [ ] ( const json_pointer & ) for unchecked access by reference <nl> - <nl> - @ since version 2 . 0 . 2 <nl> - * / <nl> - template < class ValueType , typename std : : enable_if < <nl> - std : : is_convertible < basic_json_t , ValueType > : : value , int > : : type = 0 > <nl> - ValueType value ( const json_pointer & ptr , const ValueType & default_value ) const <nl> - { <nl> - / / at only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - / / if pointer resolves a value , return it or use default value <nl> - JSON_TRY <nl> - { <nl> - return ptr . get_checked ( this ) ; <nl> - } <nl> - JSON_INTERNAL_CATCH ( out_of_range & ) <nl> - { <nl> - return default_value ; <nl> - } <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 306 , " cannot use value ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief overload for a default value of type const char * <nl> - @ copydoc basic_json : : value ( const json_pointer & , ValueType ) const <nl> - * / <nl> - string_t value ( const json_pointer & ptr , const char * default_value ) const <nl> - { <nl> - return value ( ptr , string_t ( default_value ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access the first element <nl> - <nl> - Returns a reference to the first element in the container . For a JSON <nl> - container ` c ` , the expression ` c . front ( ) ` is equivalent to ` * c . begin ( ) ` . <nl> - <nl> - @ return In case of a structured type ( array or object ) , a reference to the <nl> - first element is returned . In case of number , string , or boolean values , a <nl> - reference to the value is returned . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ pre The JSON value must not be ` null ` ( would throw ` std : : out_of_range ` ) <nl> - or an empty array or object ( undefined behavior , * * guarded by <nl> - assertions * * ) . <nl> - @ post The JSON value remains unchanged . <nl> - <nl> - @ throw invalid_iterator . 214 when called on ` null ` value <nl> - <nl> - @ liveexample { The following code shows an example for ` front ( ) ` . , front } <nl> - <nl> - @ sa @ ref back ( ) - - access the last element <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reference front ( ) <nl> - { <nl> - return * begin ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : front ( ) <nl> - * / <nl> - const_reference front ( ) const <nl> - { <nl> - return * cbegin ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access the last element <nl> - <nl> - Returns a reference to the last element in the container . For a JSON <nl> - container ` c ` , the expression ` c . back ( ) ` is equivalent to <nl> - @ code { . cpp } <nl> - auto tmp = c . end ( ) ; <nl> - - - tmp ; <nl> - return * tmp ; <nl> - @ endcode <nl> - <nl> - @ return In case of a structured type ( array or object ) , a reference to the <nl> - last element is returned . In case of number , string , or boolean values , a <nl> - reference to the value is returned . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ pre The JSON value must not be ` null ` ( would throw ` std : : out_of_range ` ) <nl> - or an empty array or object ( undefined behavior , * * guarded by <nl> - assertions * * ) . <nl> - @ post The JSON value remains unchanged . <nl> - <nl> - @ throw invalid_iterator . 214 when called on a ` null ` value . See example <nl> - below . <nl> - <nl> - @ liveexample { The following code shows an example for ` back ( ) ` . , back } <nl> - <nl> - @ sa @ ref front ( ) - - access the first element <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reference back ( ) <nl> - { <nl> - auto tmp = end ( ) ; <nl> - - - tmp ; <nl> - return * tmp ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : back ( ) <nl> - * / <nl> - const_reference back ( ) const <nl> - { <nl> - auto tmp = cend ( ) ; <nl> - - - tmp ; <nl> - return * tmp ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief remove element given an iterator <nl> - <nl> - Removes the element specified by iterator @ a pos . The iterator @ a pos must <nl> - be valid and dereferenceable . Thus the ` end ( ) ` iterator ( which is valid , <nl> - but is not dereferenceable ) cannot be used as a value for @ a pos . <nl> - <nl> - If called on a primitive type other than ` null ` , the resulting JSON value <nl> - will be ` null ` . <nl> - <nl> - @ param [ in ] pos iterator to the element to remove <nl> - @ return Iterator following the last removed element . If the iterator @ a <nl> - pos refers to the last element , the ` end ( ) ` iterator is returned . <nl> - <nl> - @ tparam IteratorType an @ ref iterator or @ ref const_iterator <nl> - <nl> - @ post Invalidates iterators and references at or after the point of the <nl> - erase , including the ` end ( ) ` iterator . <nl> - <nl> - @ throw type_error . 307 if called on a ` null ` value ; example : ` " cannot use <nl> - erase ( ) with null " ` <nl> - @ throw invalid_iterator . 202 if called on an iterator which does not belong <nl> - to the current JSON value ; example : ` " iterator does not fit current <nl> - value " ` <nl> - @ throw invalid_iterator . 205 if called on a primitive type with invalid <nl> - iterator ( i . e . , any iterator which is not ` begin ( ) ` ) ; example : ` " iterator <nl> - out of range " ` <nl> - <nl> - @ complexity The complexity depends on the type : <nl> - - objects : amortized constant <nl> - - arrays : linear in distance between @ a pos and the end of the container <nl> - - strings : linear in the length of the string <nl> - - other types : constant <nl> - <nl> - @ liveexample { The example shows the result of ` erase ( ) ` for different JSON <nl> - types . , erase__IteratorType } <nl> - <nl> - @ sa @ ref erase ( IteratorType , IteratorType ) - - removes the elements in <nl> - the given range <nl> - @ sa @ ref erase ( const typename object_t : : key_type & ) - - removes the element <nl> - from an object at the given key <nl> - @ sa @ ref erase ( const size_type ) - - removes the element from an array at <nl> - the given index <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < class IteratorType , typename std : : enable_if < <nl> - std : : is_same < IteratorType , typename basic_json_t : : iterator > : : value or <nl> - std : : is_same < IteratorType , typename basic_json_t : : const_iterator > : : value , int > : : type <nl> - = 0 > <nl> - IteratorType erase ( IteratorType pos ) <nl> - { <nl> - / / make sure iterator fits the current value <nl> - if ( JSON_UNLIKELY ( this ! = pos . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterator does not fit current value " ) ) ; <nl> - } <nl> - <nl> - IteratorType result = end ( ) ; <nl> - <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : boolean : <nl> - case value_t : : number_float : <nl> - case value_t : : number_integer : <nl> - case value_t : : number_unsigned : <nl> - case value_t : : string : <nl> - { <nl> - if ( JSON_UNLIKELY ( not pos . m_it . primitive_iterator . is_begin ( ) ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 205 , " iterator out of range " ) ) ; <nl> - } <nl> - <nl> - if ( is_string ( ) ) <nl> - { <nl> - AllocatorType < string_t > alloc ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : destroy ( alloc , m_value . string ) ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : deallocate ( alloc , m_value . string , 1 ) ; <nl> - m_value . string = nullptr ; <nl> - } <nl> - <nl> - m_type = value_t : : null ; <nl> - assert_invariant ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - result . m_it . object_iterator = m_value . object - > erase ( pos . m_it . object_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - result . m_it . array_iterator = m_value . array - > erase ( pos . m_it . array_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( type_error : : create ( 307 , " cannot use erase ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief remove elements given an iterator range <nl> - <nl> - Removes the element specified by the range ` [ first ; last ) ` . The iterator <nl> - @ a first does not need to be dereferenceable if ` first = = last ` : erasing <nl> - an empty range is a no - op . <nl> - <nl> - If called on a primitive type other than ` null ` , the resulting JSON value <nl> - will be ` null ` . <nl> - <nl> - @ param [ in ] first iterator to the beginning of the range to remove <nl> - @ param [ in ] last iterator past the end of the range to remove <nl> - @ return Iterator following the last removed element . If the iterator @ a <nl> - second refers to the last element , the ` end ( ) ` iterator is returned . <nl> - <nl> - @ tparam IteratorType an @ ref iterator or @ ref const_iterator <nl> - <nl> - @ post Invalidates iterators and references at or after the point of the <nl> - erase , including the ` end ( ) ` iterator . <nl> - <nl> - @ throw type_error . 307 if called on a ` null ` value ; example : ` " cannot use <nl> - erase ( ) with null " ` <nl> - @ throw invalid_iterator . 203 if called on iterators which does not belong <nl> - to the current JSON value ; example : ` " iterators do not fit current value " ` <nl> - @ throw invalid_iterator . 204 if called on a primitive type with invalid <nl> - iterators ( i . e . , if ` first ! = begin ( ) ` and ` last ! = end ( ) ` ) ; example : <nl> - ` " iterators out of range " ` <nl> - <nl> - @ complexity The complexity depends on the type : <nl> - - objects : ` log ( size ( ) ) + std : : distance ( first , last ) ` <nl> - - arrays : linear in the distance between @ a first and @ a last , plus linear <nl> - in the distance between @ a last and end of the container <nl> - - strings : linear in the length of the string <nl> - - other types : constant <nl> - <nl> - @ liveexample { The example shows the result of ` erase ( ) ` for different JSON <nl> - types . , erase__IteratorType_IteratorType } <nl> - <nl> - @ sa @ ref erase ( IteratorType ) - - removes the element at a given position <nl> - @ sa @ ref erase ( const typename object_t : : key_type & ) - - removes the element <nl> - from an object at the given key <nl> - @ sa @ ref erase ( const size_type ) - - removes the element from an array at <nl> - the given index <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < class IteratorType , typename std : : enable_if < <nl> - std : : is_same < IteratorType , typename basic_json_t : : iterator > : : value or <nl> - std : : is_same < IteratorType , typename basic_json_t : : const_iterator > : : value , int > : : type <nl> - = 0 > <nl> - IteratorType erase ( IteratorType first , IteratorType last ) <nl> - { <nl> - / / make sure iterator fits the current value <nl> - if ( JSON_UNLIKELY ( this ! = first . m_object or this ! = last . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 203 , " iterators do not fit current value " ) ) ; <nl> - } <nl> - <nl> - IteratorType result = end ( ) ; <nl> - <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : boolean : <nl> - case value_t : : number_float : <nl> - case value_t : : number_integer : <nl> - case value_t : : number_unsigned : <nl> - case value_t : : string : <nl> - { <nl> - if ( JSON_LIKELY ( not first . m_it . primitive_iterator . is_begin ( ) <nl> - or not last . m_it . primitive_iterator . is_end ( ) ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 204 , " iterators out of range " ) ) ; <nl> - } <nl> - <nl> - if ( is_string ( ) ) <nl> - { <nl> - AllocatorType < string_t > alloc ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : destroy ( alloc , m_value . string ) ; <nl> - std : : allocator_traits < decltype ( alloc ) > : : deallocate ( alloc , m_value . string , 1 ) ; <nl> - m_value . string = nullptr ; <nl> - } <nl> - <nl> - m_type = value_t : : null ; <nl> - assert_invariant ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - result . m_it . object_iterator = m_value . object - > erase ( first . m_it . object_iterator , <nl> - last . m_it . object_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - result . m_it . array_iterator = m_value . array - > erase ( first . m_it . array_iterator , <nl> - last . m_it . array_iterator ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - JSON_THROW ( type_error : : create ( 307 , " cannot use erase ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief remove element from a JSON object given a key <nl> - <nl> - Removes elements from a JSON object with the key value @ a key . <nl> - <nl> - @ param [ in ] key value of the elements to remove <nl> - <nl> - @ return Number of elements removed . If @ a ObjectType is the default <nl> - ` std : : map ` type , the return value will always be ` 0 ` ( @ a key was not <nl> - found ) or ` 1 ` ( @ a key was found ) . <nl> - <nl> - @ post References and iterators to the erased elements are invalidated . <nl> - Other references and iterators are not affected . <nl> - <nl> - @ throw type_error . 307 when called on a type other than JSON object ; <nl> - example : ` " cannot use erase ( ) with null " ` <nl> - <nl> - @ complexity ` log ( size ( ) ) + count ( key ) ` <nl> - <nl> - @ liveexample { The example shows the effect of ` erase ( ) ` . , erase__key_type } <nl> - <nl> - @ sa @ ref erase ( IteratorType ) - - removes the element at a given position <nl> - @ sa @ ref erase ( IteratorType , IteratorType ) - - removes the elements in <nl> - the given range <nl> - @ sa @ ref erase ( const size_type ) - - removes the element from an array at <nl> - the given index <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - size_type erase ( const typename object_t : : key_type & key ) <nl> - { <nl> - / / this erase only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - return m_value . object - > erase ( key ) ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 307 , " cannot use erase ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief remove element from a JSON array given an index <nl> - <nl> - Removes element from a JSON array at the index @ a idx . <nl> - <nl> - @ param [ in ] idx index of the element to remove <nl> - <nl> - @ throw type_error . 307 when called on a type other than JSON object ; <nl> - example : ` " cannot use erase ( ) with null " ` <nl> - @ throw out_of_range . 401 when ` idx > = size ( ) ` ; example : ` " array index 17 <nl> - is out of range " ` <nl> - <nl> - @ complexity Linear in distance between @ a idx and the end of the container . <nl> - <nl> - @ liveexample { The example shows the effect of ` erase ( ) ` . , erase__size_type } <nl> - <nl> - @ sa @ ref erase ( IteratorType ) - - removes the element at a given position <nl> - @ sa @ ref erase ( IteratorType , IteratorType ) - - removes the elements in <nl> - the given range <nl> - @ sa @ ref erase ( const typename object_t : : key_type & ) - - removes the element <nl> - from an object at the given key <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void erase ( const size_type idx ) <nl> - { <nl> - / / this erase only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - if ( JSON_UNLIKELY ( idx > = size ( ) ) ) <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 401 , " array index " + std : : to_string ( idx ) + " is out of range " ) ) ; <nl> - } <nl> - <nl> - m_value . array - > erase ( m_value . array - > begin ( ) + static_cast < difference_type > ( idx ) ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 307 , " cannot use erase ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / <nl> - / / lookup / / <nl> - / / / / / / / / / / / / <nl> - <nl> - / / / @ name lookup <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief find an element in a JSON object <nl> - <nl> - Finds an element in a JSON object with key equivalent to @ a key . If the <nl> - element is not found or the JSON value is not an object , end ( ) is <nl> - returned . <nl> - <nl> - @ note This method always returns @ ref end ( ) when executed on a JSON type <nl> - that is not an object . <nl> - <nl> - @ param [ in ] key key value of the element to search for . <nl> - <nl> - @ return Iterator to an element with key equivalent to @ a key . If no such <nl> - element is found or the JSON value is not an object , past - the - end ( see <nl> - @ ref end ( ) ) iterator is returned . <nl> - <nl> - @ complexity Logarithmic in the size of the JSON object . <nl> - <nl> - @ liveexample { The example shows how ` find ( ) ` is used . , find__key_type } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename KeyT > <nl> - iterator find ( KeyT & & key ) <nl> - { <nl> - auto result = end ( ) ; <nl> - <nl> - if ( is_object ( ) ) <nl> - { <nl> - result . m_it . object_iterator = m_value . object - > find ( std : : forward < KeyT > ( key ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief find an element in a JSON object <nl> - @ copydoc find ( KeyT & & ) <nl> - * / <nl> - template < typename KeyT > <nl> - const_iterator find ( KeyT & & key ) const <nl> - { <nl> - auto result = cend ( ) ; <nl> - <nl> - if ( is_object ( ) ) <nl> - { <nl> - result . m_it . object_iterator = m_value . object - > find ( std : : forward < KeyT > ( key ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns the number of occurrences of a key in a JSON object <nl> - <nl> - Returns the number of elements with key @ a key . If ObjectType is the <nl> - default ` std : : map ` type , the return value will always be ` 0 ` ( @ a key was <nl> - not found ) or ` 1 ` ( @ a key was found ) . <nl> - <nl> - @ note This method always returns ` 0 ` when executed on a JSON type that is <nl> - not an object . <nl> - <nl> - @ param [ in ] key key value of the element to count <nl> - <nl> - @ return Number of elements with key @ a key . If the JSON value is not an <nl> - object , the return value will be ` 0 ` . <nl> - <nl> - @ complexity Logarithmic in the size of the JSON object . <nl> - <nl> - @ liveexample { The example shows how ` count ( ) ` is used . , count } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < typename KeyT > <nl> - size_type count ( KeyT & & key ) const <nl> - { <nl> - / / return 0 for all nonobject types <nl> - return is_object ( ) ? m_value . object - > count ( std : : forward < KeyT > ( key ) ) : 0 ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / <nl> - / / iterators / / <nl> - / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name iterators <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief returns an iterator to the first element <nl> - <nl> - Returns an iterator to the first element . <nl> - <nl> - @ image html range - begin - end . svg " Illustration from cppreference . com " <nl> - <nl> - @ return iterator to the first element <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - <nl> - @ liveexample { The following code shows an example for ` begin ( ) ` . , begin } <nl> - <nl> - @ sa @ ref cbegin ( ) - - returns a const iterator to the beginning <nl> - @ sa @ ref end ( ) - - returns an iterator to the end <nl> - @ sa @ ref cend ( ) - - returns a const iterator to the end <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator begin ( ) noexcept <nl> - { <nl> - iterator result ( this ) ; <nl> - result . set_begin ( ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : cbegin ( ) <nl> - * / <nl> - const_iterator begin ( ) const noexcept <nl> - { <nl> - return cbegin ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns a const iterator to the first element <nl> - <nl> - Returns a const iterator to the first element . <nl> - <nl> - @ image html range - begin - end . svg " Illustration from cppreference . com " <nl> - <nl> - @ return const iterator to the first element <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` const_cast < const basic_json & > ( * this ) . begin ( ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` cbegin ( ) ` . , cbegin } <nl> - <nl> - @ sa @ ref begin ( ) - - returns an iterator to the beginning <nl> - @ sa @ ref end ( ) - - returns an iterator to the end <nl> - @ sa @ ref cend ( ) - - returns a const iterator to the end <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_iterator cbegin ( ) const noexcept <nl> - { <nl> - const_iterator result ( this ) ; <nl> - result . set_begin ( ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns an iterator to one past the last element <nl> - <nl> - Returns an iterator to one past the last element . <nl> - <nl> - @ image html range - begin - end . svg " Illustration from cppreference . com " <nl> - <nl> - @ return iterator one past the last element <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - <nl> - @ liveexample { The following code shows an example for ` end ( ) ` . , end } <nl> - <nl> - @ sa @ ref cend ( ) - - returns a const iterator to the end <nl> - @ sa @ ref begin ( ) - - returns an iterator to the beginning <nl> - @ sa @ ref cbegin ( ) - - returns a const iterator to the beginning <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator end ( ) noexcept <nl> - { <nl> - iterator result ( this ) ; <nl> - result . set_end ( ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : cend ( ) <nl> - * / <nl> - const_iterator end ( ) const noexcept <nl> - { <nl> - return cend ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns a const iterator to one past the last element <nl> - <nl> - Returns a const iterator to one past the last element . <nl> - <nl> - @ image html range - begin - end . svg " Illustration from cppreference . com " <nl> - <nl> - @ return const iterator one past the last element <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` const_cast < const basic_json & > ( * this ) . end ( ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` cend ( ) ` . , cend } <nl> - <nl> - @ sa @ ref end ( ) - - returns an iterator to the end <nl> - @ sa @ ref begin ( ) - - returns an iterator to the beginning <nl> - @ sa @ ref cbegin ( ) - - returns a const iterator to the beginning <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_iterator cend ( ) const noexcept <nl> - { <nl> - const_iterator result ( this ) ; <nl> - result . set_end ( ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns an iterator to the reverse - beginning <nl> - <nl> - Returns an iterator to the reverse - beginning ; that is , the last element . <nl> - <nl> - @ image html range - rbegin - rend . svg " Illustration from cppreference . com " <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ ReversibleContainer ] ( https : / / en . cppreference . com / w / cpp / named_req / ReversibleContainer ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` reverse_iterator ( end ( ) ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` rbegin ( ) ` . , rbegin } <nl> - <nl> - @ sa @ ref crbegin ( ) - - returns a const reverse iterator to the beginning <nl> - @ sa @ ref rend ( ) - - returns a reverse iterator to the end <nl> - @ sa @ ref crend ( ) - - returns a const reverse iterator to the end <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reverse_iterator rbegin ( ) noexcept <nl> - { <nl> - return reverse_iterator ( end ( ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : crbegin ( ) <nl> - * / <nl> - const_reverse_iterator rbegin ( ) const noexcept <nl> - { <nl> - return crbegin ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns an iterator to the reverse - end <nl> - <nl> - Returns an iterator to the reverse - end ; that is , one before the first <nl> - element . <nl> - <nl> - @ image html range - rbegin - rend . svg " Illustration from cppreference . com " <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ ReversibleContainer ] ( https : / / en . cppreference . com / w / cpp / named_req / ReversibleContainer ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` reverse_iterator ( begin ( ) ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` rend ( ) ` . , rend } <nl> - <nl> - @ sa @ ref crend ( ) - - returns a const reverse iterator to the end <nl> - @ sa @ ref rbegin ( ) - - returns a reverse iterator to the beginning <nl> - @ sa @ ref crbegin ( ) - - returns a const reverse iterator to the beginning <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - reverse_iterator rend ( ) noexcept <nl> - { <nl> - return reverse_iterator ( begin ( ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc basic_json : : crend ( ) <nl> - * / <nl> - const_reverse_iterator rend ( ) const noexcept <nl> - { <nl> - return crend ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns a const reverse iterator to the last element <nl> - <nl> - Returns a const iterator to the reverse - beginning ; that is , the last <nl> - element . <nl> - <nl> - @ image html range - rbegin - rend . svg " Illustration from cppreference . com " <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ ReversibleContainer ] ( https : / / en . cppreference . com / w / cpp / named_req / ReversibleContainer ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` const_cast < const basic_json & > ( * this ) . rbegin ( ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` crbegin ( ) ` . , crbegin } <nl> - <nl> - @ sa @ ref rbegin ( ) - - returns a reverse iterator to the beginning <nl> - @ sa @ ref rend ( ) - - returns a reverse iterator to the end <nl> - @ sa @ ref crend ( ) - - returns a const reverse iterator to the end <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_reverse_iterator crbegin ( ) const noexcept <nl> - { <nl> - return const_reverse_iterator ( cend ( ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns a const reverse iterator to one before the first <nl> - <nl> - Returns a const reverse iterator to the reverse - end ; that is , one before <nl> - the first element . <nl> - <nl> - @ image html range - rbegin - rend . svg " Illustration from cppreference . com " <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ ReversibleContainer ] ( https : / / en . cppreference . com / w / cpp / named_req / ReversibleContainer ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` const_cast < const basic_json & > ( * this ) . rend ( ) ` . <nl> - <nl> - @ liveexample { The following code shows an example for ` crend ( ) ` . , crend } <nl> - <nl> - @ sa @ ref rend ( ) - - returns a reverse iterator to the end <nl> - @ sa @ ref rbegin ( ) - - returns a reverse iterator to the beginning <nl> - @ sa @ ref crbegin ( ) - - returns a const reverse iterator to the beginning <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - const_reverse_iterator crend ( ) const noexcept <nl> - { <nl> - return const_reverse_iterator ( cbegin ( ) ) ; <nl> - } <nl> - <nl> - public : <nl> - / * ! <nl> - @ brief wrapper to access iterator member functions in range - based for <nl> - <nl> - This function allows to access @ ref iterator : : key ( ) and @ ref <nl> - iterator : : value ( ) during range - based for loops . In these loops , a <nl> - reference to the JSON values is returned , so there is no access to the <nl> - underlying iterator . <nl> - <nl> - For loop without iterator_wrapper : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it = j_object . begin ( ) ; it ! = j_object . end ( ) ; + + it ) <nl> - { <nl> - std : : cout < < " key : " < < it . key ( ) < < " , value : " < < it . value ( ) < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - Range - based for loop without iterator proxy : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it : j_object ) <nl> - { <nl> - / / " it " is of type json : : reference and has no key ( ) member <nl> - std : : cout < < " value : " < < it < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - Range - based for loop with iterator proxy : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it : json : : iterator_wrapper ( j_object ) ) <nl> - { <nl> - std : : cout < < " key : " < < it . key ( ) < < " , value : " < < it . value ( ) < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - @ note When iterating over an array , ` key ( ) ` will return the index of the <nl> - element as string ( see example ) . <nl> - <nl> - @ param [ in ] ref reference to a JSON value <nl> - @ return iteration proxy object wrapping @ a ref with an interface to use in <nl> - range - based for loops <nl> - <nl> - @ liveexample { The following code shows how the wrapper is used , iterator_wrapper } <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ note The name of this function is not yet final and may change in the <nl> - future . <nl> - <nl> - @ deprecated This stream operator is deprecated and will be removed in <nl> - future 4 . 0 . 0 of the library . Please use @ ref items ( ) instead ; <nl> - that is , replace ` json : : iterator_wrapper ( j ) ` with ` j . items ( ) ` . <nl> - * / <nl> - JSON_DEPRECATED <nl> - static iteration_proxy < iterator > iterator_wrapper ( reference ref ) noexcept <nl> - { <nl> - return ref . items ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc iterator_wrapper ( reference ) <nl> - * / <nl> - JSON_DEPRECATED <nl> - static iteration_proxy < const_iterator > iterator_wrapper ( const_reference ref ) noexcept <nl> - { <nl> - return ref . items ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief helper to access iterator member functions in range - based for <nl> - <nl> - This function allows to access @ ref iterator : : key ( ) and @ ref <nl> - iterator : : value ( ) during range - based for loops . In these loops , a <nl> - reference to the JSON values is returned , so there is no access to the <nl> - underlying iterator . <nl> - <nl> - For loop without ` items ( ) ` function : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it = j_object . begin ( ) ; it ! = j_object . end ( ) ; + + it ) <nl> - { <nl> - std : : cout < < " key : " < < it . key ( ) < < " , value : " < < it . value ( ) < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - Range - based for loop without ` items ( ) ` function : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it : j_object ) <nl> - { <nl> - / / " it " is of type json : : reference and has no key ( ) member <nl> - std : : cout < < " value : " < < it < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - Range - based for loop with ` items ( ) ` function : <nl> - <nl> - @ code { cpp } <nl> - for ( auto it : j_object . items ( ) ) <nl> - { <nl> - std : : cout < < " key : " < < it . key ( ) < < " , value : " < < it . value ( ) < < ' \ n ' ; <nl> - } <nl> - @ endcode <nl> - <nl> - @ note When iterating over an array , ` key ( ) ` will return the index of the <nl> - element as string ( see example ) . For primitive types ( e . g . , numbers ) , <nl> - ` key ( ) ` returns an empty string . <nl> - <nl> - @ return iteration proxy object wrapping @ a ref with an interface to use in <nl> - range - based for loops <nl> - <nl> - @ liveexample { The following code shows how the function is used . , items } <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 3 . 1 . 0 . <nl> - * / <nl> - iteration_proxy < iterator > items ( ) noexcept <nl> - { <nl> - return iteration_proxy < iterator > ( * this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc items ( ) <nl> - * / <nl> - iteration_proxy < const_iterator > items ( ) const noexcept <nl> - { <nl> - return iteration_proxy < const_iterator > ( * this ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / <nl> - / / capacity / / <nl> - / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name capacity <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief checks whether the container is empty . <nl> - <nl> - Checks if a JSON value has no elements ( i . e . whether its @ ref size is ` 0 ` ) . <nl> - <nl> - @ return The return value depends on the different types and is <nl> - defined as follows : <nl> - Value type | return value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` true ` <nl> - boolean | ` false ` <nl> - string | ` false ` <nl> - number | ` false ` <nl> - object | result of function ` object_t : : empty ( ) ` <nl> - array | result of function ` array_t : : empty ( ) ` <nl> - <nl> - @ liveexample { The following code uses ` empty ( ) ` to check if a JSON <nl> - object contains any elements . , empty } <nl> - <nl> - @ complexity Constant , as long as @ ref array_t and @ ref object_t satisfy <nl> - the Container concept ; that is , their ` empty ( ) ` functions have constant <nl> - complexity . <nl> - <nl> - @ iterators No changes . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ note This function does not return whether a string stored as JSON value <nl> - is empty - it returns whether the JSON container itself is empty which is <nl> - false in the case of a string . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` begin ( ) = = end ( ) ` . <nl> - <nl> - @ sa @ ref size ( ) - - returns the number of elements <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - bool empty ( ) const noexcept <nl> - { <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : null : <nl> - { <nl> - / / null values are empty <nl> - return true ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - / / delegate call to array_t : : empty ( ) <nl> - return m_value . array - > empty ( ) ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / delegate call to object_t : : empty ( ) <nl> - return m_value . object - > empty ( ) ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / all other types are nonempty <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns the number of elements <nl> - <nl> - Returns the number of elements in a JSON value . <nl> - <nl> - @ return The return value depends on the different types and is <nl> - defined as follows : <nl> - Value type | return value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` 0 ` <nl> - boolean | ` 1 ` <nl> - string | ` 1 ` <nl> - number | ` 1 ` <nl> - object | result of function object_t : : size ( ) <nl> - array | result of function array_t : : size ( ) <nl> - <nl> - @ liveexample { The following code calls ` size ( ) ` on the different value <nl> - types . , size } <nl> - <nl> - @ complexity Constant , as long as @ ref array_t and @ ref object_t satisfy <nl> - the Container concept ; that is , their size ( ) functions have constant <nl> - complexity . <nl> - <nl> - @ iterators No changes . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ note This function does not return the length of a string stored as JSON <nl> - value - it returns the number of elements in the JSON value which is 1 in <nl> - the case of a string . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of ` std : : distance ( begin ( ) , end ( ) ) ` . <nl> - <nl> - @ sa @ ref empty ( ) - - checks whether the container is empty <nl> - @ sa @ ref max_size ( ) - - returns the maximal number of elements <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - size_type size ( ) const noexcept <nl> - { <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : null : <nl> - { <nl> - / / null values are empty <nl> - return 0 ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - / / delegate call to array_t : : size ( ) <nl> - return m_value . array - > size ( ) ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / delegate call to object_t : : size ( ) <nl> - return m_value . object - > size ( ) ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / all other types have size 1 <nl> - return 1 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief returns the maximum possible number of elements <nl> - <nl> - Returns the maximum number of elements a JSON value is able to hold due to <nl> - system or library implementation limitations , i . e . ` std : : distance ( begin ( ) , <nl> - end ( ) ) ` for the JSON value . <nl> - <nl> - @ return The return value depends on the different types and is <nl> - defined as follows : <nl> - Value type | return value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` 0 ` ( same as ` size ( ) ` ) <nl> - boolean | ` 1 ` ( same as ` size ( ) ` ) <nl> - string | ` 1 ` ( same as ` size ( ) ` ) <nl> - number | ` 1 ` ( same as ` size ( ) ` ) <nl> - object | result of function ` object_t : : max_size ( ) ` <nl> - array | result of function ` array_t : : max_size ( ) ` <nl> - <nl> - @ liveexample { The following code calls ` max_size ( ) ` on the different value <nl> - types . Note the output is implementation specific . , max_size } <nl> - <nl> - @ complexity Constant , as long as @ ref array_t and @ ref object_t satisfy <nl> - the Container concept ; that is , their ` max_size ( ) ` functions have constant <nl> - complexity . <nl> - <nl> - @ iterators No changes . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ requirement This function helps ` basic_json ` satisfying the <nl> - [ Container ] ( https : / / en . cppreference . com / w / cpp / named_req / Container ) <nl> - requirements : <nl> - - The complexity is constant . <nl> - - Has the semantics of returning ` b . size ( ) ` where ` b ` is the largest <nl> - possible JSON value . <nl> - <nl> - @ sa @ ref size ( ) - - returns the number of elements <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - size_type max_size ( ) const noexcept <nl> - { <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : array : <nl> - { <nl> - / / delegate call to array_t : : max_size ( ) <nl> - return m_value . array - > max_size ( ) ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / delegate call to object_t : : max_size ( ) <nl> - return m_value . object - > max_size ( ) ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / all other types have max_size ( ) = = size ( ) <nl> - return size ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / <nl> - / / modifiers / / <nl> - / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name modifiers <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief clears the contents <nl> - <nl> - Clears the content of a JSON value and resets it to the default value as <nl> - if @ ref basic_json ( value_t ) would have been called with the current value <nl> - type from @ ref type ( ) : <nl> - <nl> - Value type | initial value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` null ` <nl> - boolean | ` false ` <nl> - string | ` " " ` <nl> - number | ` 0 ` <nl> - object | ` { } ` <nl> - array | ` [ ] ` <nl> - <nl> - @ post Has the same effect as calling <nl> - @ code { . cpp } <nl> - * this = basic_json ( type ( ) ) ; <nl> - @ endcode <nl> - <nl> - @ liveexample { The example below shows the effect of ` clear ( ) ` to different <nl> - JSON types . , clear } <nl> - <nl> - @ complexity Linear in the size of the JSON value . <nl> - <nl> - @ iterators All iterators , pointers and references related to this container <nl> - are invalidated . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ sa @ ref basic_json ( value_t ) - - constructor that creates an object with the <nl> - same value than calling ` clear ( ) ` <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void clear ( ) noexcept <nl> - { <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : number_integer : <nl> - { <nl> - m_value . number_integer = 0 ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_unsigned : <nl> - { <nl> - m_value . number_unsigned = 0 ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : number_float : <nl> - { <nl> - m_value . number_float = 0 . 0 ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : boolean : <nl> - { <nl> - m_value . boolean = false ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : string : <nl> - { <nl> - m_value . string - > clear ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - m_value . array - > clear ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - m_value . object - > clear ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an array <nl> - <nl> - Appends the given element @ a val to the end of the JSON value . If the <nl> - function is called on a JSON null value , an empty array is created before <nl> - appending @ a val . <nl> - <nl> - @ param [ in ] val the value to add to the JSON array <nl> - <nl> - @ throw type_error . 308 when called on a type other than JSON array or <nl> - null ; example : ` " cannot use push_back ( ) with number " ` <nl> - <nl> - @ complexity Amortized constant . <nl> - <nl> - @ liveexample { The example shows how ` push_back ( ) ` and ` + = ` can be used to <nl> - add elements to a JSON array . Note how the ` null ` value was silently <nl> - converted to a JSON array . , push_back } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void push_back ( basic_json & & val ) <nl> - { <nl> - / / push_back only works for null objects or arrays <nl> - if ( JSON_UNLIKELY ( not ( is_null ( ) or is_array ( ) ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 308 , " cannot use push_back ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / transform null object into an array <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : array ; <nl> - m_value = value_t : : array ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / add element to array ( move semantics ) <nl> - m_value . array - > push_back ( std : : move ( val ) ) ; <nl> - / / invalidate object <nl> - val . m_type = value_t : : null ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an array <nl> - @ copydoc push_back ( basic_json & & ) <nl> - * / <nl> - reference operator + = ( basic_json & & val ) <nl> - { <nl> - push_back ( std : : move ( val ) ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an array <nl> - @ copydoc push_back ( basic_json & & ) <nl> - * / <nl> - void push_back ( const basic_json & val ) <nl> - { <nl> - / / push_back only works for null objects or arrays <nl> - if ( JSON_UNLIKELY ( not ( is_null ( ) or is_array ( ) ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 308 , " cannot use push_back ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / transform null object into an array <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : array ; <nl> - m_value = value_t : : array ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / add element to array <nl> - m_value . array - > push_back ( val ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an array <nl> - @ copydoc push_back ( basic_json & & ) <nl> - * / <nl> - reference operator + = ( const basic_json & val ) <nl> - { <nl> - push_back ( val ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an object <nl> - <nl> - Inserts the given element @ a val to the JSON object . If the function is <nl> - called on a JSON null value , an empty object is created before inserting <nl> - @ a val . <nl> - <nl> - @ param [ in ] val the value to add to the JSON object <nl> - <nl> - @ throw type_error . 308 when called on a type other than JSON object or <nl> - null ; example : ` " cannot use push_back ( ) with number " ` <nl> - <nl> - @ complexity Logarithmic in the size of the container , O ( log ( ` size ( ) ` ) ) . <nl> - <nl> - @ liveexample { The example shows how ` push_back ( ) ` and ` + = ` can be used to <nl> - add elements to a JSON object . Note how the ` null ` value was silently <nl> - converted to a JSON object . , push_back__object_t__value } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void push_back ( const typename object_t : : value_type & val ) <nl> - { <nl> - / / push_back only works for null objects or objects <nl> - if ( JSON_UNLIKELY ( not ( is_null ( ) or is_object ( ) ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 308 , " cannot use push_back ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / transform null object into an object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value = value_t : : object ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / add element to array <nl> - m_value . object - > insert ( val ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an object <nl> - @ copydoc push_back ( const typename object_t : : value_type & ) <nl> - * / <nl> - reference operator + = ( const typename object_t : : value_type & val ) <nl> - { <nl> - push_back ( val ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an object <nl> - <nl> - This function allows to use ` push_back ` with an initializer list . In case <nl> - <nl> - 1 . the current value is an object , <nl> - 2 . the initializer list @ a init contains only two elements , and <nl> - 3 . the first element of @ a init is a string , <nl> - <nl> - @ a init is converted into an object element and added using <nl> - @ ref push_back ( const typename object_t : : value_type & ) . Otherwise , @ a init <nl> - is converted to a JSON value and added using @ ref push_back ( basic_json & & ) . <nl> - <nl> - @ param [ in ] init an initializer list <nl> - <nl> - @ complexity Linear in the size of the initializer list @ a init . <nl> - <nl> - @ note This function is required to resolve an ambiguous overload error , <nl> - because pairs like ` { " key " , " value " } ` can be both interpreted as <nl> - ` object_t : : value_type ` or ` std : : initializer_list < basic_json > ` , see <nl> - https : / / github . com / nlohmann / json / issues / 235 for more information . <nl> - <nl> - @ liveexample { The example shows how initializer lists are treated as <nl> - objects when possible . , push_back__initializer_list } <nl> - * / <nl> - void push_back ( initializer_list_t init ) <nl> - { <nl> - if ( is_object ( ) and init . size ( ) = = 2 and ( * init . begin ( ) ) - > is_string ( ) ) <nl> - { <nl> - basic_json & & key = init . begin ( ) - > moved_or_copied ( ) ; <nl> - push_back ( typename object_t : : value_type ( <nl> - std : : move ( key . get_ref < string_t & > ( ) ) , ( init . begin ( ) + 1 ) - > moved_or_copied ( ) ) ) ; <nl> - } <nl> - else <nl> - { <nl> - push_back ( basic_json ( init ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an object <nl> - @ copydoc push_back ( initializer_list_t ) <nl> - * / <nl> - reference operator + = ( initializer_list_t init ) <nl> - { <nl> - push_back ( init ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an array <nl> - <nl> - Creates a JSON value from the passed parameters @ a args to the end of the <nl> - JSON value . If the function is called on a JSON null value , an empty array <nl> - is created before appending the value created from @ a args . <nl> - <nl> - @ param [ in ] args arguments to forward to a constructor of @ ref basic_json <nl> - @ tparam Args compatible types to create a @ ref basic_json object <nl> - <nl> - @ throw type_error . 311 when called on a type other than JSON array or <nl> - null ; example : ` " cannot use emplace_back ( ) with number " ` <nl> - <nl> - @ complexity Amortized constant . <nl> - <nl> - @ liveexample { The example shows how ` push_back ( ) ` can be used to add <nl> - elements to a JSON array . Note how the ` null ` value was silently converted <nl> - to a JSON array . , emplace_back } <nl> - <nl> - @ since version 2 . 0 . 8 <nl> - * / <nl> - template < class . . . Args > <nl> - void emplace_back ( Args & & . . . args ) <nl> - { <nl> - / / emplace_back only works for null objects or arrays <nl> - if ( JSON_UNLIKELY ( not ( is_null ( ) or is_array ( ) ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 311 , " cannot use emplace_back ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / transform null object into an array <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : array ; <nl> - m_value = value_t : : array ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / add element to array ( perfect forwarding ) <nl> - m_value . array - > emplace_back ( std : : forward < Args > ( args ) . . . ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief add an object to an object if key does not exist <nl> - <nl> - Inserts a new element into a JSON object constructed in - place with the <nl> - given @ a args if there is no element with the key in the container . If the <nl> - function is called on a JSON null value , an empty object is created before <nl> - appending the value created from @ a args . <nl> - <nl> - @ param [ in ] args arguments to forward to a constructor of @ ref basic_json <nl> - @ tparam Args compatible types to create a @ ref basic_json object <nl> - <nl> - @ return a pair consisting of an iterator to the inserted element , or the <nl> - already - existing element if no insertion happened , and a bool <nl> - denoting whether the insertion took place . <nl> - <nl> - @ throw type_error . 311 when called on a type other than JSON object or <nl> - null ; example : ` " cannot use emplace ( ) with number " ` <nl> - <nl> - @ complexity Logarithmic in the size of the container , O ( log ( ` size ( ) ` ) ) . <nl> - <nl> - @ liveexample { The example shows how ` emplace ( ) ` can be used to add elements <nl> - to a JSON object . Note how the ` null ` value was silently converted to a <nl> - JSON object . Further note how no value is added if there was already one <nl> - value stored with the same key . , emplace } <nl> - <nl> - @ since version 2 . 0 . 8 <nl> - * / <nl> - template < class . . . Args > <nl> - std : : pair < iterator , bool > emplace ( Args & & . . . args ) <nl> - { <nl> - / / emplace only works for null objects or arrays <nl> - if ( JSON_UNLIKELY ( not ( is_null ( ) or is_object ( ) ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 311 , " cannot use emplace ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / transform null object into an object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value = value_t : : object ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / / add element to array ( perfect forwarding ) <nl> - auto res = m_value . object - > emplace ( std : : forward < Args > ( args ) . . . ) ; <nl> - / / create result iterator and set iterator to the result of emplace <nl> - auto it = begin ( ) ; <nl> - it . m_it . object_iterator = res . first ; <nl> - <nl> - / / return pair of iterator and boolean <nl> - return { it , res . second } ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts element <nl> - <nl> - Inserts element @ a val before iterator @ a pos . <nl> - <nl> - @ param [ in ] pos iterator before which the content will be inserted ; may be <nl> - the end ( ) iterator <nl> - @ param [ in ] val element to insert <nl> - @ return iterator pointing to the inserted @ a val . <nl> - <nl> - @ throw type_error . 309 if called on JSON values other than arrays ; <nl> - example : ` " cannot use insert ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if @ a pos is not an iterator of * this ; <nl> - example : ` " iterator does not fit current value " ` <nl> - <nl> - @ complexity Constant plus linear in the distance between @ a pos and end of <nl> - the container . <nl> - <nl> - @ liveexample { The example shows how ` insert ( ) ` is used . , insert } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator insert ( const_iterator pos , const basic_json & val ) <nl> - { <nl> - / / insert only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - / / check if iterator pos fits to this JSON value <nl> - if ( JSON_UNLIKELY ( pos . m_object ! = this ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterator does not fit current value " ) ) ; <nl> - } <nl> - <nl> - / / insert to array and return iterator <nl> - iterator result ( this ) ; <nl> - result . m_it . array_iterator = m_value . array - > insert ( pos . m_it . array_iterator , val ) ; <nl> - return result ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 309 , " cannot use insert ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts element <nl> - @ copydoc insert ( const_iterator , const basic_json & ) <nl> - * / <nl> - iterator insert ( const_iterator pos , basic_json & & val ) <nl> - { <nl> - return insert ( pos , val ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts elements <nl> - <nl> - Inserts @ a cnt copies of @ a val before iterator @ a pos . <nl> - <nl> - @ param [ in ] pos iterator before which the content will be inserted ; may be <nl> - the end ( ) iterator <nl> - @ param [ in ] cnt number of copies of @ a val to insert <nl> - @ param [ in ] val element to insert <nl> - @ return iterator pointing to the first element inserted , or @ a pos if <nl> - ` cnt = = 0 ` <nl> - <nl> - @ throw type_error . 309 if called on JSON values other than arrays ; example : <nl> - ` " cannot use insert ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if @ a pos is not an iterator of * this ; <nl> - example : ` " iterator does not fit current value " ` <nl> - <nl> - @ complexity Linear in @ a cnt plus linear in the distance between @ a pos <nl> - and end of the container . <nl> - <nl> - @ liveexample { The example shows how ` insert ( ) ` is used . , insert__count } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator insert ( const_iterator pos , size_type cnt , const basic_json & val ) <nl> - { <nl> - / / insert only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - / / check if iterator pos fits to this JSON value <nl> - if ( JSON_UNLIKELY ( pos . m_object ! = this ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterator does not fit current value " ) ) ; <nl> - } <nl> - <nl> - / / insert to array and return iterator <nl> - iterator result ( this ) ; <nl> - result . m_it . array_iterator = m_value . array - > insert ( pos . m_it . array_iterator , cnt , val ) ; <nl> - return result ; <nl> - } <nl> - <nl> - JSON_THROW ( type_error : : create ( 309 , " cannot use insert ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts elements <nl> - <nl> - Inserts elements from range ` [ first , last ) ` before iterator @ a pos . <nl> - <nl> - @ param [ in ] pos iterator before which the content will be inserted ; may be <nl> - the end ( ) iterator <nl> - @ param [ in ] first begin of the range of elements to insert <nl> - @ param [ in ] last end of the range of elements to insert <nl> - <nl> - @ throw type_error . 309 if called on JSON values other than arrays ; example : <nl> - ` " cannot use insert ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if @ a pos is not an iterator of * this ; <nl> - example : ` " iterator does not fit current value " ` <nl> - @ throw invalid_iterator . 210 if @ a first and @ a last do not belong to the <nl> - same JSON value ; example : ` " iterators do not fit " ` <nl> - @ throw invalid_iterator . 211 if @ a first or @ a last are iterators into <nl> - container for which insert is called ; example : ` " passed iterators may not <nl> - belong to container " ` <nl> - <nl> - @ return iterator pointing to the first element inserted , or @ a pos if <nl> - ` first = = last ` <nl> - <nl> - @ complexity Linear in ` std : : distance ( first , last ) ` plus linear in the <nl> - distance between @ a pos and end of the container . <nl> - <nl> - @ liveexample { The example shows how ` insert ( ) ` is used . , insert__range } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator insert ( const_iterator pos , const_iterator first , const_iterator last ) <nl> - { <nl> - / / insert only works for arrays <nl> - if ( JSON_UNLIKELY ( not is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 309 , " cannot use insert ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / check if iterator pos fits to this JSON value <nl> - if ( JSON_UNLIKELY ( pos . m_object ! = this ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterator does not fit current value " ) ) ; <nl> - } <nl> - <nl> - / / check if range iterators belong to the same JSON object <nl> - if ( JSON_UNLIKELY ( first . m_object ! = last . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 210 , " iterators do not fit " ) ) ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( first . m_object = = this ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 211 , " passed iterators may not belong to container " ) ) ; <nl> - } <nl> - <nl> - / / insert to array and return iterator <nl> - iterator result ( this ) ; <nl> - result . m_it . array_iterator = m_value . array - > insert ( <nl> - pos . m_it . array_iterator , <nl> - first . m_it . array_iterator , <nl> - last . m_it . array_iterator ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts elements <nl> - <nl> - Inserts elements from initializer list @ a ilist before iterator @ a pos . <nl> - <nl> - @ param [ in ] pos iterator before which the content will be inserted ; may be <nl> - the end ( ) iterator <nl> - @ param [ in ] ilist initializer list to insert the values from <nl> - <nl> - @ throw type_error . 309 if called on JSON values other than arrays ; example : <nl> - ` " cannot use insert ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if @ a pos is not an iterator of * this ; <nl> - example : ` " iterator does not fit current value " ` <nl> - <nl> - @ return iterator pointing to the first element inserted , or @ a pos if <nl> - ` ilist ` is empty <nl> - <nl> - @ complexity Linear in ` ilist . size ( ) ` plus linear in the distance between <nl> - @ a pos and end of the container . <nl> - <nl> - @ liveexample { The example shows how ` insert ( ) ` is used . , insert__ilist } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - iterator insert ( const_iterator pos , initializer_list_t ilist ) <nl> - { <nl> - / / insert only works for arrays <nl> - if ( JSON_UNLIKELY ( not is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 309 , " cannot use insert ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / check if iterator pos fits to this JSON value <nl> - if ( JSON_UNLIKELY ( pos . m_object ! = this ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterator does not fit current value " ) ) ; <nl> - } <nl> - <nl> - / / insert to array and return iterator <nl> - iterator result ( this ) ; <nl> - result . m_it . array_iterator = m_value . array - > insert ( pos . m_it . array_iterator , ilist . begin ( ) , ilist . end ( ) ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief inserts elements <nl> - <nl> - Inserts elements from range ` [ first , last ) ` . <nl> - <nl> - @ param [ in ] first begin of the range of elements to insert <nl> - @ param [ in ] last end of the range of elements to insert <nl> - <nl> - @ throw type_error . 309 if called on JSON values other than objects ; example : <nl> - ` " cannot use insert ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if iterator @ a first or @ a last does does not <nl> - point to an object ; example : ` " iterators first and last must point to <nl> - objects " ` <nl> - @ throw invalid_iterator . 210 if @ a first and @ a last do not belong to the <nl> - same JSON value ; example : ` " iterators do not fit " ` <nl> - <nl> - @ complexity Logarithmic : ` O ( N * log ( size ( ) + N ) ) ` , where ` N ` is the number <nl> - of elements to insert . <nl> - <nl> - @ liveexample { The example shows how ` insert ( ) ` is used . , insert__range_object } <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - void insert ( const_iterator first , const_iterator last ) <nl> - { <nl> - / / insert only works for objects <nl> - if ( JSON_UNLIKELY ( not is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 309 , " cannot use insert ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / check if range iterators belong to the same JSON object <nl> - if ( JSON_UNLIKELY ( first . m_object ! = last . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 210 , " iterators do not fit " ) ) ; <nl> - } <nl> - <nl> - / / passed iterators must belong to objects <nl> - if ( JSON_UNLIKELY ( not first . m_object - > is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterators first and last must point to objects " ) ) ; <nl> - } <nl> - <nl> - m_value . object - > insert ( first . m_it . object_iterator , last . m_it . object_iterator ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief updates a JSON object from another object , overwriting existing keys <nl> - <nl> - Inserts all values from JSON object @ a j and overwrites existing keys . <nl> - <nl> - @ param [ in ] j JSON object to read values from <nl> - <nl> - @ throw type_error . 312 if called on JSON values other than objects ; example : <nl> - ` " cannot use update ( ) with string " ` <nl> - <nl> - @ complexity O ( N * log ( size ( ) + N ) ) , where N is the number of elements to <nl> - insert . <nl> - <nl> - @ liveexample { The example shows how ` update ( ) ` is used . , update } <nl> - <nl> - @ sa https : / / docs . python . org / 3 . 6 / library / stdtypes . html # dict . update <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - void update ( const_reference j ) <nl> - { <nl> - / / implicitly convert null value to an empty object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value . object = create < object_t > ( ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 312 , " cannot use update ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - if ( JSON_UNLIKELY ( not j . is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 312 , " cannot use update ( ) with " + std : : string ( j . type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - for ( auto it = j . cbegin ( ) ; it ! = j . cend ( ) ; + + it ) <nl> - { <nl> - m_value . object - > operator [ ] ( it . key ( ) ) = it . value ( ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief updates a JSON object from another object , overwriting existing keys <nl> - <nl> - Inserts all values from from range ` [ first , last ) ` and overwrites existing <nl> - keys . <nl> - <nl> - @ param [ in ] first begin of the range of elements to insert <nl> - @ param [ in ] last end of the range of elements to insert <nl> - <nl> - @ throw type_error . 312 if called on JSON values other than objects ; example : <nl> - ` " cannot use update ( ) with string " ` <nl> - @ throw invalid_iterator . 202 if iterator @ a first or @ a last does does not <nl> - point to an object ; example : ` " iterators first and last must point to <nl> - objects " ` <nl> - @ throw invalid_iterator . 210 if @ a first and @ a last do not belong to the <nl> - same JSON value ; example : ` " iterators do not fit " ` <nl> - <nl> - @ complexity O ( N * log ( size ( ) + N ) ) , where N is the number of elements to <nl> - insert . <nl> - <nl> - @ liveexample { The example shows how ` update ( ) ` is used__range . , update } <nl> - <nl> - @ sa https : / / docs . python . org / 3 . 6 / library / stdtypes . html # dict . update <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - void update ( const_iterator first , const_iterator last ) <nl> - { <nl> - / / implicitly convert null value to an empty object <nl> - if ( is_null ( ) ) <nl> - { <nl> - m_type = value_t : : object ; <nl> - m_value . object = create < object_t > ( ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - if ( JSON_UNLIKELY ( not is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( type_error : : create ( 312 , " cannot use update ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - <nl> - / / check if range iterators belong to the same JSON object <nl> - if ( JSON_UNLIKELY ( first . m_object ! = last . m_object ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 210 , " iterators do not fit " ) ) ; <nl> - } <nl> - <nl> - / / passed iterators must belong to objects <nl> - if ( JSON_UNLIKELY ( not first . m_object - > is_object ( ) <nl> - or not last . m_object - > is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( invalid_iterator : : create ( 202 , " iterators first and last must point to objects " ) ) ; <nl> - } <nl> - <nl> - for ( auto it = first ; it ! = last ; + + it ) <nl> - { <nl> - m_value . object - > operator [ ] ( it . key ( ) ) = it . value ( ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief exchanges the values <nl> - <nl> - Exchanges the contents of the JSON value with those of @ a other . Does not <nl> - invoke any move , copy , or swap operations on individual elements . All <nl> - iterators and references remain valid . The past - the - end iterator is <nl> - invalidated . <nl> - <nl> - @ param [ in , out ] other JSON value to exchange the contents with <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how JSON values can be swapped with <nl> - ` swap ( ) ` . , swap__reference } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void swap ( reference other ) noexcept ( <nl> - std : : is_nothrow_move_constructible < value_t > : : value and <nl> - std : : is_nothrow_move_assignable < value_t > : : value and <nl> - std : : is_nothrow_move_constructible < json_value > : : value and <nl> - std : : is_nothrow_move_assignable < json_value > : : value <nl> - ) <nl> - { <nl> - std : : swap ( m_type , other . m_type ) ; <nl> - std : : swap ( m_value , other . m_value ) ; <nl> - assert_invariant ( ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief exchanges the values <nl> - <nl> - Exchanges the contents of a JSON array with those of @ a other . Does not <nl> - invoke any move , copy , or swap operations on individual elements . All <nl> - iterators and references remain valid . The past - the - end iterator is <nl> - invalidated . <nl> - <nl> - @ param [ in , out ] other array to exchange the contents with <nl> - <nl> - @ throw type_error . 310 when JSON value is not an array ; example : ` " cannot <nl> - use swap ( ) with string " ` <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how arrays can be swapped with <nl> - ` swap ( ) ` . , swap__array_t } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void swap ( array_t & other ) <nl> - { <nl> - / / swap only works for arrays <nl> - if ( JSON_LIKELY ( is_array ( ) ) ) <nl> - { <nl> - std : : swap ( * ( m_value . array ) , other ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 310 , " cannot use swap ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief exchanges the values <nl> - <nl> - Exchanges the contents of a JSON object with those of @ a other . Does not <nl> - invoke any move , copy , or swap operations on individual elements . All <nl> - iterators and references remain valid . The past - the - end iterator is <nl> - invalidated . <nl> - <nl> - @ param [ in , out ] other object to exchange the contents with <nl> - <nl> - @ throw type_error . 310 when JSON value is not an object ; example : <nl> - ` " cannot use swap ( ) with string " ` <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how objects can be swapped with <nl> - ` swap ( ) ` . , swap__object_t } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void swap ( object_t & other ) <nl> - { <nl> - / / swap only works for objects <nl> - if ( JSON_LIKELY ( is_object ( ) ) ) <nl> - { <nl> - std : : swap ( * ( m_value . object ) , other ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 310 , " cannot use swap ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief exchanges the values <nl> - <nl> - Exchanges the contents of a JSON string with those of @ a other . Does not <nl> - invoke any move , copy , or swap operations on individual elements . All <nl> - iterators and references remain valid . The past - the - end iterator is <nl> - invalidated . <nl> - <nl> - @ param [ in , out ] other string to exchange the contents with <nl> - <nl> - @ throw type_error . 310 when JSON value is not a string ; example : ` " cannot <nl> - use swap ( ) with boolean " ` <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The example below shows how strings can be swapped with <nl> - ` swap ( ) ` . , swap__string_t } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - void swap ( string_t & other ) <nl> - { <nl> - / / swap only works for strings <nl> - if ( JSON_LIKELY ( is_string ( ) ) ) <nl> - { <nl> - std : : swap ( * ( m_value . string ) , other ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( type_error : : create ( 310 , " cannot use swap ( ) with " + std : : string ( type_name ( ) ) ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / lexicographical comparison operators / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name lexicographical comparison operators <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief comparison : equal <nl> - <nl> - Compares two JSON values for equality according to the following rules : <nl> - - Two JSON values are equal if ( 1 ) they are from the same type and ( 2 ) <nl> - their stored values are the same according to their respective <nl> - ` operator = = ` . <nl> - - Integer and floating - point numbers are automatically converted before <nl> - comparison . Note than two NaN values are always treated as unequal . <nl> - - Two JSON null values are equal . <nl> - <nl> - @ note Floating - point inside JSON values numbers are compared with <nl> - ` json : : number_float_t : : operator = = ` which is ` double : : operator = = ` by <nl> - default . To compare floating - point while respecting an epsilon , an alternative <nl> - [ comparison function ] ( https : / / github . com / mariokonrad / marnav / blob / master / src / marnav / math / floatingpoint . hpp # L34 - # L39 ) <nl> - could be used , for instance <nl> - @ code { . cpp } <nl> - template < typename T , typename = typename std : : enable_if < std : : is_floating_point < T > : : value , T > : : type > <nl> - inline bool is_same ( T a , T b , T epsilon = std : : numeric_limits < T > : : epsilon ( ) ) noexcept <nl> - { <nl> - return std : : abs ( a - b ) < = epsilon ; <nl> - } <nl> - @ endcode <nl> - <nl> - @ note NaN values never compare equal to themselves or to other NaN values . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether the values @ a lhs and @ a rhs are equal <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__equal } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator = = ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - const auto lhs_type = lhs . type ( ) ; <nl> - const auto rhs_type = rhs . type ( ) ; <nl> - <nl> - if ( lhs_type = = rhs_type ) <nl> - { <nl> - switch ( lhs_type ) <nl> - { <nl> - case value_t : : array : <nl> - return ( * lhs . m_value . array = = * rhs . m_value . array ) ; <nl> - <nl> - case value_t : : object : <nl> - return ( * lhs . m_value . object = = * rhs . m_value . object ) ; <nl> - <nl> - case value_t : : null : <nl> - return true ; <nl> - <nl> - case value_t : : string : <nl> - return ( * lhs . m_value . string = = * rhs . m_value . string ) ; <nl> - <nl> - case value_t : : boolean : <nl> - return ( lhs . m_value . boolean = = rhs . m_value . boolean ) ; <nl> - <nl> - case value_t : : number_integer : <nl> - return ( lhs . m_value . number_integer = = rhs . m_value . number_integer ) ; <nl> - <nl> - case value_t : : number_unsigned : <nl> - return ( lhs . m_value . number_unsigned = = rhs . m_value . number_unsigned ) ; <nl> - <nl> - case value_t : : number_float : <nl> - return ( lhs . m_value . number_float = = rhs . m_value . number_float ) ; <nl> - <nl> - default : <nl> - return false ; <nl> - } <nl> - } <nl> - else if ( lhs_type = = value_t : : number_integer and rhs_type = = value_t : : number_float ) <nl> - { <nl> - return ( static_cast < number_float_t > ( lhs . m_value . number_integer ) = = rhs . m_value . number_float ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_float and rhs_type = = value_t : : number_integer ) <nl> - { <nl> - return ( lhs . m_value . number_float = = static_cast < number_float_t > ( rhs . m_value . number_integer ) ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_unsigned and rhs_type = = value_t : : number_float ) <nl> - { <nl> - return ( static_cast < number_float_t > ( lhs . m_value . number_unsigned ) = = rhs . m_value . number_float ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_float and rhs_type = = value_t : : number_unsigned ) <nl> - { <nl> - return ( lhs . m_value . number_float = = static_cast < number_float_t > ( rhs . m_value . number_unsigned ) ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_unsigned and rhs_type = = value_t : : number_integer ) <nl> - { <nl> - return ( static_cast < number_integer_t > ( lhs . m_value . number_unsigned ) = = rhs . m_value . number_integer ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_integer and rhs_type = = value_t : : number_unsigned ) <nl> - { <nl> - return ( lhs . m_value . number_integer = = static_cast < number_integer_t > ( rhs . m_value . number_unsigned ) ) ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : equal <nl> - @ copydoc operator = = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator = = ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs = = basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : equal <nl> - @ copydoc operator = = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator = = ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) = = rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : not equal <nl> - <nl> - Compares two JSON values for inequality by calculating ` not ( lhs = = rhs ) ` . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether the values @ a lhs and @ a rhs are not equal <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__notequal } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator ! = ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - return not ( lhs = = rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : not equal <nl> - @ copydoc operator ! = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator ! = ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs ! = basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : not equal <nl> - @ copydoc operator ! = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator ! = ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) ! = rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than <nl> - <nl> - Compares whether one JSON value @ a lhs is less than another JSON value @ a <nl> - rhs according to the following rules : <nl> - - If @ a lhs and @ a rhs have the same type , the values are compared using <nl> - the default ` < ` operator . <nl> - - Integer and floating - point numbers are automatically converted before <nl> - comparison <nl> - - In case @ a lhs and @ a rhs have different types , the values are ignored <nl> - and the order of the types is considered , see <nl> - @ ref operator < ( const value_t , const value_t ) . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether @ a lhs is less than @ a rhs <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__less } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator < ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - const auto lhs_type = lhs . type ( ) ; <nl> - const auto rhs_type = rhs . type ( ) ; <nl> - <nl> - if ( lhs_type = = rhs_type ) <nl> - { <nl> - switch ( lhs_type ) <nl> - { <nl> - case value_t : : array : <nl> - return ( * lhs . m_value . array ) < ( * rhs . m_value . array ) ; <nl> - <nl> - case value_t : : object : <nl> - return * lhs . m_value . object < * rhs . m_value . object ; <nl> - <nl> - case value_t : : null : <nl> - return false ; <nl> - <nl> - case value_t : : string : <nl> - return * lhs . m_value . string < * rhs . m_value . string ; <nl> - <nl> - case value_t : : boolean : <nl> - return lhs . m_value . boolean < rhs . m_value . boolean ; <nl> - <nl> - case value_t : : number_integer : <nl> - return lhs . m_value . number_integer < rhs . m_value . number_integer ; <nl> - <nl> - case value_t : : number_unsigned : <nl> - return lhs . m_value . number_unsigned < rhs . m_value . number_unsigned ; <nl> - <nl> - case value_t : : number_float : <nl> - return lhs . m_value . number_float < rhs . m_value . number_float ; <nl> - <nl> - default : <nl> - return false ; <nl> - } <nl> - } <nl> - else if ( lhs_type = = value_t : : number_integer and rhs_type = = value_t : : number_float ) <nl> - { <nl> - return static_cast < number_float_t > ( lhs . m_value . number_integer ) < rhs . m_value . number_float ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_float and rhs_type = = value_t : : number_integer ) <nl> - { <nl> - return lhs . m_value . number_float < static_cast < number_float_t > ( rhs . m_value . number_integer ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_unsigned and rhs_type = = value_t : : number_float ) <nl> - { <nl> - return static_cast < number_float_t > ( lhs . m_value . number_unsigned ) < rhs . m_value . number_float ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_float and rhs_type = = value_t : : number_unsigned ) <nl> - { <nl> - return lhs . m_value . number_float < static_cast < number_float_t > ( rhs . m_value . number_unsigned ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_integer and rhs_type = = value_t : : number_unsigned ) <nl> - { <nl> - return lhs . m_value . number_integer < static_cast < number_integer_t > ( rhs . m_value . number_unsigned ) ; <nl> - } <nl> - else if ( lhs_type = = value_t : : number_unsigned and rhs_type = = value_t : : number_integer ) <nl> - { <nl> - return static_cast < number_integer_t > ( lhs . m_value . number_unsigned ) < rhs . m_value . number_integer ; <nl> - } <nl> - <nl> - / / We only reach this line if we cannot compare values . In that case , <nl> - / / we compare types . Note we have to call the operator explicitly , <nl> - / / because MSVC has problems otherwise . <nl> - return operator < ( lhs_type , rhs_type ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than <nl> - @ copydoc operator < ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator < ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs < basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than <nl> - @ copydoc operator < ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator < ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) < rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than or equal <nl> - <nl> - Compares whether one JSON value @ a lhs is less than or equal to another <nl> - JSON value by calculating ` not ( rhs < lhs ) ` . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether @ a lhs is less than or equal to @ a rhs <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__greater } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator < = ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - return not ( rhs < lhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than or equal <nl> - @ copydoc operator < = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator < = ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs < = basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : less than or equal <nl> - @ copydoc operator < = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator < = ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) < = rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than <nl> - <nl> - Compares whether one JSON value @ a lhs is greater than another <nl> - JSON value by calculating ` not ( lhs < = rhs ) ` . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether @ a lhs is greater than to @ a rhs <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__lessequal } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator > ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - return not ( lhs < = rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than <nl> - @ copydoc operator > ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator > ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs > basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than <nl> - @ copydoc operator > ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator > ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) > rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than or equal <nl> - <nl> - Compares whether one JSON value @ a lhs is greater than or equal to another <nl> - JSON value by calculating ` not ( lhs < rhs ) ` . <nl> - <nl> - @ param [ in ] lhs first JSON value to consider <nl> - @ param [ in ] rhs second JSON value to consider <nl> - @ return whether @ a lhs is greater than or equal to @ a rhs <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ liveexample { The example demonstrates comparing several JSON <nl> - types . , operator__greaterequal } <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend bool operator > = ( const_reference lhs , const_reference rhs ) noexcept <nl> - { <nl> - return not ( lhs < rhs ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than or equal <nl> - @ copydoc operator > = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator > = ( const_reference lhs , const ScalarType rhs ) noexcept <nl> - { <nl> - return ( lhs > = basic_json ( rhs ) ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief comparison : greater than or equal <nl> - @ copydoc operator > = ( const_reference , const_reference ) <nl> - * / <nl> - template < typename ScalarType , typename std : : enable_if < <nl> - std : : is_scalar < ScalarType > : : value , int > : : type = 0 > <nl> - friend bool operator > = ( const ScalarType lhs , const_reference rhs ) noexcept <nl> - { <nl> - return ( basic_json ( lhs ) > = rhs ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / <nl> - / / serialization / / <nl> - / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name serialization <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief serialize to stream <nl> - <nl> - Serialize the given JSON value @ a j to the output stream @ a o . The JSON <nl> - value will be serialized using the @ ref dump member function . <nl> - <nl> - - The indentation of the output can be controlled with the member variable <nl> - ` width ` of the output stream @ a o . For instance , using the manipulator <nl> - ` std : : setw ( 4 ) ` on @ a o sets the indentation level to ` 4 ` and the <nl> - serialization result is the same as calling ` dump ( 4 ) ` . <nl> - <nl> - - The indentation character can be controlled with the member variable <nl> - ` fill ` of the output stream @ a o . For instance , the manipulator <nl> - ` std : : setfill ( ' \ \ t ' ) ` sets indentation to use a tab character rather than <nl> - the default space character . <nl> - <nl> - @ param [ in , out ] o stream to serialize to <nl> - @ param [ in ] j JSON value to serialize <nl> - <nl> - @ return the stream @ a o <nl> - <nl> - @ throw type_error . 316 if a string stored inside the JSON value is not <nl> - UTF - 8 encoded <nl> - <nl> - @ complexity Linear . <nl> - <nl> - @ liveexample { The example below shows the serialization with different <nl> - parameters to ` width ` to adjust the indentation level . , operator_serialize } <nl> - <nl> - @ since version 1 . 0 . 0 ; indentation character added in version 3 . 0 . 0 <nl> - * / <nl> - friend std : : ostream & operator < < ( std : : ostream & o , const basic_json & j ) <nl> - { <nl> - / / read width member and use it as indentation parameter if nonzero <nl> - const bool pretty_print = ( o . width ( ) > 0 ) ; <nl> - const auto indentation = ( pretty_print ? o . width ( ) : 0 ) ; <nl> - <nl> - / / reset width to 0 for subsequent calls to this stream <nl> - o . width ( 0 ) ; <nl> - <nl> - / / do the actual serialization <nl> - serializer s ( detail : : output_adapter < char > ( o ) , o . fill ( ) ) ; <nl> - s . dump ( j , pretty_print , false , static_cast < unsigned int > ( indentation ) ) ; <nl> - return o ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief serialize to stream <nl> - @ deprecated This stream operator is deprecated and will be removed in <nl> - future 4 . 0 . 0 of the library . Please use <nl> - @ ref operator < < ( std : : ostream & , const basic_json & ) <nl> - instead ; that is , replace calls like ` j > > o ; ` with ` o < < j ; ` . <nl> - @ since version 1 . 0 . 0 ; deprecated since version 3 . 0 . 0 <nl> - * / <nl> - JSON_DEPRECATED <nl> - friend std : : ostream & operator > > ( const basic_json & j , std : : ostream & o ) <nl> - { <nl> - return o < < j ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - / / deserialization / / <nl> - / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name deserialization <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief deserialize from a compatible input <nl> - <nl> - This function reads from a compatible input . Examples are : <nl> - - an array of 1 - byte values <nl> - - strings with character / literal type with size of 1 byte <nl> - - input streams <nl> - - container with contiguous storage of 1 - byte values . Compatible container <nl> - types include ` std : : vector ` , ` std : : string ` , ` std : : array ` , <nl> - ` std : : valarray ` , and ` std : : initializer_list ` . Furthermore , C - style <nl> - arrays can be used with ` std : : begin ( ) ` / ` std : : end ( ) ` . User - defined <nl> - containers can be used as long as they implement random - access iterators <nl> - and a contiguous storage . <nl> - <nl> - @ pre Each element of the container has a size of 1 byte . Violating this <nl> - precondition yields undefined behavior . * * This precondition is enforced <nl> - with a static assertion . * * <nl> - <nl> - @ pre The container storage is contiguous . Violating this precondition <nl> - yields undefined behavior . * * This precondition is enforced with an <nl> - assertion . * * <nl> - @ pre Each element of the container has a size of 1 byte . Violating this <nl> - precondition yields undefined behavior . * * This precondition is enforced <nl> - with a static assertion . * * <nl> - <nl> - @ warning There is no way to enforce all preconditions at compile - time . If <nl> - the function is called with a noncompliant container and with <nl> - assertions switched off , the behavior is undefined and will most <nl> - likely yield segmentation violation . <nl> - <nl> - @ param [ in ] i input to read from <nl> - @ param [ in ] cb a parser callback function of type @ ref parser_callback_t <nl> - which is used to control the deserialization by filtering unwanted values <nl> - ( optional ) <nl> - <nl> - @ return result of the deserialization <nl> - <nl> - @ throw parse_error . 101 if a parse error occurs ; example : ` " " unexpected end <nl> - of input ; expected string literal " " ` <nl> - @ throw parse_error . 102 if to_unicode fails or surrogate error <nl> - @ throw parse_error . 103 if to_unicode fails <nl> - <nl> - @ complexity Linear in the length of the input . The parser is a predictive <nl> - LL ( 1 ) parser . The complexity can be higher if the parser callback function <nl> - @ a cb has a super - linear complexity . <nl> - <nl> - @ note A UTF - 8 byte order mark is silently ignored . <nl> - <nl> - @ liveexample { The example below demonstrates the ` parse ( ) ` function reading <nl> - from an array . , parse__array__parser_callback_t } <nl> - <nl> - @ liveexample { The example below demonstrates the ` parse ( ) ` function with <nl> - and without callback function . , parse__string__parser_callback_t } <nl> - <nl> - @ liveexample { The example below demonstrates the ` parse ( ) ` function with <nl> - and without callback function . , parse__istream__parser_callback_t } <nl> - <nl> - @ liveexample { The example below demonstrates the ` parse ( ) ` function reading <nl> - from a contiguous container . , parse__contiguouscontainer__parser_callback_t } <nl> - <nl> - @ since version 2 . 0 . 3 ( contiguous containers ) <nl> - * / <nl> - static basic_json parse ( detail : : input_adapter & & i , <nl> - const parser_callback_t cb = nullptr , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - parser ( i , cb , allow_exceptions ) . parse ( true , result ) ; <nl> - return result ; <nl> - } <nl> - <nl> - static bool accept ( detail : : input_adapter & & i ) <nl> - { <nl> - return parser ( i ) . accept ( true ) ; <nl> - } <nl> - <nl> - template < typename SAX > <nl> - static bool sax_parse ( detail : : input_adapter & & i , SAX * sax , <nl> - input_format_t format = input_format_t : : json , <nl> - const bool strict = true ) <nl> - { <nl> - assert ( sax ) ; <nl> - switch ( format ) <nl> - { <nl> - case input_format_t : : json : <nl> - return parser ( std : : move ( i ) ) . sax_parse ( sax , strict ) ; <nl> - default : <nl> - return detail : : binary_reader < basic_json , SAX > ( std : : move ( i ) ) . sax_parse ( format , sax , strict ) ; <nl> - } <nl> - } <nl> - <nl> - / * ! <nl> - @ brief deserialize from an iterator range with contiguous storage <nl> - <nl> - This function reads from an iterator range of a container with contiguous <nl> - storage of 1 - byte values . Compatible container types include <nl> - ` std : : vector ` , ` std : : string ` , ` std : : array ` , ` std : : valarray ` , and <nl> - ` std : : initializer_list ` . Furthermore , C - style arrays can be used with <nl> - ` std : : begin ( ) ` / ` std : : end ( ) ` . User - defined containers can be used as long <nl> - as they implement random - access iterators and a contiguous storage . <nl> - <nl> - @ pre The iterator range is contiguous . Violating this precondition yields <nl> - undefined behavior . * * This precondition is enforced with an assertion . * * <nl> - @ pre Each element in the range has a size of 1 byte . Violating this <nl> - precondition yields undefined behavior . * * This precondition is enforced <nl> - with a static assertion . * * <nl> - <nl> - @ warning There is no way to enforce all preconditions at compile - time . If <nl> - the function is called with noncompliant iterators and with <nl> - assertions switched off , the behavior is undefined and will most <nl> - likely yield segmentation violation . <nl> - <nl> - @ tparam IteratorType iterator of container with contiguous storage <nl> - @ param [ in ] first begin of the range to parse ( included ) <nl> - @ param [ in ] last end of the range to parse ( excluded ) <nl> - @ param [ in ] cb a parser callback function of type @ ref parser_callback_t <nl> - which is used to control the deserialization by filtering unwanted values <nl> - ( optional ) <nl> - @ param [ in ] allow_exceptions whether to throw exceptions in case of a <nl> - parse error ( optional , true by default ) <nl> - <nl> - @ return result of the deserialization <nl> - <nl> - @ throw parse_error . 101 in case of an unexpected token <nl> - @ throw parse_error . 102 if to_unicode fails or surrogate error <nl> - @ throw parse_error . 103 if to_unicode fails <nl> - <nl> - @ complexity Linear in the length of the input . The parser is a predictive <nl> - LL ( 1 ) parser . The complexity can be higher if the parser callback function <nl> - @ a cb has a super - linear complexity . <nl> - <nl> - @ note A UTF - 8 byte order mark is silently ignored . <nl> - <nl> - @ liveexample { The example below demonstrates the ` parse ( ) ` function reading <nl> - from an iterator range . , parse__iteratortype__parser_callback_t } <nl> - <nl> - @ since version 2 . 0 . 3 <nl> - * / <nl> - template < class IteratorType , typename std : : enable_if < <nl> - std : : is_base_of < <nl> - std : : random_access_iterator_tag , <nl> - typename std : : iterator_traits < IteratorType > : : iterator_category > : : value , int > : : type = 0 > <nl> - static basic_json parse ( IteratorType first , IteratorType last , <nl> - const parser_callback_t cb = nullptr , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - parser ( detail : : input_adapter ( first , last ) , cb , allow_exceptions ) . parse ( true , result ) ; <nl> - return result ; <nl> - } <nl> - <nl> - template < class IteratorType , typename std : : enable_if < <nl> - std : : is_base_of < <nl> - std : : random_access_iterator_tag , <nl> - typename std : : iterator_traits < IteratorType > : : iterator_category > : : value , int > : : type = 0 > <nl> - static bool accept ( IteratorType first , IteratorType last ) <nl> - { <nl> - return parser ( detail : : input_adapter ( first , last ) ) . accept ( true ) ; <nl> - } <nl> - <nl> - template < class IteratorType , class SAX , typename std : : enable_if < <nl> - std : : is_base_of < <nl> - std : : random_access_iterator_tag , <nl> - typename std : : iterator_traits < IteratorType > : : iterator_category > : : value , int > : : type = 0 > <nl> - static bool sax_parse ( IteratorType first , IteratorType last , SAX * sax ) <nl> - { <nl> - return parser ( detail : : input_adapter ( first , last ) ) . sax_parse ( sax ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief deserialize from stream <nl> - @ deprecated This stream operator is deprecated and will be removed in <nl> - version 4 . 0 . 0 of the library . Please use <nl> - @ ref operator > > ( std : : istream & , basic_json & ) <nl> - instead ; that is , replace calls like ` j < < i ; ` with ` i > > j ; ` . <nl> - @ since version 1 . 0 . 0 ; deprecated since version 3 . 0 . 0 <nl> - * / <nl> - JSON_DEPRECATED <nl> - friend std : : istream & operator < < ( basic_json & j , std : : istream & i ) <nl> - { <nl> - return operator > > ( i , j ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief deserialize from stream <nl> - <nl> - Deserializes an input stream to a JSON value . <nl> - <nl> - @ param [ in , out ] i input stream to read a serialized JSON value from <nl> - @ param [ in , out ] j JSON value to write the deserialized input to <nl> - <nl> - @ throw parse_error . 101 in case of an unexpected token <nl> - @ throw parse_error . 102 if to_unicode fails or surrogate error <nl> - @ throw parse_error . 103 if to_unicode fails <nl> - <nl> - @ complexity Linear in the length of the input . The parser is a predictive <nl> - LL ( 1 ) parser . <nl> - <nl> - @ note A UTF - 8 byte order mark is silently ignored . <nl> - <nl> - @ liveexample { The example below shows how a JSON value is constructed by <nl> - reading a serialization from a stream . , operator_deserialize } <nl> - <nl> - @ sa parse ( std : : istream & , const parser_callback_t ) for a variant with a <nl> - parser callback function to filter values while parsing <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - friend std : : istream & operator > > ( std : : istream & i , basic_json & j ) <nl> - { <nl> - parser ( detail : : input_adapter ( i ) ) . parse ( false , j ) ; <nl> - return i ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / convenience functions / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / * ! <nl> - @ brief return the type as string <nl> - <nl> - Returns the type name as string to be used in error messages - usually to <nl> - indicate that a function was called on a wrong JSON type . <nl> - <nl> - @ return a string representation of a the @ a m_type member : <nl> - Value type | return value <nl> - mmmmmmmmm - - | mmmmmmmmmmmm - <nl> - null | ` " null " ` <nl> - boolean | ` " boolean " ` <nl> - string | ` " string " ` <nl> - number | ` " number " ` ( for all number types ) <nl> - object | ` " object " ` <nl> - array | ` " array " ` <nl> - discarded | ` " discarded " ` <nl> - <nl> - @ exceptionsafety No - throw guarantee : this function never throws exceptions . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ liveexample { The following code exemplifies ` type_name ( ) ` for all JSON <nl> - types . , type_name } <nl> - <nl> - @ sa @ ref type ( ) - - return the type of the JSON value <nl> - @ sa @ ref operator value_t ( ) - - return the type of the JSON value ( implicit ) <nl> - <nl> - @ since version 1 . 0 . 0 , public since 2 . 1 . 0 , ` const char * ` and ` noexcept ` <nl> - since 3 . 0 . 0 <nl> - * / <nl> - const char * type_name ( ) const noexcept <nl> - { <nl> - { <nl> - switch ( m_type ) <nl> - { <nl> - case value_t : : null : <nl> - return " null " ; <nl> - case value_t : : object : <nl> - return " object " ; <nl> - case value_t : : array : <nl> - return " array " ; <nl> - case value_t : : string : <nl> - return " string " ; <nl> - case value_t : : boolean : <nl> - return " boolean " ; <nl> - case value_t : : discarded : <nl> - return " discarded " ; <nl> - default : <nl> - return " number " ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - private : <nl> - / / / / / / / / / / / / / / / / / / / / / / <nl> - / / member variables / / <nl> - / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / the type of the current element <nl> - value_t m_type = value_t : : null ; <nl> - <nl> - / / / the value of the current element <nl> - json_value m_value = { } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / binary serialization / deserialization / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name binary serialization / deserialization support <nl> - / / / @ { <nl> - <nl> - public : <nl> - / * ! <nl> - @ brief create a CBOR serialization of a given JSON value <nl> - <nl> - Serializes a given JSON value @ a j to a byte vector using the CBOR ( Concise <nl> - Binary Object Representation ) serialization format . CBOR is a binary <nl> - serialization format which aims to be more compact than JSON itself , yet <nl> - more efficient to parse . <nl> - <nl> - The library uses the following mapping from JSON values types to <nl> - CBOR types according to the CBOR specification ( RFC 7049 ) : <nl> - <nl> - JSON value type | value / range | CBOR type | first byte <nl> - mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmm <nl> - null | ` null ` | Null | 0xF6 <nl> - boolean | ` true ` | True | 0xF5 <nl> - boolean | ` false ` | False | 0xF4 <nl> - number_integer | - 9223372036854775808 . . - 2147483649 | Negative integer ( 8 bytes follow ) | 0x3B <nl> - number_integer | - 2147483648 . . - 32769 | Negative integer ( 4 bytes follow ) | 0x3A <nl> - number_integer | - 32768 . . - 129 | Negative integer ( 2 bytes follow ) | 0x39 <nl> - number_integer | - 128 . . - 25 | Negative integer ( 1 byte follow ) | 0x38 <nl> - number_integer | - 24 . . - 1 | Negative integer | 0x20 . . 0x37 <nl> - number_integer | 0 . . 23 | Integer | 0x00 . . 0x17 <nl> - number_integer | 24 . . 255 | Unsigned integer ( 1 byte follow ) | 0x18 <nl> - number_integer | 256 . . 65535 | Unsigned integer ( 2 bytes follow ) | 0x19 <nl> - number_integer | 65536 . . 4294967295 | Unsigned integer ( 4 bytes follow ) | 0x1A <nl> - number_integer | 4294967296 . . 18446744073709551615 | Unsigned integer ( 8 bytes follow ) | 0x1B <nl> - number_unsigned | 0 . . 23 | Integer | 0x00 . . 0x17 <nl> - number_unsigned | 24 . . 255 | Unsigned integer ( 1 byte follow ) | 0x18 <nl> - number_unsigned | 256 . . 65535 | Unsigned integer ( 2 bytes follow ) | 0x19 <nl> - number_unsigned | 65536 . . 4294967295 | Unsigned integer ( 4 bytes follow ) | 0x1A <nl> - number_unsigned | 4294967296 . . 18446744073709551615 | Unsigned integer ( 8 bytes follow ) | 0x1B <nl> - number_float | * any value * | Double - Precision Float | 0xFB <nl> - string | * length * : 0 . . 23 | UTF - 8 string | 0x60 . . 0x77 <nl> - string | * length * : 23 . . 255 | UTF - 8 string ( 1 byte follow ) | 0x78 <nl> - string | * length * : 256 . . 65535 | UTF - 8 string ( 2 bytes follow ) | 0x79 <nl> - string | * length * : 65536 . . 4294967295 | UTF - 8 string ( 4 bytes follow ) | 0x7A <nl> - string | * length * : 4294967296 . . 18446744073709551615 | UTF - 8 string ( 8 bytes follow ) | 0x7B <nl> - array | * size * : 0 . . 23 | array | 0x80 . . 0x97 <nl> - array | * size * : 23 . . 255 | array ( 1 byte follow ) | 0x98 <nl> - array | * size * : 256 . . 65535 | array ( 2 bytes follow ) | 0x99 <nl> - array | * size * : 65536 . . 4294967295 | array ( 4 bytes follow ) | 0x9A <nl> - array | * size * : 4294967296 . . 18446744073709551615 | array ( 8 bytes follow ) | 0x9B <nl> - object | * size * : 0 . . 23 | map | 0xA0 . . 0xB7 <nl> - object | * size * : 23 . . 255 | map ( 1 byte follow ) | 0xB8 <nl> - object | * size * : 256 . . 65535 | map ( 2 bytes follow ) | 0xB9 <nl> - object | * size * : 65536 . . 4294967295 | map ( 4 bytes follow ) | 0xBA <nl> - object | * size * : 4294967296 . . 18446744073709551615 | map ( 8 bytes follow ) | 0xBB <nl> - <nl> - @ note The mapping is * * complete * * in the sense that any JSON value type <nl> - can be converted to a CBOR value . <nl> - <nl> - @ note If NaN or Infinity are stored inside a JSON number , they are <nl> - serialized properly . This behavior differs from the @ ref dump ( ) <nl> - function which serializes NaN or Infinity to ` null ` . <nl> - <nl> - @ note The following CBOR types are not used in the conversion : <nl> - - byte strings ( 0x40 . . 0x5F ) <nl> - - UTF - 8 strings terminated by " break " ( 0x7F ) <nl> - - arrays terminated by " break " ( 0x9F ) <nl> - - maps terminated by " break " ( 0xBF ) <nl> - - date / time ( 0xC0 . . 0xC1 ) <nl> - - bignum ( 0xC2 . . 0xC3 ) <nl> - - decimal fraction ( 0xC4 ) <nl> - - bigfloat ( 0xC5 ) <nl> - - tagged items ( 0xC6 . . 0xD4 , 0xD8 . . 0xDB ) <nl> - - expected conversions ( 0xD5 . . 0xD7 ) <nl> - - simple values ( 0xE0 . . 0xF3 , 0xF8 ) <nl> - - undefined ( 0xF7 ) <nl> - - half and single - precision floats ( 0xF9 - 0xFA ) <nl> - - break ( 0xFF ) <nl> - <nl> - @ param [ in ] j JSON value to serialize <nl> - @ return MessagePack serialization as byte vector <nl> - <nl> - @ complexity Linear in the size of the JSON value @ a j . <nl> - <nl> - @ liveexample { The example shows the serialization of a JSON value to a byte <nl> - vector in CBOR format . , to_cbor } <nl> - <nl> - @ sa http : / / cbor . io <nl> - @ sa @ ref from_cbor ( detail : : input_adapter , const bool strict ) for the <nl> - analogous deserialization <nl> - @ sa @ ref to_msgpack ( const basic_json & ) for the related MessagePack format <nl> - @ sa @ ref to_ubjson ( const basic_json & , const bool , const bool ) for the <nl> - related UBJSON format <nl> - <nl> - @ since version 2 . 0 . 9 <nl> - * / <nl> - static std : : vector < uint8_t > to_cbor ( const basic_json & j ) <nl> - { <nl> - std : : vector < uint8_t > result ; <nl> - to_cbor ( j , result ) ; <nl> - return result ; <nl> - } <nl> - <nl> - static void to_cbor ( const basic_json & j , detail : : output_adapter < uint8_t > o ) <nl> - { <nl> - binary_writer < uint8_t > ( o ) . write_cbor ( j ) ; <nl> - } <nl> - <nl> - static void to_cbor ( const basic_json & j , detail : : output_adapter < char > o ) <nl> - { <nl> - binary_writer < char > ( o ) . write_cbor ( j ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a MessagePack serialization of a given JSON value <nl> - <nl> - Serializes a given JSON value @ a j to a byte vector using the MessagePack <nl> - serialization format . MessagePack is a binary serialization format which <nl> - aims to be more compact than JSON itself , yet more efficient to parse . <nl> - <nl> - The library uses the following mapping from JSON values types to <nl> - MessagePack types according to the MessagePack specification : <nl> - <nl> - JSON value type | value / range | MessagePack type | first byte <nl> - mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmm - | mmmmmmmmm - <nl> - null | ` null ` | nil | 0xC0 <nl> - boolean | ` true ` | true | 0xC3 <nl> - boolean | ` false ` | false | 0xC2 <nl> - number_integer | - 9223372036854775808 . . - 2147483649 | int64 | 0xD3 <nl> - number_integer | - 2147483648 . . - 32769 | int32 | 0xD2 <nl> - number_integer | - 32768 . . - 129 | int16 | 0xD1 <nl> - number_integer | - 128 . . - 33 | int8 | 0xD0 <nl> - number_integer | - 32 . . - 1 | negative fixint | 0xE0 . . 0xFF <nl> - number_integer | 0 . . 127 | positive fixint | 0x00 . . 0x7F <nl> - number_integer | 128 . . 255 | uint 8 | 0xCC <nl> - number_integer | 256 . . 65535 | uint 16 | 0xCD <nl> - number_integer | 65536 . . 4294967295 | uint 32 | 0xCE <nl> - number_integer | 4294967296 . . 18446744073709551615 | uint 64 | 0xCF <nl> - number_unsigned | 0 . . 127 | positive fixint | 0x00 . . 0x7F <nl> - number_unsigned | 128 . . 255 | uint 8 | 0xCC <nl> - number_unsigned | 256 . . 65535 | uint 16 | 0xCD <nl> - number_unsigned | 65536 . . 4294967295 | uint 32 | 0xCE <nl> - number_unsigned | 4294967296 . . 18446744073709551615 | uint 64 | 0xCF <nl> - number_float | * any value * | float 64 | 0xCB <nl> - string | * length * : 0 . . 31 | fixstr | 0xA0 . . 0xBF <nl> - string | * length * : 32 . . 255 | str 8 | 0xD9 <nl> - string | * length * : 256 . . 65535 | str 16 | 0xDA <nl> - string | * length * : 65536 . . 4294967295 | str 32 | 0xDB <nl> - array | * size * : 0 . . 15 | fixarray | 0x90 . . 0x9F <nl> - array | * size * : 16 . . 65535 | array 16 | 0xDC <nl> - array | * size * : 65536 . . 4294967295 | array 32 | 0xDD <nl> - object | * size * : 0 . . 15 | fix map | 0x80 . . 0x8F <nl> - object | * size * : 16 . . 65535 | map 16 | 0xDE <nl> - object | * size * : 65536 . . 4294967295 | map 32 | 0xDF <nl> - <nl> - @ note The mapping is * * complete * * in the sense that any JSON value type <nl> - can be converted to a MessagePack value . <nl> - <nl> - @ note The following values can * * not * * be converted to a MessagePack value : <nl> - - strings with more than 4294967295 bytes <nl> - - arrays with more than 4294967295 elements <nl> - - objects with more than 4294967295 elements <nl> - <nl> - @ note The following MessagePack types are not used in the conversion : <nl> - - bin 8 - bin 32 ( 0xC4 . . 0xC6 ) <nl> - - ext 8 - ext 32 ( 0xC7 . . 0xC9 ) <nl> - - float 32 ( 0xCA ) <nl> - - fixext 1 - fixext 16 ( 0xD4 . . 0xD8 ) <nl> - <nl> - @ note Any MessagePack output created @ ref to_msgpack can be successfully <nl> - parsed by @ ref from_msgpack . <nl> - <nl> - @ note If NaN or Infinity are stored inside a JSON number , they are <nl> - serialized properly . This behavior differs from the @ ref dump ( ) <nl> - function which serializes NaN or Infinity to ` null ` . <nl> - <nl> - @ param [ in ] j JSON value to serialize <nl> - @ return MessagePack serialization as byte vector <nl> - <nl> - @ complexity Linear in the size of the JSON value @ a j . <nl> - <nl> - @ liveexample { The example shows the serialization of a JSON value to a byte <nl> - vector in MessagePack format . , to_msgpack } <nl> - <nl> - @ sa http : / / msgpack . org <nl> - @ sa @ ref from_msgpack ( const std : : vector < uint8_t > & , const size_t ) for the <nl> - analogous deserialization <nl> - @ sa @ ref to_cbor ( const basic_json & for the related CBOR format <nl> - @ sa @ ref to_ubjson ( const basic_json & , const bool , const bool ) for the <nl> - related UBJSON format <nl> - <nl> - @ since version 2 . 0 . 9 <nl> - * / <nl> - static std : : vector < uint8_t > to_msgpack ( const basic_json & j ) <nl> - { <nl> - std : : vector < uint8_t > result ; <nl> - to_msgpack ( j , result ) ; <nl> - return result ; <nl> - } <nl> - <nl> - static void to_msgpack ( const basic_json & j , detail : : output_adapter < uint8_t > o ) <nl> - { <nl> - binary_writer < uint8_t > ( o ) . write_msgpack ( j ) ; <nl> - } <nl> - <nl> - static void to_msgpack ( const basic_json & j , detail : : output_adapter < char > o ) <nl> - { <nl> - binary_writer < char > ( o ) . write_msgpack ( j ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a UBJSON serialization of a given JSON value <nl> - <nl> - Serializes a given JSON value @ a j to a byte vector using the UBJSON <nl> - ( Universal Binary JSON ) serialization format . UBJSON aims to be more compact <nl> - than JSON itself , yet more efficient to parse . <nl> - <nl> - The library uses the following mapping from JSON values types to <nl> - UBJSON types according to the UBJSON specification : <nl> - <nl> - JSON value type | value / range | UBJSON type | marker <nl> - mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmm - - | mmmmmm <nl> - null | ` null ` | null | ` Z ` <nl> - boolean | ` true ` | true | ` T ` <nl> - boolean | ` false ` | false | ` F ` <nl> - number_integer | - 9223372036854775808 . . - 2147483649 | int64 | ` L ` <nl> - number_integer | - 2147483648 . . - 32769 | int32 | ` l ` <nl> - number_integer | - 32768 . . - 129 | int16 | ` I ` <nl> - number_integer | - 128 . . 127 | int8 | ` i ` <nl> - number_integer | 128 . . 255 | uint8 | ` U ` <nl> - number_integer | 256 . . 32767 | int16 | ` I ` <nl> - number_integer | 32768 . . 2147483647 | int32 | ` l ` <nl> - number_integer | 2147483648 . . 9223372036854775807 | int64 | ` L ` <nl> - number_unsigned | 0 . . 127 | int8 | ` i ` <nl> - number_unsigned | 128 . . 255 | uint8 | ` U ` <nl> - number_unsigned | 256 . . 32767 | int16 | ` I ` <nl> - number_unsigned | 32768 . . 2147483647 | int32 | ` l ` <nl> - number_unsigned | 2147483648 . . 9223372036854775807 | int64 | ` L ` <nl> - number_float | * any value * | float64 | ` D ` <nl> - string | * with shortest length indicator * | string | ` S ` <nl> - array | * see notes on optimized format * | array | ` [ ` <nl> - object | * see notes on optimized format * | map | ` { ` <nl> - <nl> - @ note The mapping is * * complete * * in the sense that any JSON value type <nl> - can be converted to a UBJSON value . <nl> - <nl> - @ note The following values can * * not * * be converted to a UBJSON value : <nl> - - strings with more than 9223372036854775807 bytes ( theoretical ) <nl> - - unsigned integer numbers above 9223372036854775807 <nl> - <nl> - @ note The following markers are not used in the conversion : <nl> - - ` Z ` : no - op values are not created . <nl> - - ` C ` : single - byte strings are serialized with ` S ` markers . <nl> - <nl> - @ note Any UBJSON output created @ ref to_ubjson can be successfully parsed <nl> - by @ ref from_ubjson . <nl> - <nl> - @ note If NaN or Infinity are stored inside a JSON number , they are <nl> - serialized properly . This behavior differs from the @ ref dump ( ) <nl> - function which serializes NaN or Infinity to ` null ` . <nl> - <nl> - @ note The optimized formats for containers are supported : Parameter <nl> - @ a use_size adds size information to the beginning of a container and <nl> - removes the closing marker . Parameter @ a use_type further checks <nl> - whether all elements of a container have the same type and adds the <nl> - type marker to the beginning of the container . The @ a use_type <nl> - parameter must only be used together with @ a use_size = true . Note <nl> - that @ a use_size = true alone may result in larger representations - <nl> - the benefit of this parameter is that the receiving side is <nl> - immediately informed on the number of elements of the container . <nl> - <nl> - @ param [ in ] j JSON value to serialize <nl> - @ param [ in ] use_size whether to add size annotations to container types <nl> - @ param [ in ] use_type whether to add type annotations to container types <nl> - ( must be combined with @ a use_size = true ) <nl> - @ return UBJSON serialization as byte vector <nl> - <nl> - @ complexity Linear in the size of the JSON value @ a j . <nl> - <nl> - @ liveexample { The example shows the serialization of a JSON value to a byte <nl> - vector in UBJSON format . , to_ubjson } <nl> - <nl> - @ sa http : / / ubjson . org <nl> - @ sa @ ref from_ubjson ( detail : : input_adapter , const bool strict ) for the <nl> - analogous deserialization <nl> - @ sa @ ref to_cbor ( const basic_json & for the related CBOR format <nl> - @ sa @ ref to_msgpack ( const basic_json & ) for the related MessagePack format <nl> - <nl> - @ since version 3 . 1 . 0 <nl> - * / <nl> - static std : : vector < uint8_t > to_ubjson ( const basic_json & j , <nl> - const bool use_size = false , <nl> - const bool use_type = false ) <nl> - { <nl> - std : : vector < uint8_t > result ; <nl> - to_ubjson ( j , result , use_size , use_type ) ; <nl> - return result ; <nl> - } <nl> - <nl> - static void to_ubjson ( const basic_json & j , detail : : output_adapter < uint8_t > o , <nl> - const bool use_size = false , const bool use_type = false ) <nl> - { <nl> - binary_writer < uint8_t > ( o ) . write_ubjson ( j , use_size , use_type ) ; <nl> - } <nl> - <nl> - static void to_ubjson ( const basic_json & j , detail : : output_adapter < char > o , <nl> - const bool use_size = false , const bool use_type = false ) <nl> - { <nl> - binary_writer < char > ( o ) . write_ubjson ( j , use_size , use_type ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a JSON value from an input in CBOR format <nl> - <nl> - Deserializes a given input @ a i to a JSON value using the CBOR ( Concise <nl> - Binary Object Representation ) serialization format . <nl> - <nl> - The library maps CBOR types to JSON value types as follows : <nl> - <nl> - CBOR type | JSON value type | first byte <nl> - mmmmmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmm | mmmmmmmmm - <nl> - Integer | number_unsigned | 0x00 . . 0x17 <nl> - Unsigned integer | number_unsigned | 0x18 <nl> - Unsigned integer | number_unsigned | 0x19 <nl> - Unsigned integer | number_unsigned | 0x1A <nl> - Unsigned integer | number_unsigned | 0x1B <nl> - Negative integer | number_integer | 0x20 . . 0x37 <nl> - Negative integer | number_integer | 0x38 <nl> - Negative integer | number_integer | 0x39 <nl> - Negative integer | number_integer | 0x3A <nl> - Negative integer | number_integer | 0x3B <nl> - Negative integer | number_integer | 0x40 . . 0x57 <nl> - UTF - 8 string | string | 0x60 . . 0x77 <nl> - UTF - 8 string | string | 0x78 <nl> - UTF - 8 string | string | 0x79 <nl> - UTF - 8 string | string | 0x7A <nl> - UTF - 8 string | string | 0x7B <nl> - UTF - 8 string | string | 0x7F <nl> - array | array | 0x80 . . 0x97 <nl> - array | array | 0x98 <nl> - array | array | 0x99 <nl> - array | array | 0x9A <nl> - array | array | 0x9B <nl> - array | array | 0x9F <nl> - map | object | 0xA0 . . 0xB7 <nl> - map | object | 0xB8 <nl> - map | object | 0xB9 <nl> - map | object | 0xBA <nl> - map | object | 0xBB <nl> - map | object | 0xBF <nl> - False | ` false ` | 0xF4 <nl> - True | ` true ` | 0xF5 <nl> - Nill | ` null ` | 0xF6 <nl> - Half - Precision Float | number_float | 0xF9 <nl> - Single - Precision Float | number_float | 0xFA <nl> - Double - Precision Float | number_float | 0xFB <nl> - <nl> - @ warning The mapping is * * incomplete * * in the sense that not all CBOR <nl> - types can be converted to a JSON value . The following CBOR types <nl> - are not supported and will yield parse errors ( parse_error . 112 ) : <nl> - - byte strings ( 0x40 . . 0x5F ) <nl> - - date / time ( 0xC0 . . 0xC1 ) <nl> - - bignum ( 0xC2 . . 0xC3 ) <nl> - - decimal fraction ( 0xC4 ) <nl> - - bigfloat ( 0xC5 ) <nl> - - tagged items ( 0xC6 . . 0xD4 , 0xD8 . . 0xDB ) <nl> - - expected conversions ( 0xD5 . . 0xD7 ) <nl> - - simple values ( 0xE0 . . 0xF3 , 0xF8 ) <nl> - - undefined ( 0xF7 ) <nl> - <nl> - @ warning CBOR allows map keys of any type , whereas JSON only allows <nl> - strings as keys in object values . Therefore , CBOR maps with keys <nl> - other than UTF - 8 strings are rejected ( parse_error . 113 ) . <nl> - <nl> - @ note Any CBOR output created @ ref to_cbor can be successfully parsed by <nl> - @ ref from_cbor . <nl> - <nl> - @ param [ in ] i an input in CBOR format convertible to an input adapter <nl> - @ param [ in ] strict whether to expect the input to be consumed until EOF <nl> - ( true by default ) <nl> - @ param [ in ] allow_exceptions whether to throw exceptions in case of a <nl> - parse error ( optional , true by default ) <nl> - <nl> - @ return deserialized JSON value <nl> - <nl> - @ throw parse_error . 110 if the given input ends prematurely or the end of <nl> - file was not reached when @ a strict was set to true <nl> - @ throw parse_error . 112 if unsupported features from CBOR were <nl> - used in the given input @ a v or if the input is not valid CBOR <nl> - @ throw parse_error . 113 if a string was expected as map key , but not found <nl> - <nl> - @ complexity Linear in the size of the input @ a i . <nl> - <nl> - @ liveexample { The example shows the deserialization of a byte vector in CBOR <nl> - format to a JSON value . , from_cbor } <nl> - <nl> - @ sa http : / / cbor . io <nl> - @ sa @ ref to_cbor ( const basic_json & ) for the analogous serialization <nl> - @ sa @ ref from_msgpack ( detail : : input_adapter , const bool , const bool ) for the <nl> - related MessagePack format <nl> - @ sa @ ref from_ubjson ( detail : : input_adapter , const bool , const bool ) for the <nl> - related UBJSON format <nl> - <nl> - @ since version 2 . 0 . 9 ; parameter @ a start_index since 2 . 1 . 1 ; changed to <nl> - consume input adapters , removed start_index parameter , and added <nl> - @ a strict parameter since 3 . 0 . 0 ; added @ allow_exceptions parameter <nl> - since 3 . 2 . 0 <nl> - * / <nl> - static basic_json from_cbor ( detail : : input_adapter & & i , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( i ) ) . sax_parse ( input_format_t : : cbor , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc from_cbor ( detail : : input_adapter , const bool , const bool ) <nl> - * / <nl> - template < typename A1 , typename A2 , <nl> - detail : : enable_if_t < std : : is_constructible < detail : : input_adapter , A1 , A2 > : : value , int > = 0 > <nl> - static basic_json from_cbor ( A1 & & a1 , A2 & & a2 , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( std : : forward < A1 > ( a1 ) , std : : forward < A2 > ( a2 ) ) ) . sax_parse ( input_format_t : : cbor , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a JSON value from an input in MessagePack format <nl> - <nl> - Deserializes a given input @ a i to a JSON value using the MessagePack <nl> - serialization format . <nl> - <nl> - The library maps MessagePack types to JSON value types as follows : <nl> - <nl> - MessagePack type | JSON value type | first byte <nl> - mmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmm | mmmmmmmmm - <nl> - positive fixint | number_unsigned | 0x00 . . 0x7F <nl> - fixmap | object | 0x80 . . 0x8F <nl> - fixarray | array | 0x90 . . 0x9F <nl> - fixstr | string | 0xA0 . . 0xBF <nl> - nil | ` null ` | 0xC0 <nl> - false | ` false ` | 0xC2 <nl> - true | ` true ` | 0xC3 <nl> - float 32 | number_float | 0xCA <nl> - float 64 | number_float | 0xCB <nl> - uint 8 | number_unsigned | 0xCC <nl> - uint 16 | number_unsigned | 0xCD <nl> - uint 32 | number_unsigned | 0xCE <nl> - uint 64 | number_unsigned | 0xCF <nl> - int 8 | number_integer | 0xD0 <nl> - int 16 | number_integer | 0xD1 <nl> - int 32 | number_integer | 0xD2 <nl> - int 64 | number_integer | 0xD3 <nl> - str 8 | string | 0xD9 <nl> - str 16 | string | 0xDA <nl> - str 32 | string | 0xDB <nl> - array 16 | array | 0xDC <nl> - array 32 | array | 0xDD <nl> - map 16 | object | 0xDE <nl> - map 32 | object | 0xDF <nl> - negative fixint | number_integer | 0xE0 - 0xFF <nl> - <nl> - @ warning The mapping is * * incomplete * * in the sense that not all <nl> - MessagePack types can be converted to a JSON value . The following <nl> - MessagePack types are not supported and will yield parse errors : <nl> - - bin 8 - bin 32 ( 0xC4 . . 0xC6 ) <nl> - - ext 8 - ext 32 ( 0xC7 . . 0xC9 ) <nl> - - fixext 1 - fixext 16 ( 0xD4 . . 0xD8 ) <nl> - <nl> - @ note Any MessagePack output created @ ref to_msgpack can be successfully <nl> - parsed by @ ref from_msgpack . <nl> - <nl> - @ param [ in ] i an input in MessagePack format convertible to an input <nl> - adapter <nl> - @ param [ in ] strict whether to expect the input to be consumed until EOF <nl> - ( true by default ) <nl> - @ param [ in ] allow_exceptions whether to throw exceptions in case of a <nl> - parse error ( optional , true by default ) <nl> - <nl> - @ return deserialized JSON value <nl> - <nl> - @ throw parse_error . 110 if the given input ends prematurely or the end of <nl> - file was not reached when @ a strict was set to true <nl> - @ throw parse_error . 112 if unsupported features from MessagePack were <nl> - used in the given input @ a i or if the input is not valid MessagePack <nl> - @ throw parse_error . 113 if a string was expected as map key , but not found <nl> - <nl> - @ complexity Linear in the size of the input @ a i . <nl> - <nl> - @ liveexample { The example shows the deserialization of a byte vector in <nl> - MessagePack format to a JSON value . , from_msgpack } <nl> - <nl> - @ sa http : / / msgpack . org <nl> - @ sa @ ref to_msgpack ( const basic_json & ) for the analogous serialization <nl> - @ sa @ ref from_cbor ( detail : : input_adapter , const bool , const bool ) for the <nl> - related CBOR format <nl> - @ sa @ ref from_ubjson ( detail : : input_adapter , const bool , const bool ) for <nl> - the related UBJSON format <nl> - <nl> - @ since version 2 . 0 . 9 ; parameter @ a start_index since 2 . 1 . 1 ; changed to <nl> - consume input adapters , removed start_index parameter , and added <nl> - @ a strict parameter since 3 . 0 . 0 ; added @ allow_exceptions parameter <nl> - since 3 . 2 . 0 <nl> - * / <nl> - static basic_json from_msgpack ( detail : : input_adapter & & i , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( i ) ) . sax_parse ( input_format_t : : msgpack , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc from_msgpack ( detail : : input_adapter , const bool , const bool ) <nl> - * / <nl> - template < typename A1 , typename A2 , <nl> - detail : : enable_if_t < std : : is_constructible < detail : : input_adapter , A1 , A2 > : : value , int > = 0 > <nl> - static basic_json from_msgpack ( A1 & & a1 , A2 & & a2 , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( std : : forward < A1 > ( a1 ) , std : : forward < A2 > ( a2 ) ) ) . sax_parse ( input_format_t : : msgpack , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief create a JSON value from an input in UBJSON format <nl> - <nl> - Deserializes a given input @ a i to a JSON value using the UBJSON ( Universal <nl> - Binary JSON ) serialization format . <nl> - <nl> - The library maps UBJSON types to JSON value types as follows : <nl> - <nl> - UBJSON type | JSON value type | marker <nl> - mmmmmmmmm - - | mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmm <nl> - no - op | * no value , next value is read * | ` N ` <nl> - null | ` null ` | ` Z ` <nl> - false | ` false ` | ` F ` <nl> - true | ` true ` | ` T ` <nl> - float32 | number_float | ` d ` <nl> - float64 | number_float | ` D ` <nl> - uint8 | number_unsigned | ` U ` <nl> - int8 | number_integer | ` i ` <nl> - int16 | number_integer | ` I ` <nl> - int32 | number_integer | ` l ` <nl> - int64 | number_integer | ` L ` <nl> - string | string | ` S ` <nl> - char | string | ` C ` <nl> - array | array ( optimized values are supported ) | ` [ ` <nl> - object | object ( optimized values are supported ) | ` { ` <nl> - <nl> - @ note The mapping is * * complete * * in the sense that any UBJSON value can <nl> - be converted to a JSON value . <nl> - <nl> - @ param [ in ] i an input in UBJSON format convertible to an input adapter <nl> - @ param [ in ] strict whether to expect the input to be consumed until EOF <nl> - ( true by default ) <nl> - @ param [ in ] allow_exceptions whether to throw exceptions in case of a <nl> - parse error ( optional , true by default ) <nl> - <nl> - @ return deserialized JSON value <nl> - <nl> - @ throw parse_error . 110 if the given input ends prematurely or the end of <nl> - file was not reached when @ a strict was set to true <nl> - @ throw parse_error . 112 if a parse error occurs <nl> - @ throw parse_error . 113 if a string could not be parsed successfully <nl> - <nl> - @ complexity Linear in the size of the input @ a i . <nl> - <nl> - @ liveexample { The example shows the deserialization of a byte vector in <nl> - UBJSON format to a JSON value . , from_ubjson } <nl> - <nl> - @ sa http : / / ubjson . org <nl> - @ sa @ ref to_ubjson ( const basic_json & , const bool , const bool ) for the <nl> - analogous serialization <nl> - @ sa @ ref from_cbor ( detail : : input_adapter , const bool , const bool ) for the <nl> - related CBOR format <nl> - @ sa @ ref from_msgpack ( detail : : input_adapter , const bool , const bool ) for <nl> - the related MessagePack format <nl> - <nl> - @ since version 3 . 1 . 0 ; added @ allow_exceptions parameter since 3 . 2 . 0 <nl> - * / <nl> - static basic_json from_ubjson ( detail : : input_adapter & & i , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( i ) ) . sax_parse ( input_format_t : : ubjson , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ copydoc from_ubjson ( detail : : input_adapter , const bool , const bool ) <nl> - * / <nl> - template < typename A1 , typename A2 , <nl> - detail : : enable_if_t < std : : is_constructible < detail : : input_adapter , A1 , A2 > : : value , int > = 0 > <nl> - static basic_json from_ubjson ( A1 & & a1 , A2 & & a2 , <nl> - const bool strict = true , <nl> - const bool allow_exceptions = true ) <nl> - { <nl> - basic_json result ; <nl> - detail : : json_sax_dom_parser < basic_json > sdp ( result , allow_exceptions ) ; <nl> - const bool res = binary_reader ( detail : : input_adapter ( std : : forward < A1 > ( a1 ) , std : : forward < A2 > ( a2 ) ) ) . sax_parse ( input_format_t : : ubjson , & sdp , strict ) ; <nl> - return res ? result : basic_json ( value_t : : discarded ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON Pointer support / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name JSON Pointer functions <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief access specified element via JSON Pointer <nl> - <nl> - Uses a JSON pointer to retrieve a reference to the respective JSON value . <nl> - No bound checking is performed . Similar to @ ref operator [ ] ( const typename <nl> - object_t : : key_type & ) , ` null ` values are created in arrays and objects if <nl> - necessary . <nl> - <nl> - In particular : <nl> - - If the JSON pointer points to an object key that does not exist , it <nl> - is created an filled with a ` null ` value before a reference to it <nl> - is returned . <nl> - - If the JSON pointer points to an array index that does not exist , it <nl> - is created an filled with a ` null ` value before a reference to it <nl> - is returned . All indices between the current maximum and the given <nl> - index are also filled with ` null ` . <nl> - - The special value ` - ` is treated as a synonym for the index past the <nl> - end . <nl> - <nl> - @ param [ in ] ptr a JSON pointer <nl> - <nl> - @ return reference to the element pointed to by @ a ptr <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - <nl> - @ liveexample { The behavior is shown in the example . , operatorjson_pointer } <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - reference operator [ ] ( const json_pointer & ptr ) <nl> - { <nl> - return ptr . get_unchecked ( this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified element via JSON Pointer <nl> - <nl> - Uses a JSON pointer to retrieve a reference to the respective JSON value . <nl> - No bound checking is performed . The function does not change the JSON <nl> - value ; no ` null ` values are created . In particular , the the special value <nl> - ` - ` yields an exception . <nl> - <nl> - @ param [ in ] ptr JSON pointer to the desired element <nl> - <nl> - @ return const reference to the element pointed to by @ a ptr <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ throw parse_error . 106 if an array index begins with ' 0 ' <nl> - @ throw parse_error . 109 if an array index was not a number <nl> - @ throw out_of_range . 402 if the array index ' - ' is used <nl> - @ throw out_of_range . 404 if the JSON pointer can not be resolved <nl> - <nl> - @ liveexample { The behavior is shown in the example . , operatorjson_pointer_const } <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - const_reference operator [ ] ( const json_pointer & ptr ) const <nl> - { <nl> - return ptr . get_unchecked ( this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified element via JSON Pointer <nl> - <nl> - Returns a reference to the element at with specified JSON pointer @ a ptr , <nl> - with bounds checking . <nl> - <nl> - @ param [ in ] ptr JSON pointer to the desired element <nl> - <nl> - @ return reference to the element pointed to by @ a ptr <nl> - <nl> - @ throw parse_error . 106 if an array index in the passed JSON pointer @ a ptr <nl> - begins with ' 0 ' . See example below . <nl> - <nl> - @ throw parse_error . 109 if an array index in the passed JSON pointer @ a ptr <nl> - is not a number . See example below . <nl> - <nl> - @ throw out_of_range . 401 if an array index in the passed JSON pointer @ a ptr <nl> - is out of range . See example below . <nl> - <nl> - @ throw out_of_range . 402 if the array index ' - ' is used in the passed JSON <nl> - pointer @ a ptr . As ` at ` provides checked access ( and no elements are <nl> - implicitly inserted ) , the index ' - ' is always invalid . See example below . <nl> - <nl> - @ throw out_of_range . 403 if the JSON pointer describes a key of an object <nl> - which cannot be found . See example below . <nl> - <nl> - @ throw out_of_range . 404 if the JSON pointer @ a ptr can not be resolved . <nl> - See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - <nl> - @ liveexample { The behavior is shown in the example . , at_json_pointer } <nl> - * / <nl> - reference at ( const json_pointer & ptr ) <nl> - { <nl> - return ptr . get_checked ( this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief access specified element via JSON Pointer <nl> - <nl> - Returns a const reference to the element at with specified JSON pointer @ a <nl> - ptr , with bounds checking . <nl> - <nl> - @ param [ in ] ptr JSON pointer to the desired element <nl> - <nl> - @ return reference to the element pointed to by @ a ptr <nl> - <nl> - @ throw parse_error . 106 if an array index in the passed JSON pointer @ a ptr <nl> - begins with ' 0 ' . See example below . <nl> - <nl> - @ throw parse_error . 109 if an array index in the passed JSON pointer @ a ptr <nl> - is not a number . See example below . <nl> - <nl> - @ throw out_of_range . 401 if an array index in the passed JSON pointer @ a ptr <nl> - is out of range . See example below . <nl> - <nl> - @ throw out_of_range . 402 if the array index ' - ' is used in the passed JSON <nl> - pointer @ a ptr . As ` at ` provides checked access ( and no elements are <nl> - implicitly inserted ) , the index ' - ' is always invalid . See example below . <nl> - <nl> - @ throw out_of_range . 403 if the JSON pointer describes a key of an object <nl> - which cannot be found . See example below . <nl> - <nl> - @ throw out_of_range . 404 if the JSON pointer @ a ptr can not be resolved . <nl> - See example below . <nl> - <nl> - @ exceptionsafety Strong guarantee : if an exception is thrown , there are no <nl> - changes in the JSON value . <nl> - <nl> - @ complexity Constant . <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - <nl> - @ liveexample { The behavior is shown in the example . , at_json_pointer_const } <nl> - * / <nl> - const_reference at ( const json_pointer & ptr ) const <nl> - { <nl> - return ptr . get_checked ( this ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief return flattened JSON value <nl> - <nl> - The function creates a JSON object whose keys are JSON pointers ( see [ RFC <nl> - 6901 ] ( https : / / tools . ietf . org / html / rfc6901 ) ) and whose values are all <nl> - primitive . The original JSON value can be restored using the @ ref <nl> - unflatten ( ) function . <nl> - <nl> - @ return an object that maps JSON pointers to primitive values <nl> - <nl> - @ note Empty objects and arrays are flattened to ` null ` and will not be <nl> - reconstructed correctly by the @ ref unflatten ( ) function . <nl> - <nl> - @ complexity Linear in the size the JSON value . <nl> - <nl> - @ liveexample { The following code shows how a JSON object is flattened to an <nl> - object whose keys consist of JSON pointers . , flatten } <nl> - <nl> - @ sa @ ref unflatten ( ) for the reverse function <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - basic_json flatten ( ) const <nl> - { <nl> - basic_json result ( value_t : : object ) ; <nl> - json_pointer : : flatten ( " " , * this , result ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief unflatten a previously flattened JSON value <nl> - <nl> - The function restores the arbitrary nesting of a JSON value that has been <nl> - flattened before using the @ ref flatten ( ) function . The JSON value must <nl> - meet certain constraints : <nl> - 1 . The value must be an object . <nl> - 2 . The keys must be JSON pointers ( see <nl> - [ RFC 6901 ] ( https : / / tools . ietf . org / html / rfc6901 ) ) <nl> - 3 . The mapped values must be primitive JSON types . <nl> - <nl> - @ return the original JSON from a flattened version <nl> - <nl> - @ note Empty objects and arrays are flattened by @ ref flatten ( ) to ` null ` <nl> - values and can not unflattened to their original type . Apart from <nl> - this example , for a JSON value ` j ` , the following is always true : <nl> - ` j = = j . flatten ( ) . unflatten ( ) ` . <nl> - <nl> - @ complexity Linear in the size the JSON value . <nl> - <nl> - @ throw type_error . 314 if value is not an object <nl> - @ throw type_error . 315 if object values are not primitive <nl> - <nl> - @ liveexample { The following code shows how a flattened JSON object is <nl> - unflattened into the original nested JSON object . , unflatten } <nl> - <nl> - @ sa @ ref flatten ( ) for the reverse function <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - basic_json unflatten ( ) const <nl> - { <nl> - return json_pointer : : unflatten ( * this ) ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON Patch functions / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name JSON Patch functions <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief applies a JSON patch <nl> - <nl> - [ JSON Patch ] ( http : / / jsonpatch . com ) defines a JSON document structure for <nl> - expressing a sequence of operations to apply to a JSON ) document . With <nl> - this function , a JSON Patch is applied to the current JSON value by <nl> - executing all operations from the patch . <nl> - <nl> - @ param [ in ] json_patch JSON patch document <nl> - @ return patched document <nl> - <nl> - @ note The application of a patch is atomic : Either all operations succeed <nl> - and the patched document is returned or an exception is thrown . In <nl> - any case , the original value is not changed : the patch is applied <nl> - to a copy of the value . <nl> - <nl> - @ throw parse_error . 104 if the JSON patch does not consist of an array of <nl> - objects <nl> - <nl> - @ throw parse_error . 105 if the JSON patch is malformed ( e . g . , mandatory <nl> - attributes are missing ) ; example : ` " operation add must have member path " ` <nl> - <nl> - @ throw out_of_range . 401 if an array index is out of range . <nl> - <nl> - @ throw out_of_range . 403 if a JSON pointer inside the patch could not be <nl> - resolved successfully in the current JSON value ; example : ` " key baz not <nl> - found " ` <nl> - <nl> - @ throw out_of_range . 405 if JSON pointer has no parent ( " add " , " remove " , <nl> - " move " ) <nl> - <nl> - @ throw other_error . 501 if " test " operation was unsuccessful <nl> - <nl> - @ complexity Linear in the size of the JSON value and the length of the <nl> - JSON patch . As usually only a fraction of the JSON value is affected by <nl> - the patch , the complexity can usually be neglected . <nl> - <nl> - @ liveexample { The following code shows how a JSON patch is applied to a <nl> - value . , patch } <nl> - <nl> - @ sa @ ref diff - - create a JSON patch by comparing two JSON values <nl> - <nl> - @ sa [ RFC 6902 ( JSON Patch ) ] ( https : / / tools . ietf . org / html / rfc6902 ) <nl> - @ sa [ RFC 6901 ( JSON Pointer ) ] ( https : / / tools . ietf . org / html / rfc6901 ) <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - basic_json patch ( const basic_json & json_patch ) const <nl> - { <nl> - / / make a working copy to apply the patch to <nl> - basic_json result = * this ; <nl> - <nl> - / / the valid JSON Patch operations <nl> - enum class patch_operations { add , remove , replace , move , copy , test , invalid } ; <nl> - <nl> - const auto get_op = [ ] ( const std : : string & op ) <nl> - { <nl> - if ( op = = " add " ) <nl> - { <nl> - return patch_operations : : add ; <nl> - } <nl> - if ( op = = " remove " ) <nl> - { <nl> - return patch_operations : : remove ; <nl> - } <nl> - if ( op = = " replace " ) <nl> - { <nl> - return patch_operations : : replace ; <nl> - } <nl> - if ( op = = " move " ) <nl> - { <nl> - return patch_operations : : move ; <nl> - } <nl> - if ( op = = " copy " ) <nl> - { <nl> - return patch_operations : : copy ; <nl> - } <nl> - if ( op = = " test " ) <nl> - { <nl> - return patch_operations : : test ; <nl> - } <nl> - <nl> - return patch_operations : : invalid ; <nl> - } ; <nl> - <nl> - / / wrapper for " add " operation ; add value at ptr <nl> - const auto operation_add = [ & result ] ( json_pointer & ptr , basic_json val ) <nl> - { <nl> - / / adding to the root of the target document means replacing it <nl> - if ( ptr . is_root ( ) ) <nl> - { <nl> - result = val ; <nl> - } <nl> - else <nl> - { <nl> - / / make sure the top element of the pointer exists <nl> - json_pointer top_pointer = ptr . top ( ) ; <nl> - if ( top_pointer ! = ptr ) <nl> - { <nl> - result . at ( top_pointer ) ; <nl> - } <nl> - <nl> - / / get reference to parent of JSON pointer ptr <nl> - const auto last_path = ptr . pop_back ( ) ; <nl> - basic_json & parent = result [ ptr ] ; <nl> - <nl> - switch ( parent . m_type ) <nl> - { <nl> - case value_t : : null : <nl> - case value_t : : object : <nl> - { <nl> - / / use operator [ ] to add value <nl> - parent [ last_path ] = val ; <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : array : <nl> - { <nl> - if ( last_path = = " - " ) <nl> - { <nl> - / / special case : append to back <nl> - parent . push_back ( val ) ; <nl> - } <nl> - else <nl> - { <nl> - const auto idx = json_pointer : : array_index ( last_path ) ; <nl> - if ( JSON_UNLIKELY ( static_cast < size_type > ( idx ) > parent . size ( ) ) ) <nl> - { <nl> - / / avoid undefined behavior <nl> - JSON_THROW ( out_of_range : : create ( 401 , " array index " + std : : to_string ( idx ) + " is out of range " ) ) ; <nl> - } <nl> - else <nl> - { <nl> - / / default case : insert add offset <nl> - parent . insert ( parent . begin ( ) + static_cast < difference_type > ( idx ) , val ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / if there exists a parent it cannot be primitive <nl> - assert ( false ) ; / / LCOV_EXCL_LINE <nl> - } <nl> - } <nl> - } <nl> - } ; <nl> - <nl> - / / wrapper for " remove " operation ; remove value at ptr <nl> - const auto operation_remove = [ & result ] ( json_pointer & ptr ) <nl> - { <nl> - / / get reference to parent of JSON pointer ptr <nl> - const auto last_path = ptr . pop_back ( ) ; <nl> - basic_json & parent = result . at ( ptr ) ; <nl> - <nl> - / / remove child <nl> - if ( parent . is_object ( ) ) <nl> - { <nl> - / / perform range check <nl> - auto it = parent . find ( last_path ) ; <nl> - if ( JSON_LIKELY ( it ! = parent . end ( ) ) ) <nl> - { <nl> - parent . erase ( it ) ; <nl> - } <nl> - else <nl> - { <nl> - JSON_THROW ( out_of_range : : create ( 403 , " key ' " + last_path + " ' not found " ) ) ; <nl> - } <nl> - } <nl> - else if ( parent . is_array ( ) ) <nl> - { <nl> - / / note erase performs range check <nl> - parent . erase ( static_cast < size_type > ( json_pointer : : array_index ( last_path ) ) ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / type check : top level value must be an array <nl> - if ( JSON_UNLIKELY ( not json_patch . is_array ( ) ) ) <nl> - { <nl> - JSON_THROW ( parse_error : : create ( 104 , 0 , " JSON patch must be an array of objects " ) ) ; <nl> - } <nl> - <nl> - / / iterate and apply the operations <nl> - for ( const auto & val : json_patch ) <nl> - { <nl> - / / wrapper to get a value for an operation <nl> - const auto get_value = [ & val ] ( const std : : string & op , <nl> - const std : : string & member , <nl> - bool string_type ) - > basic_json & <nl> - { <nl> - / / find value <nl> - auto it = val . m_value . object - > find ( member ) ; <nl> - <nl> - / / context - sensitive error message <nl> - const auto error_msg = ( op = = " op " ) ? " operation " : " operation ' " + op + " ' " ; <nl> - <nl> - / / check if desired value is present <nl> - if ( JSON_UNLIKELY ( it = = val . m_value . object - > end ( ) ) ) <nl> - { <nl> - JSON_THROW ( parse_error : : create ( 105 , 0 , error_msg + " must have member ' " + member + " ' " ) ) ; <nl> - } <nl> - <nl> - / / check if result is of type string <nl> - if ( JSON_UNLIKELY ( string_type and not it - > second . is_string ( ) ) ) <nl> - { <nl> - JSON_THROW ( parse_error : : create ( 105 , 0 , error_msg + " must have string member ' " + member + " ' " ) ) ; <nl> - } <nl> - <nl> - / / no error : return value <nl> - return it - > second ; <nl> - } ; <nl> - <nl> - / / type check : every element of the array must be an object <nl> - if ( JSON_UNLIKELY ( not val . is_object ( ) ) ) <nl> - { <nl> - JSON_THROW ( parse_error : : create ( 104 , 0 , " JSON patch must be an array of objects " ) ) ; <nl> - } <nl> - <nl> - / / collect mandatory members <nl> - const std : : string op = get_value ( " op " , " op " , true ) ; <nl> - const std : : string path = get_value ( op , " path " , true ) ; <nl> - json_pointer ptr ( path ) ; <nl> - <nl> - switch ( get_op ( op ) ) <nl> - { <nl> - case patch_operations : : add : <nl> - { <nl> - operation_add ( ptr , get_value ( " add " , " value " , false ) ) ; <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : remove : <nl> - { <nl> - operation_remove ( ptr ) ; <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : replace : <nl> - { <nl> - / / the " path " location must exist - use at ( ) <nl> - result . at ( ptr ) = get_value ( " replace " , " value " , false ) ; <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : move : <nl> - { <nl> - const std : : string from_path = get_value ( " move " , " from " , true ) ; <nl> - json_pointer from_ptr ( from_path ) ; <nl> - <nl> - / / the " from " location must exist - use at ( ) <nl> - basic_json v = result . at ( from_ptr ) ; <nl> - <nl> - / / The move operation is functionally identical to a <nl> - / / " remove " operation on the " from " location , followed <nl> - / / immediately by an " add " operation at the target <nl> - / / location with the value that was just removed . <nl> - operation_remove ( from_ptr ) ; <nl> - operation_add ( ptr , v ) ; <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : copy : <nl> - { <nl> - const std : : string from_path = get_value ( " copy " , " from " , true ) ; <nl> - const json_pointer from_ptr ( from_path ) ; <nl> - <nl> - / / the " from " location must exist - use at ( ) <nl> - basic_json v = result . at ( from_ptr ) ; <nl> - <nl> - / / The copy is functionally identical to an " add " <nl> - / / operation at the target location using the value <nl> - / / specified in the " from " member . <nl> - operation_add ( ptr , v ) ; <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : test : <nl> - { <nl> - bool success = false ; <nl> - JSON_TRY <nl> - { <nl> - / / check if " value " matches the one at " path " <nl> - / / the " path " location must exist - use at ( ) <nl> - success = ( result . at ( ptr ) = = get_value ( " test " , " value " , false ) ) ; <nl> - } <nl> - JSON_INTERNAL_CATCH ( out_of_range & ) <nl> - { <nl> - / / ignore out of range errors : success remains false <nl> - } <nl> - <nl> - / / throw an exception if test fails <nl> - if ( JSON_UNLIKELY ( not success ) ) <nl> - { <nl> - JSON_THROW ( other_error : : create ( 501 , " unsuccessful : " + val . dump ( ) ) ) ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - case patch_operations : : invalid : <nl> - { <nl> - / / op must be " add " , " remove " , " replace " , " move " , " copy " , or <nl> - / / " test " <nl> - JSON_THROW ( parse_error : : create ( 105 , 0 , " operation value ' " + op + " ' is invalid " ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief creates a diff as a JSON patch <nl> - <nl> - Creates a [ JSON Patch ] ( http : / / jsonpatch . com ) so that value @ a source can <nl> - be changed into the value @ a target by calling @ ref patch function . <nl> - <nl> - @ invariant For two JSON values @ a source and @ a target , the following code <nl> - yields always ` true ` : <nl> - @ code { . cpp } <nl> - source . patch ( diff ( source , target ) ) = = target ; <nl> - @ endcode <nl> - <nl> - @ note Currently , only ` remove ` , ` add ` , and ` replace ` operations are <nl> - generated . <nl> - <nl> - @ param [ in ] source JSON value to compare from <nl> - @ param [ in ] target JSON value to compare against <nl> - @ param [ in ] path helper value to create JSON pointers <nl> - <nl> - @ return a JSON patch to convert the @ a source to @ a target <nl> - <nl> - @ complexity Linear in the lengths of @ a source and @ a target . <nl> - <nl> - @ liveexample { The following code shows how a JSON patch is created as a <nl> - diff for two JSON values . , diff } <nl> - <nl> - @ sa @ ref patch - - apply a JSON patch <nl> - @ sa @ ref merge_patch - - apply a JSON Merge Patch <nl> - <nl> - @ sa [ RFC 6902 ( JSON Patch ) ] ( https : / / tools . ietf . org / html / rfc6902 ) <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - static basic_json diff ( const basic_json & source , const basic_json & target , <nl> - const std : : string & path = " " ) <nl> - { <nl> - / / the patch <nl> - basic_json result ( value_t : : array ) ; <nl> - <nl> - / / if the values are the same , return empty patch <nl> - if ( source = = target ) <nl> - { <nl> - return result ; <nl> - } <nl> - <nl> - if ( source . type ( ) ! = target . type ( ) ) <nl> - { <nl> - / / different types : replace value <nl> - result . push_back ( <nl> - { <nl> - { " op " , " replace " } , { " path " , path } , { " value " , target } <nl> - } ) ; <nl> - } <nl> - else <nl> - { <nl> - switch ( source . type ( ) ) <nl> - { <nl> - case value_t : : array : <nl> - { <nl> - / / first pass : traverse common elements <nl> - std : : size_t i = 0 ; <nl> - while ( i < source . size ( ) and i < target . size ( ) ) <nl> - { <nl> - / / recursive call to compare array values at index i <nl> - auto temp_diff = diff ( source [ i ] , target [ i ] , path + " / " + std : : to_string ( i ) ) ; <nl> - result . insert ( result . end ( ) , temp_diff . begin ( ) , temp_diff . end ( ) ) ; <nl> - + + i ; <nl> - } <nl> - <nl> - / / i now reached the end of at least one array <nl> - / / in a second pass , traverse the remaining elements <nl> - <nl> - / / remove my remaining elements <nl> - const auto end_index = static_cast < difference_type > ( result . size ( ) ) ; <nl> - while ( i < source . size ( ) ) <nl> - { <nl> - / / add operations in reverse order to avoid invalid <nl> - / / indices <nl> - result . insert ( result . begin ( ) + end_index , object ( <nl> - { <nl> - { " op " , " remove " } , <nl> - { " path " , path + " / " + std : : to_string ( i ) } <nl> - } ) ) ; <nl> - + + i ; <nl> - } <nl> - <nl> - / / add other remaining elements <nl> - while ( i < target . size ( ) ) <nl> - { <nl> - result . push_back ( <nl> - { <nl> - { " op " , " add " } , <nl> - { " path " , path + " / " + std : : to_string ( i ) } , <nl> - { " value " , target [ i ] } <nl> - } ) ; <nl> - + + i ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - case value_t : : object : <nl> - { <nl> - / / first pass : traverse this object ' s elements <nl> - for ( auto it = source . cbegin ( ) ; it ! = source . cend ( ) ; + + it ) <nl> - { <nl> - / / escape the key name to be used in a JSON patch <nl> - const auto key = json_pointer : : escape ( it . key ( ) ) ; <nl> - <nl> - if ( target . find ( it . key ( ) ) ! = target . end ( ) ) <nl> - { <nl> - / / recursive call to compare object values at key it <nl> - auto temp_diff = diff ( it . value ( ) , target [ it . key ( ) ] , path + " / " + key ) ; <nl> - result . insert ( result . end ( ) , temp_diff . begin ( ) , temp_diff . end ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - / / found a key that is not in o - > remove it <nl> - result . push_back ( object ( <nl> - { <nl> - { " op " , " remove " } , { " path " , path + " / " + key } <nl> - } ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / second pass : traverse other object ' s elements <nl> - for ( auto it = target . cbegin ( ) ; it ! = target . cend ( ) ; + + it ) <nl> - { <nl> - if ( source . find ( it . key ( ) ) = = source . end ( ) ) <nl> - { <nl> - / / found a key that is not in this - > add it <nl> - const auto key = json_pointer : : escape ( it . key ( ) ) ; <nl> - result . push_back ( <nl> - { <nl> - { " op " , " add " } , { " path " , path + " / " + key } , <nl> - { " value " , it . value ( ) } <nl> - } ) ; <nl> - } <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - { <nl> - / / both primitive type : replace value <nl> - result . push_back ( <nl> - { <nl> - { " op " , " replace " } , { " path " , path } , { " value " , target } <nl> - } ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / / / @ } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / JSON Merge Patch functions / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / / @ name JSON Merge Patch functions <nl> - / / / @ { <nl> - <nl> - / * ! <nl> - @ brief applies a JSON Merge Patch <nl> - <nl> - The merge patch format is primarily intended for use with the HTTP PATCH <nl> - method as a means of describing a set of modifications to a target <nl> - resource ' s content . This function applies a merge patch to the current <nl> - JSON value . <nl> - <nl> - The function implements the following algorithm from Section 2 of <nl> - [ RFC 7396 ( JSON Merge Patch ) ] ( https : / / tools . ietf . org / html / rfc7396 ) : <nl> - <nl> - ` ` ` <nl> - define MergePatch ( Target , Patch ) : <nl> - if Patch is an Object : <nl> - if Target is not an Object : <nl> - Target = { } / / Ignore the contents and set it to an empty Object <nl> - for each Name / Value pair in Patch : <nl> - if Value is null : <nl> - if Name exists in Target : <nl> - remove the Name / Value pair from Target <nl> - else : <nl> - Target [ Name ] = MergePatch ( Target [ Name ] , Value ) <nl> - return Target <nl> - else : <nl> - return Patch <nl> - ` ` ` <nl> - <nl> - Thereby , ` Target ` is the current object ; that is , the patch is applied to <nl> - the current value . <nl> - <nl> - @ param [ in ] patch the patch to apply <nl> - <nl> - @ complexity Linear in the lengths of @ a patch . <nl> - <nl> - @ liveexample { The following code shows how a JSON Merge Patch is applied to <nl> - a JSON document . , merge_patch } <nl> - <nl> - @ sa @ ref patch - - apply a JSON patch <nl> - @ sa [ RFC 7396 ( JSON Merge Patch ) ] ( https : / / tools . ietf . org / html / rfc7396 ) <nl> - <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - void merge_patch ( const basic_json & patch ) <nl> - { <nl> - if ( patch . is_object ( ) ) <nl> - { <nl> - if ( not is_object ( ) ) <nl> - { <nl> - * this = object ( ) ; <nl> - } <nl> - for ( auto it = patch . begin ( ) ; it ! = patch . end ( ) ; + + it ) <nl> - { <nl> - if ( it . value ( ) . is_null ( ) ) <nl> - { <nl> - erase ( it . key ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - operator [ ] ( it . key ( ) ) . merge_patch ( it . value ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - * this = patch ; <nl> - } <nl> - } <nl> - <nl> - / / / @ } <nl> - } ; <nl> - } / / namespace nlohmann <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / nonmember support / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / specialization of std : : swap , and std : : hash <nl> - namespace std <nl> - { <nl> - / * ! <nl> - @ brief exchanges the values of two JSON objects <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - template < > <nl> - inline void swap < nlohmann : : json > ( nlohmann : : json & j1 , nlohmann : : json & j2 ) noexcept ( <nl> - is_nothrow_move_constructible < nlohmann : : json > : : value and <nl> - is_nothrow_move_assignable < nlohmann : : json > : : value <nl> - ) <nl> - { <nl> - j1 . swap ( j2 ) ; <nl> - } <nl> - <nl> - / / / hash value for JSON objects <nl> - template < > <nl> - struct hash < nlohmann : : json > <nl> - { <nl> - / * ! <nl> - @ brief return a hash value for a JSON object <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - std : : size_t operator ( ) ( const nlohmann : : json & j ) const <nl> - { <nl> - / / a naive hashing via the string representation <nl> - const auto & h = hash < nlohmann : : json : : string_t > ( ) ; <nl> - return h ( j . dump ( ) ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / / specialization for std : : less < value_t > <nl> - / / / @ note : do not remove the space after ' < ' , <nl> - / / / see https : / / github . com / nlohmann / json / pull / 679 <nl> - template < > <nl> - struct less < : : nlohmann : : detail : : value_t > <nl> - { <nl> - / * ! <nl> - @ brief compare two value_t enum values <nl> - @ since version 3 . 0 . 0 <nl> - * / <nl> - bool operator ( ) ( nlohmann : : detail : : value_t lhs , <nl> - nlohmann : : detail : : value_t rhs ) const noexcept <nl> - { <nl> - return nlohmann : : detail : : operator < ( lhs , rhs ) ; <nl> - } <nl> - } ; <nl> - <nl> - } / / namespace std <nl> - <nl> - / * ! <nl> - @ brief user - defined string literal for JSON values <nl> - <nl> - This operator implements a user - defined string literal for JSON objects . It <nl> - can be used by adding ` " _json " ` to a string literal and returns a JSON object <nl> - if no parse error occurred . <nl> - <nl> - @ param [ in ] s a string representation of a JSON object <nl> - @ param [ in ] n the length of string @ a s <nl> - @ return a JSON object <nl> - <nl> - @ since version 1 . 0 . 0 <nl> - * / <nl> - inline nlohmann : : json operator " " _json ( const char * s , std : : size_t n ) <nl> - { <nl> - return nlohmann : : json : : parse ( s , s + n ) ; <nl> - } <nl> - <nl> - / * ! <nl> - @ brief user - defined string literal for JSON pointer <nl> - <nl> - This operator implements a user - defined string literal for JSON Pointers . It <nl> - can be used by adding ` " _json_pointer " ` to a string literal and returns a JSON pointer <nl> - object if no parse error occurred . <nl> - <nl> - @ param [ in ] s a string representation of a JSON Pointer <nl> - @ param [ in ] n the length of string @ a s <nl> - @ return a JSON pointer object <nl> - <nl> - @ since version 2 . 0 . 0 <nl> - * / <nl> - inline nlohmann : : json : : json_pointer operator " " _json_pointer ( const char * s , std : : size_t n ) <nl> - { <nl> - return nlohmann : : json : : json_pointer ( std : : string ( s , n ) ) ; <nl> - } <nl> - <nl> - / / # include < nlohmann / detail / macro_unscope . hpp > <nl> - <nl> - <nl> - / / restore GCC / clang diagnostic settings <nl> - # if defined ( __clang__ ) | | defined ( __GNUC__ ) | | defined ( __GNUG__ ) <nl> - # pragma GCC diagnostic pop <nl> - # endif <nl> - # if defined ( __clang__ ) <nl> - # pragma GCC diagnostic pop <nl> - # endif <nl> - <nl> - / / clean up <nl> - # undef JSON_INTERNAL_CATCH <nl> - # undef JSON_CATCH <nl> - # undef JSON_THROW <nl> - # undef JSON_TRY <nl> - # undef JSON_LIKELY <nl> - # undef JSON_UNLIKELY <nl> - # undef JSON_DEPRECATED <nl> - # undef JSON_HAS_CPP_14 <nl> - # undef JSON_HAS_CPP_17 <nl> - # undef NLOHMANN_BASIC_JSON_TPL_DECLARATION <nl> - # undef NLOHMANN_BASIC_JSON_TPL <nl> - # undef NLOHMANN_JSON_HAS_HELPER <nl> - <nl> - <nl> - # endif <nl> mmm a / include / nlohmann / detail / input / json_sax . hpp <nl> ppp b / include / nlohmann / detail / input / json_sax . hpp <nl> class json_sax_dom_callback_parser <nl> } <nl> else <nl> { <nl> + / / skip this value if we already decided to skip the parent <nl> + / / ( https : / / github . com / nlohmann / json / issues / 971 # issuecomment - 413678360 ) <nl> + if ( not ref_stack . back ( ) ) <nl> + { <nl> + return { false , nullptr } ; <nl> + } <nl> + <nl> assert ( ref_stack . back ( ) - > is_array ( ) or ref_stack . back ( ) - > is_object ( ) ) ; <nl> if ( ref_stack . back ( ) - > is_array ( ) ) <nl> { <nl> mmm a / single_include / nlohmann / json . hpp <nl> ppp b / single_include / nlohmann / json . hpp <nl> class json_sax_dom_callback_parser <nl> } <nl> else <nl> { <nl> + / / skip this value if we already decided to skip the parent <nl> + / / ( https : / / github . com / nlohmann / json / issues / 971 # issuecomment - 413678360 ) <nl> + if ( not ref_stack . back ( ) ) <nl> + { <nl> + return { false , nullptr } ; <nl> + } <nl> + <nl> assert ( ref_stack . back ( ) - > is_array ( ) or ref_stack . back ( ) - > is_object ( ) ) ; <nl> if ( ref_stack . back ( ) - > is_array ( ) ) <nl> { <nl> mmm a / test / src / unit - regression . cpp <nl> ppp b / test / src / unit - regression . cpp <nl> TEST_CASE ( " regression tests " ) <nl> / / " [ json . exception . out_of_range . 408 ] excessive object size : 8658170730974374167 " ) ; <nl> } <nl> <nl> + SECTION ( " issue # 971 - Add a SAX parser - late bug " ) <nl> + { <nl> + / / a JSON text <nl> + auto text = R " ( <nl> + { <nl> + " Image " : { <nl> + " Width " : 800 , <nl> + " Height " : 600 , <nl> + " Title " : " View from 15th Floor " , <nl> + " Thumbnail " : { <nl> + " Url " : " http : / / www . example . com / image / 481989943 " , <nl> + " Height " : 125 , <nl> + " Width " : 100 <nl> + } , <nl> + " Animated " : false , <nl> + " IDs " : [ 116 , 943 , 234 , 38793 ] <nl> + } <nl> + } <nl> + ) " ; <nl> + <nl> + / / define parser callback <nl> + json : : parser_callback_t cb = [ ] ( int depth , json : : parse_event_t event , json & parsed ) <nl> + { <nl> + / / skip object elements with key " Thumbnail " <nl> + if ( event = = json : : parse_event_t : : key and parsed = = json ( " Thumbnail " ) ) <nl> + { <nl> + return false ; <nl> + } <nl> + else <nl> + { <nl> + return true ; <nl> + } <nl> + } ; <nl> + <nl> + / / parse ( with callback ) and serialize JSON <nl> + json j_filtered = json : : parse ( text , cb ) ; <nl> + <nl> + CHECK ( j_filtered = = R " ( { " Image " : { " Animated " : false , " Height " : 600 , " IDs " : [ 116 , 943 , 234 , 38793 ] , " Title " : " View from 15th Floor " , " Width " : 800 } } ) " _json ) ; <nl> + } <nl> + <nl> SECTION ( " issue # 972 - Segmentation fault on G + + when trying to assign json string literal to custom json type " ) <nl> { <nl> my_json foo = R " ( [ 1 , 2 , 3 ] ) " _json ; <nl> TEST_CASE ( " regression tests " ) <nl> switch ( event ) <nl> { <nl> case json : : parse_event_t : : key : <nl> - { <nl> - return true ; <nl> - } <nl> + { <nl> + return true ; <nl> + } <nl> case json : : parse_event_t : : value : <nl> - { <nl> - return false ; <nl> - } <nl> + { <nl> + return false ; <nl> + } <nl> case json : : parse_event_t : : object_start : <nl> - { <nl> - return true ; <nl> - } <nl> + { <nl> + return true ; <nl> + } <nl> case json : : parse_event_t : : object_end : <nl> - { <nl> - return false ; <nl> - } <nl> + { <nl> + return false ; <nl> + } <nl> case json : : parse_event_t : : array_start : <nl> - { <nl> - return true ; <nl> - } <nl> + { <nl> + return true ; <nl> + } <nl> case json : : parse_event_t : : array_end : <nl> - { <nl> - return false ; <nl> - } <nl> + { <nl> + return false ; <nl> + } <nl> <nl> default : <nl> - { <nl> - return true ; <nl> - } <nl> + { <nl> + return true ; <nl> + } <nl> } <nl> } ; <nl> <nl>
|
: bug : fixed callback - related issue ( https : / / github . com / nlohmann / json / issues / 971 # issuecomment - 413678360 )
|
nlohmann/json
|
e33b31e6aae013f011a6711d8e8ebca776b63013
|
2018-08-17T21:09:45Z
|
mmm a / src / sqlitetypes . cpp <nl> ppp b / src / sqlitetypes . cpp <nl> QString Table : : sql ( ) const <nl> if ( pks_found ) <nl> sql + = pk + " ) " ; <nl> } <nl> + <nl> + / / foreign keys <nl> + foreach ( FieldPtr f , m_fields ) <nl> + { <nl> + if ( ! f - > foreignKey ( ) . isEmpty ( ) ) <nl> + sql + = QString ( " , \ n \ tFOREIGN KEY ( ` % 1 ` ) REFERENCES % 2 " ) . arg ( f - > name ( ) ) . arg ( f - > foreignKey ( ) ) ; <nl> + } <nl> + <nl> sql + = " \ n ) " ; <nl> <nl> / / without rowid <nl> Table CreateTableWalker : : table ( ) <nl> } <nl> } <nl> break ; <nl> + case sqlite3TokenTypes : : FOREIGN : <nl> + { <nl> + tc = tc - > getNextSibling ( ) ; / / FOREIGN <nl> + tc = tc - > getNextSibling ( ) ; / / KEY <nl> + tc = tc - > getNextSibling ( ) ; / / LPAREN <nl> + QString column_name = identifier ( tc ) ; <nl> + tc = tc - > getNextSibling ( ) ; / / identifier <nl> + if ( tc - > getType ( ) = = sqlite3TokenTypes : : COMMA ) <nl> + { <nl> + / / No support for composite foreign keys <nl> + m_bModifySupported = false ; <nl> + break ; <nl> + } <nl> + tc = tc - > getNextSibling ( ) ; / / RPAREN <nl> + tc = tc - > getNextSibling ( ) ; / / REFERENCES <nl> + <nl> + tab . fields ( ) . at ( tab . findField ( column_name ) ) - > setForeignKey ( concatTextAST ( tc , true ) ) ; <nl> + } <nl> + break ; <nl> default : <nl> { <nl> m_bModifySupported = false ; <nl> mmm a / src / sqlitetypes . h <nl> ppp b / src / sqlitetypes . h <nl> class Field <nl> void setAutoIncrement ( bool autoinc ) { m_autoincrement = autoinc ; } <nl> void setPrimaryKey ( bool pk ) { m_primaryKey = pk ; } <nl> void setUnique ( bool u ) { m_unique = u ; } <nl> + void setForeignKey ( const QString & key ) { m_foreignKey = key ; } <nl> <nl> bool isText ( ) const ; <nl> bool isInteger ( ) const ; <nl> class Field <nl> bool autoIncrement ( ) const { return m_autoincrement ; } <nl> bool primaryKey ( ) const { return m_primaryKey ; } <nl> bool unique ( ) const { return m_unique ; } <nl> + const QString & foreignKey ( ) const { return m_foreignKey ; } <nl> <nl> static QStringList Datatypes ; <nl> private : <nl> class Field <nl> bool m_notnull ; <nl> QString m_check ; <nl> QString m_defaultvalue ; <nl> + QString m_foreignKey ; / / Even though this information is a table constraint easier for accessing and processing to store it here <nl> bool m_autoincrement ; / / ! this is stored here for simplification <nl> bool m_primaryKey ; <nl> bool m_unique ; <nl>
|
Parse and save foreign key constraints
|
sqlitebrowser/sqlitebrowser
|
f2c3c2b1a4f0d7cb8dbdaef0f891c60a828daf02
|
2014-11-06T17:28:28Z
|
mmm a / osquery / events / darwin / diskarbitration . cpp <nl> ppp b / osquery / events / darwin / diskarbitration . cpp <nl> <nl> # include " osquery / events / darwin / diskarbitration . h " <nl> <nl> namespace fs = boost : : filesystem ; <nl> + namespace errc = boost : : system : : errc ; <nl> <nl> namespace osquery { <nl> <nl> - const std : : string kIOHIDXClassPath = " IOService : / IOResources / IOHDIXController / " ; <nl> + const std : : string kIOHIDXClassPath { " IOService : / IOResources / IOHDIXController / " } ; <nl> <nl> REGISTER ( DiskArbitrationEventPublisher , " event_publisher " , " diskarbitration " ) ; <nl> <nl> void DiskArbitrationEventPublisher : : tearDown ( ) { <nl> } <nl> <nl> void DiskArbitrationEventPublisher : : DiskAppearedCallback ( DADiskRef disk , <nl> - void * context ) { <nl> + void * context ) { <nl> auto ec = createEventContext ( ) ; <nl> <nl> CFDictionaryRef disk_properties = DADiskCopyDescription ( disk ) ; <nl> void DiskArbitrationEventPublisher : : DiskAppearedCallback ( DADiskRef disk , <nl> disk_properties , kDADiskDescriptionMediaWholeKey ) ) ) { <nl> ec - > checksum = extractUdifChecksum ( ec - > path ) ; <nl> } <nl> + } else { <nl> + / / There was no interface location . <nl> + ec - > path = getProperty ( kDADiskDescriptionDevicePathKey , disk_properties ) ; <nl> } <nl> CFRelease ( protocol_properties ) ; <nl> } else { <nl> ec - > path = " " ; <nl> } <nl> <nl> - fire ( " add " , ec , disk_properties ) ; <nl> + if ( ec - > path . find ( " / SSD0 @ 0 " ) = = std : : string : : npos ) { <nl> + / / This is not an internal SSD . <nl> + fire ( " add " , ec , disk_properties ) ; <nl> + } <nl> <nl> CFRelease ( disk_properties ) ; <nl> IOObjectRelease ( entry ) ; <nl> } <nl> <nl> void DiskArbitrationEventPublisher : : DiskDisappearedCallback ( DADiskRef disk , <nl> - void * context ) { <nl> - <nl> + void * context ) { <nl> CFDictionaryRef disk_properties = DADiskCopyDescription ( disk ) ; <nl> fire ( " remove " , createEventContext ( ) , disk_properties ) ; <nl> CFRelease ( disk_properties ) ; <nl> } <nl> <nl> bool DiskArbitrationEventPublisher : : shouldFire ( <nl> - const DiskArbitrationSubscriptionContextRef & sc , <nl> - const DiskArbitrationEventContextRef & ec ) const { <nl> - <nl> + const DiskArbitrationSubscriptionContextRef & sc , <nl> + const DiskArbitrationEventContextRef & ec ) const { <nl> / / We want events for physical disks as well <nl> if ( sc - > physical_disks ) { <nl> return true ; <nl> } else { <nl> - / / We want only virtual disk ( DMG ) events <nl> + / / We ' could ' only want only virtual disk ( DMG ) events <nl> if ( ec - > action = = " add " ) { <nl> / / Filter events by matching on Virtual Interface based on IO device path <nl> - return ( boost : : starts_with ( ec - > device_path , kIOHIDXClassPath ) ) ; <nl> + / / return ( boost : : starts_with ( ec - > device_path , kIOHIDXClassPath ) ) ; <nl> + return true ; <nl> } else { <nl> return true ; <nl> } <nl> bool DiskArbitrationEventPublisher : : shouldFire ( <nl> } <nl> <nl> std : : string DiskArbitrationEventPublisher : : extractUdifChecksum ( <nl> - const std : : string & path_str ) { <nl> + const std : : string & path_str ) { <nl> fs : : path path = path_str ; <nl> if ( ! pathExists ( path ) . ok ( ) | | ! isReadable ( path ) . ok ( ) ) { <nl> return " " ; <nl> } <nl> - if ( ! fs : : is_regular_file ( path ) ) { <nl> + <nl> + boost : : system : : error_code ec ; <nl> + if ( ! fs : : is_regular_file ( path , ec ) | | ec . value ( ) ! = errc : : success ) { <nl> return " " ; <nl> } <nl> + <nl> / / The koly trailer ( footer ) is 512 bytes <nl> / / http : / / newosxbook . com / DMG . html <nl> if ( fs : : file_size ( path ) < 512 ) { <nl> std : : string DiskArbitrationEventPublisher : : extractUdifChecksum ( <nl> if ( dmg_file . is_open ( ) ) { <nl> dmg_file . seekg ( - 512L , std : : ios : : end ) ; <nl> <nl> - char * buffer = new char [ 4 ] ; <nl> + char * buffer = new char [ 4 ] ; <nl> dmg_file . read ( buffer , 4 ) ; <nl> std : : string koly_signature ; <nl> koly_signature . assign ( buffer , 4 ) ; <nl> std : : string DiskArbitrationEventPublisher : : extractUdifChecksum ( <nl> <nl> uint32_t checksum_size ; <nl> dmg_file . seekg ( - 156L , std : : ios : : end ) ; <nl> - dmg_file . read ( ( char * ) & checksum_size , sizeof ( checksum_size ) ) ; <nl> + dmg_file . read ( ( char * ) & checksum_size , sizeof ( checksum_size ) ) ; <nl> / / checksum_size is in big endian and we need to byte swap <nl> checksum_size = CFSwapInt32 ( checksum_size ) ; <nl> <nl> dmg_file . seekg ( - 152L , std : : ios : : end ) ; / / checksum offset <nl> - unsigned char * u_buffer = new unsigned char [ checksum_size ] ; <nl> - dmg_file . read ( ( char * ) u_buffer , checksum_size ) ; <nl> + unsigned char * u_buffer = new unsigned char [ checksum_size ] ; <nl> + dmg_file . read ( ( char * ) u_buffer , checksum_size ) ; <nl> / / we don ' t want to byte swap checksum as disk utility / hdiutil doesn ' t <nl> std : : stringstream checksum ; <nl> for ( size_t i = 0 ; i < checksum_size ; i + + ) { <nl> std : : string DiskArbitrationEventPublisher : : extractUdifChecksum ( <nl> } <nl> <nl> void DiskArbitrationEventPublisher : : fire ( <nl> - const std : : string & action , <nl> - const DiskArbitrationEventContextRef & ec , <nl> - const CFDictionaryRef & dict ) { <nl> - <nl> + const std : : string & action , <nl> + const DiskArbitrationEventContextRef & ec , <nl> + const CFDictionaryRef & dict ) { <nl> ec - > action = action ; <nl> ec - > name = getProperty ( kDADiskDescriptionMediaNameKey , dict ) ; <nl> - ec - > bsd_name = getProperty ( kDADiskDescriptionMediaBSDNameKey , dict ) ; <nl> + ec - > device = " / dev / " + getProperty ( kDADiskDescriptionMediaBSDNameKey , dict ) ; <nl> ec - > uuid = getProperty ( kDADiskDescriptionVolumeUUIDKey , dict ) ; <nl> ec - > size = getProperty ( kDADiskDescriptionMediaSizeKey , dict ) ; <nl> - ec - > ejectable = getProperty ( kDADiskDescriptionMediaEjectableKey , dict ) ; <nl> + ec - > ejectable = getProperty ( kDADiskDescriptionMediaRemovableKey , dict ) ; <nl> ec - > mountable = getProperty ( kDADiskDescriptionVolumeMountableKey , dict ) ; <nl> ec - > writable = getProperty ( kDADiskDescriptionMediaWritableKey , dict ) ; <nl> ec - > content = getProperty ( kDADiskDescriptionMediaContentKey , dict ) ; <nl> void DiskArbitrationEventPublisher : : fire ( <nl> ec - > vendor = getProperty ( kDADiskDescriptionDeviceVendorKey , dict ) ; <nl> ec - > filesystem = getProperty ( kDADiskDescriptionVolumeKindKey , dict ) ; <nl> ec - > disk_appearance_time = getProperty ( CFSTR ( kDAAppearanceTime_ ) , dict ) ; <nl> + if ( ec - > path . find ( " IOService : / " ) = = 0 ) { <nl> + ec - > path = ec - > device ; <nl> + } <nl> <nl> EventFactory : : fire < DiskArbitrationEventPublisher > ( ec ) ; <nl> } <nl> <nl> std : : string DiskArbitrationEventPublisher : : getProperty ( <nl> - const CFStringRef & property , const CFDictionaryRef & dict ) { <nl> + const CFStringRef & property , const CFDictionaryRef & dict ) { <nl> CFTypeRef value = ( CFTypeRef ) CFDictionaryGetValue ( dict , property ) ; <nl> if ( value = = nullptr ) { <nl> return " " ; <nl> mmm a / osquery / events / darwin / diskarbitration . h <nl> ppp b / osquery / events / darwin / diskarbitration . h <nl> struct DiskArbitrationEventContext : public EventContext { <nl> std : : string path ; <nl> std : : string device_path ; <nl> std : : string name ; <nl> - std : : string bsd_name ; <nl> + std : : string device ; <nl> std : : string uuid ; <nl> std : : string size ; <nl> std : : string ejectable ; <nl> class DiskArbitrationEventPublisher <nl> <nl> void tearDown ( ) override ; <nl> <nl> - bool shouldFire ( const DiskArbitrationSubscriptionContextRef & sc , <nl> - const DiskArbitrationEventContextRef & ec ) const override ; <nl> + bool shouldFire ( const DiskArbitrationSubscriptionContextRef & sc , <nl> + const DiskArbitrationEventContextRef & ec ) const override ; <nl> <nl> Status run ( ) override ; <nl> <nl> - static void DiskAppearedCallback ( DADiskRef disk , void * context ) ; <nl> + static void DiskAppearedCallback ( DADiskRef disk , void * context ) ; <nl> <nl> - static void DiskDisappearedCallback ( DADiskRef disk , void * context ) ; <nl> + static void DiskDisappearedCallback ( DADiskRef disk , void * context ) ; <nl> <nl> private : <nl> void restart ( ) ; <nl> <nl> void stop ( ) override ; <nl> <nl> - static std : : string getProperty ( const CFStringRef & property , <nl> - const CFDictionaryRef & dict ) ; <nl> + static std : : string getProperty ( const CFStringRef & property , <nl> + const CFDictionaryRef & dict ) ; <nl> <nl> - static std : : string extractUdifChecksum ( const std : : string & path ) ; <nl> + static std : : string extractUdifChecksum ( const std : : string & path ) ; <nl> <nl> - static void fire ( const std : : string & action , <nl> - const DiskArbitrationEventContextRef & ec , <nl> - const CFDictionaryRef & dict ) ; <nl> + static void fire ( const std : : string & action , <nl> + const DiskArbitrationEventContextRef & ec , <nl> + const CFDictionaryRef & dict ) ; <nl> <nl> private : <nl> / / / Disk arbitration session . <nl> mmm a / osquery / tables / events / darwin / disk_events . cpp <nl> ppp b / osquery / tables / events / darwin / disk_events . cpp <nl> Status DiskEventSubscriber : : Callback ( const ECRef & ec , const SCRef & sc ) { <nl> r [ " action " ] = ec - > action ; <nl> r [ " path " ] = ec - > path ; <nl> r [ " name " ] = ec - > name ; <nl> - r [ " bsd_name " ] = " / dev / " + ec - > bsd_name ; <nl> + r [ " device " ] = ec - > device ; <nl> r [ " uuid " ] = ec - > uuid ; <nl> r [ " size " ] = ec - > size ; <nl> r [ " ejectable " ] = ec - > ejectable ; <nl> mmm a / specs / darwin / disk_events . table <nl> ppp b / specs / darwin / disk_events . table <nl> schema ( [ <nl> Column ( " action " , TEXT , " Appear or disappear " ) , <nl> Column ( " path " , TEXT , " Path of the DMG file accessed " ) , <nl> Column ( " name " , TEXT , " Disk event name " ) , <nl> - Column ( " bsd_name " , TEXT , " Disk event BSD name " ) , <nl> + Column ( " device " , TEXT , " Disk event BSD name " , <nl> + aliases = [ " bsd_name " ] ) , <nl> Column ( " uuid " , TEXT , " UUID of the volume inside DMG if available " ) , <nl> Column ( " size " , BIGINT , " Size of partition in bytes " ) , <nl> Column ( " ejectable " , INTEGER , " 1 if ejectable , 0 if not " ) , <nl>
|
darwin : Improve disk_events add detection ( )
|
osquery/osquery
|
9ba0edb4bb5d060edcf644418480420503c85569
|
2017-05-26T17:38:26Z
|
mmm a / test / core / end2end / tests / bad_ping . c <nl> ppp b / test / core / end2end / tests / bad_ping . c <nl> static void test_bad_ping ( grpc_end2end_test_config config ) { <nl> . value . integer = 300000 / * 5 minutes * / } , <nl> { . type = GRPC_ARG_INTEGER , <nl> . key = GRPC_ARG_HTTP2_MAX_PING_STRIKES , <nl> - . value . integer = MAX_PING_STRIKES } } ; <nl> + . value . integer = MAX_PING_STRIKES } , <nl> + { . type = GRPC_ARG_INTEGER , <nl> + . key = GRPC_ARG_HTTP2_BDP_PROBE , <nl> + . value . integer = 0 } } ; <nl> grpc_channel_args client_args = { . num_args = GPR_ARRAY_SIZE ( client_a ) , <nl> . args = client_a } ; <nl> grpc_channel_args server_args = { . num_args = GPR_ARRAY_SIZE ( server_a ) , <nl>
|
Merge pull request from y - zeng / fix_bad_ping
|
grpc/grpc
|
8bec6a93163861e467005a23c997eb93b793710b
|
2017-06-26T18:17:28Z
|
mmm a / libraries / chain / include / eosio / chain / block_state . hpp <nl> ppp b / libraries / chain / include / eosio / chain / block_state . hpp <nl> namespace eosio { namespace chain { <nl> <nl> } } / / / namespace eosio : : chain <nl> <nl> - FC_REFLECT_DERIVED ( eosio : : chain : : block_state , ( eosio : : chain : : block_header_state ) , ( block ) ( validated ) ) <nl> + FC_REFLECT_DERIVED ( eosio : : chain : : block_state , ( eosio : : chain : : block_header_state ) , ( block ) ( validated ) ( in_current_chain ) ) <nl>
|
Merge pull request from harrywong / master
|
EOSIO/eos
|
7fc813ca9b542786af7683b6fbb46747a59f261d
|
2018-05-14T18:34:43Z
|
mmm a / NEWS . md <nl> ppp b / NEWS . md <nl> <nl> <nl> # # Beta <nl> <nl> - - Changed event code format to decimal number from hex on EventViewer . <nl> + - Event code format on EventViewer changed to decimal number from hex . <nl> <nl> # # Version 12 . 3 . 0 <nl> <nl>
|
update NEWS
|
pqrs-org/Karabiner-Elements
|
30cb2cb468d3cbd5b682c8bc92d9981c334c892f
|
2019-04-25T06:02:33Z
|
mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> medium_kernel_test_list = glob ( [ <nl> sharded_kernel_test_list = glob ( [ <nl> " kernel_tests / cwise_ops_test . py " , <nl> " kernel_tests / linalg_grad_test . py " , <nl> - " kernel_tests / pooling_ops_test . py " , <nl> ] ) <nl> <nl> cpu_only_kernel_test_list = glob ( [ <nl> mmm a / tensorflow / python / kernel_tests / pooling_ops_test . py <nl> ppp b / tensorflow / python / kernel_tests / pooling_ops_test . py <nl> def NHWCToNCHW ( input_tensor ) : <nl> <nl> Args : <nl> input_tensor : a 4 - D tensor , or a 4 - element array representing the same . <nl> + <nl> Returns : <nl> the converted tensor or a shape array <nl> " " " <nl> def NCHWToNHWC ( input_tensor ) : <nl> <nl> Args : <nl> input_tensor : a 4 - D tensor , or a 4 - element array representing the same . <nl> + <nl> Returns : <nl> the converted tensor or a shape array <nl> " " " <nl> def GetTestConfigs ( ) : <nl> return test_configs <nl> <nl> <nl> - def GetInceptionMaxPoolShapes ( ) : <nl> + def GetShrunkInceptionMaxPoolShapes ( shrink = 30 ) : <nl> " " " Iterator for some of the max pool ops in the Inception 2015 model . <nl> <nl> + Args : <nl> + shrink : Factor to shrink depth relative to Inception . <nl> + <nl> Yields : <nl> Tuple ( name , input_size , filter_size , out_size , strides , padding ) <nl> " " " <nl> def GetInceptionMaxPoolShapes ( ) : <nl> [ 32 , 8 , 8 , 1248 ] , [ 32 , 8 , 8 , 2048 ] ] <nl> strides = [ [ 1 , 2 , 2 , 1 ] , [ 1 , 2 , 2 , 1 ] , [ 1 , 2 , 2 , 1 ] , <nl> [ 1 , 1 , 1 , 1 ] ] <nl> + # Shrink each depth value <nl> + for i in input_sizes : <nl> + i [ 3 ] / / = shrink <nl> + for o in output_sizes : <nl> + o [ 3 ] / / = shrink <nl> paddings = [ " VALID " , " VALID " , " VALID " , " SAME " ] <nl> for n , i , f , o , s , p in zip ( names , input_sizes , filter_sizes , output_sizes , <nl> strides , paddings ) : <nl> def _ConstructAndTestGradient ( self , pool_func , input_sizes , output_sizes , <nl> use_gpu : whether we are running on GPU <nl> x_init_value : Values to be passed to the gradient checker . <nl> " " " <nl> + assert input_sizes [ 0 ] = = output_sizes [ 0 ] <nl> + assert input_sizes [ 3 ] = = output_sizes [ 3 ] <nl> total_size = 1 <nl> for s in input_sizes : <nl> total_size * = s <nl> def Test ( self ) : <nl> <nl> if __name__ = = " __main__ " : <nl> for ( name_ , input_size_ , filter_size_ , output_size_ , stride_ , <nl> - padding_ ) in GetInceptionMaxPoolShapes ( ) : <nl> + padding_ ) in GetShrunkInceptionMaxPoolShapes ( ) : <nl> setattr ( PoolingTest , " testMaxPoolFwd_ " + name_ , <nl> GetMaxPoolFwdTest ( input_size_ , filter_size_ , stride_ , padding_ ) ) <nl> setattr ( PoolingTest , " testMaxPoolGrad_ " + name_ , <nl>
|
Shrink pooling_ops_test and unshard
|
tensorflow/tensorflow
|
0663ed111abce98a22d8311a122313df11acde68
|
2016-03-22T22:25:05Z
|
mmm a / hphp / runtime / vm / jit / back - end - x64 . cpp <nl> ppp b / hphp / runtime / vm / jit / back - end - x64 . cpp <nl> struct BackEnd final : jit : : BackEnd { <nl> * when we call it from C + + , we have to tell gcc to clobber all the other <nl> * callee - saved registers . <nl> * / <nl> + # if defined ( __CYGWIN__ ) | | defined ( __MINGW__ ) <nl> + # define CALLEE_SAVED_BARRIER ( ) \ <nl> + asm volatile ( " " : : : " rbx " , " rsi " , " rdi " , " r12 " , " r13 " , " r14 " , " r15 " ) ; <nl> + # else <nl> # define CALLEE_SAVED_BARRIER ( ) \ <nl> asm volatile ( " " : : : " rbx " , " r12 " , " r13 " , " r14 " , " r15 " ) ; <nl> + # endif <nl> <nl> / * <nl> * enterTCHelper is a handwritten assembly function that transfers control in <nl>
|
Add callee saved registers for the barrier on Windows .
|
facebook/hhvm
|
779408eeea7d5dbaff8bb19a756b09d08c2e886e
|
2015-07-16T19:32:21Z
|
mmm a / src / gui / optionsdialog . cpp <nl> ppp b / src / gui / optionsdialog . cpp <nl> bool OptionsDialog : : isAlternativeWebUIPathValid ( ) <nl> <nl> void OptionsDialog : : on_banListButton_clicked ( ) <nl> { <nl> - / / call dialog window <nl> - if ( BanListOptionsDialog ( this ) . exec ( ) = = QDialog : : Accepted ) <nl> - enableApplyButton ( ) ; <nl> + auto dialog = new BanListOptionsDialog ( this ) ; <nl> + dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + connect ( dialog , & QDialog : : accepted , this , & OptionsDialog : : enableApplyButton ) ; <nl> + dialog - > open ( ) ; <nl> } <nl> <nl> void OptionsDialog : : on_IPSubnetWhitelistButton_clicked ( ) <nl> { <nl> - / / call dialog window <nl> - if ( IPSubnetWhitelistOptionsDialog ( this ) . exec ( ) = = QDialog : : Accepted ) <nl> - enableApplyButton ( ) ; <nl> + auto dialog = new IPSubnetWhitelistOptionsDialog ( this ) ; <nl> + dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + connect ( dialog , & QDialog : : accepted , this , & OptionsDialog : : enableApplyButton ) ; <nl> + dialog - > open ( ) ; <nl> } <nl> mmm a / src / gui / search / searchjobwidget . cpp <nl> ppp b / src / gui / search / searchjobwidget . cpp <nl> void SearchJobWidget : : saveSettings ( ) const <nl> Preferences : : instance ( ) - > setSearchTabHeaderState ( header ( ) - > saveState ( ) ) ; <nl> } <nl> <nl> - void SearchJobWidget : : displayToggleColumnsMenu ( const QPoint & ) <nl> + void SearchJobWidget : : displayToggleColumnsMenu ( const QPoint & ) <nl> { <nl> - QMenu hideshowColumn ( this ) ; <nl> - hideshowColumn . setTitle ( tr ( " Column visibility " ) ) ; <nl> - QList < QAction * > actions ; <nl> + auto menu = new QMenu ( this ) ; <nl> + menu - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + menu - > setTitle ( tr ( " Column visibility " ) ) ; <nl> + <nl> for ( int i = 0 ; i < SearchSortModel : : DL_LINK ; + + i ) { <nl> - QAction * myAct = hideshowColumn . addAction ( m_searchListModel - > headerData ( i , Qt : : Horizontal , Qt : : DisplayRole ) . toString ( ) ) ; <nl> + QAction * myAct = menu - > addAction ( m_searchListModel - > headerData ( i , Qt : : Horizontal , Qt : : DisplayRole ) . toString ( ) ) ; <nl> myAct - > setCheckable ( true ) ; <nl> myAct - > setChecked ( ! m_ui - > resultsBrowser - > isColumnHidden ( i ) ) ; <nl> - actions . append ( myAct ) ; <nl> + myAct - > setData ( i ) ; <nl> } <nl> - int visibleCols = 0 ; <nl> - for ( int i = 0 ; i < SearchSortModel : : DL_LINK ; + + i ) { <nl> - if ( ! m_ui - > resultsBrowser - > isColumnHidden ( i ) ) <nl> - + + visibleCols ; <nl> <nl> - if ( visibleCols > 1 ) <nl> - break ; <nl> - } <nl> + connect ( menu , & QMenu : : triggered , this , [ this ] ( const QAction * action ) <nl> + { <nl> + int visibleCols = 0 ; <nl> + for ( int i = 0 ; i < SearchSortModel : : DL_LINK ; + + i ) { <nl> + if ( ! m_ui - > resultsBrowser - > isColumnHidden ( i ) ) <nl> + + + visibleCols ; <nl> + <nl> + if ( visibleCols > 1 ) <nl> + break ; <nl> + } <nl> + <nl> + const int col = action - > data ( ) . toInt ( ) ; <nl> <nl> - / / Call menu <nl> - QAction * act = hideshowColumn . exec ( QCursor : : pos ( ) ) ; <nl> - if ( act ) { <nl> - int col = actions . indexOf ( act ) ; <nl> - Q_ASSERT ( col > = 0 ) ; <nl> - Q_ASSERT ( visibleCols > 0 ) ; <nl> if ( ( ! m_ui - > resultsBrowser - > isColumnHidden ( col ) ) & & ( visibleCols = = 1 ) ) <nl> return ; <nl> + <nl> m_ui - > resultsBrowser - > setColumnHidden ( col , ! m_ui - > resultsBrowser - > isColumnHidden ( col ) ) ; <nl> + <nl> if ( ( ! m_ui - > resultsBrowser - > isColumnHidden ( col ) ) & & ( m_ui - > resultsBrowser - > columnWidth ( col ) < = 5 ) ) <nl> m_ui - > resultsBrowser - > resizeColumnToContents ( col ) ; <nl> + <nl> saveSettings ( ) ; <nl> - } <nl> + } ) ; <nl> + <nl> + menu - > popup ( QCursor : : pos ( ) ) ; <nl> } <nl> <nl> void SearchJobWidget : : searchFinished ( bool cancelled ) <nl> mmm a / src / gui / search / searchjobwidget . h <nl> ppp b / src / gui / search / searchjobwidget . h <nl> class SearchJobWidget : public QWidget <nl> void updateFilter ( ) ; <nl> void filterSearchResults ( const QString & name ) ; <nl> void showFilterContextMenu ( const QPoint & ) ; <nl> - void displayToggleColumnsMenu ( const QPoint & ) ; <nl> + void displayToggleColumnsMenu ( const QPoint & ) ; <nl> void onItemDoubleClicked ( const QModelIndex & index ) ; <nl> void searchFinished ( bool cancelled ) ; <nl> void searchFailed ( ) ; <nl> mmm a / src / gui / torrentcategorydialog . cpp <nl> ppp b / src / gui / torrentcategorydialog . cpp <nl> void TorrentCategoryDialog : : editCategory ( QWidget * parent , const QString & categor <nl> <nl> Q_ASSERT ( Session : : instance ( ) - > categories ( ) . contains ( categoryName ) ) ; <nl> <nl> - TorrentCategoryDialog dialog ( parent ) ; <nl> - dialog . setCategoryNameEditable ( false ) ; <nl> - dialog . setCategoryName ( categoryName ) ; <nl> - dialog . setSavePath ( Session : : instance ( ) - > categories ( ) [ categoryName ] ) ; <nl> - if ( dialog . exec ( ) = = TorrentCategoryDialog : : Accepted ) { <nl> - Session : : instance ( ) - > editCategory ( categoryName , dialog . savePath ( ) ) ; <nl> - } <nl> + auto dialog = new TorrentCategoryDialog ( parent ) ; <nl> + dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + dialog - > setCategoryNameEditable ( false ) ; <nl> + dialog - > setCategoryName ( categoryName ) ; <nl> + dialog - > setSavePath ( Session : : instance ( ) - > categories ( ) [ categoryName ] ) ; <nl> + connect ( dialog , & TorrentCategoryDialog : : accepted , parent , [ dialog , categoryName ] ( ) <nl> + { <nl> + Session : : instance ( ) - > editCategory ( categoryName , dialog - > savePath ( ) ) ; <nl> + } ) ; <nl> + dialog - > open ( ) ; <nl> } <nl> <nl> void TorrentCategoryDialog : : setCategoryNameEditable ( bool editable ) <nl> mmm a / src / gui / transferlistwidget . cpp <nl> ppp b / src / gui / transferlistwidget . cpp <nl> void TransferListWidget : : setMaxRatioSelectedTorrents ( ) <nl> useGlobalValue = ( torrents [ 0 ] - > ratioLimit ( ) = = BitTorrent : : TorrentHandle : : USE_GLOBAL_RATIO ) <nl> & & ( torrents [ 0 ] - > seedingTimeLimit ( ) = = BitTorrent : : TorrentHandle : : USE_GLOBAL_SEEDING_TIME ) ; <nl> <nl> - UpDownRatioDialog dlg ( useGlobalValue , currentMaxRatio , BitTorrent : : TorrentHandle : : MAX_RATIO , <nl> + auto dialog = new UpDownRatioDialog ( useGlobalValue , currentMaxRatio , BitTorrent : : TorrentHandle : : MAX_RATIO , <nl> currentMaxSeedingTime , BitTorrent : : TorrentHandle : : MAX_SEEDING_TIME , this ) ; <nl> - if ( dlg . exec ( ) ! = QDialog : : Accepted ) return ; <nl> - <nl> - for ( BitTorrent : : TorrentHandle * const torrent : torrents ) { <nl> - qreal ratio = ( dlg . useDefault ( ) ? BitTorrent : : TorrentHandle : : USE_GLOBAL_RATIO : dlg . ratio ( ) ) ; <nl> - torrent - > setRatioLimit ( ratio ) ; <nl> - <nl> - int seedingTime = ( dlg . useDefault ( ) ? BitTorrent : : TorrentHandle : : USE_GLOBAL_SEEDING_TIME : dlg . seedingTime ( ) ) ; <nl> - torrent - > setSeedingTimeLimit ( seedingTime ) ; <nl> - } <nl> + dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + connect ( dialog , & QDialog : : accepted , this , [ this , dialog , torrents ] ( ) <nl> + { <nl> + for ( BitTorrent : : TorrentHandle * const torrent : torrents ) { <nl> + const qreal ratio = ( dialog - > useDefault ( ) <nl> + ? BitTorrent : : TorrentHandle : : USE_GLOBAL_RATIO : dialog - > ratio ( ) ) ; <nl> + torrent - > setRatioLimit ( ratio ) ; <nl> + <nl> + const int seedingTime = ( dialog - > useDefault ( ) <nl> + ? BitTorrent : : TorrentHandle : : USE_GLOBAL_SEEDING_TIME : dialog - > seedingTime ( ) ) ; <nl> + torrent - > setSeedingTimeLimit ( seedingTime ) ; <nl> + } <nl> + } ) ; <nl> + dialog - > open ( ) ; <nl> } <nl> <nl> void TransferListWidget : : recheckSelectedTorrents ( ) <nl> void TransferListWidget : : reannounceSelectedTorrents ( ) <nl> / / hide / show columns menu <nl> void TransferListWidget : : displayDLHoSMenu ( const QPoint & ) <nl> { <nl> - QMenu hideshowColumn ( this ) ; <nl> - hideshowColumn . setTitle ( tr ( " Column visibility " ) ) ; <nl> - QList < QAction * > actions ; <nl> + auto menu = new QMenu ( this ) ; <nl> + menu - > setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> + menu - > setTitle ( tr ( " Column visibility " ) ) ; <nl> + <nl> for ( int i = 0 ; i < m_listModel - > columnCount ( ) ; + + i ) { <nl> - if ( ! BitTorrent : : Session : : instance ( ) - > isQueueingSystemEnabled ( ) & & ( i = = TransferListModel : : TR_PRIORITY ) ) { <nl> - actions . append ( nullptr ) ; <nl> + if ( ! BitTorrent : : Session : : instance ( ) - > isQueueingSystemEnabled ( ) & & ( i = = TransferListModel : : TR_PRIORITY ) ) <nl> continue ; <nl> - } <nl> - QAction * myAct = hideshowColumn . addAction ( m_listModel - > headerData ( i , Qt : : Horizontal , Qt : : DisplayRole ) . toString ( ) ) ; <nl> + <nl> + QAction * myAct = menu - > addAction ( m_listModel - > headerData ( i , Qt : : Horizontal , Qt : : DisplayRole ) . toString ( ) ) ; <nl> myAct - > setCheckable ( true ) ; <nl> myAct - > setChecked ( ! isColumnHidden ( i ) ) ; <nl> - actions . append ( myAct ) ; <nl> + myAct - > setData ( i ) ; <nl> } <nl> - int visibleCols = 0 ; <nl> - for ( int i = 0 ; i < TransferListModel : : NB_COLUMNS ; + + i ) { <nl> - if ( ! isColumnHidden ( i ) ) <nl> - + + visibleCols ; <nl> <nl> - if ( visibleCols > 1 ) <nl> - break ; <nl> - } <nl> + connect ( menu , & QMenu : : triggered , this , [ this ] ( const QAction * action ) <nl> + { <nl> + int visibleCols = 0 ; <nl> + for ( int i = 0 ; i < TransferListModel : : NB_COLUMNS ; + + i ) { <nl> + if ( ! isColumnHidden ( i ) ) <nl> + + + visibleCols ; <nl> + <nl> + if ( visibleCols > 1 ) <nl> + break ; <nl> + } <nl> + <nl> + const int col = action - > data ( ) . toInt ( ) ; <nl> <nl> - / / Call menu <nl> - QAction * act = hideshowColumn . exec ( QCursor : : pos ( ) ) ; <nl> - if ( act ) { <nl> - int col = actions . indexOf ( act ) ; <nl> - Q_ASSERT ( col > = 0 ) ; <nl> - Q_ASSERT ( visibleCols > 0 ) ; <nl> if ( ! isColumnHidden ( col ) & & visibleCols = = 1 ) <nl> return ; <nl> + <nl> setColumnHidden ( col , ! isColumnHidden ( col ) ) ; <nl> + <nl> if ( ! isColumnHidden ( col ) & & columnWidth ( col ) < = 5 ) <nl> resizeColumnToContents ( col ) ; <nl> + <nl> saveSettings ( ) ; <nl> - } <nl> + } ) ; <nl> + <nl> + menu - > popup ( QCursor : : pos ( ) ) ; <nl> } <nl> <nl> void TransferListWidget : : toggleSelectedTorrentsSuperSeeding ( ) const <nl>
|
Merge pull request from Chocobo1 / exec
|
qbittorrent/qBittorrent
|
17c601e8b8fb6cfe8e48ac72c2e084a96d34ebdc
|
2019-06-22T03:24:20Z
|
mmm a / src / fsck / checker . cc <nl> ppp b / src / fsck / checker . cc <nl> bool check_static_config ( nondirect_file_t * file , file_knowledge * knog , static_co <nl> return true ; <nl> } <nl> <nl> - std : : string extract_static_config_flags ( direct_file_t * file , file_knowledge * knog ) { <nl> + std : : string extract_static_config_flags ( nondirect_file_t * file , UNUSED file_knowledge * knog ) { <nl> block header ; <nl> header . init ( DEVICE_BLOCK_SIZE , file , 0 ) ; <nl> static_header_t * buf = ptr_cast < static_header_t > ( header . realbuf ) ; <nl> void print_interfile_summary ( const multiplexer_config_block_t & c , const mc_confi <nl> printf ( " config_block n_log_blocks : % d \ n " , mcc . cache . n_patch_log_blocks ) ; <nl> } <nl> <nl> - std : : string extract_slices_flags ( const serializer_config_block_t & c ) { <nl> + std : : string extract_slices_flags ( const multiplexer_config_block_t & c ) { <nl> char flags [ 100 ] ; <nl> - snprintf ( flags , 100 , " - s % d " , c . btree_config . n_slices ) ; <nl> + snprintf ( flags , 100 , " - s % d " , c . n_proxies ) ; <nl> return std : : string ( flags ) ; <nl> } <nl> <nl> bool check_files ( const config_t & cfg ) { <nl> } <nl> <nl> if ( ! cfg . print_command_line ) { <nl> - print_interfile_summary ( * knog . file_knog [ 0 ] - > config_block ) ; <nl> + print_interfile_summary ( * knog . file_knog [ 0 ] - > config_block , * knog . file_knog [ 0 ] - > mc_config_block ) ; <nl> <nl> / / A thread for every slice . <nl> - int n_slices = knog . file_knog [ 0 ] - > config_block - > btree_config . n_slices ; <nl> + int n_slices = knog . file_knog [ 0 ] - > config_block - > n_proxies ; <nl> std : : vector < pthread_t > threads ( n_slices ) ; <nl> all_slices_errors slices_errs ( n_slices ) ; <nl> for ( int i = 0 ; i < num_files ; + + i ) { <nl> - launch_check_after_config_block ( knog . files [ i ] , threads , knog . file_knog [ i ] , & slices_errs ) ; <nl> + launch_check_after_config_block ( knog . files [ i ] , threads , knog . file_knog [ i ] , & slices_errs , cfg ) ; <nl> } <nl> <nl> / / Wait for all threads to finish . <nl> mmm a / src / fsck / checker . hpp <nl> ppp b / src / fsck / checker . hpp <nl> struct config_t { <nl> std : : string log_file_name ; <nl> bool ignore_diff_log ; <nl> <nl> - config_t ( ) { <nl> - / / Default values <nl> - ignore_diff_log = false ; <nl> - } <nl> bool print_command_line ; <nl> <nl> - config_t ( ) : print_command_line ( false ) { } <nl> + config_t ( ) : ignore_diff_log ( false ) , print_command_line ( false ) { } <nl> } ; <nl> <nl> bool check_files ( const config_t & config ) ; <nl>
|
Making command line extraction work .
|
rethinkdb/rethinkdb
|
d9610302457655fb8158c7466656352081f6eb67
|
2011-05-10T00:28:38Z
|
mmm a / Marlin / Configuration . h <nl> ppp b / Marlin / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / Configuration_adv . h <nl> ppp b / Marlin / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / Marlin . cpp <nl> ppp b / Marlin / src / Marlin . cpp <nl> millis_t max_inactive_time , / / = 0 <nl> stepper_inactive_time = ( DEFAULT_STEPPER_DEACTIVE_TIME ) * 1000UL ; <nl> <nl> # if PIN_EXISTS ( CHDK ) <nl> - extern bool chdk_active ; <nl> extern millis_t chdk_timeout ; <nl> # endif <nl> <nl> void manage_inactivity ( const bool ignore_stepper_queue / * = false * / ) { <nl> } <nl> <nl> # if PIN_EXISTS ( CHDK ) / / Check if pin should be set to LOW ( after M240 set it HIGH ) <nl> - if ( chdk_active & & ELAPSED ( ms , chdk_timeout ) ) { <nl> - chdk_active = false ; <nl> + if ( chdk_timeout & & ELAPSED ( ms , chdk_timeout ) ) { <nl> + chdk_timeout = 0 ; <nl> WRITE ( CHDK_PIN , LOW ) ; <nl> } <nl> # endif <nl> mmm a / Marlin / src / config / default / Configuration . h <nl> ppp b / Marlin / src / config / default / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / default / Configuration_adv . h <nl> ppp b / Marlin / src / config / default / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / 3DFabXYZ / Migbot / Configuration . h <nl> ppp b / Marlin / src / config / examples / 3DFabXYZ / Migbot / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / 3DFabXYZ / Migbot / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / 3DFabXYZ / Migbot / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / AlephObjects / TAZ4 / Configuration . h <nl> ppp b / Marlin / src / config / examples / AlephObjects / TAZ4 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / AlephObjects / TAZ4 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / AlephObjects / TAZ4 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / AliExpress / CL - 260 / Configuration . h <nl> ppp b / Marlin / src / config / examples / AliExpress / CL - 260 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Anet / A2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Anet / A2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Anet / A2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Anet / A2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Anet / A2plus / Configuration . h <nl> ppp b / Marlin / src / config / examples / Anet / A2plus / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Anet / A2plus / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Anet / A2plus / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Anet / A6 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Anet / A6 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Anet / A6 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Anet / A6 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Anet / A8 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Anet / A8 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Anet / A8 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Anet / A8 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / AnyCubic / i3 / Configuration . h <nl> ppp b / Marlin / src / config / examples / AnyCubic / i3 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / AnyCubic / i3 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / AnyCubic / i3 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / ArmEd / Configuration . h <nl> ppp b / Marlin / src / config / examples / ArmEd / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / ArmEd / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / ArmEd / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Azteeg / X5GT / Configuration . h <nl> ppp b / Marlin / src / config / examples / Azteeg / X5GT / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BIBO / TouchX / cyclops / Configuration . h <nl> ppp b / Marlin / src / config / examples / BIBO / TouchX / cyclops / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BIBO / TouchX / cyclops / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / BIBO / TouchX / cyclops / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / BIBO / TouchX / default / Configuration . h <nl> ppp b / Marlin / src / config / examples / BIBO / TouchX / default / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BIBO / TouchX / default / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / BIBO / TouchX / default / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / BQ / Hephestos / Configuration . h <nl> ppp b / Marlin / src / config / examples / BQ / Hephestos / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BQ / Hephestos / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / BQ / Hephestos / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / BQ / Hephestos_2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / BQ / Hephestos_2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BQ / Hephestos_2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / BQ / Hephestos_2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / BQ / WITBOX / Configuration . h <nl> ppp b / Marlin / src / config / examples / BQ / WITBOX / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / BQ / WITBOX / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / BQ / WITBOX / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Cartesio / Configuration . h <nl> ppp b / Marlin / src / config / examples / Cartesio / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Cartesio / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Cartesio / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10S / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10S / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10S / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10S / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10mini / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10mini / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / CR - 10mini / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 10mini / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / CR - 8 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 8 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / CR - 8 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / CR - 8 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 3 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 3 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 3 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 3 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 4 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 4 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Creality / Ender - 4 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Creality / Ender - 4 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Einstart - S / Configuration . h <nl> ppp b / Marlin / src / config / examples / Einstart - S / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Einstart - S / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Einstart - S / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Felix / Configuration . h <nl> ppp b / Marlin / src / config / examples / Felix / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Felix / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Felix / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Felix / DUAL / Configuration . h <nl> ppp b / Marlin / src / config / examples / Felix / DUAL / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / FlashForge / CreatorPro / Configuration . h <nl> ppp b / Marlin / src / config / examples / FlashForge / CreatorPro / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / FlashForge / CreatorPro / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / FlashForge / CreatorPro / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / FolgerTech / i3 - 2020 / Configuration . h <nl> ppp b / Marlin / src / config / examples / FolgerTech / i3 - 2020 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / FolgerTech / i3 - 2020 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / FolgerTech / i3 - 2020 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Formbot / Raptor / Configuration . h <nl> ppp b / Marlin / src / config / examples / Formbot / Raptor / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Formbot / Raptor / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Formbot / Raptor / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Formbot / T_Rex_2 + / Configuration . h <nl> ppp b / Marlin / src / config / examples / Formbot / T_Rex_2 + / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Formbot / T_Rex_2 + / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Formbot / T_Rex_2 + / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Formbot / T_Rex_3 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Formbot / T_Rex_3 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Formbot / T_Rex_3 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Formbot / T_Rex_3 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Geeetech / A10M / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / A10M / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Geeetech / A10M / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Geeetech / A10M / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Geeetech / A20M / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / A20M / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Geeetech / A20M / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Geeetech / A20M / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Geeetech / GT2560 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / GT2560 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Geeetech / I3_Pro_X - GT2560 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / I3_Pro_X - GT2560 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Geeetech / MeCreator2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / MeCreator2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Geeetech / MeCreator2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Geeetech / MeCreator2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / bltouch / Configuration . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / bltouch / Configuration . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / bltouch / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / bltouch / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / noprobe / Configuration . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / noprobe / Configuration . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / noprobe / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro B / noprobe / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration_adv . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration_adv . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro C / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration_adv . h b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration_adv . h <nl> mmm a / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Geeetech / Prusa i3 Pro W / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Infitary / i3 - M508 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Infitary / i3 - M508 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Infitary / i3 - M508 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Infitary / i3 - M508 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / JGAurora / A5 / Configuration . h <nl> ppp b / Marlin / src / config / examples / JGAurora / A5 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / JGAurora / A5 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / JGAurora / A5 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / MakerParts / Configuration . h <nl> ppp b / Marlin / src / config / examples / MakerParts / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / MakerParts / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / MakerParts / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Malyan / M150 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Malyan / M150 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Malyan / M150 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Malyan / M150 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Malyan / M200 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Malyan / M200 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Malyan / M200 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Malyan / M200 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Micromake / C1 / basic / Configuration . h <nl> ppp b / Marlin / src / config / examples / Micromake / C1 / basic / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Micromake / C1 / enhanced / Configuration . h <nl> ppp b / Marlin / src / config / examples / Micromake / C1 / enhanced / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Micromake / C1 / enhanced / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Micromake / C1 / enhanced / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Mks / Robin / Configuration . h <nl> ppp b / Marlin / src / config / examples / Mks / Robin / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Mks / Robin / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Mks / Robin / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Mks / Sbase / Configuration . h <nl> ppp b / Marlin / src / config / examples / Mks / Sbase / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Mks / Sbase / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Mks / Sbase / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / RapideLite / RL200 / Configuration . h <nl> ppp b / Marlin / src / config / examples / RapideLite / RL200 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / RapideLite / RL200 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / RapideLite / RL200 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / RepRapPro / Huxley / Configuration . h <nl> ppp b / Marlin / src / config / examples / RepRapPro / Huxley / Configuration . h <nl> Black rubber belt ( MXL ) , 18 - tooth aluminium pulley : 87 . 489 step per mm ( Huxley <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / RepRapWorld / Megatronics / Configuration . h <nl> ppp b / Marlin / src / config / examples / RepRapWorld / Megatronics / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / RigidBot / Configuration . h <nl> ppp b / Marlin / src / config / examples / RigidBot / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / RigidBot / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / RigidBot / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / SCARA / Configuration . h <nl> ppp b / Marlin / src / config / examples / SCARA / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / SCARA / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / SCARA / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / STM32F10 / Configuration . h <nl> ppp b / Marlin / src / config / examples / STM32F10 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / STM32F4 / Configuration . h <nl> ppp b / Marlin / src / config / examples / STM32F4 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Sanguinololu / Configuration . h <nl> ppp b / Marlin / src / config / examples / Sanguinololu / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Sanguinololu / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Sanguinololu / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / TheBorg / Configuration . h <nl> ppp b / Marlin / src / config / examples / TheBorg / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / TheBorg / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / TheBorg / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / TinyBoy2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / TinyBoy2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / TinyBoy2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / TinyBoy2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Tronxy / X1 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Tronxy / X1 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Tronxy / X3A / Configuration . h <nl> ppp b / Marlin / src / config / examples / Tronxy / X3A / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Tronxy / X3A / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Tronxy / X3A / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Tronxy / X5S / Configuration . h <nl> ppp b / Marlin / src / config / examples / Tronxy / X5S / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Tronxy / XY100 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Tronxy / XY100 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / UltiMachine / Archim1 / Configuration . h <nl> ppp b / Marlin / src / config / examples / UltiMachine / Archim1 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / UltiMachine / Archim1 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / UltiMachine / Archim1 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / UltiMachine / Archim2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / UltiMachine / Archim2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / UltiMachine / Archim2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / UltiMachine / Archim2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / VORONDesign / Configuration . h <nl> ppp b / Marlin / src / config / examples / VORONDesign / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / VORONDesign / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / VORONDesign / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Velleman / K8200 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Velleman / K8200 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Velleman / K8200 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Velleman / K8200 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Velleman / K8400 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Velleman / K8400 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / Velleman / K8400 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Velleman / K8400 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / Velleman / K8400 / Dual - head / Configuration . h <nl> ppp b / Marlin / src / config / examples / Velleman / K8400 / Dual - head / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / WASP / PowerWASP / Configuration . h <nl> ppp b / Marlin / src / config / examples / WASP / PowerWASP / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / WASP / PowerWASP / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / WASP / PowerWASP / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> diff - - git a / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration . h b / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration . h <nl> mmm a / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration . h <nl> ppp b / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration_adv . h b / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration_adv . h <nl> mmm a / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / Wanhao / Duplicator 6 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / adafruit / ST7565 / Configuration . h <nl> ppp b / Marlin / src / config / examples / adafruit / ST7565 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / Anycubic / Kossel / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / Anycubic / Kossel / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / Anycubic / Kossel / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / Anycubic / Kossel / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / auto_calibrate / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / auto_calibrate / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / auto_calibrate / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / auto_calibrate / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / kossel / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / kossel / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / kossel / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / kossel / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / kossel_mini / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / kossel_mini / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / FLSUN / kossel_mini / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / FLSUN / kossel_mini / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> diff - - git a / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration . h b / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration . h <nl> mmm a / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration_adv . h b / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration_adv . h <nl> mmm a / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / Geeetech / Rostock 301 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / Hatchbox_Alpha / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / Hatchbox_Alpha / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / MKS / SBASE / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / MKS / SBASE / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / MKS / SBASE / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / MKS / SBASE / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> diff - - git a / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration . h b / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration . h <nl> mmm a / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> diff - - git a / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration_adv . h b / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration_adv . h <nl> mmm a / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / Tevo Little Monster / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / generic / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / generic / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / generic / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / generic / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / kossel_mini / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / kossel_mini / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / kossel_mini / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / kossel_mini / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / delta / kossel_pro / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / kossel_pro / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / kossel_xl / Configuration . h <nl> ppp b / Marlin / src / config / examples / delta / kossel_xl / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / delta / kossel_xl / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / delta / kossel_xl / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / gCreate / gMax1 . 5 + / Configuration . h <nl> ppp b / Marlin / src / config / examples / gCreate / gMax1 . 5 + / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / gCreate / gMax1 . 5 + / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / gCreate / gMax1 . 5 + / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / makibox / Configuration . h <nl> ppp b / Marlin / src / config / examples / makibox / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / makibox / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / makibox / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / stm32f103ret6 / Configuration . h <nl> ppp b / Marlin / src / config / examples / stm32f103ret6 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / tvrrug / Round2 / Configuration . h <nl> ppp b / Marlin / src / config / examples / tvrrug / Round2 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / tvrrug / Round2 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / tvrrug / Round2 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / config / examples / wt150 / Configuration . h <nl> ppp b / Marlin / src / config / examples / wt150 / Configuration . h <nl> <nl> / / then the BLUE led is on . Otherwise the RED led is on . ( 1C hysteresis ) <nl> / / # define TEMP_STAT_LEDS <nl> <nl> - / / M240 Triggers a camera by emulating a Canon RC - 1 Remote <nl> - / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> - / / # define PHOTOGRAPH_PIN 23 <nl> - <nl> / / SkeinForge sends the wrong arc g - codes when using Arc Point as fillet procedure <nl> / / # define SF_ARC_FIX <nl> <nl> mmm a / Marlin / src / config / examples / wt150 / Configuration_adv . h <nl> ppp b / Marlin / src / config / examples / wt150 / Configuration_adv . h <nl> <nl> / / @ section extras <nl> <nl> / * * <nl> - * Canon Hack Development Kit <nl> - * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * Photo G - code <nl> + * Add the M240 G - code to take a photo . <nl> + * The photo can be triggered by a digital pin or a physical movement . <nl> * / <nl> - / / # define CHDK_PIN 4 / / Set and enable a pin for triggering CHDK to take a picture <nl> - # if PIN_EXISTS ( CHDK ) <nl> - # define CHDK_DELAY 50 / / ( ms ) How long the pin should remain HIGH <nl> + / / # define PHOTO_GCODE <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + / / A position to move to ( and raise Z ) before taking the photo <nl> + / / # define PHOTO_POSITION { X_MAX_POS - 5 , Y_MAX_POS , 0 } / / { xpos , ypos , zraise } <nl> + / / # define PHOTO_DELAY_MS 100 / / ( ms ) Duration to pause before moving back <nl> + / / # define PHOTO_RETRACT_MM 6 . 5 / / ( mm ) E retract / recover for the photo move <nl> + <nl> + / / Canon RC - 1 or homebrew digital camera trigger <nl> + / / Data from : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + / / # define PHOTOGRAPH_PIN 23 <nl> + <nl> + / / Canon Hack Development Kit <nl> + / / http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + / / # define CHDK_PIN 4 <nl> + <nl> + / / Optional second move with delay to trigger the camera shutter <nl> + / / # define PHOTO_SWITCH_POSITION { X_MAX_POS , Y_MAX_POS } / / { xpos , ypos } <nl> + <nl> + / / Duration to hold the switch or keep CHDK_PIN high <nl> + / / # define PHOTO_SWITCH_MS 50 / / ( ms ) <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / gcode / feature / camera / M240 . cpp <nl> ppp b / Marlin / src / gcode / feature / camera / M240 . cpp <nl> <nl> <nl> # include " . . / . . / . . / inc / MarlinConfig . h " <nl> <nl> - # if PIN_EXISTS ( CHDK ) | | HAS_PHOTOGRAPH <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> <nl> # include " . . / . . / gcode . h " <nl> + # include " . . / . . / . . / module / motion . h " / / for active_extruder and current_position <nl> <nl> - bool chdk_active ; / / = false <nl> - millis_t chdk_timeout ; <nl> + # if PIN_EXISTS ( CHDK ) <nl> + millis_t chdk_timeout ; / / = 0 <nl> + # endif <nl> + <nl> + # ifdef PHOTO_RETRACT_MM <nl> + <nl> + # define _PHOTO_RETRACT_MM ( PHOTO_RETRACT_MM + 0 ) <nl> + <nl> + # include " . . / . . / . . / module / planner . h " <nl> + # include " . . / . . / . . / module / temperature . h " <nl> + <nl> + # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + # include " . . / . . / . . / feature / pause . h " <nl> + # endif <nl> + <nl> + inline void e_move_m240 ( const float length ) { <nl> + if ( _PHOTO_RETRACT_MM ) { <nl> + constexpr float rfr = ( MMS_TO_MMM ( <nl> + # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + PAUSE_PARK_RETRACT_FEEDRATE <nl> + # elif ENABLED ( FWRETRACT ) <nl> + RETRACT_FEEDRATE <nl> + # else <nl> + 45 <nl> + # endif <nl> + ) ) ; <nl> + if ( thermalManager . hotEnoughToExtrude ( active_extruder ) ) { <nl> + # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + do_pause_e_move ( length , rfr ) ; <nl> + # else <nl> + current_position [ E_AXIS ] + = length / planner . e_factor [ active_extruder ] ; <nl> + planner . buffer_line ( current_position , MMM_TO_MMS ( rfr ) , active_extruder ) ; <nl> + # endif <nl> + } <nl> + } <nl> + } <nl> + <nl> + # endif <nl> <nl> / * * <nl> - * M240 : Trigger a camera by emulating a Canon RC - 1 <nl> - * See http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + * M240 : Trigger a camera by . . . <nl> + * <nl> + * - CHDK : Emulate a Canon RC - 1 with a configurable ON duration . <nl> + * http : / / captain - slow . dk / 2014 / 03 / 09 / 3d - printing - timelapses / <nl> + * - PHOTOGRAPH_PIN : Pulse a digital pin 16 times . <nl> + * See http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + * - PHOTO_SWITCH_POSITION : Bump a physical switch with the X - carriage using a <nl> + * configured position , delay , and retract length . <nl> + * Parameters : <nl> + * X - Move to X before triggering the shutter ( Requires PHOTO_POSITION ) <nl> + * Y - Move to Y before triggering the shutter ( Requires PHOTO_POSITION ) <nl> + * Z - Raise Z by a distance before triggering the shutter ( Requires PHOTO_POSITION ) <nl> + * P - Delay ( ms ) after triggering the shutter <nl> * / <nl> void GcodeSuite : : M240 ( ) { <nl> <nl> + # ifdef PHOTO_POSITION <nl> + <nl> + const float old_pos [ XYZ ] = { current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] } ; <nl> + <nl> + # ifdef PHOTO_RETRACT_MM <nl> + e_move_m240 ( - ( _PHOTO_RETRACT_MM ) ) ; <nl> + # endif <nl> + <nl> + constexpr float photo_position [ XYZ ] = PHOTO_POSITION ; <nl> + float raw [ XYZ ] = { <nl> + parser . seenval ( ' X ' ) ? RAW_X_POSITION ( parser . value_linear_units ( ) ) : photo_position [ X_AXIS ] , <nl> + parser . seenval ( ' Y ' ) ? RAW_Y_POSITION ( parser . value_linear_units ( ) ) : photo_position [ X_AXIS ] , <nl> + ( parser . seenval ( ' Z ' ) ? parser . value_linear_units ( ) : photo_position [ Z_AXIS ] ) + current_position [ Z_AXIS ] <nl> + } ; <nl> + clamp_to_software_endstops ( raw ) ; <nl> + do_blocking_move_to ( raw ) ; <nl> + <nl> + # ifdef PHOTO_SWITCH_POSITION <nl> + const float photo_switch_position [ 2 ] = PHOTO_SWITCH_POSITION ; <nl> + do_blocking_move_to_xy ( photo_switch_position [ X_AXIS ] , photo_switch_position [ Y_AXIS ] , get_homing_bump_feedrate ( X_AXIS ) ) ; <nl> + # if PHOTO_SWITCH_MS > 0 <nl> + safe_delay ( PHOTO_SWITCH_MS ) ; <nl> + # endif <nl> + do_blocking_move_to ( raw ) ; <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> # if PIN_EXISTS ( CHDK ) <nl> <nl> OUT_WRITE ( CHDK_PIN , HIGH ) ; <nl> - chdk_timeout = millis ( ) + CHDK_DELAY ; <nl> - chdk_active = true ; <nl> + chdk_timeout = millis ( ) + PHOTO_SWITCH_MS ; <nl> <nl> # elif HAS_PHOTOGRAPH <nl> <nl> void GcodeSuite : : M240 ( ) { <nl> } <nl> <nl> # endif <nl> + <nl> + # ifdef PHOTO_POSITION <nl> + # if PHOTO_DELAY_MS > 0 <nl> + safe_delay ( parser . intval ( ' P ' , PHOTO_DELAY_MS ) ) ; <nl> + # endif <nl> + do_blocking_move_to ( old_pos ) ; <nl> + # ifdef PHOTO_RETRACT_MM <nl> + e_move_m240 ( _PHOTO_RETRACT_MM ) ; <nl> + # endif <nl> + # endif <nl> } <nl> <nl> - # endif / / CHDK_PIN | | HAS_PHOTOGRAPH <nl> + # endif / / PHOTO_GCODE <nl> mmm a / Marlin / src / gcode / gcode . cpp <nl> ppp b / Marlin / src / gcode / gcode . cpp <nl> void GcodeSuite : : process_parsed_command ( <nl> case 304 : M304 ( ) ; break ; / / M304 : Set bed PID parameters <nl> # endif <nl> <nl> - # if PIN_EXISTS ( CHDK ) | | HAS_PHOTOGRAPH <nl> - case 240 : M240 ( ) ; break ; / / M240 : Trigger a camera by emulating a Canon RC - 1 : http : / / www . doc - diy . net / photo / rc - 1_hacked / <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + case 240 : M240 ( ) ; break ; / / M240 : Trigger a camera <nl> # endif <nl> <nl> # if HAS_LCD_CONTRAST <nl> mmm a / Marlin / src / gcode / gcode . h <nl> ppp b / Marlin / src / gcode / gcode . h <nl> <nl> * M220 - Set Feedrate Percentage : " M220 S < percent > " ( i . e . , " FR " on the LCD ) <nl> * M221 - Set Flow Percentage : " M221 S < percent > " <nl> * M226 - Wait until a pin is in a given state : " M226 P < pin > S < state > " <nl> - * M240 - Trigger a camera to take a photograph . ( Requires CHDK_PIN or PHOTOGRAPH_PIN ) <nl> + * M240 - Trigger a camera to take a photograph . ( Requires PHOTO_GCODE ) <nl> * M250 - Set LCD contrast : " M250 C < contrast > " ( 0 - 63 ) . ( Requires LCD support ) <nl> * M260 - i2c Send Data ( Requires EXPERIMENTAL_I2CBUS ) <nl> * M261 - i2c Request Data ( Requires EXPERIMENTAL_I2CBUS ) <nl> class GcodeSuite { <nl> static void M221 ( ) ; <nl> static void M226 ( ) ; <nl> <nl> - # if PIN_EXISTS ( CHDK ) | | HAS_PHOTOGRAPH <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> static void M240 ( ) ; <nl> # endif <nl> <nl> mmm a / Marlin / src / inc / SanityCheck . h <nl> ppp b / Marlin / src / inc / SanityCheck . h <nl> static_assert ( sanity_arr_3 [ 0 ] > 0 & & sanity_arr_3 [ 1 ] > 0 & & sanity_arr_3 [ 2 ] > 0 <nl> # error " GRADIENT_MIX requires 2 or more MIXING_VIRTUAL_TOOLS . " <nl> # endif <nl> <nl> + / * * <nl> + * Photo G - code requirements <nl> + * / <nl> + # if ENABLED ( PHOTO_GCODE ) <nl> + # if ( PIN_EXISTS ( CHDK ) + PIN_EXISTS ( PHOTOGRAPH_PIN ) + defined ( PHOTO_SWITCH_POSITION ) ) > 1 <nl> + # error " Please define only one of CHDK_PIN , PHOTOGRAPH_PIN , or PHOTO_SWITCH_POSITION . " <nl> + # elif defined ( PHOTO_SWITCH_POSITION ) & & ! defined ( PHOTO_POSITION ) <nl> + # error " PHOTO_SWITCH_POSITION requires PHOTO_POSITION . Please update your Configuration_adv . h . " <nl> + # elif PIN_EXISTS ( CHDK ) & & defined ( CHDK_DELAY ) <nl> + # error " CHDK_DELAY has been replaced by PHOTO_SWITCH_MS . Please update your Configuration_adv . h . " <nl> + # elif PIN_EXISTS ( CHDK ) & & ! defined ( PHOTO_SWITCH_MS ) <nl> + # error " PHOTO_SWITCH_MS is required with CHDK_PIN . Please update your Configuration_adv . h . " <nl> + # elif defined ( PHOTO_RETRACT_MM ) <nl> + static_assert ( PHOTO_RETRACT_MM + 0 > = 0 , " PHOTO_RETRACT_MM must be > = 0 . " ) ; <nl> + # endif <nl> + # endif <nl> + <nl> / * * <nl> * Prusa MMU2 requirements <nl> * / <nl> mmm a / buildroot / share / tests / teensy35_tests <nl> ppp b / buildroot / share / tests / teensy35_tests <nl> opt_set EXTRUDERS 2 <nl> opt_set TEMP_SENSOR_0 1 <nl> opt_set TEMP_SENSOR_1 5 <nl> opt_set TEMP_SENSOR_BED 1 <nl> - opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT \ <nl> + opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ <nl> FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE \ <nl> FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ <nl> BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ <nl> PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \ <nl> - ADVANCED_PAUSE_FEATURE LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA PARK_HEAD_ON_PAUSE \ <nl> + ADVANCED_PAUSE_FEATURE ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES PARK_HEAD_ON_PAUSE \ <nl> + PHOTO_GCODE PHOTO_POSITION PHOTO_SWITCH_POSITION PHOTO_SWITCH_MS PHOTO_DELAY_MS PHOTO_RETRACT_MM \ <nl> HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT <nl> opt_set I2C_SLAVE_ADDRESS 63 <nl> opt_set GRID_MAX_POINTS_X 16 <nl>
|
Add PHOTO_GCODE option , photo trigger physical move ( )
|
MarlinFirmware/Marlin
|
d2bdb71c13fa18957638b137395200ba2c28e1b2
|
2019-02-14T21:09:35Z
|
mmm a / README . md <nl> ppp b / README . md <nl> On a Skylake processor , the parsing speeds ( in GB / s ) of various processors on th <nl> <nl> # # Requirements <nl> <nl> - - We support platforms like Linux or macOS , as well as Windows through Visual Studio 2017 or later . <nl> + - We support 64 - bit platforms like Linux or macOS , as well as Windows through Visual Studio 2017 or later . <nl> - A processor with <nl> - AVX2 ( i . e . , Intel processors starting with the Haswell microarchitecture released 2013 and AMD processors starting with the Zen microarchitecture released 2017 ) , <nl> - or SSE 4 . 2 and CLMUL ( i . e . , Intel processors going back to Westmere released in 2010 or AMD processors starting with the Jaguar used in the PS4 and XBox One ) <nl> make <nl> make test <nl> ` ` ` <nl> <nl> - # # Usage ( CMake on Windows using Visual Studio ) <nl> + # # Usage ( CMake on 64 - bit Windows using Visual Studio ) <nl> <nl> - We assume you have a common Windows PC with at least Visual Studio 2017 and an x64 processor with AVX2 support ( 2013 Intel Haswell or later ) or SSE 4 . 2 + CLMUL ( 2010 Westmere or later ) . <nl> + We assume you have a common 64 - bit Windows PC with at least Visual Studio 2017 and an x64 processor with AVX2 support ( 2013 Intel Haswell or later ) or SSE 4 . 2 + CLMUL ( 2010 Westmere or later ) . <nl> <nl> - Grab the simdjson code from GitHub , e . g . , by cloning it using [ GitHub Desktop ] ( https : / / desktop . github . com / ) . <nl> - Install [ CMake ] ( https : / / cmake . org / download / ) . When you install it , make sure to ask that ` cmake ` be made available from the command line . Please choose a recent version of cmake . <nl> We assume you have a common Windows PC with at least Visual Studio 2017 and an x <nl> <nl> <nl> <nl> - # # Usage ( Using ` vcpkg ` on Windows , Linux and MacOS ) <nl> + # # Usage ( Using ` vcpkg ` on 64 - bit Windows , Linux and MacOS ) <nl> <nl> [ vcpkg ] ( https : / / github . com / Microsoft / vcpkg ) users on Windows , Linux and MacOS can download and install ` simdjson ` with one single command from their favorite shell . <nl> <nl>
|
Making it clearer that this is a 64 - bit library
|
simdjson/simdjson
|
7e28708e1d622ca9a229e44f224e51d2c5d691a8
|
2019-12-05T14:18:49Z
|
mmm a / emcc . py <nl> ppp b / emcc . py <nl> def __init__ ( self ) : <nl> # Linux & MacOS ) <nl> self . output_eol = os . linesep <nl> self . binaryen_passes = [ ] <nl> - # Whether we will expand the full path of any input files to remove any <nl> - # symlinks . <nl> - self . expand_symlinks = True <nl> self . no_entry = False <nl> <nl> <nl> def add_link_flag ( i , f ) : <nl> # https : / / bugs . python . org / issue1311 <nl> if not os . path . exists ( arg ) and arg ! = os . devnull : <nl> exit_with_error ( ' % s : No such file or directory ( " % s " was expected to be an input file , based on the commandline arguments provided ) ' , arg , arg ) <nl> - if options . expand_symlinks and os . path . islink ( arg ) : <nl> - arg = os . path . realpath ( arg ) <nl> file_suffix = get_file_suffix ( arg ) <nl> if file_suffix in SOURCE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS or building . is_ar ( arg ) : <nl> # we already removed - o < target > , so all these should be inputs <nl> def consume_arg ( ) : <nl> elif newargs [ i ] in ( ' - fno - diagnostics - color ' , ' - fdiagnostics - color = never ' ) : <nl> colored_logger . disable ( ) <nl> diagnostics . color_enabled = False <nl> - elif newargs [ i ] = = ' - no - canonical - prefixes ' : <nl> - options . expand_symlinks = False <nl> elif newargs [ i ] = = ' - fno - rtti ' : <nl> shared . Settings . USE_RTTI = 0 <nl> elif newargs [ i ] = = ' - frtti ' : <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def test_symlink_points_to_bad_suffix ( self , flags ) : <nl> os . symlink ( ' foobar . xxx ' , ' foobar . c ' ) <nl> self . run_process ( [ EMCC , ' foobar . c ' , ' - c ' , ' - o ' , ' foobar . o ' ] + flags ) <nl> <nl> - @ parameterized ( { <nl> - ' expand_symlinks ' : ( [ ] , True ) , <nl> - ' no_canonical_prefixes ' : ( [ ' - no - canonical - prefixes ' ] , False ) , <nl> - } ) <nl> @ no_windows ( ' Windows does not support symlinks ' ) <nl> - def test_symlink_has_bad_suffix ( self , flags , expect_success ) : <nl> - " " " Tests compiling a symlink where foobar . xxx points to foobar . c . <nl> - <nl> - In this case , setting - no - canonical - prefixes will result in a build failure <nl> - due to the inappropriate file suffix on foobar . xxx . " " " <nl> + def test_symlink_has_bad_suffix ( self ) : <nl> + " " " Tests that compiling foobar . xxx fails even if it points to foobar . c . <nl> + " " " <nl> create_test_file ( ' foobar . c ' , ' int main ( ) { return 0 ; } ' ) <nl> os . symlink ( ' foobar . c ' , ' foobar . xxx ' ) <nl> - proc = self . run_process ( [ EMCC , ' foobar . xxx ' , ' - o ' , ' foobar . js ' ] + flags , check = expect_success , stderr = PIPE ) <nl> - if not expect_success : <nl> - self . assertNotEqual ( proc . returncode , 0 ) <nl> - self . assertContained ( ' unknown file type : foobar . xxx ' , proc . stderr ) <nl> + err = self . expect_fail ( [ EMCC , ' foobar . xxx ' , ' - o ' , ' foobar . js ' ] ) <nl> + self . assertContained ( ' unknown file type : foobar . xxx ' , err ) <nl> <nl> def test_multiply_defined_libsymbols ( self ) : <nl> lib_name = ' libA . c ' <nl>
|
Don ' t follow symlinks passed as inputs ( )
|
emscripten-core/emscripten
|
34047f2c9f98538dcc3c9118eeb98ac1994802db
|
2020-08-04T18:35:56Z
|
mmm a / tensorflow / contrib / learn / python / learn / datasets / base . py <nl> ppp b / tensorflow / contrib / learn / python / learn / datasets / base . py <nl> def _is_retriable ( e ) : <nl> <nl> <nl> @ retry ( initial_delay = 1 . 0 , max_delay = 16 . 0 , is_retriable = _is_retriable ) <nl> - def urlretrieve_with_retry ( url , filename ) : <nl> - urllib . request . urlretrieve ( url , filename ) <nl> + def urlretrieve_with_retry ( url , filename = None ) : <nl> + return urllib . request . urlretrieve ( url , filename ) <nl> <nl> <nl> def maybe_download ( filename , work_directory , source_url ) : <nl> def maybe_download ( filename , work_directory , source_url ) : <nl> gfile . MakeDirs ( work_directory ) <nl> filepath = os . path . join ( work_directory , filename ) <nl> if not gfile . Exists ( filepath ) : <nl> - with tempfile . NamedTemporaryFile ( ) as tmpfile : <nl> - temp_file_name = tmpfile . name <nl> - urlretrieve_with_retry ( source_url , temp_file_name ) <nl> - gfile . Copy ( temp_file_name , filepath ) <nl> - with gfile . GFile ( filepath ) as f : <nl> - size = f . size ( ) <nl> - print ( ' Successfully downloaded ' , filename , size , ' bytes . ' ) <nl> + temp_file_name , _ = urlretrieve_with_retry ( source_url ) <nl> + gfile . Copy ( temp_file_name , filepath ) <nl> + with gfile . GFile ( filepath ) as f : <nl> + size = f . size ( ) <nl> + print ( ' Successfully downloaded ' , filename , size , ' bytes . ' ) <nl> return filepath <nl>
|
Merge pull request from chadkennedyonline / master
|
tensorflow/tensorflow
|
778539ce3cb4a0effabe46e7674c22602cb08dc0
|
2016-12-05T09:04:01Z
|
mmm a / include / swift / AST / DiagnosticsSIL . def <nl> ppp b / include / swift / AST / DiagnosticsSIL . def <nl> NOTE ( previous_inout_alias , none , <nl> " previous aliasing argument " , ( ) ) <nl> <nl> WARNING ( exclusivity_access_required_swift3 , none , <nl> - " simultaneous accesses to % 0 % 1 , but " <nl> - " % select { initialization | read | modification | deinitialization } 2 requires " <nl> + " overlapping accesses to % 0 , but " <nl> + " % select { initialization | read | modification | deinitialization } 1 requires " <nl> " exclusive access ; consider copying to a local variable " , <nl> - ( DescriptiveDeclKind , StringRef , unsigned ) ) <nl> + ( StringRef , unsigned ) ) <nl> <nl> ERROR ( exclusivity_access_required , none , <nl> - " simultaneous accesses to % 0 % 1 , but " <nl> - " % select { initialization | read | modification | deinitialization } 2 requires " <nl> + " overlapping accesses to % 0 , but " <nl> + " % select { initialization | read | modification | deinitialization } 1 requires " <nl> " exclusive access ; consider copying to a local variable " , <nl> - ( DescriptiveDeclKind , StringRef , unsigned ) ) <nl> + ( StringRef , unsigned ) ) <nl> <nl> ERROR ( exclusivity_access_required_unknown_decl , none , <nl> - " simultaneous accesses , but " <nl> + " overlapping accesses , but " <nl> " % select { initialization | read | modification | deinitialization } 0 requires " <nl> " exclusive access ; consider copying to a local variable " , ( unsigned ) ) <nl> <nl> WARNING ( exclusivity_access_required_unknown_decl_swift3 , none , <nl> - " simultaneous accesses , but " <nl> + " overlapping accesses , but " <nl> " % select { initialization | read | modification | deinitialization } 0 requires " <nl> " exclusive access ; consider copying to a local variable " , ( unsigned ) ) <nl> <nl> mmm a / lib / SILOptimizer / Mandatory / DiagnoseStaticExclusivity . cpp <nl> ppp b / lib / SILOptimizer / Mandatory / DiagnoseStaticExclusivity . cpp <nl> static void diagnoseExclusivityViolation ( const ConflictingAccess & Violation , <nl> VD - > getBaseName ( ) , BaseType , MainAccess . getSubPath ( ) , M ) ; <nl> auto D = <nl> diagnose ( Ctx , MainAccess . getAccessLoc ( ) . getSourceLoc ( ) , DiagnosticID , <nl> - VD - > getDescriptiveKind ( ) , PathDescription , AccessKindForMain ) ; <nl> + PathDescription , AccessKindForMain ) ; <nl> D . highlight ( RangeForMain ) ; <nl> tryFixItWithCallToCollectionSwapAt ( FirstAccess . getInstruction ( ) , <nl> SecondAccess . getInstruction ( ) , <nl> mmm a / test / SILGen / polymorphic_inout_aliasing . swift <nl> ppp b / test / SILGen / polymorphic_inout_aliasing . swift <nl> class Story { <nl> } <nl> <nl> func test ( ) { <nl> - / / expected - warning @ + 2 { { simultaneous accesses to var ' finalStored ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - warning @ + 2 { { overlapping accesses to ' finalStored ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & self . finalStored [ 0 ] , & self . finalStored [ 1 ] ) <nl> swap ( & self . overridableStored [ 0 ] , & self . overridableStored [ 1 ] ) <nl> protocol Storied { <nl> } <nl> <nl> func testProtocol < T : Storied > ( x : inout T ) { <nl> - / / expected - warning @ + 2 { { simultaneous accesses to parameter ' x ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - warning @ + 2 { { overlapping accesses to ' x ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & x . protocolRequirement [ 0 ] , & x . protocolRequirement [ 1 ] ) <nl> } <nl> mmm a / test / SILOptimizer / exclusivity_static_diagnostics . sil <nl> ppp b / test / SILOptimizer / exclusivity_static_diagnostics . sil <nl> bb0 ( % 0 : $ Int ) : <nl> % 3 = project_box % 2 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> % 7 = apply % 4 ( % 5 , % 6 ) : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> end_access % 6 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> % 3 = project_box % 2 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = begin_access [ modify ] [ unknown ] % 5 : $ * Int <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> % 8 = apply % 4 ( % 5 , % 6 ) : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> bb0 ( % 0 : $ Int , % 1 : $ Builtin . Int1 ) : <nl> br bb1 <nl> bb1 : <nl> / / Make sure we don ' t diagnose twice . <nl> - % 4 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 4 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> end_access % 5 : $ * Int <nl> end_access % 4 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> % 2 = project_box % 1 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 2 : $ * Int <nl> % 4 = begin_access [ read ] [ unknown ] % 2 : $ * Int / / expected - note { { conflicting access is here } } <nl> - % 5 = begin_access [ modify ] [ unknown ] % 2 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 2 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> end_access % 5 : $ * Int <nl> end_access % 4 : $ * Int <nl> destroy_value % 1 : $ { var Int } <nl> bb0 ( % 0 : $ Int ) : <nl> % 1 = alloc_box $ { var Int } <nl> % 2 = project_box % 1 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 2 : $ * Int <nl> - % 4 = begin_access [ modify ] [ unknown ] % 2 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 4 = begin_access [ modify ] [ unknown ] % 2 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 5 = begin_access [ read ] [ unknown ] % 2 : $ * Int / / expected - note { { conflicting access is here } } <nl> end_access % 5 : $ * Int <nl> end_access % 4 : $ * Int <nl> sil hidden @ classStoredProperty : $ @ convention ( thin ) ( ClassWithStoredProperty ) - <nl> bb0 ( % 0 : $ ClassWithStoredProperty ) : <nl> % 1 = ref_element_addr % 0 : $ ClassWithStoredProperty , # ClassWithStoredProperty . f <nl> <nl> - / / expected - error @ + 1 { { simultaneous accesses to var ' f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 1 { { overlapping accesses to ' f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 2 = begin_access [ modify ] [ dynamic ] % 1 : $ * Int <nl> % 3 = ref_element_addr % 0 : $ ClassWithStoredProperty , # ClassWithStoredProperty . f <nl> <nl> bb0 ( % 0 : $ ClassWithStoredProperty ) : <nl> % 2 = begin_borrow % 0 : $ ClassWithStoredProperty <nl> % 3 = ref_element_addr % 1 : $ ClassWithStoredProperty , # ClassWithStoredProperty . f <nl> <nl> - / / expected - error @ + 1 { { simultaneous accesses to var ' f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 1 { { overlapping accesses to ' f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 4 = begin_access [ modify ] [ dynamic ] % 3 : $ * Int <nl> % 5 = ref_element_addr % 2 : $ ClassWithStoredProperty , # ClassWithStoredProperty . f <nl> <nl> bb0 ( % 0 : $ Int ) : <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = copy_value % 2 : $ { var Int } <nl> % 5 = project_box % 4 : $ { var Int } , 0 <nl> - % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 7 = begin_access [ modify ] [ unknown ] % 5 : $ * Int / / expected - note { { conflicting access is here } } <nl> end_access % 7 : $ * Int <nl> end_access % 6 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> % 3 = project_box % 2 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = project_box % 2 : $ { var Int } , 0 <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = begin_access [ modify ] [ unknown ] % 4 : $ * Int / / expected - note { { conflicting access is here } } <nl> end_access % 6 : $ * Int <nl> end_access % 5 : $ * Int <nl> sil hidden @ modifySameGlobal : $ @ convention ( thin ) ( Int ) - > ( ) { <nl> bb0 ( % 0 : $ Int ) : <nl> % 1 = global_addr @ global1 : $ * Int <nl> % 2 = global_addr @ global1 : $ * Int <nl> - % 3 = begin_access [ modify ] [ unknown ] % 1 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 3 = begin_access [ modify ] [ unknown ] % 1 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 4 = begin_access [ modify ] [ unknown ] % 2 : $ * Int / / expected - note { { conflicting access is here } } <nl> end_access % 4 : $ * Int <nl> end_access % 3 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> % 5 = begin_access [ read ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> - % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 7 = begin_access [ read ] [ unknown ] % 3 : $ * Int / / no - error <nl> % 8 = apply % 4 ( % 5 , % 6 ) : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> end_access % 7 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> % 3 = project_box % 2 : $ { var Int } , 0 <nl> store % 0 to [ trivial ] % 3 : $ * Int <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / no - error <nl> % 8 = apply % 4 ( % 5 , % 6 ) : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> bb0 ( % 0 : $ Int ) : <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / no - note <nl> end_access % 5 : $ * Int <nl> - % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 6 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * Int / / expected - note { { conflicting access is here } } <nl> % 8 = apply % 4 ( % 5 , % 6 ) : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> end_access % 7 : $ * Int <nl> bb0 ( % 0 : $ Int ) : <nl> % 2 = alloc_box $ { var StructWithStoredProps } <nl> % 3 = project_box % 2 : $ { var StructWithStoredProps } , 0 <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = struct_element_addr % 5 : $ * StructWithStoredProps , # StructWithStoredProps . x <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - note { { conflicting access is here } } <nl> % 8 = struct_element_addr % 7 : $ * StructWithStoredProps , # StructWithStoredProps . x <nl> bb0 ( % 0 : $ Int ) : <nl> % 2 = alloc_box $ { var StructWithStoredProps } <nl> % 3 = project_box % 2 : $ { var StructWithStoredProps } , 0 <nl> % 4 = function_ref @ takesInoutIntAndStructWithStoredProps : $ @ convention ( thin ) ( @ inout Int , @ inout StructWithStoredProps ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = struct_element_addr % 5 : $ * StructWithStoredProps , # StructWithStoredProps . x <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - note { { conflicting access is here } } <nl> % 8 = apply % 4 ( % 6 , % 7 ) : $ @ convention ( thin ) ( @ inout Int , @ inout StructWithStoredProps ) - > ( ) <nl> bb0 ( % 0 : $ Int ) : <nl> % 2 = alloc_box $ { var StructWithStoredProps } <nl> % 3 = project_box % 2 : $ { var StructWithStoredProps } , 0 <nl> % 4 = function_ref @ takesInoutIntAndStructWithStoredProps : $ @ convention ( thin ) ( @ inout Int , @ inout StructWithStoredProps ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = struct_element_addr % 5 : $ * StructWithStoredProps , # StructWithStoredProps . n <nl> % 7 = struct_element_addr % 6 : $ * NestedStructWithStoredProps , # NestedStructWithStoredProps . a <nl> % 8 = begin_access [ modify ] [ unknown ] % 3 : $ * StructWithStoredProps / / expected - note { { conflicting access is here } } <nl> bb0 ( % 0 : $ Int ) : <nl> % 2 = alloc_box $ { var ( Int , Int ) } <nl> % 3 = project_box % 2 : $ { var ( Int , Int ) } , 0 <nl> % 4 = function_ref @ takesTwoInouts : $ @ convention ( thin ) ( @ inout Int , @ inout Int ) - > ( ) <nl> - % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * ( Int , Int ) / / expected - error { { simultaneous accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> + % 5 = begin_access [ modify ] [ unknown ] % 3 : $ * ( Int , Int ) / / expected - error { { overlapping accesses , but modification requires exclusive access ; consider copying to a local variable } } <nl> % 6 = tuple_element_addr % 5 : $ * ( Int , Int ) , 0 <nl> % 7 = begin_access [ modify ] [ unknown ] % 3 : $ * ( Int , Int ) / / expected - note { { conflicting access is here } } <nl> % 8 = tuple_element_addr % 7 : $ * ( Int , Int ) , 0 <nl> mmm a / test / SILOptimizer / exclusivity_static_diagnostics . swift <nl> ppp b / test / SILOptimizer / exclusivity_static_diagnostics . swift <nl> func simpleInoutDiagnostic ( ) { <nl> / / turned on by default . <nl> / / expected - error @ + 4 { { inout arguments are not allowed to alias each other } } <nl> / / expected - note @ + 3 { { previous aliasing argument } } <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' i ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' i ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> takesTwoInouts ( & i , & i ) <nl> } <nl> func simpleInoutDiagnostic ( ) { <nl> func inoutOnInoutParameter ( p : inout Int ) { <nl> / / expected - error @ + 4 { { inout arguments are not allowed to alias each other } } <nl> / / expected - note @ + 3 { { previous aliasing argument } } <nl> - / / expected - error @ + 2 { { simultaneous accesses to parameter ' p ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' p ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> takesTwoInouts ( & p , & p ) <nl> } <nl> func inoutOnInoutParameter ( p : inout Int ) { <nl> func swapNoSuppression ( _ i : Int , _ j : Int ) { <nl> var a : [ Int ] = [ 1 , 2 , 3 ] <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' a ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' a ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & a [ i ] , & a [ j ] ) / / no - warning <nl> } <nl> struct StructWithMutatingMethodThatTakesSelfInout { <nl> mutating func callMutatingMethodThatTakesSelfInout ( ) { <nl> / / expected - error @ + 4 { { inout arguments are not allowed to alias each other } } <nl> / / expected - note @ + 3 { { previous aliasing argument } } <nl> - / / expected - error @ + 2 { { simultaneous accesses to parameter ' self ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' self ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> mutate ( & self ) <nl> } <nl> <nl> mutating func callMutatingMethodThatTakesSelfStoredPropInout ( ) { <nl> - / / expected - error @ + 2 { { simultaneous accesses to parameter ' self ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' self ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> mutate ( & self . f ) <nl> } <nl> struct StructWithMutatingMethodThatTakesSelfInout { <nl> <nl> var globalStruct1 = StructWithMutatingMethodThatTakesSelfInout ( ) <nl> func callMutatingMethodThatTakesGlobalStoredPropInout ( ) { <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' globalStruct1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' globalStruct1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> globalStruct1 . mutate ( & globalStruct1 . f ) <nl> } <nl> class ClassWithFinalStoredProp { <nl> func callMutatingMethodThatTakesClassStoredPropInout ( ) { <nl> s1 . mutate ( & s2 . f ) / / no - warning <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' s1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' s1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> s1 . mutate ( & s1 . f ) <nl> <nl> let local1 = self <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' s1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' s1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> local1 . s1 . mutate ( & local1 . s1 . f ) <nl> } <nl> func violationWithGenericType < T > ( _ p : T ) { <nl> var local = p <nl> / / expected - error @ + 4 { { inout arguments are not allowed to alias each other } } <nl> / / expected - note @ + 3 { { previous aliasing argument } } <nl> - / / expected - error @ + 2 { { simultaneous accesses to var ' local ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ + 2 { { overlapping accesses to ' local ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> takesTwoInouts ( & local , & local ) <nl> } <nl> struct StructWithFixits { <nl> mutating <nl> func shouldHaveFixIts < T > ( _ i : Int , _ j : Int , _ param : T , _ paramIndex : T . Index ) where T : MutableCollection { <nl> var array1 = [ 1 , 2 , 3 ] <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { 5 - 41 = array1 . swapAt ( i + 5 , j - 2 ) } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { 5 - 41 = array1 . swapAt ( i + 5 , j - 2 ) } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & array1 [ i + 5 ] , & array1 [ j - 2 ] ) <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { 5 - 49 = self . arrayProp . swapAt ( i , j ) } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { 5 - 49 = self . arrayProp . swapAt ( i , j ) } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & self . arrayProp [ i ] , & self . arrayProp [ j ] ) <nl> <nl> var localOfGenericType = param <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { 5 - 75 = localOfGenericType . swapAt ( paramIndex , paramIndex ) } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { 5 - 75 = localOfGenericType . swapAt ( paramIndex , paramIndex ) } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & localOfGenericType [ paramIndex ] , & localOfGenericType [ paramIndex ] ) <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { 5 - 39 = array1 . swapAt ( i , j ) } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { 5 - 39 = array1 . swapAt ( i , j ) } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> Swift . swap ( & array1 [ i ] , & array1 [ j ] ) / / no - crash <nl> } <nl> struct StructWithFixits { <nl> mutating <nl> func shouldHaveNoFixIts ( _ i : Int , _ j : Int ) { <nl> var s = StructWithField ( ) <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { none } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { none } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & s . f , & s . f ) <nl> <nl> struct StructWithFixits { <nl> swap ( & array1 [ i ] , & self . arrayProp [ j ] ) / / no - warning no - fixit <nl> <nl> / / Dictionaries aren ' t MutableCollections so don ' t support swapAt ( ) . <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { none } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { none } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & dictionaryProp [ i ] , & dictionaryProp [ j ] ) <nl> <nl> / / We could safely Fix - It this but don ' t now because the left and <nl> / / right bases are not textually identical . <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { none } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { none } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> swap ( & self . arrayProp [ i ] , & arrayProp [ j ] ) <nl> <nl> struct StructWithFixits { <nl> / / We don ' t suppress when swap ( ) is used as a value <nl> let mySwap : ( inout Int , inout Int ) - > ( ) = swap <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { none } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { none } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> mySwap ( & array1 [ i ] , & array1 [ j ] ) <nl> <nl> struct StructWithFixits { <nl> swap ( & a , & b ) / / no - warning <nl> } <nl> <nl> - / / expected - error @ + 2 { { simultaneous accesses } } { { none } } <nl> + / / expected - error @ + 2 { { overlapping accesses } } { { none } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> mySwap ( & array1 [ i ] , & array1 [ j ] ) <nl> } <nl> func inoutSeparateStructStoredProperties ( ) { <nl> func inoutSameStoredProperty ( ) { <nl> var s = StructWithTwoStoredProp ( ) <nl> takesTwoInouts ( & s . f1 , & s . f1 ) <nl> - / / expected - error @ - 1 { { simultaneous accesses to var ' s . f1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ - 1 { { overlapping accesses to ' s . f1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ - 2 { { conflicting access is here } } <nl> } <nl> <nl> func inoutSeparateTupleElements ( ) { <nl> func inoutSameTupleElement ( ) { <nl> var t = ( 1 , 4 ) <nl> takesTwoInouts ( & t . 0 , & t . 0 ) / / no - error <nl> - / / expected - error @ - 1 { { simultaneous accesses to var ' t . 0 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ - 1 { { overlapping accesses to ' t . 0 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ - 2 { { conflicting access is here } } <nl> } <nl> <nl> func inoutSameTupleNamedElement ( ) { <nl> var t = ( name1 : 1 , name2 : 4 ) <nl> takesTwoInouts ( & t . name2 , & t . name2 ) / / no - error <nl> - / / expected - error @ - 1 { { simultaneous accesses to var ' t . name2 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ - 1 { { overlapping accesses to ' t . name2 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ - 2 { { conflicting access is here } } <nl> } <nl> <nl> func inoutSamePropertyInSameTuple ( ) { <nl> var t = ( name1 : 1 , name2 : StructWithTwoStoredProp ( ) ) <nl> takesTwoInouts ( & t . name2 . f1 , & t . name2 . f1 ) / / no - error <nl> - / / expected - error @ - 1 { { simultaneous accesses to var ' t . name2 . f1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - error @ - 1 { { overlapping accesses to ' t . name2 . f1 ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ - 2 { { conflicting access is here } } <nl> } <nl> mmm a / test / SILOptimizer / exclusivity_static_diagnostics_swift3 . swift <nl> ppp b / test / SILOptimizer / exclusivity_static_diagnostics_swift3 . swift <nl> func simpleInoutDiagnostic ( ) { <nl> <nl> / / expected - error @ + 4 { { inout arguments are not allowed to alias each other } } <nl> / / expected - note @ + 3 { { previous aliasing argument } } <nl> - / / expected - warning @ + 2 { { simultaneous accesses to var ' i ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - warning @ + 2 { { overlapping accesses to ' i ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> takesTwoInouts ( & i , & i ) <nl> } <nl> struct X { <nl> func diagnoseOnSameField ( ) { <nl> var x = X ( ) <nl> <nl> - / / expected - warning @ + 2 { { simultaneous accesses to var ' x . f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> + / / expected - warning @ + 2 { { overlapping accesses to ' x . f ' , but modification requires exclusive access ; consider copying to a local variable } } <nl> / / expected - note @ + 1 { { conflicting access is here } } <nl> takesTwoInouts ( & x . f , & x . f ) <nl> } <nl>
|
Merge pull request from devincoughlin / exclusivity - simultaneous - to - overlapping
|
apple/swift
|
cc222a4372cfadbec0f165ad7406c8e21cbabe9d
|
2017-06-14T03:33:59Z
|
mmm a / Marlin / Marlin_main . cpp <nl> ppp b / Marlin / Marlin_main . cpp <nl> void unknown_command_error ( ) { <nl> <nl> # endif / / HOST_KEEPALIVE_FEATURE <nl> <nl> + bool position_is_reachable ( float target [ XYZ ] ) { <nl> + float dx = RAW_X_POSITION ( target [ X_AXIS ] ) , <nl> + dy = RAW_Y_POSITION ( target [ Y_AXIS ] ) ; <nl> + <nl> + # if ENABLED ( DELTA ) <nl> + return HYPOT2 ( dx , dy ) < = sq ( DELTA_PRINTABLE_RADIUS ) ; <nl> + # else <nl> + float dz = RAW_Z_POSITION ( target [ Z_AXIS ] ) ; <nl> + return dx > = X_MIN_POS - 0 . 0001 & & dx < = X_MAX_POS + 0 . 0001 <nl> + & & dy > = Y_MIN_POS - 0 . 0001 & & dy < = Y_MAX_POS + 0 . 0001 <nl> + & & dz > = Z_MIN_POS - 0 . 0001 & & dz < = Z_MAX_POS + 0 . 0001 ; <nl> + # endif <nl> + } <nl> + <nl> / * * <nl> * G0 , G1 : Coordinated movement of X Y Z E axes <nl> * / <nl> inline void gcode_G4 ( ) { <nl> / * * <nl> * Move the Z probe ( or just the nozzle ) to the safe homing point <nl> * / <nl> - float cpx = Z_SAFE_HOMING_X_POINT , cpy = Z_SAFE_HOMING_Y_POINT ; <nl> + destination [ X_AXIS ] = LOGICAL_X_POSITION ( Z_SAFE_HOMING_X_POINT ) ; <nl> + destination [ Y_AXIS ] = LOGICAL_Y_POSITION ( Z_SAFE_HOMING_Y_POINT ) ; <nl> + destination [ Z_AXIS ] = current_position [ Z_AXIS ] ; / / Z is already at the right height <nl> + <nl> # if HAS_BED_PROBE <nl> - cpx - = X_PROBE_OFFSET_FROM_EXTRUDER ; <nl> - cpy - = Y_PROBE_OFFSET_FROM_EXTRUDER ; <nl> + destination [ X_AXIS ] - = X_PROBE_OFFSET_FROM_EXTRUDER ; <nl> + destination [ Y_AXIS ] - = Y_PROBE_OFFSET_FROM_EXTRUDER ; <nl> # endif <nl> <nl> # if ENABLED ( DEBUG_LEVELING_FEATURE ) <nl> - if ( DEBUGGING ( LEVELING ) ) { <nl> - SERIAL_ECHOPAIR ( " Z_SAFE_HOMING X : " , cpx ) ; <nl> - SERIAL_ECHOLNPAIR ( " Y : " , cpy ) ; <nl> - } <nl> + if ( DEBUGGING ( LEVELING ) ) DEBUG_POS ( " Z_SAFE_HOMING " , destination ) ; <nl> # endif <nl> <nl> - if ( cpx > = X_MIN_POS & & cpx < = X_MAX_POS & & cpy > = Y_MIN_POS & & cpy < = Y_MAX_POS ) { <nl> - do_blocking_move_to_xy ( LOGICAL_X_POSITION ( destination [ X_AXIS ] ) , LOGICAL_Y_POSITION ( destination [ Y_AXIS ] ) ) ; <nl> + if ( position_is_reachable ( destination ) ) { <nl> + do_blocking_move_to_xy ( destination [ X_AXIS ] , destination [ Y_AXIS ] ) ; <nl> HOMEAXIS ( Z ) ; <nl> } <nl> else { <nl>
|
Add position_is_reachable , use in home_z_safely
|
MarlinFirmware/Marlin
|
786d1afb72f6374bdef5fd8fcc591d7a0df22499
|
2016-09-13T08:33:00Z
|
mmm a / editor / plugins / canvas_item_editor_plugin . cpp <nl> ppp b / editor / plugins / canvas_item_editor_plugin . cpp <nl> void CanvasItemEditor : : _draw_straight_line ( Point2 p_from , Point2 p_to , Color p_c <nl> } <nl> <nl> void CanvasItemEditor : : _draw_axis ( ) { <nl> - RID ci = viewport - > get_canvas_item ( ) ; <nl> <nl> - Color x_axis_color ( 1 . 0 , 0 . 4 , 0 . 4 , 0 . 6 ) ; <nl> - Color y_axis_color ( 0 . 4 , 1 . 0 , 0 . 4 , 0 . 6 ) ; <nl> - Color area_axis_color ( 0 . 4 , 0 . 4 , 1 . 0 , 0 . 4 ) ; <nl> + if ( show_origin ) { <nl> <nl> - _draw_straight_line ( Point2 ( ) , Point2 ( 1 , 0 ) , x_axis_color ) ; <nl> - _draw_straight_line ( Point2 ( ) , Point2 ( 0 , 1 ) , y_axis_color ) ; <nl> + Color x_axis_color ( 1 . 0 , 0 . 4 , 0 . 4 , 0 . 6 ) ; <nl> + Color y_axis_color ( 0 . 4 , 1 . 0 , 0 . 4 , 0 . 6 ) ; <nl> <nl> - Size2 screen_size = Size2 ( ProjectSettings : : get_singleton ( ) - > get ( " display / window / size / width " ) , ProjectSettings : : get_singleton ( ) - > get ( " display / window / size / height " ) ) ; <nl> + _draw_straight_line ( Point2 ( ) , Point2 ( 1 , 0 ) , x_axis_color ) ; <nl> + _draw_straight_line ( Point2 ( ) , Point2 ( 0 , 1 ) , y_axis_color ) ; <nl> + } <nl> <nl> - Vector2 screen_endpoints [ 4 ] = { <nl> - transform . xform ( Vector2 ( 0 , 0 ) ) , <nl> - transform . xform ( Vector2 ( screen_size . width , 0 ) ) , <nl> - transform . xform ( Vector2 ( screen_size . width , screen_size . height ) ) , <nl> - transform . xform ( Vector2 ( 0 , screen_size . height ) ) <nl> - } ; <nl> + if ( show_viewport ) { <nl> + <nl> + RID ci = viewport - > get_canvas_item ( ) ; <nl> + <nl> + Color area_axis_color ( 0 . 4 , 0 . 4 , 1 . 0 , 0 . 4 ) ; <nl> <nl> - for ( int i = 0 ; i < 4 ; i + + ) { <nl> - VisualServer : : get_singleton ( ) - > canvas_item_add_line ( ci , screen_endpoints [ i ] , screen_endpoints [ ( i + 1 ) % 4 ] , area_axis_color ) ; <nl> + Size2 screen_size = Size2 ( ProjectSettings : : get_singleton ( ) - > get ( " display / window / size / width " ) , ProjectSettings : : get_singleton ( ) - > get ( " display / window / size / height " ) ) ; <nl> + <nl> + Vector2 screen_endpoints [ 4 ] = { <nl> + transform . xform ( Vector2 ( 0 , 0 ) ) , <nl> + transform . xform ( Vector2 ( screen_size . width , 0 ) ) , <nl> + transform . xform ( Vector2 ( screen_size . width , screen_size . height ) ) , <nl> + transform . xform ( Vector2 ( 0 , screen_size . height ) ) <nl> + } ; <nl> + <nl> + for ( int i = 0 ; i < 4 ; i + + ) { <nl> + VisualServer : : get_singleton ( ) - > canvas_item_add_line ( ci , screen_endpoints [ i ] , screen_endpoints [ ( i + 1 ) % 4 ] , area_axis_color ) ; <nl> + } <nl> } <nl> } <nl> <nl> void CanvasItemEditor : : _popup_callback ( int p_op ) { <nl> view_menu - > get_popup ( ) - > set_item_checked ( idx , show_grid ) ; <nl> viewport - > update ( ) ; <nl> } break ; <nl> + case SHOW_ORIGIN : { <nl> + show_origin = ! show_origin ; <nl> + int idx = view_menu - > get_popup ( ) - > get_item_index ( SHOW_ORIGIN ) ; <nl> + view_menu - > get_popup ( ) - > set_item_checked ( idx , show_origin ) ; <nl> + viewport - > update ( ) ; <nl> + } break ; <nl> + case SHOW_VIEWPORT : { <nl> + show_viewport = ! show_viewport ; <nl> + int idx = view_menu - > get_popup ( ) - > get_item_index ( SHOW_VIEWPORT ) ; <nl> + view_menu - > get_popup ( ) - > set_item_checked ( idx , show_viewport ) ; <nl> + viewport - > update ( ) ; <nl> + } break ; <nl> case SNAP_USE_NODE_PARENT : { <nl> snap_node_parent = ! snap_node_parent ; <nl> int idx = smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_PARENT ) ; <nl> Dictionary CanvasItemEditor : : get_state ( ) const { <nl> state [ " snap_grid " ] = snap_grid ; <nl> state [ " snap_guides " ] = snap_guides ; <nl> state [ " show_grid " ] = show_grid ; <nl> + state [ " show_origin " ] = show_origin ; <nl> + state [ " show_viewport " ] = show_viewport ; <nl> state [ " show_rulers " ] = show_rulers ; <nl> state [ " show_guides " ] = show_guides ; <nl> state [ " show_helpers " ] = show_helpers ; <nl> void CanvasItemEditor : : set_state ( const Dictionary & p_state ) { <nl> view_menu - > get_popup ( ) - > set_item_checked ( idx , show_grid ) ; <nl> } <nl> <nl> + if ( state . has ( " show_origin " ) ) { <nl> + show_origin = state [ " show_origin " ] ; <nl> + int idx = view_menu - > get_popup ( ) - > get_item_index ( SHOW_ORIGIN ) ; <nl> + view_menu - > get_popup ( ) - > set_item_checked ( idx , show_origin ) ; <nl> + } <nl> + <nl> + if ( state . has ( " show_viewport " ) ) { <nl> + show_viewport = state [ " show_viewport " ] ; <nl> + int idx = view_menu - > get_popup ( ) - > get_item_index ( SHOW_VIEWPORT ) ; <nl> + view_menu - > get_popup ( ) - > set_item_checked ( idx , show_viewport ) ; <nl> + } <nl> + <nl> if ( state . has ( " show_rulers " ) ) { <nl> show_rulers = state [ " show_rulers " ] ; <nl> int idx = view_menu - > get_popup ( ) - > get_item_index ( SHOW_RULERS ) ; <nl> CanvasItemEditor : : CanvasItemEditor ( EditorNode * p_editor ) { <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor / show_helpers " , TTR ( " Show Helpers " ) , KEY_H ) , SHOW_HELPERS ) ; <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor / show_rulers " , TTR ( " Show Rulers " ) , KEY_R ) , SHOW_RULERS ) ; <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor / show_guides " , TTR ( " Show Guides " ) , KEY_Y ) , SHOW_GUIDES ) ; <nl> + p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor / show_origin " , TTR ( " Show Origin " ) ) , SHOW_ORIGIN ) ; <nl> + p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor / show_viewport " , TTR ( " Show Viewport " ) ) , SHOW_VIEWPORT ) ; <nl> p - > add_separator ( ) ; <nl> p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor / center_selection " , TTR ( " Center Selection " ) , KEY_F ) , VIEW_CENTER_TO_SELECTION ) ; <nl> p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor / frame_selection " , TTR ( " Frame Selection " ) , KEY_MASK_SHIFT | KEY_F ) , VIEW_FRAME_TO_SELECTION ) ; <nl> CanvasItemEditor : : CanvasItemEditor ( EditorNode * p_editor ) { <nl> key_scale = false ; <nl> <nl> show_grid = false ; <nl> + show_origin = true ; <nl> + show_viewport = true ; <nl> show_helpers = false ; <nl> show_rulers = true ; <nl> show_guides = true ; <nl> mmm a / editor / plugins / canvas_item_editor_plugin . h <nl> ppp b / editor / plugins / canvas_item_editor_plugin . h <nl> class CanvasItemEditor : public VBoxContainer { <nl> SHOW_HELPERS , <nl> SHOW_RULERS , <nl> SHOW_GUIDES , <nl> + SHOW_ORIGIN , <nl> + SHOW_VIEWPORT , <nl> LOCK_SELECTED , <nl> UNLOCK_SELECTED , <nl> GROUP_SELECTED , <nl> class CanvasItemEditor : public VBoxContainer { <nl> bool show_grid ; <nl> bool show_rulers ; <nl> bool show_guides ; <nl> + bool show_origin ; <nl> + bool show_viewport ; <nl> bool show_helpers ; <nl> float zoom ; <nl> <nl>
|
Merge pull request from StateOff / add_show_axis_options
|
godotengine/godot
|
fcd81c9627fd9ec13be4ed3ff55d7213b2f7c3ba
|
2018-03-13T11:53:11Z
|
mmm a / drivers / vulkan / vulkan_context . cpp <nl> ppp b / drivers / vulkan / vulkan_context . cpp <nl> Error VulkanContext : : _create_validation_layers ( ) { <nl> } <nl> <nl> Error VulkanContext : : _initialize_extensions ( ) { <nl> - VkResult err ; <nl> uint32_t instance_extension_count = 0 ; <nl> <nl> enabled_extension_count = 0 ; <nl> Error VulkanContext : : _initialize_extensions ( ) { <nl> VkBool32 platformSurfaceExtFound = 0 ; <nl> memset ( extension_names , 0 , sizeof ( extension_names ) ) ; <nl> <nl> - err = vkEnumerateInstanceExtensionProperties ( nullptr , & instance_extension_count , nullptr ) ; <nl> - ERR_FAIL_COND_V ( err , ERR_CANT_CREATE ) ; <nl> + VkResult err = vkEnumerateInstanceExtensionProperties ( nullptr , & instance_extension_count , nullptr ) ; <nl> + ERR_FAIL_COND_V ( err ! = VK_SUCCESS & & err ! = VK_INCOMPLETE , ERR_CANT_CREATE ) ; <nl> <nl> if ( instance_extension_count > 0 ) { <nl> VkExtensionProperties * instance_extensions = ( VkExtensionProperties * ) malloc ( sizeof ( VkExtensionProperties ) * instance_extension_count ) ; <nl> err = vkEnumerateInstanceExtensionProperties ( nullptr , & instance_extension_count , instance_extensions ) ; <nl> - if ( err ) { <nl> + if ( err ! = VK_SUCCESS & & err ! = VK_INCOMPLETE ) { <nl> free ( instance_extensions ) ; <nl> ERR_FAIL_V ( ERR_CANT_CREATE ) ; <nl> } <nl>
|
Merge pull request from hbina / vk_error_handling
|
godotengine/godot
|
d1943f6a77c9a1832795c6e095d61d8d5b63a371
|
2020-11-29T12:03:01Z
|
mmm a / atom / browser / native_window_views . cc <nl> ppp b / atom / browser / native_window_views . cc <nl> views : : NonClientFrameView * NativeWindowViews : : CreateNonClientFrameView ( <nl> return NULL ; <nl> } <nl> <nl> + void NativeWindowViews : : HandleMouseDown ( ) { <nl> + if ( menu_bar_autohide_ & & menu_bar_show_ ) { <nl> + SetMenuBarVisibility ( false ) ; <nl> + Layout ( ) ; <nl> + } <nl> + } <nl> + <nl> void NativeWindowViews : : HandleKeyboardEvent ( <nl> content : : WebContents * , <nl> const content : : NativeWebKeyboardEvent & event ) { <nl> mmm a / atom / browser / native_window_views . h <nl> ppp b / atom / browser / native_window_views . h <nl> class NativeWindowViews : public NativeWindow , <nl> views : : Widget * widget ) OVERRIDE ; <nl> <nl> / / content : : WebContentsDelegate : <nl> + virtual void HandleMouseDown ( ) OVERRIDE ; <nl> virtual void HandleKeyboardEvent ( <nl> content : : WebContents * , <nl> const content : : NativeWebKeyboardEvent & event ) OVERRIDE ; <nl>
|
views : Hide menu bar when web view is clicked .
|
electron/electron
|
92d6fd641f69585f98f7e214165090e50f717b89
|
2014-08-07T06:14:43Z
|
mmm a / torch / csrc / api / include / torch / torch . h <nl> ppp b / torch / csrc / api / include / torch / torch . h <nl> <nl> # ifdef TORCH_API_INCLUDE_EXTENSION_H <nl> # include < torch / extension . h > <nl> <nl> - # ifdef _MSC_VER <nl> - # pragma message ( " Including torch / torch . h for C + + extensions is deprecated . Please include torch / extension . h " ) <nl> - # else <nl> - # warning " Including torch / torch . h for C + + extensions is deprecated . Please include torch / extension . h " <nl> - # endif <nl> - <nl> # endif / / defined ( TORCH_API_INCLUDE_EXTENSION_H ) <nl>
|
Removing deprecated warning message from torch . h ( )
|
pytorch/pytorch
|
4ccb707161356bcb9caa1f0727084384e9d7bbbe
|
2019-08-08T19:49:48Z
|
mmm a / build / Common . targets <nl> ppp b / build / Common . targets <nl> Targets For Tools <nl> Targets For GenerateSource <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - > <nl> <nl> + < Target Name = " _GenerateProjects " > <nl> + < Exec Command = " $ ( CsProjectProjector ) csproj_templates src \ ProtocolBuffersLibrary . sln " WorkingDirectory = " $ ( ProjectDirectory ) " / > <nl> + < / Target > <nl> + <nl> < Target Name = " _CleanTempSource " > <nl> < MSBuild Projects = " $ ( MSBuildProjectFullPath ) " Properties = " CleanFolderDirectory = $ ( SourceTempDirectory ) ; " Targets = " _CleanFolder " / > <nl> < MakeDir Directories = " $ ( SourceTempDirectory ) " / > <nl> Targets For Package <nl> <nl> < Target Name = " _GeneratePackage " > <nl> < Copy SourceFiles = " @ ( StaticPackageItem ) " DestinationFolder = " $ ( BuildOutputPackage ) \ % ( StaticPackageItem . TargetDirectory ) \ % ( StaticPackageItem . RecursiveDir ) " / > <nl> - < Exec Command = " & quot ; $ ( ZipExePath ) & quot ; a - tzip . . \ $ ( PackageName ) - binaries . zip * - x ! * . pdb - r " WorkingDirectory = " $ ( BuildOutputPackage ) " / > <nl> - < Exec Command = " & quot ; $ ( ZipExePath ) & quot ; a - tzip . . \ $ ( PackageName ) - symbols . zip * - r " WorkingDirectory = " $ ( BuildOutputPackage ) " / > <nl> + < Exec Command = " & quot ; $ ( ZipExePath ) & quot ; a - tzip $ ( BuildTempDirectory ) \ $ ( PackageName ) - binaries . zip * - x ! * . pdb - r " WorkingDirectory = " $ ( BuildOutputPackage ) " / > <nl> + < Exec Command = " & quot ; $ ( ZipExePath ) & quot ; a - tzip $ ( BuildTempDirectory ) \ $ ( PackageName ) - symbols . zip * - r " WorkingDirectory = " $ ( BuildOutputPackage ) " / > <nl> < / Target > <nl> <nl> < ! - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> mmm a / build / Google . ProtocolBuffers . nuspec <nl> ppp b / build / Google . ProtocolBuffers . nuspec <nl> Language Guide - http : / / code . google . com / apis / protocolbuffers / docs / proto . html <nl> < / metadata > <nl> < files > <nl> < ! - - Release Binaries - - > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release \ Google . ProtocolBuffers . ? ? ? " target = " lib \ net20 " / > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ net20 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release \ Google . ProtocolBuffers . ? ? ? " target = " lib \ net35 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ net35 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release \ Google . ProtocolBuffers . ? ? ? " target = " lib \ net40 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ net40 " / > <nl> - < ! - - Silverlight Binaries - - > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release_Silverlight \ Google . ProtocolBuffers . ? ? ? " target = " lib \ sl20 " / > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release_Silverlight \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ sl20 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release_Silverlight \ Google . ProtocolBuffers . ? ? ? " target = " lib \ sl30 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release_Silverlight \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ sl30 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release_Silverlight \ Google . ProtocolBuffers . ? ? ? " target = " lib \ sl40 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release_Silverlight \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ sl40 " / > <nl> + < file src = " . . \ build_output \ Release \ * * \ Google . ProtocolBuffers . ? ? ? " target = " lib \ " / > <nl> + < file src = " . . \ build_output \ Release \ * * \ Google . ProtocolBuffers . Serialization . ? ? ? " target = " lib \ " / > <nl> < ! - - Tools - - > <nl> - < file src = " . . \ lib \ Protoc . exe " target = " tools " / > <nl> - < file src = " . . \ build_output \ ProtoGen \ * " target = " tools " / > <nl> + < file src = " . . \ build_output \ tools \ * * \ * " target = " tools \ " / > <nl> + < file src = " . . \ build_output \ protos \ * * \ * " target = " content \ protos \ " / > <nl> < ! - - Content - - > <nl> - < file src = " . . \ CHANGES . txt " target = " content " / > <nl> - < file src = " . . \ license . txt " target = " content \ licenses " / > <nl> - < file src = " . . \ lib \ protoc - license . txt " target = " content \ licenses " / > <nl> - < file src = " . . \ protos \ google \ protobuf \ descriptor . proto " target = " content \ protos \ google \ protobuf " / > <nl> - < file src = " . . \ protos \ google \ protobuf \ csharp_options . proto " target = " content \ protos \ google \ protobuf " / > <nl> - <nl> + < file src = " . . \ build_output \ CHANGES . txt " target = " content " / > <nl> + < file src = " . . \ build_output \ license . txt " target = " content \ licenses " / > <nl> + < file src = " . . \ build_output \ tools \ protoc - license . txt " target = " content \ licenses " / > <nl> + < ! - - Source - - > <nl> < file src = " . . \ src \ ProtocolBuffers \ * * \ * . cs " target = " src \ ProtocolBuffers \ " / > <nl> < file src = " . . \ src \ ProtocolBuffers . Serialization \ * * \ * . cs " target = " src \ ProtocolBuffers . Serialization \ " / > <nl> < / files > <nl> mmm a / build / Google . ProtocolBuffersLite . nuspec <nl> ppp b / build / Google . ProtocolBuffersLite . nuspec <nl> Language Guide - http : / / code . google . com / apis / protocolbuffers / docs / proto . html <nl> < / references > <nl> <nl> < / metadata > <nl> + <nl> < files > <nl> < ! - - Release Binaries - - > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ net20 " / > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ net20 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ net35 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ net35 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ net40 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ net40 " / > <nl> - < ! - - Silverlight Binaries - - > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release_Silverlight \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ sl20 " / > <nl> - < file src = " . . \ build_output \ v2 . 0 \ Release_Silverlight \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ sl20 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release_Silverlight \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ sl30 " / > <nl> - < file src = " . . \ build_output \ v3 . 5 \ Release_Silverlight \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ sl30 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release_Silverlight \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ sl40 " / > <nl> - < file src = " . . \ build_output \ v4 . 0 \ Release_Silverlight \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ sl40 " / > <nl> + < file src = " . . \ build_output \ Release \ * * \ Google . ProtocolBuffersLite . ? ? ? " target = " lib \ " / > <nl> + < file src = " . . \ build_output \ Release \ * * \ Google . ProtocolBuffersLite . Serialization . ? ? ? " target = " lib \ " / > <nl> < ! - - Tools - - > <nl> - < file src = " . . \ lib \ Protoc . exe " target = " tools " / > <nl> - < file src = " . . \ build_output \ ProtoGen \ * " target = " tools " / > <nl> + < file src = " . . \ build_output \ tools \ * * \ * " target = " tools \ " / > <nl> + < file src = " . . \ build_output \ protos \ * * \ * " target = " content \ protos \ " / > <nl> < ! - - Content - - > <nl> - < file src = " . . \ CHANGES . txt " target = " content " / > <nl> - < file src = " . . \ license . txt " target = " content \ licenses " / > <nl> - < file src = " . . \ lib \ protoc - license . txt " target = " content \ licenses " / > <nl> - < file src = " . . \ protos \ google \ protobuf \ descriptor . proto " target = " content \ protos \ google \ protobuf " / > <nl> - < file src = " . . \ protos \ google \ protobuf \ csharp_options . proto " target = " content \ protos \ google \ protobuf " / > <nl> - <nl> + < file src = " . . \ build_output \ CHANGES . txt " target = " content " / > <nl> + < file src = " . . \ build_output \ license . txt " target = " content \ licenses " / > <nl> + < file src = " . . \ build_output \ tools \ protoc - license . txt " target = " content \ licenses " / > <nl> + < ! - - Source - - > <nl> < file src = " . . \ src \ ProtocolBuffers \ * * \ * . cs " target = " src \ ProtocolBuffers \ " / > <nl> < file src = " . . \ src \ ProtocolBuffers . Serialization \ * * \ * . cs " target = " src \ ProtocolBuffers . Serialization \ " / > <nl> < / files > <nl> deleted file mode 100644 <nl> index c6cb6f95b6 . . 0000000000 <nl> mmm a / build / PublishRelease . bat <nl> ppp / dev / null <nl> <nl> - REM @ ECHO OFF <nl> - @ PUSHD % ~ dp0 <nl> - @ IF " % 1 " = = " version " @ GOTO VERSION <nl> - @ IF " % 1 " = = " build " @ GOTO BUILD <nl> - @ IF " % 1 " = = " fpush " @ GOTO FILEPUSH <nl> - @ IF " % 1 " = = " nupush " @ GOTO NUGETPUSH <nl> - @ IF " % 1 " = = " push " @ GOTO PUSH <nl> - @ GOTO HELP <nl> - <nl> - : VERSION <nl> - IF NOT EXIST " . . \ build_temp \ " MD " . . \ build_temp \ " <nl> - hg log - l 1 - - template " Revision : { rev } " > . . \ build_temp \ revision . txt <nl> - CMD . exe / Q / C " CD . . & & lib \ StampVersion . exe / major : 2 / minor : 4 / build : 1 / revision : build_temp \ revision . txt " <nl> - @ TYPE . . \ src \ ProtocolBuffers \ Properties \ AssemblyInfo . cs | FIND " AssemblyFileVersion " <nl> - @ ECHO . <nl> - @ ECHO NEXT : Use the above version number to run " % 0 build { Version } " <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : BUILD <nl> - @ IF " % 2 " = = " " @ GOTO HELP <nl> - IF EXIST " C : \ Program Files \ Microsoft SDKs \ Windows \ v7 . 0 \ Bin \ sn . exe " SET WIN7SDK_DIR = C : \ Program Files \ Microsoft SDKs \ Windows \ v7 . 0 \ Bin \ <nl> - <nl> - IF NOT EXIST " . . \ release - key " hg clone https : / / bitbucket . org / rknapp / protobuf - csharp - port - keyfile . . \ release - key <nl> - <nl> - MD " % 2 " <nl> - CMD . exe / Q / C " BuildAll . bat / verbosity : minimal " / p : AssemblyOriginatorKeyFile = % ~ dp0 . . \ release - key \ Google . ProtocolBuffers . snk " <nl> - <nl> - COPY / y . . \ build_output \ release - binaries . zip % 2 \ protobuf - csharp - port - % 2 - release - binaries . zip <nl> - COPY / y . . \ build_output \ full - binaries . zip % 2 \ protobuf - csharp - port - % 2 - full - binaries . zip <nl> - <nl> - . . \ lib \ NuGet . exe pack Google . ProtocolBuffers . nuspec - Symbols - Version % 2 - NoPackageAnalysis - OutputDirectory % 2 <nl> - . . \ lib \ NuGet . exe pack Google . ProtocolBuffersLite . nuspec - Symbols - Version % 2 - NoPackageAnalysis - OutputDirectory % 2 <nl> - <nl> - hg archive % 2 \ protobuf - csharp - port - % 2 - source . zip <nl> - <nl> - " % WIN7SDK_DIR % sn . exe " - T . . \ build_output \ v2 . 0 \ Release \ Google . ProtocolBuffers . dll <nl> - @ ECHO . <nl> - @ ECHO * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - @ ECHO IMPORTANT : Verify the above key output is : 55f7125234beb589 <nl> - @ ECHO * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - @ ECHO . <nl> - @ ECHO NEXT : Verify the output in % ~ dp0 \ % 2 and then run " % 0 push % 2 " <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : PUSH <nl> - @ IF " % 2 " = = " " @ GOTO HELP <nl> - <nl> - hg commit - m " version % 2 " <nl> - hg tag % 2 <nl> - hg push <nl> - @ ECHO . <nl> - @ ECHO NEXT : Verify the repository state and run " % 0 fpush % 2 { google - code - user } { google - code - password } " <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : FILEPUSH <nl> - @ IF " % 2 " = = " " @ GOTO HELP <nl> - @ IF " % 3 " = = " " @ GOTO HELP <nl> - @ IF " % 4 " = = " " @ GOTO HELP <nl> - SET GOOGLEUPLOAD = python . exe googlecode_upload . py - - project protobuf - csharp - port - - user " % 3 " - - password " % 4 " <nl> - <nl> - % GOOGLEUPLOAD % - - labels Type - Source , Featured - - summary " Version % 2 source " % 2 \ protobuf - csharp - port - % 2 - source . zip <nl> - % GOOGLEUPLOAD % - - labels Type - Executable , Featured - - summary " Version % 2 binaries ( all configurations ) " % 2 \ protobuf - csharp - port - % 2 - full - binaries . zip <nl> - % GOOGLEUPLOAD % - - labels Type - Executable , Featured - - summary " Version % 2 binaries ( release only ) " % 2 \ protobuf - csharp - port - % 2 - release - binaries . zip <nl> - <nl> - @ SET GOOGLEUPLOAD = <nl> - @ ECHO . <nl> - @ ECHO NEXT : Verify the uploads and run " % 0 nupush % 2 " <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : NUGETPUSH <nl> - <nl> - . . \ lib \ NuGet . exe push " % 2 \ Google . ProtocolBuffers . % 2 . nupkg " <nl> - . . \ lib \ NuGet . exe push " % 2 \ Google . ProtocolBuffersLite . % 2 . nupkg " <nl> - . . \ lib \ NuGet . exe push " % 2 \ Google . ProtocolBuffers . % 2 . symbols . nupkg " <nl> - . . \ lib \ NuGet . exe push " % 2 \ Google . ProtocolBuffersLite . % 2 . symbols . nupkg " <nl> - <nl> - @ ECHO . <nl> - @ ECHO NEXT : Verify the nuget packages at http : / / nuget . org <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : HELP <nl> - @ ECHO . <nl> - @ ECHO Available commands , run in the following order : <nl> - @ ECHO 1 . % 0 version <nl> - @ ECHO 2 . % 0 build { version from step 1 } <nl> - @ ECHO 3 . % 0 push { version from step 1 } <nl> - @ ECHO 4 . % 0 fpush { version from step 1 } { google - code - user } { google - code - password } <nl> - @ ECHO 5 . % 0 nupush { version from step 1 } <nl> - @ ECHO . <nl> - @ GOTO EXIT <nl> - <nl> - : EXIT <nl> - @ POPD <nl> \ No newline at end of file <nl> mmm a / build / build . csproj <nl> ppp b / build / build . csproj <nl> <nl> < ! - - build targets - - > <nl> < Target Name = " Clean " DependsOnTargets = " _CleanAll " / > <nl> < Target Name = " BuildTools " DependsOnTargets = " _BuildTools " / > <nl> + < Target Name = " GenerateProjects " DependsOnTargets = " _GenerateProjects " / > <nl> < Target Name = " GenerateSource " DependsOnTargets = " _GenerateSource ; _CopyGeneratedSource " / > <nl> < Target Name = " RebuildSource " DependsOnTargets = " Clean ; BuildTools ; GenerateSource " / > <nl> - < Target Name = " Build " DependsOnTargets = " BuildTools ; GenerateSource ; _CompileAll " / > <nl> + < Target Name = " Build " DependsOnTargets = " GenerateProjects ; BuildTools ; GenerateSource ; _CompileAll " / > <nl> < Target Name = " Rebuild " DependsOnTargets = " Clean ; Build " / > <nl> < Target Name = " GeneratePackage " DependsOnTargets = " _PackageAll ; _GeneratePackage " / > <nl> < Target Name = " FullBuild " DependsOnTargets = " Rebuild ; GeneratePackage " / > <nl> <nl> < ProtocExePath > $ ( BuildOutputDirectory ) \ tools \ protoc . exe < / ProtocExePath > <nl> < ProtogenExePath > $ ( BuildOutputDirectory ) \ tools \ protogen . exe < / ProtogenExePath > <nl> < NUnitExePath > $ ( LibDirectory ) \ NUnit \ tools \ nunit - console . exe < / NUnitExePath > <nl> + < CsProjectProjector > $ ( LibDirectory ) \ CsProjectProjector \ CsProjectProjector . exe < / CsProjectProjector > <nl> < ZipExePath > $ ( LibDirectory ) \ 7 - Zip 9 . 20 \ 7za . exe < / ZipExePath > <nl> - < / PropertyGroup > <nl> + <nl> + < / PropertyGroup > <nl> <nl> < Import Project = " Common . targets " / > <nl> <nl> new file mode 100644 <nl> index 0000000000 . . 9cb4390834 <nl> mmm / dev / null <nl> ppp b / build / publish . csproj <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < Project DefaultTargets = " Publish " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + <nl> + < ! - - build targets - - > <nl> + < Target Name = " Clean " DependsOnTargets = " _Clean " / > <nl> + < Target Name = " Publish " DependsOnTargets = " _Publish " / > <nl> + <nl> + < PropertyGroup > <nl> + < ProjectName > Protocol Buffers < / ProjectName > <nl> + < VersionMajor > 2 < / VersionMajor > <nl> + < VersionMinor > 4 < / VersionMinor > <nl> + < VersionBuild > 1 < / VersionBuild > <nl> + < VersionRevision > < / VersionRevision > <nl> + < VersionLabel > < / VersionLabel > <nl> + <nl> + < PackagePrefix > protobuf - csharp - port - < / PackagePrefix > <nl> + < PublishDebug > false < / PublishDebug > <nl> + <nl> + < GoogleUsername > < / GoogleUsername > <nl> + < GooglePassword > < / GooglePassword > <nl> + <nl> + < ! - - Directory Paths - - > <nl> + < ProjectDirectory > $ ( MSBuildProjectDirectory ) \ . . < / ProjectDirectory > <nl> + < BuildTempDirectory > $ ( ProjectDirectory ) \ build_temp < / BuildTempDirectory > <nl> + < BuildOutputDirectory > $ ( ProjectDirectory ) \ build_output < / BuildOutputDirectory > <nl> + < SourceDirectory > $ ( ProjectDirectory ) \ src < / SourceDirectory > <nl> + < LibDirectory > $ ( ProjectDirectory ) \ lib < / LibDirectory > <nl> + <nl> + < ! - - File Paths - - > <nl> + < SigningKey > $ ( ProjectDirectory ) \ release - key \ Google . ProtocolBuffers . snk < / SigningKey > <nl> + <nl> + < ! - - Tool Paths - - > <nl> + < HgTool > hg . exe < / HgTool > <nl> + < Python > C : \ Python25 \ python . exe < / Python > <nl> + < SnTool > $ ( registry : HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Microsoft SDKs \ Windows \ v7 . 0A @ InstallationFolder ) Bin \ sn . exe < / SnTool > <nl> + < StampVer > $ ( LibDirectory ) \ StampVersion . exe < / StampVer > <nl> + < ZipExePath > $ ( LibDirectory ) \ 7 - Zip 9 . 20 \ 7za . exe < / ZipExePath > <nl> + < NuGet > $ ( LibDirectory ) \ NuGet . exe < / NuGet > <nl> + < ProtogenExePath > $ ( BuildOutputDirectory ) \ tools \ protogen . exe < / ProtogenExePath > <nl> + < / PropertyGroup > <nl> + <nl> + < ! - - Import user settings - - > <nl> + < Import Project = " $ ( MSBuildProjectFullPath ) . user " Condition = " Exists ( ' $ ( MSBuildProjectFullPath ) . user ' ) " / > <nl> + <nl> + < ! - - Files - - > <nl> + < ItemGroup > <nl> + < / ItemGroup > <nl> + <nl> + < ! - - Tasks - - > <nl> + <nl> + < Target Name = " _Publish " DependsOnTargets = " _PrepBuild ; _PushAll " / > <nl> + <nl> + < Target Name = " _Prerequisites " DependsOnTargets = " _CheckEnvironment ; _ReadVersion " / > <nl> + < Target Name = " _PrepBuild " DependsOnTargets = " _Clean ; _Prerequisites ; _StampVersion ; _GenerateSource ; _Build ; _NugetPack ; _HgLabel " / > <nl> + < Target Name = " _PushAll " DependsOnTargets = " _HgPush ; _PkgPush ; _NugetPush " / > <nl> + <nl> + < Target Name = " _Clean " > <nl> + < MSBuild Properties = " Configuration = Debug ; " Targets = " Clean " Projects = " $ ( MSBuildProjectDirectory ) \ target . csproj " / > <nl> + < MSBuild Properties = " Configuration = Release ; " Targets = " Clean " Projects = " $ ( MSBuildProjectDirectory ) \ target . csproj " / > <nl> + < MakeDir Directories = " $ ( BuildTempDirectory ) " / > <nl> + < MakeDir Directories = " $ ( BuildOutputDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _WriteUserConfig " > <nl> + < ItemGroup > <nl> + < Lines Include = " & lt ; Project xmlns = ' http : / / schemas . microsoft . com / developer / msbuild / 2003 ' > " / > <nl> + < Lines Include = " & lt ; PropertyGroup > " / > <nl> + < Lines Include = " & lt ; GoogleUsername > ( Enter your google - code user / password here ) & lt ; / GoogleUsername > " / > <nl> + < Lines Include = " & lt ; GooglePassword > & lt ; / GooglePassword > " / > <nl> + < Lines Include = " & lt ; / PropertyGroup > " / > <nl> + < Lines Include = " & lt ; / Project > " / > <nl> + < / ItemGroup > <nl> + < WriteLinesToFile File = " $ ( MSBuildProjectFullPath ) . user " Lines = " @ ( Lines ) " Overwrite = " true " Condition = " ! Exists ( ' $ ( MSBuildProjectFullPath ) . user ' ) " / > <nl> + < Exec Command = " Notepad . exe $ ( MSBuildProjectFullPath ) . user " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _CheckEnvironment " > <nl> + < ! - - Require google credentials - - > <nl> + < CallTarget Targets = " _WriteUserConfig " Condition = " ' $ ( GooglePassword ) ' = = ' ' " / > <nl> + < Error Text = " Restart after you verify your credentials in $ ( MSBuildProjectFullPath ) . user " Condition = " ' $ ( GooglePassword ) ' = = ' ' " / > <nl> + < ! - - Require Win7 . 0A SDK to verify strong - name - - > <nl> + < Error Text = " Unable to locate Win7SDK Tools : $ ( SnTool ) " Condition = " ! Exists ( $ ( SnTool ) ) " / > <nl> + < ! - - Require Python 2 . 5 installed - - > <nl> + < Error Text = " Unable to locate Python 2 . 5 : $ ( Python ) " Condition = " ! Exists ( $ ( Python ) ) " / > <nl> + < ! - - Require production signing key - - > <nl> + < Exec Command = " $ ( HgTool ) clone https : / / bitbucket . org / rknapp / protobuf - csharp - port - keyfile $ ( ProjectDirectory ) \ release - key " Condition = " ! Exists ( ' $ ( SigningKey ) ' ) " / > <nl> + < Error Text = " Unable to locate release signing key : $ ( SigningKey ) " Condition = " ! Exists ( $ ( SigningKey ) ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _ReadVersion " Condition = " ' $ ( VersionLabel ) ' = = ' ' " > <nl> + < Exec Command = " $ ( HgTool ) log - l 1 - - template & quot ; { rev } & quot ; > & quot ; $ ( BuildTempDirectory ) \ revision . txt & quot ; " > < / Exec > <nl> + < ReadLinesFromFile File = " $ ( BuildTempDirectory ) \ revision . txt " > <nl> + < Output TaskParameter = " Lines " PropertyName = " VersionRevision " / > <nl> + < / ReadLinesFromFile > <nl> + <nl> + < PropertyGroup > <nl> + < VersionLabel > $ ( VersionMajor ) . $ ( VersionMinor ) . $ ( VersionBuild ) . $ ( VersionRevision ) < / VersionLabel > <nl> + < / PropertyGroup > <nl> + <nl> + < Message Text = " Building version $ ( VersionLabel ) " Importance = " high " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _StampVersion " DependsOnTargets = " _Prerequisites " > <nl> + < Exec Command = " $ ( StampVer ) / major : $ ( VersionMajor ) / minor : $ ( VersionMinor ) / build : $ ( VersionBuild ) / revision : $ ( VersionRevision ) " WorkingDirectory = " $ ( SourceDirectory ) " / > <nl> + < Exec Command = " FIND & quot ; $ ( VersionLabel ) & quot ; ProtocolBuffers \ Properties \ AssemblyInfo . cs " WorkingDirectory = " $ ( SourceDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _GenerateSource " DependsOnTargets = " _Prerequisites " > <nl> + < MSBuild Properties = " Configuration = Release ; AssemblyOriginatorKeyFile = $ ( SigningKey ) " Targets = " GenerateProjects ; BuildTools ; GenerateSource " Projects = " $ ( MSBuildProjectDirectory ) \ build . csproj " / > <nl> + < Exec Command = " & quot ; $ ( SnTool ) & quot ; - T & quot ; $ ( ProtogenExePath ) & quot ; > signkey . txt " WorkingDirectory = " $ ( BuildTempDirectory ) " / > <nl> + < ! - - Make sure we are signing with the correct key - - > <nl> + < Exec Command = " FIND & quot ; 55f7125234beb589 & quot ; signkey . txt " WorkingDirectory = " $ ( BuildTempDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _Build " DependsOnTargets = " _Prerequisites " > <nl> + < ! - - Release Build - - > <nl> + < MSBuild Properties = " Configuration = Release ; AssemblyOriginatorKeyFile = $ ( SigningKey ) " Targets = " _CompileAll " Projects = " $ ( MSBuildProjectDirectory ) \ build . csproj " / > <nl> + < MSBuild Properties = " Configuration = Release ; AssemblyOriginatorKeyFile = $ ( SigningKey ) ; PackageName = $ ( PackagePrefix ) $ ( VersionLabel ) - release " Targets = " GeneratePackage " Projects = " $ ( MSBuildProjectDirectory ) \ build . csproj " / > <nl> + < ! - - Debug Build - - > <nl> + < MSBuild Condition = " ' $ ( PublishDebug ) ' = = ' true ' " Properties = " Configuration = Debug ; AssemblyOriginatorKeyFile = $ ( SigningKey ) " Targets = " _CompileAll " Projects = " $ ( MSBuildProjectDirectory ) \ build . csproj " / > <nl> + < MSBuild Condition = " ' $ ( PublishDebug ) ' = = ' true ' " Properties = " Configuration = Debug ; AssemblyOriginatorKeyFile = $ ( SigningKey ) ; PackageName = $ ( PackagePrefix ) $ ( VersionLabel ) - full " Targets = " GeneratePackage " Projects = " $ ( MSBuildProjectDirectory ) \ build . csproj " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _HgLabel " DependsOnTargets = " _Prerequisites " > <nl> + < Exec Command = " $ ( HgTool ) tag $ ( VersionLabel ) " WorkingDirectory = " $ ( ProjectDirectory ) " / > <nl> + < Exec Command = " $ ( HgTool ) commit - m & quot ; version $ ( VersionLabel ) & quot ; " WorkingDirectory = " $ ( ProjectDirectory ) " / > <nl> + < Exec Command = " $ ( HgTool ) archive $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - source . zip " WorkingDirectory = " $ ( ProjectDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _HgPush " DependsOnTargets = " _Prerequisites " > <nl> + < Exec Command = " $ ( HgTool ) push " WorkingDirectory = " $ ( ProjectDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _PkgPush " DependsOnTargets = " _Prerequisites " > <nl> + < PropertyGroup > <nl> + < UploadPackage > $ ( Python ) " $ ( MSBuildProjectDirectory ) \ googlecode_upload . py " - - project protobuf - csharp - port - - user " $ ( GoogleUsername ) " - - password " $ ( GooglePassword ) " < / UploadPackage > <nl> + <nl> + < SourcePackage > $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - source . zip < / SourcePackage > <nl> + < ReleasePackageBin > $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - release - binaries . zip < / ReleasePackageBin > <nl> + < ReleasePackageSyb > $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - release - symbols . zip < / ReleasePackageSyb > <nl> + < DebugPackageBin > $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - full - binaries . zip < / DebugPackageBin > <nl> + < DebugPackageSyb > $ ( BuildTempDirectory ) \ $ ( PackagePrefix ) $ ( VersionLabel ) - full - symbols . zip < / DebugPackageSyb > <nl> + < / PropertyGroup > <nl> + <nl> + < Error Condition = " ! Exists ( ' $ ( SourcePackage ) ' ) " Text = " File not found : $ ( SourcePackage ) " / > <nl> + < Error Condition = " ! Exists ( ' $ ( ReleasePackageBin ) ' ) " Text = " File not found : $ ( ReleasePackageBin ) " / > <nl> + < Error Condition = " ! Exists ( ' $ ( ReleasePackageSyb ) ' ) " Text = " File not found : $ ( ReleasePackageSyb ) " / > <nl> + < Error Condition = " ' $ ( PublishDebug ) ' = = ' true ' And ! Exists ( ' $ ( DebugPackageBin ) ' ) " Text = " File not found : $ ( DebugPackageBin ) " / > <nl> + < Error Condition = " ' $ ( PublishDebug ) ' = = ' true ' And ! Exists ( ' $ ( DebugPackageSyb ) ' ) " Text = " File not found : $ ( DebugPackageSyb ) " / > <nl> + <nl> + < Exec WorkingDirectory = " $ ( ProjectDirectory ) " <nl> + Command = " $ ( UploadPackage ) - - labels Type - Source , Featured - - summary & quot ; Version $ ( VersionLabel ) source & quot ; $ ( SourcePackage ) " / > <nl> + <nl> + < Exec WorkingDirectory = " $ ( ProjectDirectory ) " <nl> + Command = " $ ( UploadPackage ) - - labels Type - Executable , Featured - - summary & quot ; Version $ ( VersionLabel ) release binaries only & quot ; $ ( ReleasePackageBin ) " / > <nl> + < Exec WorkingDirectory = " $ ( ProjectDirectory ) " <nl> + Command = " $ ( UploadPackage ) - - labels Type - Executable , Featured - - summary & quot ; Version $ ( VersionLabel ) release binaries and symbols & quot ; $ ( ReleasePackageSyb ) " / > <nl> + <nl> + < Exec WorkingDirectory = " $ ( ProjectDirectory ) " Condition = " ' $ ( PublishDebug ) ' = = ' true ' " <nl> + Command = " $ ( UploadPackage ) - - labels Type - Executable , Featured - - summary & quot ; Version $ ( VersionLabel ) all binaries & quot ; $ ( DebugPackageBin ) " / > <nl> + < Exec WorkingDirectory = " $ ( ProjectDirectory ) " Condition = " ' $ ( PublishDebug ) ' = = ' true ' " <nl> + Command = " $ ( UploadPackage ) - - labels Type - Executable , Featured - - summary & quot ; Version $ ( VersionLabel ) all binaries and symbols & quot ; $ ( DebugPackageSyb ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _NugetPack " DependsOnTargets = " _Prerequisites " > <nl> + < Exec WorkingDirectory = " $ ( MSBuildProjectDirectory ) " <nl> + Command = " $ ( NuGet ) update - self " / > <nl> + < Exec WorkingDirectory = " $ ( MSBuildProjectDirectory ) " <nl> + Command = " $ ( NuGet ) pack Google . ProtocolBuffers . nuspec - Symbols - Version $ ( VersionLabel ) - NoPackageAnalysis - OutputDirectory $ ( BuildTempDirectory ) " / > <nl> + < Exec WorkingDirectory = " $ ( MSBuildProjectDirectory ) " <nl> + Command = " $ ( NuGet ) pack Google . ProtocolBuffersLite . nuspec - Symbols - Version $ ( VersionLabel ) - NoPackageAnalysis - OutputDirectory $ ( BuildTempDirectory ) " / > <nl> + < / Target > <nl> + <nl> + < Target Name = " _NugetPush " DependsOnTargets = " _Prerequisites " > <nl> + < Exec WorkingDirectory = " $ ( BuildTempDirectory ) " Command = " $ ( NuGet ) push Google . ProtocolBuffers . $ ( VersionLabel ) . nupkg " ContinueOnError = " true " / > <nl> + < Exec WorkingDirectory = " $ ( BuildTempDirectory ) " Command = " $ ( NuGet ) push Google . ProtocolBuffersLite . $ ( VersionLabel ) . nupkg " ContinueOnError = " true " / > <nl> + <nl> + < Exec WorkingDirectory = " $ ( BuildTempDirectory ) " Command = " $ ( NuGet ) push Google . ProtocolBuffers . $ ( VersionLabel ) . symbols . nupkg " ContinueOnError = " true " / > <nl> + < Exec WorkingDirectory = " $ ( BuildTempDirectory ) " Command = " $ ( NuGet ) push Google . ProtocolBuffersLite . $ ( VersionLabel ) . symbols . nupkg " ContinueOnError = " true " / > <nl> + < / Target > <nl> + <nl> + < / Project > <nl> Binary files a / lib / NuGet . exe and b / lib / NuGet . exe differ <nl> mmm a / src / ProtocolBuffers . sln <nl> ppp b / src / ProtocolBuffers . sln <nl> Project ( " { 2150E333 - 8FDC - 42A3 - 9474 - 1A3956D46DE8 } " ) = " build " , " build " , " { 66ED1950 <nl> . . \ build \ build . bat = . . \ build \ build . bat <nl> . . \ build \ build . csproj = . . \ build \ build . csproj <nl> . . \ build \ BuildAll . bat = . . \ build \ BuildAll . bat <nl> + . . \ build \ GenerateProjects . bat = . . \ build \ GenerateProjects . bat <nl> + . . \ build \ PublishTool . bat = . . \ build \ PublishTool . bat <nl> . . \ build \ Common . targets = . . \ build \ Common . targets <nl> . . \ build \ GenerateSource . bat = . . \ build \ GenerateSource . bat <nl> . . \ build \ Google . ProtocolBuffers . nuspec = . . \ build \ Google . ProtocolBuffers . nuspec <nl> . . \ build \ Google . ProtocolBuffersLite . nuspec = . . \ build \ Google . ProtocolBuffersLite . nuspec <nl> - . . \ build \ PublishRelease . bat = . . \ build \ PublishRelease . bat <nl> + . . \ build \ publish . csproj = . . \ build \ publish . csproj <nl> . . \ build \ RunBenchmarks . bat = . . \ build \ RunBenchmarks . bat <nl> . . \ build \ target . csproj = . . \ build \ target . csproj <nl> EndProjectSection <nl>
|
Rewrote the PublishRelease . bat file in MSBuild ( publish . csproj ) , updated nuspec files
|
protocolbuffers/protobuf
|
832b08e238523cfa57856da814cadee492c144f8
|
2012-10-17T00:41:35Z
|
mmm a / buildscripts / clang_format . py <nl> ppp b / buildscripts / clang_format . py <nl> <nl> # <nl> <nl> # Expected version of clang - format <nl> - CLANG_FORMAT_VERSION = " 3 . 6 . 0 " <nl> + CLANG_FORMAT_VERSION = " 3 . 8 . 0 " <nl> + CLANG_FORMAT_SHORT_VERSION = " 3 . 8 " <nl> <nl> # Name of clang - format as a binary <nl> CLANG_FORMAT_PROGNAME = " clang - format " <nl> <nl> # URL location of the " cached " copy of clang - format to download <nl> # for users which do not have clang - format installed <nl> - CLANG_FORMAT_HTTP_LINUX_CACHE = " https : / / s3 . amazonaws . com / boxes . 10gen . com / build / clang - format - rhel55 . tar . gz " <nl> + CLANG_FORMAT_HTTP_LINUX_CACHE = " https : / / s3 . amazonaws . com / boxes . 10gen . com / build / clang - format - 3 . 8 - rhel55 . tar . gz " <nl> <nl> - # URL on LLVM ' s website to download the clang tarball <nl> - CLANG_FORMAT_SOURCE_URL_BASE = string . Template ( " http : / / llvm . org / releases / $ version / clang + llvm - $ version - $ llvm_distro . tar . xz " ) <nl> + CLANG_FORMAT_HTTP_DARWIN_CACHE = " https : / / s3 . amazonaws . com / boxes . 10gen . com / build / clang % 2Bllvm - 3 . 8 . 0 - x86_64 - apple - darwin . tar . xz " <nl> <nl> # Path in the tarball to the clang - format binary <nl> CLANG_FORMAT_SOURCE_TAR_BASE = string . Template ( " clang + llvm - $ version - $ tar_path / bin / " + CLANG_FORMAT_PROGNAME ) <nl> def callo ( args ) : <nl> " " " <nl> return check_output ( args ) <nl> <nl> - def get_llvm_url ( version , llvm_distro ) : <nl> - " " " Get the url to download clang - format from llvm . org <nl> - " " " <nl> - return CLANG_FORMAT_SOURCE_URL_BASE . substitute ( <nl> - version = version , <nl> - llvm_distro = llvm_distro ) <nl> - <nl> def get_tar_path ( version , tar_path ) : <nl> " " " Get the path to clang - format in the llvm tarball <nl> " " " <nl> def extract_clang_format ( tar_path ) : <nl> tarfp . extract ( name ) <nl> tarfp . close ( ) <nl> <nl> - def get_clang_format_from_llvm ( llvm_distro , tar_path , dest_file ) : <nl> - " " " Download clang - format from llvm . org , unpack the tarball , <nl> - and put clang - format in the specified place <nl> + def get_clang_format_from_cache_and_extract ( url , tarball_ext ) : <nl> + " " " Get clang - format from mongodb ' s cache <nl> + and extract the tarball <nl> " " " <nl> - # Build URL <nl> - url = get_llvm_url ( CLANG_FORMAT_VERSION , llvm_distro ) <nl> - <nl> dest_dir = tempfile . gettempdir ( ) <nl> - temp_tar_file = os . path . join ( dest_dir , " temp . tar . xz " ) <nl> + temp_tar_file = os . path . join ( dest_dir , " temp . tar " + tarball_ext ) <nl> <nl> - # Download from LLVM <nl> + # Download from file <nl> print ( " Downloading clang - format % s from % s , saving to % s " % ( CLANG_FORMAT_VERSION , <nl> url , temp_tar_file ) ) <nl> urllib . urlretrieve ( url , temp_tar_file ) <nl> <nl> extract_clang_format ( temp_tar_file ) <nl> <nl> + def get_clang_format_from_darwin_cache ( dest_file ) : <nl> + " " " Download clang - format from llvm . org , unpack the tarball , <nl> + and put clang - format in the specified place <nl> + " " " <nl> + get_clang_format_from_cache_and_extract ( CLANG_FORMAT_HTTP_DARWIN_CACHE , " . xz " ) <nl> + <nl> # Destination Path <nl> - shutil . move ( get_tar_path ( CLANG_FORMAT_VERSION , tar_path ) , dest_file ) <nl> + shutil . move ( get_tar_path ( CLANG_FORMAT_VERSION , " x86_64 - apple - darwin " ) , dest_file ) <nl> <nl> def get_clang_format_from_linux_cache ( dest_file ) : <nl> " " " Get clang - format from mongodb ' s cache <nl> " " " <nl> - # Get URL <nl> - url = CLANG_FORMAT_HTTP_LINUX_CACHE <nl> - <nl> - dest_dir = tempfile . gettempdir ( ) <nl> - temp_tar_file = os . path . join ( dest_dir , " temp . tar . xz " ) <nl> - <nl> - # Download the file <nl> - print ( " Downloading clang - format % s from % s , saving to % s " % ( CLANG_FORMAT_VERSION , <nl> - url , temp_tar_file ) ) <nl> - urllib . urlretrieve ( url , temp_tar_file ) <nl> - <nl> - extract_clang_format ( temp_tar_file ) <nl> + get_clang_format_from_cache_and_extract ( CLANG_FORMAT_HTTP_LINUX_CACHE , " . gz " ) <nl> <nl> # Destination Path <nl> - shutil . move ( " llvm / Release / bin / clang - format " , dest_file ) <nl> + shutil . move ( " build / bin / clang - format " , dest_file ) <nl> <nl> class ClangFormat ( object ) : <nl> " " " Class encapsulates finding a suitable copy of clang - format , <nl> and linting / formating an individual file <nl> " " " <nl> def __init__ ( self , path , cache_dir ) : <nl> - if os . path . exists ( ' / usr / bin / clang - format - 3 . 6 ' ) : <nl> - clang_format_progname = ' clang - format - 3 . 6 ' <nl> - else : <nl> - clang_format_progname = CLANG_FORMAT_PROGNAME <nl> - <nl> - # Initialize clang - format configuration information <nl> - if sys . platform . startswith ( " linux " ) : <nl> - # " 3 . 6 . 0 / clang + llvm - 3 . 6 . 0 - x86_64 - linux - gnu - ubuntu - 14 . 04 . tar . xz <nl> - self . platform = " linux_x64 " <nl> - self . llvm_distro = " x86_64 - linux - gnu - ubuntu " <nl> - self . tar_path = " x86_64 - linux - gnu " <nl> - elif sys . platform = = " win32 " : <nl> - self . platform = " windows_x64 " <nl> - self . llvm_distro = " windows_x64 " <nl> - self . tar_path = None <nl> - clang_format_progname + = " . exe " <nl> - elif sys . platform = = " darwin " : <nl> - # " 3 . 6 . 0 / clang + llvm - 3 . 6 . 0 - x86_64 - apple - darwin . tar . xz <nl> - self . platform = " darwin_x64 " <nl> - self . llvm_distro = " x86_64 - apple - darwin " <nl> - self . tar_path = " x86_64 - apple - darwin " <nl> - <nl> self . path = None <nl> + clang_format_progname_ext = " " <nl> + <nl> + if sys . platform = = " win32 " : <nl> + clang_format_progname_ext + = " . exe " <nl> <nl> - # Find Clang - Format now <nl> + # Check the clang - format the user specified <nl> if path is not None : <nl> if os . path . isfile ( path ) : <nl> self . path = path <nl> else : <nl> print ( " WARNING : Could not find clang - format % s " % ( path ) ) <nl> <nl> - # Check the envionrment variable <nl> + # Check the environment variable <nl> if " MONGO_CLANG_FORMAT " in os . environ : <nl> self . path = os . environ [ " MONGO_CLANG_FORMAT " ] <nl> <nl> - if self . path and not self . _validate_version ( warn = True ) : <nl> + if self . path and not self . _validate_version ( ) : <nl> self . path = None <nl> <nl> # Check the users ' PATH environment variable now <nl> if self . path is None : <nl> - self . path = spawn . find_executable ( clang_format_progname ) <nl> - <nl> - if self . path and not self . _validate_version ( warn = True ) : <nl> - self . path = None <nl> + # Check for various versions staring with binaries with version specific suffixes in the <nl> + # user ' s path <nl> + programs = [ <nl> + CLANG_FORMAT_PROGNAME + " - " + CLANG_FORMAT_VERSION , <nl> + CLANG_FORMAT_PROGNAME + " - " + CLANG_FORMAT_SHORT_VERSION , <nl> + CLANG_FORMAT_PROGNAME , <nl> + ] <nl> + <nl> + if sys . platform = = " win32 " : <nl> + for i in range ( len ( programs ) ) : <nl> + programs [ i ] + = ' . exe ' <nl> + <nl> + for program in programs : <nl> + self . path = spawn . find_executable ( program ) <nl> + <nl> + if self . path : <nl> + if not self . _validate_version ( ) : <nl> + self . path = None <nl> + else : <nl> + break <nl> <nl> # If Windows , try to grab it from Program Files <nl> if sys . platform = = " win32 " : <nl> def __init__ ( self , path , cache_dir ) : <nl> if not os . path . isdir ( cache_dir ) : <nl> os . makedirs ( cache_dir ) <nl> <nl> - self . path = os . path . join ( cache_dir , clang_format_progname ) <nl> + self . path = os . path . join ( cache_dir , CLANG_FORMAT_PROGNAME + " - " + CLANG_FORMAT_VERSION + clang_format_progname_ext ) <nl> <nl> - if not os . path . isfile ( self . path ) : <nl> + # Download a new version if the cache is empty or stale <nl> + if not os . path . isfile ( self . path ) or not self . _validate_version ( ) : <nl> if sys . platform . startswith ( " linux " ) : <nl> get_clang_format_from_linux_cache ( self . path ) <nl> elif sys . platform = = " darwin " : <nl> - get_clang_format_from_llvm ( self . llvm_distro , self . tar_path , self . path ) <nl> + get_clang_format_from_darwin_cache ( self . path ) <nl> else : <nl> print ( " ERROR : clang - format . py does not support downloading clang - format " + <nl> " on this platform , please install clang - format " + CLANG_FORMAT_VERSION ) <nl> <nl> # Validate we have the correct version <nl> - self . _validate_version ( ) <nl> + # We only can fail here if the user specified a clang - format binary and it is the wrong <nl> + # version <nl> + if not self . _validate_version ( ) : <nl> + print ( " ERROR : exiting because of previous warning . " ) <nl> + sys . exit ( 1 ) <nl> <nl> self . print_lock = threading . Lock ( ) <nl> <nl> - def _validate_version ( self , warn = False ) : <nl> + def _validate_version ( self ) : <nl> " " " Validate clang - format is the expected version <nl> " " " <nl> cf_version = callo ( [ self . path , " - - version " ] ) <nl> def _validate_version ( self , warn = False ) : <nl> if CLANG_FORMAT_VERSION in cf_version : <nl> return True <nl> <nl> - if warn : <nl> - print ( " WARNING : clang - format found in path , but incorrect version found at " + <nl> - self . path + " with version : " + cf_version ) <nl> + print ( " WARNING : clang - format found in path , but incorrect version found at " + <nl> + self . path + " with version : " + cf_version ) <nl> <nl> return False <nl> <nl>
|
SERVER - 23339 Update clang_format . py to use clang - format 3 . 8
|
mongodb/mongo
|
fea3cf185cae4197262b3a4bbf737131869d72ce
|
2016-05-28T21:55:10Z
|
mmm a / src / php / ext / grpc / php_grpc . c <nl> ppp b / src / php / ext / grpc / php_grpc . c <nl> ZEND_GET_MODULE ( grpc ) <nl> <nl> / * { { { PHP_INI <nl> * / <nl> - / * Remove comments and fill if you need to have entries in php . ini <nl> PHP_INI_BEGIN ( ) <nl> - STD_PHP_INI_ENTRY ( " grpc . global_value " , " 42 " , PHP_INI_ALL , OnUpdateLong , <nl> - global_value , zend_grpc_globals , grpc_globals ) <nl> - STD_PHP_INI_ENTRY ( " grpc . global_string " , " foobar " , PHP_INI_ALL , <nl> - OnUpdateString , global_string , zend_grpc_globals , <nl> - grpc_globals ) <nl> + STD_PHP_INI_ENTRY ( " grpc . enable_fork_support " , " 0 " , PHP_INI_SYSTEM , OnUpdateBool , <nl> + enable_fork_support , zend_grpc_globals , grpc_globals ) <nl> + STD_PHP_INI_ENTRY ( " grpc . poll_strategy " , NULL , PHP_INI_SYSTEM , OnUpdateString , <nl> + poll_strategy , zend_grpc_globals , grpc_globals ) <nl> PHP_INI_END ( ) <nl> - * / <nl> / * } } } * / <nl> <nl> / * { { { php_grpc_init_globals <nl> * / <nl> - / * Uncomment this function if you have INI entries <nl> - static void php_grpc_init_globals ( zend_grpc_globals * grpc_globals ) <nl> - { <nl> - grpc_globals - > global_value = 0 ; <nl> - grpc_globals - > global_string = NULL ; <nl> - } <nl> - * / <nl> + static void php_grpc_init_globals ( zend_grpc_globals * grpc_globals ) { <nl> + grpc_globals - > enable_fork_support = 0 ; <nl> + grpc_globals - > poll_strategy = NULL ; <nl> + } <nl> / * } } } * / <nl> + <nl> void create_new_channel ( <nl> wrapped_grpc_channel * channel , <nl> char * target , <nl> void register_fork_handlers ( ) { <nl> } <nl> } <nl> <nl> + void apply_ini_settings ( ) { <nl> + if ( GRPC_G ( enable_fork_support ) ) { <nl> + setenv ( " GRPC_ENABLE_FORK_SUPPORT " , " 1 " , 1 / * overwrite ? * / ) ; <nl> + } <nl> + <nl> + if ( GRPC_G ( poll_strategy ) ) { <nl> + setenv ( " GRPC_POLL_STRATEGY " , GRPC_G ( poll_strategy ) , 1 / * overwrite ? * / ) ; <nl> + } <nl> + } <nl> + <nl> / * { { { PHP_MINIT_FUNCTION <nl> * / <nl> PHP_MINIT_FUNCTION ( grpc ) { <nl> - / * If you have INI entries , uncomment these lines <nl> - REGISTER_INI_ENTRIES ( ) ; <nl> - * / <nl> + ZEND_INIT_MODULE_GLOBALS ( grpc , php_grpc_init_globals , NULL ) ; <nl> + REGISTER_INI_ENTRIES ( ) ; <nl> + <nl> / * Register call error constants * / <nl> REGISTER_LONG_CONSTANT ( " Grpc \ \ CALL_OK " , GRPC_CALL_OK , <nl> CONST_CS | CONST_PERSISTENT ) ; <nl> PHP_MINIT_FUNCTION ( grpc ) { <nl> / * { { { PHP_MSHUTDOWN_FUNCTION <nl> * / <nl> PHP_MSHUTDOWN_FUNCTION ( grpc ) { <nl> - / * uncomment this line if you have INI entries <nl> - UNREGISTER_INI_ENTRIES ( ) ; <nl> - * / <nl> + UNREGISTER_INI_ENTRIES ( ) ; <nl> / / WARNING : This function IS being called by PHP when the extension <nl> / / is unloaded but the logs were somehow suppressed . <nl> if ( GRPC_G ( initialized ) ) { <nl> PHP_MINFO_FUNCTION ( grpc ) { <nl> php_info_print_table_row ( 2 , " grpc support " , " enabled " ) ; <nl> php_info_print_table_row ( 2 , " grpc module version " , PHP_GRPC_VERSION ) ; <nl> php_info_print_table_end ( ) ; <nl> - / * Remove comments if you have entries in php . ini <nl> - DISPLAY_INI_ENTRIES ( ) ; <nl> - * / <nl> + DISPLAY_INI_ENTRIES ( ) ; <nl> } <nl> / * } } } * / <nl> <nl> PHP_MINFO_FUNCTION ( grpc ) { <nl> * / <nl> PHP_RINIT_FUNCTION ( grpc ) { <nl> if ( ! GRPC_G ( initialized ) ) { <nl> + apply_ini_settings ( ) ; <nl> grpc_init ( ) ; <nl> register_fork_handlers ( ) ; <nl> grpc_php_init_completion_queue ( TSRMLS_C ) ; <nl> mmm a / src / php / ext / grpc / php_grpc . h <nl> ppp b / src / php / ext / grpc / php_grpc . h <nl> PHP_RINIT_FUNCTION ( grpc ) ; <nl> * / <nl> ZEND_BEGIN_MODULE_GLOBALS ( grpc ) <nl> zend_bool initialized ; <nl> + zend_bool enable_fork_support ; <nl> + char * poll_strategy ; <nl> ZEND_END_MODULE_GLOBALS ( grpc ) <nl> <nl> / * In every utility function you add that needs to use variables <nl> new file mode 100644 <nl> index 00000000000 . . 0fbcc1f119e <nl> mmm / dev / null <nl> ppp b / src / php / ext / grpc / tests / grpc - default - ini . phpt <nl> <nl> + - - TEST - - <nl> + Ensure default ini settings <nl> + - - SKIPIF - - <nl> + < ? php if ( ! extension_loaded ( " grpc " ) ) print " skip " ; ? > <nl> + - - FILE - - <nl> + < ? php <nl> + if ( ini_get ( ' grpc . enable_fork_support ' ) ) { <nl> + die ( ' grpc . enable_fork_support not off by default ' ) ; <nl> + } <nl> + if ( ini_get ( ' grpc . poll_strategy ' ) ! = = " " ) { <nl> + die ( ' grpc . poll_strategy not empty by default ' ) ; <nl> + } <nl> + echo ' ok ' ; <nl> + - - EXPECT - - <nl> + ok <nl> new file mode 100644 <nl> index 00000000000 . . 55c18ee526e <nl> mmm / dev / null <nl> ppp b / src / php / ext / grpc / tests / grpc - set - ini . phpt <nl> <nl> + - - TEST - - <nl> + Ensure ini settings are handled <nl> + - - SKIPIF - - <nl> + < ? php if ( ! extension_loaded ( " grpc " ) ) print " skip " ; ? > <nl> + - - INI - - <nl> + grpc . enable_fork_support = 1 <nl> + grpc . poll_strategy = epoll1 <nl> + - - FILE - - <nl> + < ? php <nl> + if ( ! ini_get ( ' grpc . enable_fork_support ' ) ) { <nl> + die ( ' grpc . enable_fork_support not set ' ) ; <nl> + } <nl> + if ( ! getenv ( ' GRPC_ENABLE_FORK_SUPPORT ' ) ) { <nl> + die ( ' env GRPC_ENABLE_FORK_SUPPORT not set ' ) ; <nl> + } <nl> + if ( ini_get ( ' grpc . poll_strategy ' ) ! = = ' epoll1 ' ) { <nl> + die ( ' grpc . poll_strategy ! = = epoll1 ' ) ; <nl> + } <nl> + if ( getenv ( ' GRPC_POLL_STRATEGY ' ) ! = = ' epoll1 ' ) { <nl> + die ( ' env GRPC_POLL_STRATEGY not epoll1 ' ) ; <nl> + } <nl> + echo ' ok ' ; <nl> + - - EXPECT - - <nl> + ok <nl>
|
Add ini settings for fork support to PHP extension .
|
grpc/grpc
|
3107cda311853ce57f3a67847ce15dd14a5c9fd5
|
2019-03-28T10:43:47Z
|
mmm a / tensorflow / lite / kernels / test_util . cc <nl> ppp b / tensorflow / lite / kernels / test_util . cc <nl> TfLiteStatus SingleOpModel : : InvokeUnchecked ( ) { return interpreter_ - > Invoke ( ) ; } <nl> <nl> void SingleOpModel : : BuildInterpreter ( <nl> std : : vector < std : : vector < int > > input_shapes ) { <nl> - BuildInterpreter ( input_shapes , - 1 , false ) ; <nl> + BuildInterpreter ( input_shapes , / * num_threads = * / - 1 , <nl> + / * allow_fp32_relax_to_fp16 = * / false ) ; <nl> } <nl> <nl> void SingleOpModel : : BuildInterpreter ( std : : vector < std : : vector < int > > input_shapes , <nl> int num_threads ) { <nl> - BuildInterpreter ( input_shapes , num_threads , false ) ; <nl> + BuildInterpreter ( input_shapes , num_threads , <nl> + / * allow_fp32_relax_to_fp16 = * / false ) ; <nl> } <nl> <nl> void SingleOpModel : : BuildInterpreter ( std : : vector < std : : vector < int > > input_shapes , <nl> bool allow_fp32_relax_to_fp16 ) { <nl> - BuildInterpreter ( input_shapes , - 1 , allow_fp32_relax_to_fp16 ) ; <nl> + BuildInterpreter ( input_shapes , / * num_threads = * / - 1 , allow_fp32_relax_to_fp16 ) ; <nl> } <nl> <nl> / / static <nl>
|
[ 3 ] Review comments handled
|
tensorflow/tensorflow
|
c26e2f0e328d2e4a9a8d3c376623dfa45fc9b45a
|
2019-07-02T09:05:05Z
|
mmm a / src / mongo / db / repl / repl_coordinator_impl . cpp <nl> ppp b / src / mongo / db / repl / repl_coordinator_impl . cpp <nl> namespace repl { <nl> const ReplSettings & settings , <nl> ReplicationCoordinatorExternalState * externalState ) : <nl> _settings ( settings ) , <nl> - _inShutdown ( false ) , <nl> _externalState ( externalState ) , <nl> + _inShutdown ( false ) , <nl> _thisMembersConfigIndex ( - 1 ) { <nl> <nl> } <nl> mmm a / src / mongo / db / repl / repl_coordinator_impl . h <nl> ppp b / src / mongo / db / repl / repl_coordinator_impl . h <nl> namespace repl { <nl> <nl> private : <nl> <nl> + / / Struct that holds information about clients waiting for replication . <nl> + struct WaiterInfo ; <nl> + <nl> + / / Struct that holds information about nodes in this replication group , mainly used for <nl> + / / tracking replication progress for write concern satisfaction . <nl> + struct SlaveInfo { <nl> + OpTime opTime ; / / Our last known OpTime that this slave has replicated to . <nl> + HostAndPort hostAndPort ; / / Client address of the slave . <nl> + int memberID ; / / ID of the node in the replica set config , or - 1 if we ' re not a replSet . <nl> + SlaveInfo ( ) : memberID ( - 1 ) { } <nl> + } ; <nl> + <nl> + / / Map of node RIDs to their SlaveInfo . <nl> + typedef unordered_map < OID , SlaveInfo , OID : : Hasher > SlaveInfoMap ; <nl> + <nl> + typedef std : : vector < ReplicationExecutor : : CallbackHandle > HeartbeatHandles ; <nl> + <nl> / / Called by the TopologyCoordinator whenever this node ' s replica set state transitions . <nl> void _onSelfStateChange ( const MemberState & newState ) ; <nl> <nl> / / Called by the TopologyCoordinator whenever the replica set configuration is updated <nl> void _onReplicaSetConfigChange ( const ReplicaSetConfig & newConfig , int myIndex ) ; <nl> <nl> - / / Struct that holds information about clients waiting for replication . <nl> - struct WaiterInfo ; <nl> - <nl> / * <nl> * Returns the OpTime of the last applied operation on this node . <nl> * / <nl> namespace repl { <nl> * / <nl> Mode _getReplicationMode_inlock ( ) const ; <nl> <nl> - / / Handles to actively queued heartbeats <nl> - typedef std : : vector < ReplicationExecutor : : CallbackHandle > HeartbeatHandles ; <nl> + / / Handles to actively queued heartbeats . <nl> + / / Only accessed serially in ReplicationExecutor callbacks , which makes it safe to access <nl> + / / outside of _mutex . <nl> HeartbeatHandles _heartbeatHandles ; <nl> <nl> / / Parsed command line arguments related to replication . Set once at startup and then <nl> namespace repl { <nl> / / Our RID , used to identify us to our sync source when sending replication progress <nl> / / updates upstream . Set once at startup and then never modified again , which makes it <nl> / / safe to read outside of _mutex . <nl> + / / TODO ( spencer ) : put behind _mutex <nl> OID _myRID ; <nl> <nl> - / / Protects all member data of this ReplicationCoordinator except _settings and _myRID . <nl> - mutable boost : : mutex _mutex ; <nl> - <nl> - / / list of information about clients waiting on replication . Does * not * own the <nl> - / / WaiterInfos . <nl> - std : : vector < WaiterInfo * > _replicationWaiterList ; <nl> - <nl> - / / Set to true when we are in the process of shutting down replication . <nl> - bool _inShutdown ; <nl> - <nl> - / / Election ID of the last election that resulted in this node becoming primary . <nl> - OID _electionID ; <nl> - <nl> / / Pointer to the TopologyCoordinator owned by this ReplicationCoordinator . <nl> boost : : scoped_ptr < TopologyCoordinator > _topCoord ; <nl> <nl> namespace repl { <nl> / / Thread that drives actions in the topology coordinator <nl> boost : : scoped_ptr < boost : : thread > _topCoordDriverThread ; <nl> <nl> - struct SlaveInfo { <nl> - OpTime opTime ; / / Our last known OpTime that this slave has replicated to . <nl> - HostAndPort hostAndPort ; / / Client address of the slave . <nl> - int memberID ; / / ID of the node in the replica set config , or - 1 if we ' re not a replSet . <nl> - SlaveInfo ( ) : memberID ( - 1 ) { } <nl> - } ; <nl> + / / Protects member data of this ReplicationCoordinator . <nl> + mutable boost : : mutex _mutex ; <nl> + <nl> + / / / = = = = = = = = = = = = = All members below this line are guarded by _mutex = = = = = = = = = = = = = = = = = = = = / / / <nl> + <nl> + / / list of information about clients waiting on replication . Does * not * own the <nl> + / / WaiterInfos . <nl> + std : : vector < WaiterInfo * > _replicationWaiterList ; <nl> + <nl> + / / Set to true when we are in the process of shutting down replication . <nl> + bool _inShutdown ; <nl> + <nl> + / / Election ID of the last election that resulted in this node becoming primary . <nl> + OID _electionID ; <nl> + <nl> / / Maps nodes in this replication group to information known about it such as its <nl> / / replication progress and its ID in the replica set config . <nl> - typedef unordered_map < OID , SlaveInfo , OID : : Hasher > SlaveInfoMap ; <nl> SlaveInfoMap _slaveInfoMap ; <nl> <nl> / / Current ReplicaSet state . <nl>
|
SERVER - 14135 Improve clarity around locking rules in the header for ReplicationCoordinatorImpl
|
mongodb/mongo
|
ec23ec25b5b6aaae4611a87eee246c646df0361c
|
2014-08-08T15:58:30Z
|
mmm a / folly / FBString . h <nl> ppp b / folly / FBString . h <nl> namespace folly { <nl> / / that would break ABI - compatibility and wouldn ' t allow linking code <nl> / / compiled with this flag with code compiled without . <nl> # ifdef FBSTRING_SANITIZE_ADDRESS <nl> - # define FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> + # define FBSTRING_DISABLE_SSO true <nl> + # else <nl> + # define FBSTRING_DISABLE_SSO false <nl> # endif <nl> <nl> namespace fbstring_detail { <nl> template < class Char > class fbstring_core { <nl> goner . reset ( ) ; <nl> } <nl> <nl> - fbstring_core ( const Char * const data , const size_t size ) { <nl> + fbstring_core ( const Char * const data , <nl> + const size_t size , <nl> + bool disableSSO = FBSTRING_DISABLE_SSO ) { <nl> # ifndef NDEBUG <nl> # ifndef _LIBSTDCXX_FBSTRING <nl> SCOPE_EXIT { <nl> template < class Char > class fbstring_core { <nl> # endif <nl> # endif <nl> <nl> - # ifndef FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> / / Simplest case first : small strings are bitblitted <nl> - if ( size < = maxSmallSize ) { <nl> + if ( ! disableSSO & & size < = maxSmallSize ) { <nl> / / Layout is : Char * data_ , size_t size_ , size_t capacity_ <nl> static_assert ( sizeof ( * this ) = = sizeof ( Char * ) + 2 * sizeof ( size_t ) , <nl> " fbstring has unexpected size " ) ; <nl> template < class Char > class fbstring_core { <nl> <nl> / / If data is aligned , use fast word - wise copying . Otherwise , <nl> / / use conservative memcpy . <nl> - if ( reinterpret_cast < size_t > ( data ) & ( sizeof ( size_t ) - 1 ) ) { <nl> - fbstring_detail : : pod_copy ( data , data + size , small_ ) ; <nl> - } else { <nl> - / / Copy one word at a time . <nl> - / / NOTE : This reads bytes which are outside the range of the <nl> - / / string , and makes ASan unhappy , but the small case is <nl> - / / disabled under ASan . <nl> - <nl> + / / The word - wise path reads bytes which are outside the range of <nl> + / / the string , and makes ASan unhappy , so we disable it when <nl> + / / compiling with ASan . <nl> + # ifndef FBSTRING_SANITIZE_ADDRESS <nl> + if ( ( reinterpret_cast < size_t > ( data ) & ( sizeof ( size_t ) - 1 ) ) = = 0 ) { <nl> const size_t byteSize = size * sizeof ( Char ) ; <nl> constexpr size_t wordWidth = sizeof ( size_t ) ; <nl> switch ( ( byteSize + wordWidth - 1 ) / wordWidth ) { / / Number of words . <nl> template < class Char > class fbstring_core { <nl> case 0 : <nl> break ; <nl> } <nl> + } else <nl> + # endif <nl> + { <nl> + fbstring_detail : : pod_copy ( data , data + size , small_ ) ; <nl> } <nl> setSmallSize ( size ) ; <nl> - } else <nl> - # endif / / FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> - { <nl> + } else { <nl> if ( size < = maxMediumSize ) { <nl> / / Medium strings are allocated normally . Don ' t forget to <nl> / / allocate one extra Char for the terminating null . <nl> template < class Char > class fbstring_core { <nl> } <nl> } <nl> <nl> - void reserve ( size_t minCapacity ) { <nl> + void reserve ( size_t minCapacity , bool disableSSO = FBSTRING_DISABLE_SSO ) { <nl> if ( category ( ) = = Category : : isLarge ) { <nl> / / Ensure unique <nl> if ( RefCounted : : refs ( ml_ . data_ ) > 1 ) { <nl> template < class Char > class fbstring_core { <nl> } <nl> } else { <nl> assert ( category ( ) = = Category : : isSmall ) ; <nl> - # ifndef FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> - if ( minCapacity < = maxSmallSize ) { <nl> + if ( ! disableSSO & & minCapacity < = maxSmallSize ) { <nl> / / small <nl> / / Nothing to do , everything stays put <nl> - } else <nl> - # endif / / FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> - if ( minCapacity < = maxMediumSize ) { <nl> + } else if ( minCapacity < = maxMediumSize ) { <nl> / / medium <nl> / / Don ' t forget to allocate one extra Char for the terminating null <nl> auto const allocSizeBytes = <nl> template < class Char > class fbstring_core { <nl> assert ( capacity ( ) > = minCapacity ) ; <nl> } <nl> <nl> - Char * expand_noinit ( const size_t delta , bool expGrowth = false ) { <nl> + Char * expand_noinit ( const size_t delta , <nl> + bool expGrowth = false , <nl> + bool disableSSO = FBSTRING_DISABLE_SSO ) { <nl> / / Strategy is simple : make room , then change size <nl> assert ( capacity ( ) > = size ( ) ) ; <nl> size_t sz , newSz ; <nl> if ( category ( ) = = Category : : isSmall ) { <nl> sz = smallSize ( ) ; <nl> newSz = sz + delta ; <nl> - # ifndef FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> - if ( FBSTRING_LIKELY ( newSz < = maxSmallSize ) ) { <nl> + if ( ! disableSSO & & FBSTRING_LIKELY ( newSz < = maxSmallSize ) ) { <nl> setSmallSize ( newSz ) ; <nl> return small_ + sz ; <nl> } <nl> - # endif / / FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> reserve ( expGrowth ? std : : max ( newSz , 2 * maxSmallSize ) : newSz ) ; <nl> } else { <nl> sz = ml_ . size_ ; <nl> class basic_fbstring { <nl> private : <nl> template < int i > class Selector { } ; <nl> <nl> - iterator insertImplDiscr ( const_iterator p , <nl> + iterator insertImplDiscr ( const_iterator i , <nl> size_type n , value_type c , Selector < 1 > ) { <nl> Invariant checker ( * this ) ; <nl> <nl> - auto const pos = p - begin ( ) ; <nl> - assert ( p > = begin ( ) & & p < = end ( ) ) ; <nl> - if ( capacity ( ) - size ( ) < n ) { <nl> - const size_type sz = p - begin ( ) ; <nl> - reserve ( size ( ) + n ) ; <nl> - p = begin ( ) + sz ; <nl> - } <nl> - const iterator oldEnd = end ( ) ; <nl> - if ( n < size_type ( oldEnd - p ) ) { <nl> - append ( oldEnd - n , oldEnd ) ; <nl> - / / Also copies terminator . <nl> - fbstring_detail : : pod_move ( & * p , & * oldEnd - n + 1 , begin ( ) + pos + n ) ; <nl> - std : : fill ( begin ( ) + pos , begin ( ) + pos + n , c ) ; <nl> - } else { <nl> - append ( n - ( end ( ) - p ) , c ) ; <nl> - append ( iterator ( p ) , oldEnd ) ; <nl> - std : : fill ( iterator ( p ) , oldEnd , c ) ; <nl> - } <nl> - return begin ( ) + pos ; <nl> + assert ( i > = begin ( ) & & i < = end ( ) ) ; <nl> + const size_type pos = i - begin ( ) ; <nl> + <nl> + auto oldSize = size ( ) ; <nl> + store_ . expand_noinit ( n , / * expGrowth = * / true ) ; <nl> + auto b = begin ( ) ; <nl> + fbstring_detail : : pod_move ( b + pos , b + oldSize , b + pos + n ) ; <nl> + fbstring_detail : : pod_fill ( b + pos , b + pos + n , c ) ; <nl> + <nl> + return b + pos ; <nl> } <nl> <nl> template < class InputIter > <nl> class basic_fbstring { <nl> std : : forward_iterator_tag ) { <nl> Invariant checker ( * this ) ; <nl> <nl> + assert ( i > = begin ( ) & & i < = end ( ) ) ; <nl> const size_type pos = i - begin ( ) ; <nl> auto n = std : : distance ( s1 , s2 ) ; <nl> assert ( n > = 0 ) ; <nl> - assert ( pos < = size ( ) ) ; <nl> <nl> auto oldSize = size ( ) ; <nl> store_ . expand_noinit ( n , / * expGrowth = * / true ) ; <nl> FOLLY_FBSTRING_HASH <nl> <nl> # pragma GCC diagnostic pop <nl> <nl> - # undef FBSTRING_DISABLE_SMALL_STRING_OPTIMIZATION <nl> + # undef FBSTRING_DISABLE_SSO <nl> # undef FBSTRING_SANITIZE_ADDRESS <nl> # undef throw <nl> # undef FBSTRING_LIKELY <nl>
|
fbstring : Make SSO disabling and insertImplDiscr implementation simpler
|
facebook/folly
|
aafcc64b0aaf719d59cc8ce5c7849eb1a1879a1f
|
2016-04-02T22:20:21Z
|
mmm a / tensorflow / python / distribute / input_lib . py <nl> ppp b / tensorflow / python / distribute / input_lib . py <nl> def _enable_get_next_as_optional ( strategy , dataset ) : <nl> False ) : <nl> return False <nl> <nl> - if context . executing_eagerly ( ) and cardinality . cardinality ( <nl> - dataset ) . numpy ( ) = = cardinality . INFINITE : <nl> + if context . executing_eagerly ( ) : <nl> # If the dataset is inifinite , we don ' t need to enable last partial batch <nl> # support . Currently the logic only applies to the case that distributed <nl> # dataset is created in eager mode , as we need to evaluate the dataset <nl> # cardinality . <nl> - return False <nl> + return cardinality . cardinality ( dataset ) . numpy ( ) ! = cardinality . INFINITE <nl> <nl> return not _is_statically_shaped ( <nl> dataset . element_spec ) or strategy . extended . _in_multi_worker_mode ( ) # pylint : disable = protected - access <nl> mmm a / tensorflow / python / distribute / input_lib_test . py <nl> ppp b / tensorflow / python / distribute / input_lib_test . py <nl> def sum_while_loop ( iterator , reduce_fn ) : <nl> except ( StopIteration , errors . OutOfRangeError ) : <nl> return sums <nl> <nl> + expected_for_sum = 200 . <nl> + if ( not drop_remainder or input_type = = " input_fn " ) : <nl> + expected_for_sum = 310 . <nl> while_sums = sum_while_loop ( <nl> iter ( dataset ) , <nl> defun ( lambda state , iterator : _reduce ( state , next ( iterator ) ) ) ) <nl> - self . assertAllEqual ( <nl> - nest . flatten ( while_sums ) , <nl> - # When there ' s no partial batch , the sum is smaller . <nl> - [ 200 . if drop_remainder else 310 . ] * 3 ) <nl> - for_sums = defun ( sum_for_loop ) ( dataset ) <nl> + self . assertAllEqual ( nest . flatten ( while_sums ) , [ expected_for_sum ] * 3 ) <nl> + <nl> # For loops always call get next as optional inside tf functions , so we <nl> # expect 310 here when using an input function ( as there are 5 batches of <nl> # size 4 round robined over 2 replicas . <nl> expected_for_sum = 200 . <nl> - if ( not drop_remainder or ( <nl> - defun_type = = " tf_function " and input_type = = " input_fn " ) ) : <nl> + if ( not drop_remainder or input_type = = " input_fn " ) : <nl> expected_for_sum = 310 . <nl> + for_sums = defun ( sum_for_loop ) ( dataset ) <nl> self . assertAllEqual ( nest . flatten ( for_sums ) , [ expected_for_sum ] * 3 ) <nl> <nl> @ combinations . generate ( <nl> def sum_while_loop ( iterator , reduce_fn ) : <nl> ] , <nl> input_type = [ " dataset " , " input_fn " ] , <nl> drop_remainder = [ False , True ] , <nl> + repeat = [ False , True ] , <nl> tensor_type = [ " sparse " , " ragged " ] , <nl> - enable_get_next_as_optional = [ True , False ] <nl> - ) ) <nl> - def testRaggedSparseGetNextAsOptional ( <nl> - self , distribution , input_type , drop_remainder , tensor_type , <nl> - enable_get_next_as_optional ) : <nl> + enable_get_next_as_optional = [ True , False ] ) ) <nl> + def testRaggedSparseGetNextAsOptional ( self , distribution , input_type , <nl> + drop_remainder , repeat , tensor_type , <nl> + enable_get_next_as_optional ) : <nl> " " " Test with ` RaggedTensor ` s and ` SparseTensor ` s . " " " <nl> if not tf2 . enabled ( ) : <nl> self . skipTest ( " Only V2 is supported . " ) <nl> def dataset_fn ( ctx = None ) : <nl> ragged_tensor . to_sparse ( ) ) , <nl> } ) <nl> dataset = dataset . shard ( ctx . num_input_pipelines , ctx . input_pipeline_id ) <nl> + if repeat : <nl> + dataset = dataset . repeat ( ) <nl> return dataset . batch ( batch_size , drop_remainder = drop_remainder ) <nl> <nl> if input_type = = " dataset " : <nl> def dataset_fn ( ctx = None ) : <nl> ds = distribution . distribute_datasets_from_function ( dataset_fn ) <nl> iterator = iter ( ds ) <nl> <nl> - self . assertEqual ( iterator . _enable_get_next_as_optional , <nl> - ( not drop_remainder ) and enable_get_next_as_optional ) <nl> + self . assertEqual ( iterator . _enable_get_next_as_optional , ( not repeat ) and <nl> + enable_get_next_as_optional ) <nl> <nl> @ combinations . generate ( <nl> combinations . combine ( <nl>
|
Always enable get_next_as_optional unless the dataset is finite .
|
tensorflow/tensorflow
|
61b3c9887fe6901a0ab9a2bbf6185db1ede57b73
|
2020-10-26T22:09:36Z
|
new file mode 100644 <nl> index 000000000000 . . 732981fe7c5d <nl> mmm / dev / null <nl> ppp b / contrib / bitcoin - cli . bash - completion <nl> <nl> + # bash programmable completion for bitcoin - cli ( 1 ) <nl> + # Copyright ( c ) 2012 - 2016 The Bitcoin Core developers <nl> + # Distributed under the MIT software license , see the accompanying <nl> + # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + <nl> + # call $ bitcoin - cli for RPC <nl> + _bitcoin_rpc ( ) { <nl> + # determine already specified args necessary for RPC <nl> + local rpcargs = ( ) <nl> + for i in $ { COMP_LINE } ; do <nl> + case " $ i " in <nl> + - conf = * | - datadir = * | - regtest | - rpc * | - testnet ) <nl> + rpcargs = ( " $ { rpcargs [ @ ] } " " $ i " ) <nl> + ; ; <nl> + esac <nl> + done <nl> + $ bitcoin_cli " $ { rpcargs [ @ ] } " " $ @ " <nl> + } <nl> + <nl> + # Add wallet accounts to COMPREPLY <nl> + _bitcoin_accounts ( ) { <nl> + local accounts <nl> + accounts = $ ( _bitcoin_rpc listaccounts | awk - F ' " ' ' { print $ 2 } ' ) <nl> + COMPREPLY = ( " $ { COMPREPLY [ @ ] } " $ ( compgen - W " $ accounts " - - " $ cur " ) ) <nl> + } <nl> + <nl> + _bitcoin_cli ( ) { <nl> + local cur prev words = ( ) cword <nl> + local bitcoin_cli <nl> + <nl> + # save and use original argument to invoke bitcoin - cli for - help , help and RPC <nl> + # as bitcoin - cli might not be in $ PATH <nl> + bitcoin_cli = " $ 1 " <nl> + <nl> + COMPREPLY = ( ) <nl> + _get_comp_words_by_ref - n = cur prev words cword <nl> + <nl> + if ( ( cword > 5 ) ) ; then <nl> + case $ { words [ cword - 5 ] } in <nl> + sendtoaddress ) <nl> + COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + fi <nl> + <nl> + if ( ( cword > 4 ) ) ; then <nl> + case $ { words [ cword - 4 ] } in <nl> + importaddress | listtransactions | setban ) <nl> + COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + signrawtransaction ) <nl> + COMPREPLY = ( $ ( compgen - W " ALL NONE SINGLE ALL | ANYONECANPAY NONE | ANYONECANPAY SINGLE | ANYONECANPAY " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + fi <nl> + <nl> + if ( ( cword > 3 ) ) ; then <nl> + case $ { words [ cword - 3 ] } in <nl> + addmultisigaddress ) <nl> + _bitcoin_accounts <nl> + return 0 <nl> + ; ; <nl> + getbalance | gettxout | importaddress | importpubkey | importprivkey | listreceivedbyaccount | listreceivedbyaddress | listsinceblock ) <nl> + COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + fi <nl> + <nl> + if ( ( cword > 2 ) ) ; then <nl> + case $ { words [ cword - 2 ] } in <nl> + addnode ) <nl> + COMPREPLY = ( $ ( compgen - W " add remove onetry " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + setban ) <nl> + COMPREPLY = ( $ ( compgen - W " add remove " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + fundrawtransaction | getblock | getblockheader | getmempoolancestors | getmempooldescendants | getrawtransaction | gettransaction | listaccounts | listreceivedbyaccount | listreceivedbyaddress | sendrawtransaction ) <nl> + COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + move | setaccount ) <nl> + _bitcoin_accounts <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + fi <nl> + <nl> + case " $ prev " in <nl> + backupwallet | dumpwallet | importwallet ) <nl> + _filedir <nl> + return 0 <nl> + ; ; <nl> + getaddednodeinfo | getrawmempool | lockunspent | setgenerate ) <nl> + COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> + return 0 <nl> + ; ; <nl> + getaccountaddress | getaddressesbyaccount | getbalance | getnewaddress | getreceivedbyaccount | listtransactions | move | sendfrom | sendmany ) <nl> + _bitcoin_accounts <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + <nl> + case " $ cur " in <nl> + - conf = * ) <nl> + cur = " $ { cur # * = } " <nl> + _filedir <nl> + return 0 <nl> + ; ; <nl> + - datadir = * ) <nl> + cur = " $ { cur # * = } " <nl> + _filedir - d <nl> + return 0 <nl> + ; ; <nl> + - * = * ) # prevent nonsense completions <nl> + return 0 <nl> + ; ; <nl> + * ) <nl> + local helpopts commands <nl> + <nl> + # only parse - help if senseful <nl> + if [ [ - z " $ cur " | | " $ cur " = ~ ^ - ] ] ; then <nl> + helpopts = $ ( $ bitcoin_cli - help 2 > & 1 | awk ' $ 1 ~ / ^ - / { sub ( / = . * / , " = " ) ; print $ 1 } ' ) <nl> + fi <nl> + <nl> + # only parse help if senseful <nl> + if [ [ - z " $ cur " | | " $ cur " = ~ ^ [ a - z ] ] ] ; then <nl> + commands = $ ( _bitcoin_rpc help 2 > / dev / null | awk ' $ 1 ~ / ^ [ a - z ] / { print $ 1 ; } ' ) <nl> + fi <nl> + <nl> + COMPREPLY = ( $ ( compgen - W " $ helpopts $ commands " - - " $ cur " ) ) <nl> + <nl> + # Prevent space if an argument is desired <nl> + if [ [ $ COMPREPLY = = * = ] ] ; then <nl> + compopt - o nospace <nl> + fi <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + } & & <nl> + complete - F _bitcoin_cli bitcoin - cli <nl> + <nl> + # Local variables : <nl> + # mode : shell - script <nl> + # sh - basic - offset : 4 <nl> + # sh - indent - comment : t <nl> + # indent - tabs - mode : nil <nl> + # End : <nl> + # ex : ts = 4 sw = 4 et filetype = sh <nl> new file mode 100644 <nl> index 000000000000 . . a83d2979ed3a <nl> mmm / dev / null <nl> ppp b / contrib / bitcoin - tx . bash - completion <nl> <nl> + # bash programmable completion for bitcoin - tx ( 1 ) <nl> + # Copyright ( c ) 2016 The Bitcoin Core developers <nl> + # Distributed under the MIT software license , see the accompanying <nl> + # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + <nl> + _bitcoin_tx ( ) { <nl> + local cur prev words = ( ) cword <nl> + local bitcoin_tx <nl> + <nl> + # save and use original argument to invoke bitcoin - tx for - help <nl> + # it might not be in $ PATH <nl> + bitcoin_tx = " $ 1 " <nl> + <nl> + COMPREPLY = ( ) <nl> + _get_comp_words_by_ref - n = : cur prev words cword <nl> + <nl> + case " $ cur " in <nl> + load = * : * ) <nl> + cur = " $ { cur # load = * : } " <nl> + _filedir <nl> + return 0 <nl> + ; ; <nl> + * = * ) # prevent attempts to complete other arguments <nl> + return 0 <nl> + ; ; <nl> + esac <nl> + <nl> + if [ [ " $ cword " = = 1 | | ( " $ prev " ! = " - create " & & " $ prev " = = - * ) ] ] ; then <nl> + # only options ( or an uncompletable hex - string ) allowed <nl> + # parse bitcoin - tx - help for options <nl> + local helpopts <nl> + helpopts = $ ( $ bitcoin_tx - help | sed - e ' / ^ - / p ' - e d ) <nl> + COMPREPLY = ( $ ( compgen - W " $ helpopts " - - " $ cur " ) ) <nl> + else <nl> + # only commands are allowed <nl> + # parse - help for commands <nl> + local helpcmds <nl> + helpcmds = $ ( $ bitcoin_tx - help | sed - e ' 1 , / Commands : / d ' - e ' s / = . * / = / ' - e ' / ^ [ a - z ] / p ' - e d ) <nl> + COMPREPLY = ( $ ( compgen - W " $ helpcmds " - - " $ cur " ) ) <nl> + fi <nl> + <nl> + # Prevent space if an argument is desired <nl> + if [ [ $ COMPREPLY = = * = ] ] ; then <nl> + compopt - o nospace <nl> + fi <nl> + <nl> + return 0 <nl> + } & & <nl> + complete - F _bitcoin_tx bitcoin - tx <nl> + <nl> + # Local variables : <nl> + # mode : shell - script <nl> + # sh - basic - offset : 4 <nl> + # sh - indent - comment : t <nl> + # indent - tabs - mode : nil <nl> + # End : <nl> + # ex : ts = 4 sw = 4 et filetype = sh <nl> mmm a / contrib / bitcoind . bash - completion <nl> ppp b / contrib / bitcoind . bash - completion <nl> <nl> - # bash programmable completion for bitcoind ( 1 ) and bitcoin - cli ( 1 ) <nl> - # Copyright ( c ) 2012 , 2014 Christian von Roques < roques @ mti . ag > <nl> + # bash programmable completion for bitcoind ( 1 ) and bitcoin - qt ( 1 ) <nl> + # Copyright ( c ) 2012 - 2016 The Bitcoin Core developers <nl> # Distributed under the MIT software license , see the accompanying <nl> # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> <nl> - have bitcoind & & { <nl> - <nl> - # call $ bitcoind for RPC <nl> - _bitcoin_rpc ( ) { <nl> - # determine already specified args necessary for RPC <nl> - local rpcargs = ( ) <nl> - for i in $ { COMP_LINE } ; do <nl> - case " $ i " in <nl> - - conf = * | - proxy * | - rpc * ) <nl> - rpcargs = ( " $ { rpcargs [ @ ] } " " $ i " ) <nl> - ; ; <nl> - esac <nl> - done <nl> - $ bitcoind " $ { rpcargs [ @ ] } " " $ @ " <nl> - } <nl> - <nl> - # Add bitcoin accounts to COMPREPLY <nl> - _bitcoin_accounts ( ) { <nl> - local accounts <nl> - accounts = $ ( _bitcoin_rpc listaccounts | awk ' / " . * " / { a = $ 1 ; gsub ( / " / , " " , a ) ; print a } ' ) <nl> - COMPREPLY = ( " $ { COMPREPLY [ @ ] } " $ ( compgen - W " $ accounts " - - " $ cur " ) ) <nl> - } <nl> - <nl> _bitcoind ( ) { <nl> local cur prev words = ( ) cword <nl> local bitcoind <nl> <nl> - # save and use original argument to invoke bitcoind <nl> - # bitcoind might not be in $ PATH <nl> + # save and use original argument to invoke bitcoind for - help <nl> + # it might not be in $ PATH <nl> bitcoind = " $ 1 " <nl> <nl> COMPREPLY = ( ) <nl> _get_comp_words_by_ref - n = cur prev words cword <nl> <nl> - if ( ( cword > 4 ) ) ; then <nl> - case $ { words [ cword - 4 ] } in <nl> - listtransactions ) <nl> - COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - signrawtransaction ) <nl> - COMPREPLY = ( $ ( compgen - W " ALL NONE SINGLE ALL | ANYONECANPAY NONE | ANYONECANPAY SINGLE | ANYONECANPAY " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - esac <nl> - fi <nl> - <nl> - if ( ( cword > 3 ) ) ; then <nl> - case $ { words [ cword - 3 ] } in <nl> - addmultisigaddress ) <nl> - _bitcoin_accounts <nl> - return 0 <nl> - ; ; <nl> - getbalance | gettxout | importaddress | importprivkey | listreceivedbyaccount | listreceivedbyaddress | listsinceblock ) <nl> - COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - esac <nl> - fi <nl> - <nl> - if ( ( cword > 2 ) ) ; then <nl> - case $ { words [ cword - 2 ] } in <nl> - addnode ) <nl> - COMPREPLY = ( $ ( compgen - W " add remove onetry " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - getblock | getrawtransaction | gettransaction | listaccounts | listreceivedbyaccount | listreceivedbyaddress | sendrawtransaction ) <nl> - COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - move | setaccount ) <nl> - _bitcoin_accounts <nl> - return 0 <nl> - ; ; <nl> - esac <nl> - fi <nl> - <nl> - case " $ prev " in <nl> - backupwallet | dumpwallet | importwallet ) <nl> - _filedir <nl> - return 0 <nl> - ; ; <nl> - getmempool | lockunspent | setgenerate ) <nl> - COMPREPLY = ( $ ( compgen - W " true false " - - " $ cur " ) ) <nl> - return 0 <nl> - ; ; <nl> - getaccountaddress | getaddressesbyaccount | getbalance | getnewaddress | getreceivedbyaccount | listtransactions | move | sendfrom | sendmany ) <nl> - _bitcoin_accounts <nl> - return 0 <nl> - ; ; <nl> - esac <nl> - <nl> case " $ cur " in <nl> - - conf = * | - pid = * | - loadblock = * | - wallet = * ) <nl> + - conf = * | - pid = * | - loadblock = * | - rootcertificates = * | - rpccookiefile = * | - wallet = * ) <nl> cur = " $ { cur # * = } " <nl> _filedir <nl> return 0 <nl> _bitcoind ( ) { <nl> return 0 <nl> ; ; <nl> * ) <nl> - local helpopts commands <nl> <nl> - # only parse - - help if senseful <nl> + # only parse - help if senseful <nl> if [ [ - z " $ cur " | | " $ cur " = ~ ^ - ] ] ; then <nl> - helpopts = $ ( $ bitcoind - - help 2 > & 1 | awk ' $ 1 ~ / ^ - / { sub ( / = . * / , " = " ) ; print $ 1 } ' ) <nl> + local helpopts <nl> + helpopts = $ ( $ bitcoind - help 2 > & 1 | awk ' $ 1 ~ / ^ - / { sub ( / = . * / , " = " ) ; print $ 1 } ' ) <nl> + COMPREPLY = ( $ ( compgen - W " $ helpopts " - - " $ cur " ) ) <nl> fi <nl> <nl> - # only parse help if senseful <nl> - if [ [ - z " $ cur " | | " $ cur " = ~ ^ [ a - z ] ] ] ; then <nl> - commands = $ ( _bitcoin_rpc help 2 > / dev / null | awk ' $ 1 ~ / ^ [ a - z ] / { print $ 1 ; } ' ) <nl> - fi <nl> - <nl> - COMPREPLY = ( $ ( compgen - W " $ helpopts $ commands " - - " $ cur " ) ) <nl> - <nl> # Prevent space if an argument is desired <nl> if [ [ $ COMPREPLY = = * = ] ] ; then <nl> compopt - o nospace <nl> _bitcoind ( ) { <nl> return 0 <nl> ; ; <nl> esac <nl> - } <nl> - <nl> - complete - F _bitcoind bitcoind bitcoin - cli <nl> - } <nl> + } & & <nl> + complete - F _bitcoind bitcoind bitcoin - qt <nl> <nl> # Local variables : <nl> # mode : shell - script <nl> new file mode 100644 <nl> index 000000000000 . . 7acb0b0aea66 <nl> mmm / dev / null <nl> ppp b / contrib / debian / bitcoin - tx . bash - completion <nl> @ @ - 0 , 0 + 1 @ @ <nl> + contrib / bitcoin - tx . bash - completion bitcoin - tx <nl> mmm a / contrib / debian / bitcoind . bash - completion <nl> ppp b / contrib / debian / bitcoind . bash - completion <nl> @ @ - 1 + 1 , 2 @ @ <nl> contrib / bitcoind . bash - completion bitcoind <nl> + contrib / bitcoin - cli . bash - completion bitcoin - cli <nl>
|
Merge : bash - completion : Adapt for 0 . 12 and 0 . 13
|
bitcoin/bitcoin
|
26316ffa7dc55fc191d7a981782685f5de961c20
|
2016-07-11T09:02:57Z
|
mmm a / src / core / lib / iomgr / exec_ctx . cc <nl> ppp b / src / core / lib / iomgr / exec_ctx . cc <nl> static void exec_ctx_sched ( grpc_exec_ctx * exec_ctx , grpc_closure * closure , <nl> grpc_closure_list_append ( & exec_ctx - > closure_list , closure , error ) ; <nl> } <nl> <nl> + / * This time pair is not entirely thread - safe as store / load of tv_sec and <nl> + * tv_nsec are performed separately . However g_start_time do not need to have <nl> + * sub - second precision , so it is ok if the value of tv_nsec is off in this <nl> + * case . * / <nl> typedef struct time_atm_pair { <nl> gpr_atm tv_sec ; <nl> gpr_atm tv_nsec ; <nl> void grpc_exec_ctx_maybe_update_start_time ( grpc_exec_ctx * exec_ctx ) { <nl> grpc_millis now = grpc_exec_ctx_now ( exec_ctx ) ; <nl> grpc_millis last_start_time_update = <nl> gpr_atm_no_barrier_load ( & g_last_start_time_update ) ; <nl> + <nl> if ( now > last_start_time_update & & <nl> now - last_start_time_update > GRPC_START_TIME_UPDATE_INTERVAL ) { <nl> + / * Get the current system time and subtract \ a now from it , where \ a now is <nl> + * the relative time from grpc_init ( ) from monotonic clock . This calibrates <nl> + * the time when grpc_exec_ctx_global_init was called based on current <nl> + * system clock . * / <nl> gpr_atm_no_barrier_store ( & g_last_start_time_update , now ) ; <nl> gpr_timespec real_now = gpr_now ( GPR_CLOCK_REALTIME ) ; <nl> gpr_timespec real_start_time = <nl> mmm a / src / core / lib / iomgr / timer_manager . cc <nl> ppp b / src / core / lib / iomgr / timer_manager . cc <nl> static void timer_main_loop ( grpc_exec_ctx * exec_ctx ) { <nl> grpc_millis next = GRPC_MILLIS_INF_FUTURE ; <nl> grpc_exec_ctx_invalidate_now ( exec_ctx ) ; <nl> <nl> - / / Check if it is time to update g_start_time <nl> + / * Calibrate g_start_time in exec_ctx . cc with a regular interval in case the <nl> + * system clock has changed * / <nl> grpc_exec_ctx_maybe_update_start_time ( exec_ctx ) ; <nl> <nl> / / check timer state , updates next to the next time to run a check <nl>
|
Add comments
|
grpc/grpc
|
39662f682eb977ce491b3dd52484647f7d48b96b
|
2017-11-11T00:50:29Z
|
mmm a / lib / ClangImporter / ImportType . cpp <nl> ppp b / lib / ClangImporter / ImportType . cpp <nl> namespace { <nl> return { mappedType , underlyingResult . Hint } ; <nl> } <nl> <nl> - # define SUGAR_TYPE ( KIND ) \ <nl> - ImportResult Visit # # KIND # # Type ( const clang : : KIND # # Type * type ) { \ <nl> - return Visit ( type - > desugar ( ) ) ; \ <nl> - } <nl> - SUGAR_TYPE ( TypeOfExpr ) <nl> - SUGAR_TYPE ( TypeOf ) <nl> - SUGAR_TYPE ( Decltype ) <nl> - SUGAR_TYPE ( UnaryTransform ) <nl> - SUGAR_TYPE ( Elaborated ) <nl> - SUGAR_TYPE ( SubstTemplateTypeParm ) <nl> - SUGAR_TYPE ( TemplateSpecialization ) <nl> - SUGAR_TYPE ( Auto ) <nl> - SUGAR_TYPE ( DeducedTemplateSpecialization ) <nl> - SUGAR_TYPE ( Adjusted ) <nl> - SUGAR_TYPE ( PackExpansion ) <nl> - SUGAR_TYPE ( Attributed ) <nl> + / / TODO : add custom visitors for these types . <nl> + # define MAYBE_SUGAR_TYPE ( KIND ) \ <nl> + ImportResult Visit # # KIND # # Type ( const clang : : KIND # # Type * type ) { \ <nl> + if ( type - > isSugared ( ) ) \ <nl> + return Visit ( type - > desugar ( ) ) ; \ <nl> + return Type ( ) ; \ <nl> + } <nl> + MAYBE_SUGAR_TYPE ( TypeOfExpr ) <nl> + MAYBE_SUGAR_TYPE ( TypeOf ) <nl> + MAYBE_SUGAR_TYPE ( Decltype ) <nl> + MAYBE_SUGAR_TYPE ( UnaryTransform ) <nl> + MAYBE_SUGAR_TYPE ( TemplateSpecialization ) <nl> + MAYBE_SUGAR_TYPE ( Auto ) <nl> + MAYBE_SUGAR_TYPE ( DeducedTemplateSpecialization ) <nl> + MAYBE_SUGAR_TYPE ( PackExpansion ) <nl> + <nl> + / / These types are ALWAYS sugared . <nl> + # define SUGAR_TYPE ( KIND ) \ <nl> + ImportResult Visit # # KIND # # Type ( const clang : : KIND # # Type * type ) { \ <nl> + return Visit ( type - > desugar ( ) ) ; \ <nl> + } <nl> SUGAR_TYPE ( MacroQualified ) <nl> + SUGAR_TYPE ( Attributed ) <nl> + SUGAR_TYPE ( Adjusted ) <nl> + SUGAR_TYPE ( SubstTemplateTypeParm ) <nl> + SUGAR_TYPE ( Elaborated ) <nl> <nl> ImportResult VisitDecayedType ( const clang : : DecayedType * type ) { <nl> clang : : ASTContext & clangCtx = Impl . getClangASTContext ( ) ; <nl> mmm a / test / Interop / Cxx / templates / Inputs / function - templates . h <nl> ppp b / test / Interop / Cxx / templates / Inputs / function - templates . h <nl> template < class R , class T , class U > R returns_template ( T a , U b ) { <nl> <nl> / / Same here : <nl> template < class T > void cannot_infer_template ( ) { } <nl> + <nl> + / / TODO : We should support these types . Until then , make sure we don ' t crash when importing . <nl> + template < class . . . Ts > <nl> + void testPackExpansion ( Ts . . . ) { } <nl> + <nl> + template < class T > <nl> + void testTypeOfExpr ( T a , typeof ( a + 1 ) b ) { } <nl> + <nl> + template < class T > <nl> + void testTypeOf ( T a , typeof a b ) { } <nl> + <nl> + template < class T > <nl> + decltype ( auto ) testAuto ( T arg ) { <nl> + return arg ; <nl> + } <nl> + <nl> + / / TODO : Add tests for Decltype , UnaryTransform , and TemplateSpecialization with a dependent type once those are supported . <nl> + <nl> + / / TODO : Add test for DeducedTemplateSpecializationType once we support class templates . <nl>
|
Merge pull request from zoecarver / cxx / variadic - args
|
apple/swift
|
ee9b12fb9b2f20feabb5c79bccb881079a9eaa7e
|
2020-11-02T19:26:41Z
|
mmm a / db / flushtest . cpp <nl> ppp b / db / flushtest . cpp <nl> int main ( int argc , char * argv [ ] , char * envp [ ] ) { <nl> for ( int i = 0 ; i < 10000 ; i + + ) { <nl> fwrite ( " abc " , 3 , 1 , f ) ; <nl> fflush ( f ) ; <nl> - fsync ( fileno ( f ) ) ; <nl> + fsync ( fileno ( f ) ) ; <nl> } <nl> int ms = t . millis ( ) ; <nl> cout < < " flush : " < < ms < < " ms , " < < ms / 10000 . 0 < < " ms / request " < < endl ; <nl> int main ( int argc , char * argv [ ] , char * envp [ ] ) { <nl> for ( int i = 0 ; i < 500 ; i + + ) { <nl> fwrite ( " abc " , 3 , 1 , f ) ; <nl> fflush ( f ) ; <nl> - fsync ( fileno ( f ) ) ; <nl> - sleepmillis ( 10 ) ; <nl> + fsync ( fileno ( f ) ) ; <nl> + sleepmillis ( 2 ) ; <nl> } <nl> - int ms = t . millis ( ) ; <nl> - cout < < " flush with sleeps intermixed : " < < ms < < " ms , " < < ( ms - 5000 ) / 500 . 0 < < " ms / request " < < endl ; <nl> + int ms = t . millis ( ) - 500 * 2 ; <nl> + cout < < " flush with sleeps : " < < ms < < " ms , " < < ms / 500 . 0 < < " ms / request " < < endl ; <nl> } <nl> <nl> char buf [ 8192 ] ; <nl> int main ( int argc , char * argv [ ] , char * envp [ ] ) { <nl> buf [ 0 ] + + ; <nl> fflush ( f ) ; <nl> fullsync ( fileno ( f ) ) ; <nl> - sleepmillis ( 10 ) ; <nl> + sleepmillis ( 2 ) ; <nl> } <nl> - int ms = t . millis ( ) ; <nl> - cout < < " fullsync with sleeps intermixed : " < < ms < < " ms , " < < ( ms - 5000 ) / 500 . 0 < < " ms / request " < < endl ; <nl> + int ms = t . millis ( ) - 2 * 500 ; <nl> + cout < < " fullsync with sleeps : " < < ms < < " ms , " < < ms / 500 . 0 < < " ms / request " < < endl ; <nl> } <nl> } <nl> <nl> - / / with noatime <nl> + / / without growing <nl> { <nl> fclose ( f ) ; <nl> / * try from beginning of the file , where we aren ' t appending and changing the file length , <nl> int main ( int argc , char * argv [ ] , char * envp [ ] ) { <nl> int ms = t . millis ( ) ; <nl> cout < < " fullsync without growing : " < < ms < < " ms , " < < ms / ( ( double ) n ) < < " ms / request " < < endl ; <nl> } <nl> + <nl> + / / without growing , with delay <nl> + { <nl> + fclose ( f ) ; <nl> + / * try from beginning of the file , where we aren ' t appending and changing the file length , <nl> + to see if this is faster as the directory entry then doesn ' t have to be flushed ( if noatime in effect ) . <nl> + * / <nl> + f = fopen ( " / data / db / temptest " , " r + " ) ; <nl> + Timer t ; <nl> + int n = 500 ; <nl> + for ( int i = 0 ; i < n ; i + + ) { <nl> + fwrite ( " xyz " , 3 , 1 , f ) ; <nl> + fflush ( f ) ; <nl> + fullsync ( fileno ( f ) ) ; <nl> + sleepmillis ( 2 ) ; <nl> + } <nl> + int ms = t . millis ( ) - 2 * 500 ; <nl> + cout < < " fullsync without growing with sleeps : " < < ms < < " ms , " < < ms / ( ( double ) n ) < < " ms / request " < < endl ; <nl> + } <nl> <nl> return 0 ; <nl> } <nl>
|
more flushtest
|
mongodb/mongo
|
b726cbeed57f1242defe4780b4a7c21159916986
|
2009-01-04T19:13:51Z
|
mmm a / atom / browser / api / atom_api_window . cc <nl> ppp b / atom / browser / api / atom_api_window . cc <nl> void Window : : OnWindowLeaveFullScreen ( ) { <nl> Emit ( " leave - full - screen " ) ; <nl> } <nl> <nl> + void Window : : OnWindowScrollTouchUp ( ) { <nl> + Emit ( " scroll - touch - up " ) ; <nl> + } <nl> + <nl> + void Window : : OnWindowScrollTouchDown ( ) { <nl> + Emit ( " scroll - touch - down " ) ; <nl> + } <nl> + <nl> void Window : : OnWindowEnterHtmlFullScreen ( ) { <nl> Emit ( " enter - html - full - screen " ) ; <nl> } <nl> mmm a / atom / browser / api / atom_api_window . h <nl> ppp b / atom / browser / api / atom_api_window . h <nl> class Window : public mate : : TrackableObject < Window > , <nl> void OnWindowResize ( ) override ; <nl> void OnWindowMove ( ) override ; <nl> void OnWindowMoved ( ) override ; <nl> + void OnWindowScrollTouchUp ( ) override ; <nl> + void OnWindowScrollTouchDown ( ) override ; <nl> void OnWindowEnterFullScreen ( ) override ; <nl> void OnWindowLeaveFullScreen ( ) override ; <nl> void OnWindowEnterHtmlFullScreen ( ) override ; <nl> mmm a / atom / browser / native_window . cc <nl> ppp b / atom / browser / native_window . cc <nl> void NativeWindow : : NotifyWindowEnterFullScreen ( ) { <nl> OnWindowEnterFullScreen ( ) ) ; <nl> } <nl> <nl> + void NativeWindow : : NotifyWindowScrollTouchUp ( ) { <nl> + FOR_EACH_OBSERVER ( NativeWindowObserver , observers_ , <nl> + OnWindowScrollTouchUp ( ) ) ; <nl> + } <nl> + <nl> + void NativeWindow : : NotifyWindowScrollTouchDown ( ) { <nl> + FOR_EACH_OBSERVER ( NativeWindowObserver , observers_ , <nl> + OnWindowScrollTouchDown ( ) ) ; <nl> + } <nl> + <nl> void NativeWindow : : NotifyWindowLeaveFullScreen ( ) { <nl> FOR_EACH_OBSERVER ( NativeWindowObserver , observers_ , <nl> OnWindowLeaveFullScreen ( ) ) ; <nl> mmm a / atom / browser / native_window . h <nl> ppp b / atom / browser / native_window . h <nl> class NativeWindow : public base : : SupportsUserData , <nl> void NotifyWindowMove ( ) ; <nl> void NotifyWindowResize ( ) ; <nl> void NotifyWindowMoved ( ) ; <nl> + void NotifyWindowScrollTouchUp ( ) ; <nl> + void NotifyWindowScrollTouchDown ( ) ; <nl> void NotifyWindowEnterFullScreen ( ) ; <nl> void NotifyWindowLeaveFullScreen ( ) ; <nl> void NotifyWindowEnterHtmlFullScreen ( ) ; <nl> mmm a / atom / browser / native_window_mac . mm <nl> ppp b / atom / browser / native_window_mac . mm <nl> - ( void ) drawRect : ( NSRect ) dirtyRect { <nl> NSView * view = inspectable_web_contents ( ) - > GetView ( ) - > GetNativeView ( ) ; <nl> [ view setAutoresizingMask : NSViewWidthSizable | NSViewHeightSizable ] ; <nl> <nl> + BOOL __block down = NO ; <nl> + [ NSEvent addLocalMonitorForEventsMatchingMask : NSScrollWheelMask handler : ^ NSEvent * _Nullable ( NSEvent * event ) { <nl> + if ( ! [ window_ isKeyWindow ] ) <nl> + return event ; <nl> + <nl> + if ( ! web_contents ) <nl> + return event ; <nl> + <nl> + if ( ! down & & ( ( [ event phase ] = = NSEventPhaseMayBegin ) | | ( [ event phase ] = = NSEventPhaseBegan ) ) ) { <nl> + this - > NotifyWindowScrollTouchDown ( ) ; <nl> + down = YES ; <nl> + } <nl> + if ( down & & ( ( [ event phase ] = = NSEventPhaseEnded ) | | ( [ event phase ] = = NSEventPhaseCancelled ) ) ) { <nl> + this - > NotifyWindowScrollTouchUp ( ) ; <nl> + down = NO ; <nl> + } <nl> + return event ; <nl> + } ] ; <nl> + <nl> InstallView ( ) ; <nl> } <nl> <nl> mmm a / atom / browser / native_window_observer . h <nl> ppp b / atom / browser / native_window_observer . h <nl> class NativeWindowObserver { <nl> virtual void OnWindowResize ( ) { } <nl> virtual void OnWindowMove ( ) { } <nl> virtual void OnWindowMoved ( ) { } <nl> + virtual void OnWindowScrollTouchUp ( ) { } <nl> + virtual void OnWindowScrollTouchDown ( ) { } <nl> virtual void OnWindowEnterFullScreen ( ) { } <nl> virtual void OnWindowLeaveFullScreen ( ) { } <nl> virtual void OnWindowEnterHtmlFullScreen ( ) { } <nl>
|
Extend NativeWindow to track touch - based scroll events on OS X
|
electron/electron
|
bd2252ea559db6d95a9eae12913ff4d2e8472c78
|
2016-01-21T17:40:21Z
|
mmm a / Code / CryEngine / CryAnimation / AttachmentSkin . cpp <nl> ppp b / Code / CryEngine / CryAnimation / AttachmentSkin . cpp <nl> void CAttachmentSKIN : : DrawAttachment ( SRendParams & RendParams , const SRenderingPa <nl> pD - > m_pSkinningData = GetVertexTransformationData ( bUseCPUDeformation , nRenderLOD , passInfo ) ; <nl> <nl> Vec3 skinOffset = m_pModelSkin - > m_arrModelMeshes [ nRenderLOD ] . m_vRenderMeshOffset ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 0 ] = skinOffset . x ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 1 ] = skinOffset . y ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 2 ] = skinOffset . z ; <nl> + pD - > m_pSkinningData - > vecAdditionalOffset = skinOffset ; <nl> <nl> IRenderMesh * pRenderMesh = m_pModelSkin - > GetIRenderMesh ( nRenderLOD ) ; <nl> <nl> mmm a / Code / CryEngine / CryAnimation / AttachmentVCloth . cpp <nl> ppp b / Code / CryEngine / CryAnimation / AttachmentVCloth . cpp <nl> void CAttachmentVCLOTH : : DrawAttachment ( SRendParams & RendParams , const SRendering <nl> m_pSimSkin - > m_arrModelMeshes [ nRenderLOD ] . m_stream . nFrameId = passInfo . GetMainFrameID ( ) ; <nl> <nl> Vec3 skinOffset = m_pRenderSkin - > m_arrModelMeshes [ nRenderLOD ] . m_vRenderMeshOffset ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 0 ] = skinOffset . x ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 1 ] = skinOffset . y ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 2 ] = skinOffset . z ; <nl> + pD - > m_pSkinningData - > vecAdditionalOffset = skinOffset ; <nl> <nl> SVertexAnimationJob * pVertexAnimation = static_cast < SVertexAnimationJob * > ( pD - > m_pSkinningData - > pCustomData ) ; <nl> <nl> mmm a / Code / CryEngine / CryAnimation / CharacterInstance_Render . cpp <nl> ppp b / Code / CryEngine / CryAnimation / CharacterInstance_Render . cpp <nl> void CCharInstance : : RenderCHR ( const SRendParams & RendParams , const Matrix34 & rRe <nl> Vec3 skinOffset ( ZERO ) ; <nl> if ( m_pDefaultSkeleton - > GetModelMesh ( ) ) <nl> skinOffset = m_pDefaultSkeleton - > GetModelMesh ( ) - > m_vRenderMeshOffset ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 0 ] = skinOffset . x ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 1 ] = skinOffset . y ; <nl> - pD - > m_pSkinningData - > vecPrecisionOffset [ 2 ] = skinOffset . z ; <nl> + pD - > m_pSkinningData - > vecAdditionalOffset = skinOffset ; <nl> <nl> if ( g_pI3DEngine - > IsTessellationAllowed ( pObj , passInfo ) ) <nl> { <nl> mmm a / Code / CryEngine / CryCommon / CryRenderer / RenderObject . h <nl> ppp b / Code / CryEngine / CryCommon / CryRenderer / RenderObject . h <nl> struct SSkinningData <nl> void * pCustomData ; / / client specific data , used for example for sw - skinning on animation side <nl> SSkinningData * * pMasterSkinningDataList ; / / used by the SkinningData for a Character Instance , contains a list of all Skin Instances which need SW - Skinning <nl> SSkinningData * pNextSkinningData ; / / List to the next element which needs SW - Skinning <nl> - float vecPrecisionOffset [ 3 ] ; / / Special precision offset correction when 16bit precision floats used <nl> + Vec3 vecAdditionalOffset ; / / ! < Contains MeshNode translation and in case of floats with 16bit precision : an additional precision - offset - correction <nl> <nl> IRenderMesh * pRenderMesh ; <nl> } ; <nl> mmm a / Code / CryEngine / RenderDll / Common / RenderMesh . h <nl> ppp b / Code / CryEngine / RenderDll / Common / RenderMesh . h <nl> struct SMeshStream <nl> ~ SMeshStream ( ) { memset ( this , 0x0 , sizeof ( * this ) ) ; } <nl> } ; <nl> <nl> - / / CRenderMesh : : m_nFlags <nl> - # define FRM_RELEASED BIT ( 0 ) <nl> - # define FRM_DEPRECTATED_FLAG BIT ( 1 ) <nl> - # define FRM_READYTOUPLOAD BIT ( 2 ) <nl> - # define FRM_ALLOCFAILURE BIT ( 3 ) <nl> - # define FRM_SKINNED BIT ( 4 ) <nl> - # define FRM_SKINNEDNEXTDRAW BIT ( 5 ) / / no proper support yet for objects that can be skinned and not skinned . <nl> - # define FRM_ENABLE_NORMALSTREAM BIT ( 6 ) <nl> - # define FRM_SKINNED_EIGHT_WEIGHTS BIT ( 7 ) <nl> + / / Flags for CRenderMesh : : m_nFlags <nl> + / / Starting with BIT ( 8 ) , to avoid double occupancy - since flags FSM_XXX ( e . g . , FSM_USE_COMPUTE_SKINNING , see IRenderMesh . h ) are used in CRenderMesh : : m_nFlags as well <nl> + # define FRM_RELEASED BIT ( 8 ) <nl> + # define FRM_DEPRECTATED_FLAG BIT ( 9 ) <nl> + # define FRM_READYTOUPLOAD BIT ( 10 ) <nl> + # define FRM_ALLOCFAILURE BIT ( 11 ) <nl> + # define FRM_SKINNED BIT ( 12 ) <nl> + # define FRM_SKINNEDNEXTDRAW BIT ( 13 ) / / no proper support yet for objects that can be skinned and not skinned . <nl> + # define FRM_ENABLE_NORMALSTREAM BIT ( 14 ) <nl> + # define FRM_SKINNED_EIGHT_WEIGHTS BIT ( 15 ) <nl> <nl> # if defined ( FEATURE_SVO_GI ) <nl> # define MAX_RELEASED_MESH_FRAMES ( 4 ) / / GI voxelization threads may keep using render mesh for several frames <nl> mmm a / Code / CryEngine / RenderDll / Common / Renderer . cpp <nl> ppp b / Code / CryEngine / RenderDll / Common / Renderer . cpp <nl> SSkinningData * CRenderer : : EF_CreateSkinningData ( IRenderView * pRenderView , uint32 <nl> pSkinningRenderData - > pPreviousSkinningRenderData = NULL ; <nl> pSkinningRenderData - > pCharInstCB = FX_AllocateCharInstCB ( pSkinningRenderData , m_nPoolIndex ) ; <nl> pSkinningRenderData - > remapGUID = ~ 0u ; <nl> + pSkinningRenderData - > vecAdditionalOffset . zero ( ) ; <nl> <nl> pSkinningRenderData - > pNextSkinningData = NULL ; <nl> pSkinningRenderData - > pMasterSkinningDataList = & pSkinningRenderData - > pNextSkinningData ; <nl> mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / CompiledRenderObject . cpp <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / CompiledRenderObject . cpp <nl> void CCompiledRenderObject : : CompilePerInstanceConstantBuffer ( CRenderObject * pRen <nl> / / Skinning precision offset <nl> if ( pOD - > m_pSkinningData ) <nl> { <nl> - cb - > SkinningInfo [ 0 ] = pOD - > m_pSkinningData - > vecPrecisionOffset [ 0 ] ; <nl> - cb - > SkinningInfo [ 1 ] = pOD - > m_pSkinningData - > vecPrecisionOffset [ 1 ] ; <nl> - cb - > SkinningInfo [ 2 ] = pOD - > m_pSkinningData - > vecPrecisionOffset [ 2 ] ; <nl> + cb - > SkinningInfo = Vec4 ( pOD - > m_pSkinningData - > vecAdditionalOffset , 0 . 0f ) ; <nl> } <nl> / / wrinkles mask <nl> if ( pOD - > m_pShaderParams ) <nl> mmm a / Engine / Shaders / HWScripts / CryFX / ModificatorVT . cfi <nl> ppp b / Engine / Shaders / HWScripts / CryFX / ModificatorVT . cfi <nl> cbuffer CBPerInstanceNewBackend : register ( b12 ) <nl> float4 PerInstanceCustomData1 ; / / [ xyzw = ShilouetteColor ] <nl> / / TODO : Should be moved after all the data below <nl> float4 PerInstanceCustomData2 ; / / [ x = selectionIDs in debug pass , y = AmbientColor , zw = Not used ] <nl> + float4 PerInstanceSkinningInfo ; / / Additional offset <nl> <nl> # if % TEMP_TERRAIN | | % TEMP_VEGETATION <nl> float4 PerInstanceBlendTerrainColInfo ; <nl> float4x4 PerInstanceTerrainLayerInfo ; <nl> # elif % WRINKLE_BLENDING | | % _RT_SKELETON_SSD_LINEAR | | % _RT_SKELETON_SSD <nl> - float4 PerInstanceSkinningInfo ; <nl> float4 PerInstanceWrinklesMask0 ; <nl> float4 PerInstanceWrinklesMask1 ; <nl> float4 PerInstanceWrinklesMask2 ; <nl> cbuffer CBPerInstanceNewBackend : register ( b12 ) <nl> <nl> float4 Get_SPI_SkinningInfo ( ) <nl> { <nl> - # if ! % TEMP_TERRAIN & & ! % TEMP_VEGETATION & & ( % _RT_SKELETON_SSD | | % _RT_SKELETON_SSD_LINEAR ) <nl> + # if ! % TEMP_TERRAIN & & ! % TEMP_VEGETATION & & ( % _RT_SKELETON_SSD | | % _RT_SKELETON_SSD_LINEAR | | % _RT_COMPUTE_SKINNING ) <nl> return PerInstanceSkinningInfo ; <nl> # else <nl> return float4 ( 0 , 0 , 0 , 0 ) ; <nl> float4 _pos_WaterLevel ( float4x4 VPMatrix , inout float4 InPos , float _Level ) <nl> float4 _pos_Modificators ( float4x4 VPMatrix , float4x4 InstMatrix , inout streamPos IN , bool bRelativeToCam = true , bool bPrevFrame = false , float fPrevDelta = 0 ) <nl> { <nl> int nType = 0 ; <nl> - float4 InPos = IN . Position ; <nl> + float4 InPos = IN . Position ; <nl> <nl> # if % _VT_TYPE <nl> nType = % _VT_TYPE ; <nl> # endif <nl> <nl> - # if % _RT_SKELETON_SSD | | % _RT_SKELETON_SSD_LINEAR <nl> + # if % _RT_SKELETON_SSD | | % _RT_SKELETON_SSD_LINEAR | | % _RT_COMPUTE_SKINNING <nl> # if ! % TEMP_TERRAIN <nl> # if ENABLE_TESSELLATION & & ! % _RT_NO_TESSELLATION <nl> float3 vNormal = IN . Normal . xyz ; <nl> # else <nl> float3 vNormal = 0 ; <nl> # endif <nl> + <nl> + InPos . xyz + = Get_SPI_SkinningInfo ( ) . xyz ; <nl> <nl> # if ! % _RT_COMPUTE_SKINNING <nl> - InPos . xyz + = Get_SPI_SkinningInfo ( ) . xyz ; <nl> - <nl> if ( bPrevFrame = = false ) <nl> { <nl> SkinPositionTangent ( <nl>
|
! I ( cl 1690124 ) / / ce / main - > / / ce / main_stabilization
|
CRYTEK/CRYENGINE
|
c08fb3d40bf5cb35977eaad15de27dece146698d
|
2018-05-15T14:26:28Z
|
mmm a / documentation / sphinx / source / downloads . rst <nl> ppp b / documentation / sphinx / source / downloads . rst <nl> macOS <nl> <nl> The macOS installation package is supported on macOS 10 . 7 + . It includes the client and ( optionally ) the server . <nl> <nl> - * ` FoundationDB - 6 . 2 . 14 . pkg < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / macOS / installers / FoundationDB - 6 . 2 . 14 . pkg > ` _ <nl> + * ` FoundationDB - 6 . 2 . 15 . pkg < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / macOS / installers / FoundationDB - 6 . 2 . 15 . pkg > ` _ <nl> <nl> Ubuntu <nl> mmmmmm <nl> <nl> The Ubuntu packages are supported on 64 - bit Ubuntu 12 . 04 + , but beware of the Linux kernel bug in Ubuntu 12 . x . <nl> <nl> - * ` foundationdb - clients - 6 . 2 . 14 - 1_amd64 . deb < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / ubuntu / installers / foundationdb - clients_6 . 2 . 14 - 1_amd64 . deb > ` _ <nl> - * ` foundationdb - server - 6 . 2 . 14 - 1_amd64 . deb < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / ubuntu / installers / foundationdb - server_6 . 2 . 14 - 1_amd64 . deb > ` _ ( depends on the clients package ) <nl> + * ` foundationdb - clients - 6 . 2 . 15 - 1_amd64 . deb < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / ubuntu / installers / foundationdb - clients_6 . 2 . 15 - 1_amd64 . deb > ` _ <nl> + * ` foundationdb - server - 6 . 2 . 15 - 1_amd64 . deb < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / ubuntu / installers / foundationdb - server_6 . 2 . 15 - 1_amd64 . deb > ` _ ( depends on the clients package ) <nl> <nl> RHEL / CentOS EL6 <nl> mmmmmmmmmmmmmmm <nl> <nl> The RHEL / CentOS EL6 packages are supported on 64 - bit RHEL / CentOS 6 . x . <nl> <nl> - * ` foundationdb - clients - 6 . 2 . 14 - 1 . el6 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / rhel6 / installers / foundationdb - clients - 6 . 2 . 14 - 1 . el6 . x86_64 . rpm > ` _ <nl> - * ` foundationdb - server - 6 . 2 . 14 - 1 . el6 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / rhel6 / installers / foundationdb - server - 6 . 2 . 14 - 1 . el6 . x86_64 . rpm > ` _ ( depends on the clients package ) <nl> + * ` foundationdb - clients - 6 . 2 . 15 - 1 . el6 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / rhel6 / installers / foundationdb - clients - 6 . 2 . 15 - 1 . el6 . x86_64 . rpm > ` _ <nl> + * ` foundationdb - server - 6 . 2 . 15 - 1 . el6 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / rhel6 / installers / foundationdb - server - 6 . 2 . 15 - 1 . el6 . x86_64 . rpm > ` _ ( depends on the clients package ) <nl> <nl> RHEL / CentOS EL7 <nl> mmmmmmmmmmmmmmm <nl> <nl> The RHEL / CentOS EL7 packages are supported on 64 - bit RHEL / CentOS 7 . x . <nl> <nl> - * ` foundationdb - clients - 6 . 2 . 14 - 1 . el7 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / rhel7 / installers / foundationdb - clients - 6 . 2 . 14 - 1 . el7 . x86_64 . rpm > ` _ <nl> - * ` foundationdb - server - 6 . 2 . 14 - 1 . el7 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / rhel7 / installers / foundationdb - server - 6 . 2 . 14 - 1 . el7 . x86_64 . rpm > ` _ ( depends on the clients package ) <nl> + * ` foundationdb - clients - 6 . 2 . 15 - 1 . el7 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / rhel7 / installers / foundationdb - clients - 6 . 2 . 15 - 1 . el7 . x86_64 . rpm > ` _ <nl> + * ` foundationdb - server - 6 . 2 . 15 - 1 . el7 . x86_64 . rpm < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / rhel7 / installers / foundationdb - server - 6 . 2 . 15 - 1 . el7 . x86_64 . rpm > ` _ ( depends on the clients package ) <nl> <nl> Windows <nl> mmmmmm - <nl> <nl> The Windows installer is supported on 64 - bit Windows XP and later . It includes the client and ( optionally ) the server . <nl> <nl> - * ` foundationdb - 6 . 2 . 14 - x64 . msi < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / windows / installers / foundationdb - 6 . 2 . 14 - x64 . msi > ` _ <nl> + * ` foundationdb - 6 . 2 . 15 - x64 . msi < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / windows / installers / foundationdb - 6 . 2 . 15 - x64 . msi > ` _ <nl> <nl> API Language Bindings <nl> = = = = = = = = = = = = = = = = = = = = = <nl> On macOS and Windows , the FoundationDB Python API bindings are installed as part <nl> <nl> If you need to use the FoundationDB Python API from other Python installations or paths , download the Python package : <nl> <nl> - * ` foundationdb - 6 . 2 . 14 . tar . gz < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / bindings / python / foundationdb - 6 . 2 . 14 . tar . gz > ` _ <nl> + * ` foundationdb - 6 . 2 . 15 . tar . gz < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / bindings / python / foundationdb - 6 . 2 . 15 . tar . gz > ` _ <nl> <nl> Ruby 1 . 9 . 3 / 2 . 0 . 0 + <nl> mmmmmmmmmmmmmmm - - <nl> <nl> - * ` fdb - 6 . 2 . 14 . gem < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / bindings / ruby / fdb - 6 . 2 . 14 . gem > ` _ <nl> + * ` fdb - 6 . 2 . 15 . gem < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / bindings / ruby / fdb - 6 . 2 . 15 . gem > ` _ <nl> <nl> Java 8 + <nl> mmmmmm - <nl> <nl> - * ` fdb - java - 6 . 2 . 14 . jar < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / bindings / java / fdb - java - 6 . 2 . 14 . jar > ` _ <nl> - * ` fdb - java - 6 . 2 . 14 - javadoc . jar < https : / / www . foundationdb . org / downloads / 6 . 2 . 14 / bindings / java / fdb - java - 6 . 2 . 14 - javadoc . jar > ` _ <nl> + * ` fdb - java - 6 . 2 . 15 . jar < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / bindings / java / fdb - java - 6 . 2 . 15 . jar > ` _ <nl> + * ` fdb - java - 6 . 2 . 15 - javadoc . jar < https : / / www . foundationdb . org / downloads / 6 . 2 . 15 / bindings / java / fdb - java - 6 . 2 . 15 - javadoc . jar > ` _ <nl> <nl> Go 1 . 11 + <nl> mmmmmm - - <nl> mmm a / documentation / sphinx / source / release - notes . rst <nl> ppp b / documentation / sphinx / source / release - notes . rst <nl> <nl> Release Notes <nl> # # # # # # # # # # # # # <nl> <nl> + 6 . 2 . 15 <nl> + = = = = = = <nl> + <nl> + Fixes <nl> + mmm - - <nl> + <nl> + * TLS throttling could block legitimate connections . ` ( PR # 2575 ) < https : / / github . com / apple / foundationdb / pull / 2575 > ` _ . <nl> + <nl> 6 . 2 . 14 <nl> = = = = = = <nl> <nl> mmm a / fdbrpc / TLSConnection . actor . cpp <nl> ppp b / fdbrpc / TLSConnection . actor . cpp <nl> ACTOR static Future < Void > handshake ( TLSConnection * self ) { <nl> if ( ! self - > is_client ) { <nl> auto iter ( g_network - > networkInfo . serverTLSConnectionThrottler . find ( peerIP ) ) ; <nl> if ( iter ! = g_network - > networkInfo . serverTLSConnectionThrottler . end ( ) ) { <nl> - if ( now ( ) < iter - > second ) { <nl> - TraceEvent ( " TLSIncomingConnectionThrottlingWarning " , self - > getDebugID ( ) ) . suppressFor ( 1 . 0 ) . detail ( " PeerIP " , peerIP . first . toString ( ) ) ; <nl> - wait ( delay ( FLOW_KNOBS - > CONNECTION_MONITOR_TIMEOUT ) ) ; <nl> - throw connection_failed ( ) ; <nl> + if ( now ( ) < iter - > second . second ) { <nl> + if ( iter - > second . first > = FLOW_KNOBS - > TLS_SERVER_CONNECTION_THROTTLE_ATTEMPTS ) { <nl> + TraceEvent ( " TLSIncomingConnectionThrottlingWarning " , self - > getDebugID ( ) ) . suppressFor ( 1 . 0 ) . detail ( " PeerIP " , peerIP . first . toString ( ) ) ; <nl> + wait ( delay ( FLOW_KNOBS - > CONNECTION_MONITOR_TIMEOUT ) ) ; <nl> + throw connection_failed ( ) ; <nl> + } <nl> } else { <nl> g_network - > networkInfo . serverTLSConnectionThrottler . erase ( peerIP ) ; <nl> } <nl> ACTOR static Future < Void > handshake ( TLSConnection * self ) { <nl> if ( r = = ITLSSession : : SUCCESS ) break ; <nl> if ( r = = ITLSSession : : FAILED ) { <nl> TraceEvent ( " TLSConnectionHandshakeError " , self - > getDebugID ( ) ) . suppressFor ( 1 . 0 ) . detail ( " Peer " , self - > getPeerAddress ( ) ) ; <nl> - g_network - > networkInfo . serverTLSConnectionThrottler [ peerIP ] = now ( ) + ( self - > is_client ? FLOW_KNOBS - > TLS_CLIENT_CONNECTION_THROTTLE_TIMEOUT : FLOW_KNOBS - > TLS_SERVER_CONNECTION_THROTTLE_TIMEOUT ) ; <nl> + auto iter ( g_network - > networkInfo . serverTLSConnectionThrottler . find ( peerIP ) ) ; <nl> + if ( iter ! = g_network - > networkInfo . serverTLSConnectionThrottler . end ( ) ) { <nl> + iter - > second . first + + ; <nl> + } else { <nl> + g_network - > networkInfo . serverTLSConnectionThrottler [ peerIP ] = std : : make_pair ( 0 , now ( ) + ( self - > is_client ? FLOW_KNOBS - > TLS_CLIENT_CONNECTION_THROTTLE_TIMEOUT : FLOW_KNOBS - > TLS_SERVER_CONNECTION_THROTTLE_TIMEOUT ) ) ; <nl> + } <nl> throw connection_failed ( ) ; <nl> } <nl> ASSERT ( r = = ITLSSession : : WANT_WRITE | | r = = ITLSSession : : WANT_READ ) ; <nl> int TLSConnection : : write ( SendBuffer const * buffer , int limit ) { <nl> } <nl> <nl> ACTOR Future < Reference < IConnection > > wrap ( Reference < ITLSPolicy > policy , bool is_client , Future < Reference < IConnection > > c , std : : string host ) { <nl> - Reference < IConnection > conn = wait ( c ) ; <nl> - return Reference < IConnection > ( new TLSConnection ( conn , policy , is_client , host ) ) ; <nl> + state Reference < IConnection > conn = wait ( c ) ; <nl> + try { <nl> + state Reference < TLSConnection > tlsConn ( new TLSConnection ( conn , policy , is_client , host ) ) ; <nl> + if ( is_client ) { <nl> + wait ( tlsConn - > handshook ) ; <nl> + } <nl> + return tlsConn ; <nl> + } catch ( Error & e ) { <nl> + conn - > close ( ) ; <nl> + throw e ; <nl> + } <nl> } <nl> <nl> Future < Reference < IConnection > > TLSListener : : accept ( ) { <nl> Future < Reference < IConnection > > TLSNetworkConnections : : connect ( NetworkAddress to <nl> std : : pair < IPAddress , uint16_t > peerIP = std : : make_pair ( toAddr . ip , toAddr . port ) ; <nl> auto iter ( g_network - > networkInfo . serverTLSConnectionThrottler . find ( peerIP ) ) ; <nl> if ( iter ! = g_network - > networkInfo . serverTLSConnectionThrottler . end ( ) ) { <nl> - if ( now ( ) < iter - > second ) { <nl> - TraceEvent ( " TLSOutgoingConnectionThrottlingWarning " ) . suppressFor ( 1 . 0 ) . detail ( " PeerIP " , toAddr ) ; <nl> - return waitAndFailConnection ( ) ; <nl> + if ( now ( ) < iter - > second . second ) { <nl> + if ( iter - > second . first > = FLOW_KNOBS - > TLS_CLIENT_CONNECTION_THROTTLE_ATTEMPTS ) { <nl> + TraceEvent ( " TLSOutgoingConnectionThrottlingWarning " ) . suppressFor ( 1 . 0 ) . detail ( " PeerIP " , toAddr ) ; <nl> + return waitAndFailConnection ( ) ; <nl> + } <nl> } else { <nl> g_network - > networkInfo . serverTLSConnectionThrottler . erase ( peerIP ) ; <nl> } <nl> mmm a / flow / Knobs . cpp <nl> ppp b / flow / Knobs . cpp <nl> FlowKnobs : : FlowKnobs ( bool randomize , bool isSimulated ) { <nl> init ( TLS_CERT_REFRESH_DELAY_SECONDS , 12 * 60 * 60 ) ; <nl> init ( TLS_SERVER_CONNECTION_THROTTLE_TIMEOUT , 9 . 0 ) ; <nl> init ( TLS_CLIENT_CONNECTION_THROTTLE_TIMEOUT , 11 . 0 ) ; <nl> + init ( TLS_SERVER_CONNECTION_THROTTLE_ATTEMPTS , 1 ) ; <nl> + init ( TLS_CLIENT_CONNECTION_THROTTLE_ATTEMPTS , 0 ) ; <nl> <nl> / / AsyncFileCached <nl> init ( PAGE_CACHE_4K , 2LL < < 30 ) ; <nl> mmm a / flow / Knobs . h <nl> ppp b / flow / Knobs . h <nl> class FlowKnobs : public Knobs { <nl> int TLS_CERT_REFRESH_DELAY_SECONDS ; <nl> double TLS_SERVER_CONNECTION_THROTTLE_TIMEOUT ; <nl> double TLS_CLIENT_CONNECTION_THROTTLE_TIMEOUT ; <nl> + int TLS_SERVER_CONNECTION_THROTTLE_ATTEMPTS ; <nl> + int TLS_CLIENT_CONNECTION_THROTTLE_ATTEMPTS ; <nl> <nl> / / AsyncFileCached <nl> int64_t PAGE_CACHE_4K ; <nl> mmm a / flow / network . h <nl> ppp b / flow / network . h <nl> struct NetworkInfo { <nl> double newestAlternativesFailure = 0 ; <nl> double lastAlternativesFailureSkipDelay = 0 ; <nl> <nl> - std : : map < std : : pair < IPAddress , uint16_t > , double > serverTLSConnectionThrottler ; <nl> + std : : map < std : : pair < IPAddress , uint16_t > , std : : pair < int , double > > serverTLSConnectionThrottler ; <nl> <nl> NetworkInfo ( ) { } <nl> } ; <nl>
|
Merge pull request from etschannen / feature - wait - handshake
|
apple/foundationdb
|
a9eede7bc4d74cff672595ffd8721cca5595a2b9
|
2020-01-22T03:07:26Z
|
mmm a / Code / Sandbox / EditorQt / Objects / EditorCommands_Group . cpp <nl> ppp b / Code / Sandbox / EditorQt / Objects / EditorCommands_Group . cpp <nl> class CAttachToGroup : public IPickObjectCallback <nl> / / ! Called when object picked . <nl> virtual void OnPick ( CBaseObject * pPickedObject ) <nl> { <nl> - assert ( pPickedObject - > GetType ( ) = = OBJTYPE_PREFAB | | pPickedObject - > GetType ( ) = = OBJTYPE_GROUP ) ; <nl> + CRY_ASSERT ( pPickedObject - > GetType ( ) = = OBJTYPE_PREFAB | | pPickedObject - > GetType ( ) = = OBJTYPE_GROUP ) ; <nl> <nl> - IObjectManager * pObjectManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> + string description ; <nl> + description . Format ( " Attach to % s " , pPickedObject - > GetTypeName ( ) ) ; <nl> + CUndo undo ( description ) ; <nl> <nl> - if ( pPickedObject - > GetType ( ) = = OBJTYPE_GROUP ) <nl> - { <nl> - CUndo undo ( " Attach to Group " ) ; <nl> - CGroup * pPickedGroup = static_cast < CGroup * > ( pPickedObject ) ; <nl> - const CSelectionGroup * pSelection = GetIEditorImpl ( ) - > GetSelection ( ) ; <nl> - pSelection - > FilterParents ( ) ; <nl> - std : : vector < CBaseObject * > filteredObjects ; <nl> - filteredObjects . reserve ( pSelection - > GetFilteredCount ( ) ) ; <nl> - <nl> - / / Save filtered list locally because we will be doing selections , which will invalidate the filtered group <nl> - for ( int i = 0 ; i < pSelection - > GetFilteredCount ( ) ; i + + ) <nl> - filteredObjects . push_back ( pSelection - > GetFilteredObject ( i ) ) ; <nl> - <nl> - for ( CBaseObject * pSelectedObject : filteredObjects ) <nl> - { <nl> - if ( ChildIsValid ( pPickedObject , pSelectedObject ) ) <nl> - { <nl> - pPickedGroup - > AddMember ( pSelectedObject ) ; <nl> - <nl> - / / If this is not an open group we are adding to , we must also update the selection <nl> - if ( ! pPickedGroup - > IsOpen ( ) ) <nl> - { <nl> - pObjectManager - > UnselectObject ( pSelectedObject ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( ! pPickedGroup - > IsOpen ( ) & & ! pPickedGroup - > IsSelected ( ) ) <nl> - { <nl> - pObjectManager - > SelectObject ( pPickedGroup ) ; <nl> - } <nl> - } <nl> - else if ( pPickedObject - > GetType ( ) = = OBJTYPE_PREFAB ) <nl> - { <nl> - CUndo undo ( " Attach to Prefab " ) ; <nl> - <nl> - CPrefabObject * pPickedGroup = static_cast < CPrefabObject * > ( pPickedObject ) ; <nl> - GetIEditor ( ) - > GetPrefabManager ( ) - > AddSelectionToPrefab ( pPickedGroup , * pObjectManager - > GetSelection ( ) ) ; <nl> - } <nl> + CBaseObjectsArray objects ; <nl> + GetIEditorImpl ( ) - > GetSelection ( ) - > GetObjects ( objects ) ; <nl> + pPickedObject - > AddMembers ( objects ) ; <nl> <nl> delete this ; <nl> } <nl> class CAttachToGroup : public IPickObjectCallback <nl> else <nl> return false ; <nl> } <nl> - private : <nl> - bool ChildIsValid ( CBaseObject * pParent , CBaseObject * pChild , int nDir = 3 ) <nl> - { <nl> - if ( pParent = = pChild ) <nl> - return false ; <nl> - <nl> - CBaseObject * pObj ; <nl> - if ( nDir & 1 ) <nl> - { <nl> - if ( pObj = pChild - > GetParent ( ) ) <nl> - { <nl> - if ( ! ChildIsValid ( pParent , pObj , 1 ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - if ( nDir & 2 ) <nl> - { <nl> - for ( int i = 0 ; i < pChild - > GetChildCount ( ) ; i + + ) <nl> - { <nl> - if ( pObj = pChild - > GetChild ( i ) ) <nl> - { <nl> - if ( ! ChildIsValid ( pParent , pObj , 2 ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> } ; <nl> <nl> void CreateGroupFromSelection ( ) <nl> void CreateGroupFromSelection ( ) <nl> <nl> void UngroupSelected ( ) <nl> { <nl> - / / Ungroup all groups in selection . <nl> - std : : vector < CBaseObjectPtr > objects ; <nl> - <nl> - const CSelectionGroup * pSelection = GetIEditorImpl ( ) - > GetSelection ( ) ; <nl> - for ( int i = 0 ; i < pSelection - > GetCount ( ) ; i + + ) <nl> + / / find all groups in selection . <nl> + std : : vector < CBaseObject * > objects = GetIEditorImpl ( ) - > GetSelection ( ) - > GetObjectsByFilter ( [ ] ( CBaseObject * pObject ) <nl> { <nl> - objects . push_back ( pSelection - > GetObject ( i ) ) ; <nl> - } <nl> + return static_cast < bool > ( pObject - > IsKindOf ( RUNTIME_CLASS ( CGroup ) ) ) ; <nl> + } ) ; <nl> <nl> + / / For each group in selection ungroup and the remove the object ( if the object is inside a prefab then it will be removed and the prefab will be updated ) <nl> if ( objects . size ( ) ) <nl> { <nl> CUndo undo ( " Ungroup " ) ; <nl> <nl> for ( int i = 0 ; i < objects . size ( ) ; i + + ) <nl> { <nl> - CBaseObject * obj = objects [ i ] ; <nl> - if ( obj & & obj - > GetRuntimeClass ( ) = = RUNTIME_CLASS ( CGroup ) ) <nl> + CBaseObject * pObject = objects [ i ] ; <nl> + if ( pObject ) <nl> { <nl> - static_cast < CGroup * > ( obj ) - > Ungroup ( ) ; <nl> - / / Signal prefab if part of any <nl> - if ( CPrefabObject * pPrefab = ( CPrefabObject * ) obj - > GetPrefab ( ) ) <nl> - { <nl> - pPrefab - > RemoveMember ( obj ) ; <nl> - } <nl> - GetIEditorImpl ( ) - > DeleteObject ( obj ) ; <nl> + static_cast < CGroup * > ( pObject ) - > Ungroup ( ) ; <nl> + GetIEditorImpl ( ) - > DeleteObject ( pObject ) ; <nl> } <nl> } <nl> } <nl> DECLARE_PYTHON_MODULE ( group ) ; <nl> <nl> REGISTER_EDITOR_AND_SCRIPT_COMMAND ( Private_EditorCommands : : CreateGroupFromSelection , group , create_from_selection , <nl> CCommandDescription ( " Creates new group from selected objects " ) ) <nl> - REGISTER_EDITOR_UI_COMMAND_DESC ( group , create_from_selection , " Create Group " , " Ctrl + Shift + G " , " icons : General / Group . ico " , false ) ; <nl> + REGISTER_EDITOR_UI_COMMAND_DESC ( group , create_from_selection , " Create Group . . . " , " Ctrl + Shift + G " , " icons : General / Group . ico " , false ) ; <nl> REGISTER_COMMAND_REMAPPING ( ui_action , actionGroup , group , create_from_selection ) <nl> <nl> REGISTER_EDITOR_AND_SCRIPT_COMMAND ( Private_EditorCommands : : UngroupSelected , group , ungroup , <nl> mmm a / Code / Sandbox / EditorQt / Objects / EditorCommands_PrefabObject . cpp <nl> ppp b / Code / Sandbox / EditorQt / Objects / EditorCommands_PrefabObject . cpp <nl> REGISTER_EDITOR_AND_SCRIPT_COMMAND ( Private_PrefabCommands : : PyUpdateAllPrefabs , p <nl> CCommandDescription ( " Update all prefabs to latest version " ) ) ; <nl> <nl> REGISTER_EDITOR_AND_SCRIPT_COMMAND ( Private_PrefabCommands : : PyCreateFromSelection , prefab , create_from_selection , <nl> - CCommandDescription ( " Create prefab " ) ) ; <nl> + CCommandDescription ( " Create Prefab . . . " ) ) ; <nl> REGISTER_EDITOR_COMMAND_ICON ( prefab , create_from_selection , " icons : Tools / Create_Prefab . ico " ) ; <nl> <nl> REGISTER_EDITOR_AND_SCRIPT_COMMAND ( Private_PrefabCommands : : PyAddSelection , prefab , add_to_prefab , <nl> mmm a / Code / Sandbox / EditorQt / Objects / Group . cpp <nl> ppp b / Code / Sandbox / EditorQt / Objects / Group . cpp <nl> class CBatchAttachChildrenTransformationsHandler <nl> { <nl> pChild - > InvalidateTM ( 0 ) ; <nl> } <nl> + <nl> + / / This forces the matrix to be correctly recomputed BEFORE parent is assigned <nl> + / / This is introduced to fix an issue where detach undo of a group inside two nested prefabs was calculating an incorrect matrix <nl> + pChild - > GetWorldTM ( ) ; <nl> + <nl> m_pParent - > SetChildsParent ( pChild ) ; <nl> if ( m_shouldKeepPos ) <nl> { <nl> class CUndoAttachmentHelper : public IUndoObject <nl> <nl> for ( int i = 0 ; i < children . size ( ) ; + + i ) <nl> { <nl> - children [ i ] - > SetLayer ( pObjectManager - > GetIObjectLayerManager ( ) - > FindLayer ( oldLayersGuids [ i ] ) ) ; <nl> - children [ i ] - > UpdatePrefab ( ) ; <nl> + children [ i ] - > SetLayer ( pObjectManager - > GetIObjectLayerManager ( ) - > FindLayer ( oldLayersGuids [ i ] ) ) ; <nl> + children [ i ] - > UpdatePrefab ( ) ; <nl> } <nl> } ) ; <nl> } <nl> class CUndoAttachmentHelper : public IUndoObject <nl> { <nl> objects . emplace_back ( pObject ) ; <nl> } / / make sure we actually have items to delete in the guid arrays <nl> - else if ( oldLayersGuids . size ( ) & & parentGuids . size ( ) ) <nl> + else if ( oldLayersGuids . size ( ) & & parentGuids . size ( ) ) <nl> { <nl> oldLayersGuids . erase ( oldLayersGuids . begin ( ) + i ) ; <nl> parentGuids . erase ( parentGuids . begin ( ) + i ) ; <nl> class CUndoAttachmentHelper : public IUndoObject <nl> class CUndoAttach : public CUndoAttachmentHelper <nl> { <nl> public : <nl> - CUndoAttach ( const std : : vector < CBaseObject * > & objects , const CBaseObject * pParent , bool shouldKeepPos ) <nl> + CUndoAttach ( const std : : vector < CBaseObject * > & objects , const CBaseObject * pParent , bool shouldKeepPos ) <nl> : m_shouldKeepPos ( shouldKeepPos ) <nl> { <nl> CRY_ASSERT_MESSAGE ( pParent , " Invalid parent " ) ; <nl> CGroup : : CGroup ( ) <nl> SetColor ( ColorB ( 0 , 255 , 0 ) ) ; / / Green <nl> } <nl> <nl> + void CGroup : : FilterObjectsToAdd ( std : : vector < CBaseObject * > & objects ) <nl> + { <nl> + objects . erase ( std : : remove_if ( objects . begin ( ) , objects . end ( ) , [ this ] ( CBaseObject * pObject ) <nl> + { <nl> + return ! CanAddMember ( pObject ) ; <nl> + } ) , objects . end ( ) ) ; <nl> + } <nl> + <nl> void CGroup : : Done ( ) <nl> { <nl> CRY_PROFILE_FUNCTION_ARG ( PROFILE_LOADING_ONLY , GetName ( ) . c_str ( ) ) ; <nl> bool CGroup : : CreateFrom ( std : : vector < CBaseObject * > & objects ) <nl> SetLayer ( pLastSelectedObject - > GetLayer ( ) ) ; <nl> GetIEditorImpl ( ) - > GetIUndoManager ( ) - > Resume ( ) ; <nl> <nl> - / / add ourselves to the last selected group <nl> - if ( CBaseObject * pLastParent = pLastSelectedObject - > GetGroup ( ) ) <nl> + / / Add ourselves to the last selected group if it ' s necessary <nl> + CBaseObject * pLastParent = pLastSelectedObject - > GetGroup ( ) ; <nl> + if ( pLastParent & & pLastParent ! = m_parent ) <nl> + { <nl> pLastParent - > AddMember ( this ) ; <nl> + } <nl> <nl> / / Prefab support <nl> CPrefabObject * pPrefabToCompareAgainst = nullptr ; <nl> CGroup * CGroup : : CreateFrom ( std : : vector < CBaseObject * > & objects , Vec3 center ) <nl> return nullptr ; <nl> } <nl> <nl> - if ( CBaseObject * pLastParent = objects [ objects . size ( ) - 1 ] - > GetGroup ( ) ) <nl> - { <nl> - Matrix34 m = pLastParent - > GetWorldTM ( ) ; <nl> - m . Invert ( ) ; <nl> - center = m . TransformPoint ( center ) ; <nl> - } <nl> / / Snap center to grid . <nl> pGroup - > SetPos ( gSnappingPreferences . Snap3D ( center ) ) ; <nl> <nl> void CGroup : : AddMembers ( std : : vector < CBaseObject * > & objects , bool keepPos / * = tru <nl> { <nl> using namespace Private_Group ; <nl> <nl> + FilterObjectsToAdd ( objects ) ; <nl> + <nl> RemoveIfAlreadyChildrenOf ( this , objects ) ; <nl> <nl> if ( objects . empty ( ) ) <nl> void CGroup : : AddMembers ( std : : vector < CBaseObject * > & objects , bool keepPos / * = tru <nl> / / 3 - from another prefab : Needs remove from prefab <nl> / / 4 - from outside group to inside group in prefab : Needs remove from old group and add to new group in prefab <nl> { <nl> - / / Don ' t record the detach undos since attach undo will take care of this anyways <nl> - CScopedSuspendUndo suspendUndo ; <nl> ForEachParentOf ( objects , [ keepPos ] ( CGroup * pParent , std : : vector < CBaseObject * > & children ) <nl> { <nl> if ( pParent ) <nl> { <nl> - pParent - > RemoveMembers ( children , true , true ) ; <nl> + pParent - > RemoveMembers ( children , true , true ) ; <nl> } <nl> } ) ; <nl> } <nl> void CGroup : : AddMembers ( std : : vector < CBaseObject * > & objects , bool keepPos / * = tru <nl> if ( CBaseObject * pPrefabObject = GetPrefab ( ) ) <nl> { <nl> CPrefabObject * pPrefab = static_cast < CPrefabObject * > ( pPrefabObject ) ; <nl> - for ( auto pObj : objects ) <nl> + for ( auto pObject : objects ) <nl> { <nl> - pPrefab - > GenerateGUIDsForObjectAndChildren ( pObj ) ; <nl> + pPrefab - > GenerateGUIDsForObjectAndChildren ( pObject ) ; <nl> } <nl> } <nl> <nl> void CGroup : : RemoveMember ( CBaseObject * pMember , bool keepPos , bool placeOnRoot ) <nl> void CGroup : : RemoveMembers ( std : : vector < CBaseObject * > & members , bool keepPos / * = true * / , bool placeOnRoot / * = false * / ) <nl> { <nl> CRY_PROFILE_FUNCTION ( PROFILE_LOADING_ONLY ) <nl> - CBaseObject * pPrefab = GetPrefab ( ) ; <nl> + CBaseObject * pPrefab = GetPrefab ( ) ; <nl> if ( pPrefab ! = this ) <nl> { <nl> DetachChildren ( members , keepPos , placeOnRoot ) ; <nl> void CGroup : : SerializeGeneralVisualProperties ( Serialization : : IArchive & ar , bool <nl> } <nl> <nl> void CGroup : : RemoveChild ( CBaseObject * pChild ) <nl> - { <nl> + { <nl> RemoveChildren ( { pChild } ) ; <nl> } <nl> <nl> bool CGroup : : CanAddMembers ( std : : vector < CBaseObject * > & objects ) <nl> { <nl> for ( CBaseObject * pObject : objects ) <nl> { <nl> + / / Make sure we are not adding ourselves to the group <nl> + if ( pObject = = this ) <nl> + { <nl> + return false ; <nl> + } <nl> + <nl> if ( IsDescendantOf ( pObject ) ) <nl> { <nl> return false ; <nl> void CGroup : : SerializeMembers ( CObjectArchive & ar ) <nl> { <nl> if ( ! ar . bUndo ) <nl> { <nl> + / / Delete forces the object to be erased from m_children , we need a copy of m_children to make sure everything is deleted properly <nl> + std : : vector < _smart_ptr < CBaseObject > > childrenToRemove { m_children } ; <nl> + <nl> / / If we are loading a group that ' s already full we need to clean it up and reinstance all it ' s members from the ground up <nl> - for ( auto pChild : m_children ) <nl> + for ( _smart_ptr < CBaseObject > pChild : childrenToRemove ) <nl> { <nl> GetIEditor ( ) - > GetObjectManager ( ) - > DeleteObject ( pChild ) ; <nl> } <nl> void CGroup : : Ungroup ( ) <nl> } <nl> <nl> if ( m_children . empty ( ) ) <nl> + { <nl> return ; <nl> + } <nl> <nl> - std : : vector < CBaseObject * > newSelection ; <nl> - newSelection . reserve ( m_children . size ( ) ) ; <nl> + std : : vector < CBaseObject * > children ; <nl> + children . reserve ( m_children . size ( ) ) ; <nl> <nl> for ( CBaseObject * pChild : m_children ) <nl> { <nl> if ( pChild ) <nl> { <nl> - newSelection . push_back ( pChild ) ; <nl> + children . push_back ( pChild ) ; <nl> } <nl> } <nl> <nl> - DetachChildren ( newSelection ) ; <nl> + RemoveMembers ( children ) ; <nl> <nl> - GetObjectManager ( ) - > AddObjectsToSelection ( newSelection ) ; <nl> + GetObjectManager ( ) - > AddObjectsToSelection ( children ) ; <nl> } <nl> <nl> void CGroup : : Open ( ) <nl> mmm a / Code / Sandbox / EditorQt / Objects / Group . h <nl> ppp b / Code / Sandbox / EditorQt / Objects / Group . h <nl> class SANDBOX_API CGroup : public CBaseObject <nl> public : <nl> DECLARE_DYNCREATE ( CGroup ) <nl> <nl> - static void ForEachParentOf ( const std : : vector < CBaseObject * > & objects , std : : function < void ( CGroup * , std : : vector < CBaseObject * > & ) > ) ; <nl> - static bool CanCreateFrom ( std : : vector < CBaseObject * > & objects ) ; <nl> + static void ForEachParentOf ( const std : : vector < CBaseObject * > & objects , std : : function < void ( CGroup * , std : : vector < CBaseObject * > & ) > ) ; <nl> + static bool CanCreateFrom ( std : : vector < CBaseObject * > & objects ) ; <nl> static CGroup * CreateFrom ( std : : vector < CBaseObject * > & objects , Vec3 center ) ; <nl> <nl> / / Creates a new group with provided objects <nl> class SANDBOX_API CGroup : public CBaseObject <nl> void CreateInspectorWidgets ( CInspectorWidgetCreator & creator ) override ; <nl> <nl> / / ! Add / remove members <nl> - virtual bool CanAddMembers ( std : : vector < CBaseObject * > & objects ) ; <nl> - virtual bool CanAddMember ( CBaseObject * pMember ) ; <nl> - virtual void AddMember ( CBaseObject * pMember , bool bKeepPos = true ) override ; <nl> - virtual void AddMembers ( std : : vector < CBaseObject * > & objects , bool shouldKeepPos = true ) override ; <nl> - virtual void RemoveMember ( CBaseObject * pMember , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> - virtual void RemoveMembers ( std : : vector < CBaseObject * > & members , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> + virtual bool CanAddMembers ( std : : vector < CBaseObject * > & objects ) ; <nl> + virtual bool CanAddMember ( CBaseObject * pMember ) ; <nl> + virtual void AddMember ( CBaseObject * pMember , bool bKeepPos = true ) override ; <nl> + virtual void AddMembers ( std : : vector < CBaseObject * > & objects , bool shouldKeepPos = true ) override ; <nl> + virtual void RemoveMember ( CBaseObject * pMember , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> + virtual void RemoveMembers ( std : : vector < CBaseObject * > & members , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> <nl> - virtual void DetachChildren ( std : : vector < CBaseObject * > & objects , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> + virtual void DetachChildren ( std : : vector < CBaseObject * > & objects , bool shouldKeepPos = true , bool shouldPlaceOnRoot = false ) override ; <nl> <nl> / / ! Detach all childs of this node . <nl> virtual void DetachAll ( bool bKeepPos = true , bool bPlaceOnRoot = false ) override ; <nl> virtual void AttachChildren ( std : : vector < CBaseObject * > & objects , bool shouldKeepPos = true , bool shouldInvalidateTM = true ) override ; <nl> <nl> - virtual void SetMaterial ( IEditorMaterial * mtl ) ; <nl> + virtual void SetMaterial ( IEditorMaterial * mtl ) ; <nl> <nl> - void GetBoundBox ( AABB & box ) ; <nl> - void GetLocalBounds ( AABB & box ) ; <nl> - bool HitTest ( HitContext & hc ) ; <nl> - virtual bool HitHelperTestForChildObjects ( HitContext & hc ) ; <nl> + void GetBoundBox ( AABB & box ) ; <nl> + void GetLocalBounds ( AABB & box ) ; <nl> + bool HitTest ( HitContext & hc ) ; <nl> + virtual bool HitHelperTestForChildObjects ( HitContext & hc ) ; <nl> <nl> - void Serialize ( CObjectArchive & ar ) ; <nl> + void Serialize ( CObjectArchive & ar ) ; <nl> <nl> / / ! Overwrite event handler from CBaseObject . <nl> void OnEvent ( ObjectEvent event ) ; <nl> class SANDBOX_API CGroup : public CBaseObject <nl> / / ! Dtor must be protected . <nl> CGroup ( ) ; <nl> <nl> + / / ! Remove from the objects vector all the objects that cannot be added to the group by calling the CanAddMember function <nl> + void FilterObjectsToAdd ( std : : vector < CBaseObject * > & objects ) ; <nl> + bool ChildIsValid ( CBaseObject * pParent , CBaseObject * pChild , int nDir = 3 ) ; <nl> virtual bool HitTestMembers ( HitContext & hc ) ; <nl> void SerializeMembers ( CObjectArchive & ar ) ; <nl> virtual void CalcBoundBox ( ) ; <nl> class SANDBOX_API CGroup : public CBaseObject <nl> / / Groups and derived shouldn ' t have visual properties visible . Specifically in prefabs where there is no way to reliably store global prefab properties ( they get saved in the layer and not in the xml ) <nl> virtual void SerializeGeneralVisualProperties ( Serialization : : IArchive & ar , bool bMultiEdit ) override ; <nl> <nl> - AABB m_bbox ; <nl> - bool m_bBBoxValid : 1 ; <nl> - bool m_opened : 1 ; <nl> - bool m_bAlwaysDrawBox : 1 ; <nl> - bool m_ignoreChildModify : 1 ; <nl> - bool m_bUpdatingPivot : 1 ; <nl> + AABB m_bbox ; <nl> + bool m_bBBoxValid : 1 ; <nl> + bool m_opened : 1 ; <nl> + bool m_bAlwaysDrawBox : 1 ; <nl> + bool m_ignoreChildModify : 1 ; <nl> + bool m_bUpdatingPivot : 1 ; <nl> <nl> friend Private_Group : : CBatchAttachChildrenTransformationsHandler ; <nl> friend Private_Group : : CUndoBatchAttachBaseObject ; <nl> mmm a / Code / Sandbox / EditorQt / Objects / PrefabObject . cpp <nl> ppp b / Code / Sandbox / EditorQt / Objects / PrefabObject . cpp <nl> XmlNodeRef CPrefabObject : : Export ( const string & levelPath , XmlNodeRef & xmlNode ) <nl> return nullptr ; <nl> } <nl> <nl> - inline void RecursivelySendEventToPrefabChilds ( CBaseObject * obj , ObjectEvent event ) <nl> + inline void RecursivelySendEventToPrefabChildren ( CBaseObject * pObject , ObjectEvent event ) <nl> { <nl> - for ( int i = 0 ; i < obj - > GetChildCount ( ) ; i + + ) <nl> + for ( int i = 0 ; i < pObject - > GetChildCount ( ) ; i + + ) <nl> { <nl> - CBaseObject * c = obj - > GetChild ( i ) ; <nl> - if ( c - > CheckFlags ( OBJFLAG_PREFAB ) ) <nl> + CBaseObject * pChild = pObject - > GetChild ( i ) ; <nl> + if ( pChild - > CheckFlags ( OBJFLAG_PREFAB ) ) <nl> { <nl> - c - > OnEvent ( event ) ; <nl> - if ( c - > GetChildCount ( ) > 0 ) <nl> + pChild - > OnEvent ( event ) ; <nl> + if ( pChild - > GetChildCount ( ) > 0 ) <nl> { <nl> - RecursivelySendEventToPrefabChilds ( c , event ) ; <nl> + RecursivelySendEventToPrefabChildren ( pChild , event ) ; <nl> } <nl> } <nl> } <nl> void CPrefabObject : : OnEvent ( ObjectEvent event ) <nl> / / Send event to all prefab childs . <nl> if ( event ! = EVENT_ALIGN_TOGRID ) <nl> { <nl> - RecursivelySendEventToPrefabChilds ( this , event ) ; <nl> + RecursivelySendEventToPrefabChildren ( this , event ) ; <nl> } <nl> CBaseObject : : OnEvent ( event ) ; <nl> } <nl> void CPrefabObject : : AddMembers ( std : : vector < CBaseObject * > & objects , bool shouldKe <nl> return ; <nl> } <nl> <nl> - if ( ! CanAddMembers ( objects ) ) <nl> + FilterObjectsToAdd ( objects ) ; <nl> + <nl> + if ( objects . empty ( ) ) <nl> { <nl> - CryWarning ( EValidatorModule : : VALIDATOR_MODULE_EDITOR , EValidatorSeverity : : VALIDATOR_ERROR , " Cannot add objects to prefab % s " , GetName ( ) . c_str ( ) ) ; <nl> return ; <nl> } <nl> <nl> static void Prefab_RecursivelyGetBoundBox ( CBaseObject * object , AABB & box , const <nl> box . Add ( b . min ) ; <nl> box . Add ( b . max ) ; <nl> <nl> - int numChilds = object - > GetChildCount ( ) ; <nl> - for ( int i = 0 ; i < numChilds ; i + + ) <nl> + int numChildren = object - > GetChildCount ( ) ; <nl> + for ( int i = 0 ; i < numChildren ; i + + ) <nl> Prefab_RecursivelyGetBoundBox ( object - > GetChild ( i ) , box , worldTM ) ; <nl> <nl> int numLinkedObjects = object - > GetLinkedObjectCount ( ) ; <nl> void CPrefabObject : : CalcBoundBox ( ) <nl> AABB box ; <nl> box . Reset ( ) ; <nl> <nl> - int numChilds = GetChildCount ( ) ; <nl> - for ( int i = 0 ; i < numChilds ; i + + ) <nl> + int numChildren = GetChildCount ( ) ; <nl> + for ( int i = 0 ; i < numChildren ; i + + ) <nl> { <nl> if ( GetChild ( i ) - > CheckFlags ( OBJFLAG_PREFAB ) ) <nl> { <nl> void CPrefabObject : : CalcBoundBox ( ) <nl> } <nl> } <nl> <nl> - if ( numChilds = = 0 ) <nl> + if ( numChildren = = 0 ) <nl> { <nl> box . min = Vec3 ( - 1 , - 1 , - 1 ) ; <nl> box . max = Vec3 ( 1 , 1 , 1 ) ; <nl> void CPrefabObject : : UpdatePivot ( const Vec3 & newWorldPivotPos ) <nl> CGroup : : UpdatePivot ( newWorldPivotPos ) ; <nl> SetModifyInProgress ( false ) ; <nl> <nl> - TBaseObjects childs ; <nl> - childs . reserve ( GetChildCount ( ) ) ; <nl> + TBaseObjects children ; <nl> + children . reserve ( GetChildCount ( ) ) ; <nl> / / Cache childs ptr because in the update prefab we are modifying the m_childs array since we are attaching / detaching before we save in the prefab lib xml <nl> for ( int i = 0 , iChildCount = GetChildCount ( ) ; i < iChildCount ; + + i ) <nl> { <nl> - childs . push_back ( GetChild ( i ) ) ; <nl> + children . push_back ( GetChild ( i ) ) ; <nl> } <nl> <nl> / / Update the prefab lib and reposition all prefab childs according to the new pivot <nl> - for ( int i = 0 , iChildCount = childs . size ( ) ; i < iChildCount ; + + i ) <nl> + for ( int i = 0 , iChildCount = children . size ( ) ; i < iChildCount ; + + i ) <nl> { <nl> - childs [ i ] - > UpdatePrefab ( eOCOT_ModifyTransformInLibOnly ) ; <nl> + children [ i ] - > UpdatePrefab ( eOCOT_ModifyTransformInLibOnly ) ; <nl> } <nl> <nl> / / Update all the rest prefab instance of the same type <nl> mmm a / Code / Sandbox / EditorQt / Prefabs / PrefabItem . cpp <nl> ppp b / Code / Sandbox / EditorQt / Prefabs / PrefabItem . cpp <nl> CPrefabItem * CPrefabItem : : CreateCopy ( ) const <nl> return pCopy ; <nl> } <nl> <nl> - void CPrefabItem : : SaveLinkedObjects ( CObjectArchive & ar , CBaseObject * pObj , bool bAllowOwnedByPrefab ) <nl> + void CPrefabItem : : SaveLinkedObjects ( CObjectArchive & ar , CBaseObject * pObject , bool bAllowOwnedByPrefab ) <nl> { <nl> - for ( auto i = 0 ; i < pObj - > GetLinkedObjectCount ( ) ; + + i ) <nl> + for ( auto i = 0 ; i < pObject - > GetLinkedObjectCount ( ) ; + + i ) <nl> { <nl> - CBaseObject * pLinkedObject = pObj - > GetLinkedObject ( i ) ; <nl> + CBaseObject * pLinkedObject = pObject - > GetLinkedObject ( i ) ; <nl> if ( bAllowOwnedByPrefab | | ! pLinkedObject - > IsPartOfPrefab ( ) ) <nl> { <nl> ar . SaveObject ( pLinkedObject , false , true ) ; <nl> void CPrefabItem : : SaveLinkedObjects ( CObjectArchive & ar , CBaseObject * pObj , bool <nl> } <nl> } <nl> <nl> - void CPrefabItem : : CollectLinkedObjects ( CBaseObject * pObj , std : : vector < CBaseObject * > & linkedObjects , CSelectionGroup & selection ) <nl> + void CPrefabItem : : CollectLinkedObjects ( CBaseObject * pObject , std : : vector < CBaseObject * > & linkedObjects , CSelectionGroup & selection ) <nl> { <nl> - for ( auto i = 0 ; i < pObj - > GetLinkedObjectCount ( ) ; + + i ) <nl> + for ( auto i = 0 ; i < pObject - > GetLinkedObjectCount ( ) ; + + i ) <nl> { <nl> - CBaseObject * pLinkedObject = pObj - > GetLinkedObject ( i ) ; <nl> + CBaseObject * pLinkedObject = pObject - > GetLinkedObject ( i ) ; <nl> if ( selection . IsContainObject ( pLinkedObject ) ) <nl> selection . RemoveObject ( pLinkedObject ) ; <nl> <nl> void CPrefabItem : : UpdateFromPrefabObject ( CPrefabObject * pPrefabObject , const SOb <nl> return ; <nl> } <nl> <nl> - IObjectManager * const pObjMan = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> - CBaseObject * pObj = pObjMan - > FindObject ( context . m_modifiedObjectGlobalId ) ; <nl> - if ( ! pObj ) <nl> + IObjectManager * const pObjectManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> + CBaseObject * pObject = pObjectManager - > FindObject ( context . m_modifiedObjectGlobalId ) ; <nl> + if ( ! pObject ) <nl> + { <nl> return ; <nl> + } <nl> <nl> CheckVersionAndUpgrade ( ) ; <nl> <nl> void CPrefabItem : : UpdateFromPrefabObject ( CPrefabObject * pPrefabObject , const SOb <nl> <nl> / / If modify transform case <nl> if ( context . m_operation = = eOCOT_ModifyTransform ) <nl> - modifiedContext . m_localTM = pObj - > GetLocalTM ( ) ; <nl> + modifiedContext . m_localTM = pObject - > GetLocalTM ( ) ; <nl> <nl> / / Now change all the rest instances of this prefab in the level ( skipping this one , since it is already been modified ) <nl> pPrefabManager - > SetSelectedItem ( this ) ; <nl> void CPrefabItem : : UpdateFromPrefabObject ( CPrefabObject * pPrefabObject , const SOb <nl> CScopedSuspendUndo suspendUndo ; <nl> <nl> CBaseObjectsArray allInstancedPrefabs ; <nl> - pObjMan - > FindObjectsOfType ( RUNTIME_CLASS ( CPrefabObject ) , allInstancedPrefabs ) ; <nl> + pObjectManager - > FindObjectsOfType ( RUNTIME_CLASS ( CPrefabObject ) , allInstancedPrefabs ) ; <nl> <nl> for ( size_t i = 0 , prefabsCount = allInstancedPrefabs . size ( ) ; i < prefabsCount ; + + i ) <nl> { <nl> bool CPrefabItem : : FixDuplicateObjects ( ) <nl> <nl> void CPrefabItem : : ModifyLibraryPrefab ( CSelectionGroup & objectsInPrefabAsFlatSelection , CPrefabObject * pPrefabObject , const SObjectChangedContext & context , const TObjectIdMapping & guidMapping ) <nl> { <nl> - IObjectManager * const pObjManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> + IObjectManager * const pObjectManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> <nl> std : : vector < XmlNodeRef > objects ; <nl> / / Find all the objects in this prefab item <nl> FindAllObjectsInLibrary ( m_objectsNode , objects ) ; <nl> / / If this object actually exists in the instance <nl> - if ( CBaseObject * const pObj = objectsInPrefabAsFlatSelection . GetObjectByGuidInPrefab ( context . m_modifiedObjectGuidInPrefab ) ) <nl> + if ( CBaseObject * const pObject = objectsInPrefabAsFlatSelection . GetObjectByGuidInPrefab ( context . m_modifiedObjectGuidInPrefab ) ) <nl> { <nl> / / Add a new member to the to level of the prefab <nl> if ( context . m_operation = = eOCOT_Add ) <nl> { <nl> / / If we are trying to add something which already exists in the prefab definition we are trying to modify it <nl> - if ( FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , true ) ) <nl> + if ( FindObjectByGuid ( pObject - > GetIdInPrefab ( ) , true ) ) <nl> { <nl> SObjectChangedContext correctedContext = context ; <nl> correctedContext . m_operation = eOCOT_Modify ; <nl> void CPrefabItem : : ModifyLibraryPrefab ( CSelectionGroup & objectsInPrefabAsFlatSele <nl> return ; <nl> } <nl> / / Create a new archive and serialize the object in it <nl> - CObjectArchive ar ( pObjManager , m_objectsNode , false ) ; <nl> + CObjectArchive ar ( pObjectManager , m_objectsNode , false ) ; <nl> <nl> - ar . SaveObject ( pObj , false , true ) ; <nl> + ar . SaveObject ( pObject , false , true ) ; <nl> <nl> / / Update all the linked objects <nl> - SaveLinkedObjects ( ar , pObj , true ) ; <nl> + SaveLinkedObjects ( ar , pObject , true ) ; <nl> <nl> / / Update all the ids to link to the correct prefab objects ( parents / ecc ) <nl> XmlNodeRef savedObj = m_objectsNode - > getChild ( m_objectsNode - > getChildCount ( ) - 1 ) ; <nl> void CPrefabItem : : ModifyLibraryPrefab ( CSelectionGroup & objectsInPrefabAsFlatSele <nl> { <nl> / / This object could be everywhere in the hierarchy , we do not want to modify it all , just find it in the flattened version ( aka the list of all the objects in the XML ) and reserialize <nl> / / Find - > remove previous definition of the object and serialize the new changes <nl> - if ( XmlNodeRef object = FindObjectByGuidInFlattenedNodes ( objects , pObj - > GetIdInPrefab ( ) , true ) ) / / FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , true ) ) <nl> + if ( XmlNodeRef object = FindObjectByGuidInFlattenedNodes ( objects , pObject - > GetIdInPrefab ( ) , true ) ) <nl> { <nl> / / Parent could be every level in the hierarchy , like an < Objects > node ( we are in a group ) , or the top level of a prefab <nl> XmlNodeRef parent = object - > getParent ( ) ; <nl> parent - > removeChild ( object ) ; <nl> <nl> - CObjectArchive ar ( pObjManager , parent , false ) ; <nl> - ar . SaveObject ( pObj , false , true ) ; <nl> + CObjectArchive ar ( pObjectManager , parent , false ) ; <nl> + ar . SaveObject ( pObject , false , true ) ; <nl> <nl> XmlNodeRef savedObj = parent - > getChild ( parent - > getChildCount ( ) - 1 ) ; <nl> RemapIDsInNodeAndChildren ( savedObj , guidMapping , false ) ; <nl> void CPrefabItem : : ModifyLibraryPrefab ( CSelectionGroup & objectsInPrefabAsFlatSele <nl> else if ( context . m_operation = = eOCOT_Delete ) <nl> { <nl> / / Just find an object from the flattened hierarchy and then remove it <nl> - if ( XmlNodeRef object = FindObjectByGuidInFlattenedNodes ( objects , pObj - > GetIdInPrefab ( ) , true ) ) / / FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , true ) ) <nl> + if ( XmlNodeRef object = FindObjectByGuidInFlattenedNodes ( objects , pObject - > GetIdInPrefab ( ) , true ) ) / / FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , true ) ) <nl> { <nl> XmlNodeRef parent = object - > getParent ( ) ; <nl> parent - > removeChild ( object ) ; <nl> void CPrefabItem : : ModifyLibraryPrefab ( CSelectionGroup & objectsInPrefabAsFlatSele <nl> for ( int i = 0 , count = parent - > getChildCount ( ) ; i < count ; + + i ) <nl> { <nl> CryGUID parentGuid = CryGUID : : Null ( ) ; <nl> - if ( parent - > getChild ( i ) - > getAttr ( " Parent " , parentGuid ) & & parentGuid = = pObj - > GetIdInPrefab ( ) ) <nl> + if ( parent - > getChild ( i ) - > getAttr ( " Parent " , parentGuid ) & & parentGuid = = pObject - > GetIdInPrefab ( ) ) <nl> { <nl> parent - > getChild ( i ) - > delAttr ( " Parent " ) ; <nl> } <nl> } <nl> } <nl> - } / / ~ Member DELETE <nl> - } / / ~ if ( CBaseObject * const pObj = objectsInPrefabAsFlatSelection . GetObjectByGuidInPrefab ( context . m_modifiedObjectGuidInPrefab ) ) <nl> + } <nl> + } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CPrefabItem : : FindAllObjectsInLibrary ( XmlNodeRef nodeRef , std : : vector < XmlNod <nl> / / This updates all the instanced objects with the exception of the original prefab instance that is calling the prefab item update ( as it ' s obviously already up to date ) <nl> void CPrefabItem : : ModifyInstancedPrefab ( CSelectionGroup & objectsInPrefabAsFlatSelection , CPrefabObject * pPrefabObject , const SObjectChangedContext & context , const TObjectIdMapping & guidMapping ) <nl> { <nl> - IObjectManager * const pObjManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> + IObjectManager * const pObjectManager = GetIEditorImpl ( ) - > GetObjectManager ( ) ; <nl> std : : vector < XmlNodeRef > objects ; <nl> / / we re generate the list it again because it can be modified if the prefab item m_objectsNode is changed ( which happens in ModifyPrefab ) <nl> FindAllObjectsInLibrary ( m_objectsNode , objects ) ; <nl> <nl> if ( context . m_operation = = eOCOT_Add ) <nl> { <nl> - if ( CBaseObject * const pObj = pObjManager - > FindObject ( context . m_modifiedObjectGlobalId ) ) <nl> + if ( CBaseObject * const pObject = pObjectManager - > FindObject ( context . m_modifiedObjectGlobalId ) ) <nl> { <nl> / / NB : Note that we search only in the top level hierarchy , for hierarchies the parents ( aka a Group ) will deal with addition / removal of children <nl> - if ( XmlNodeRef changedObject = FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , false ) ) <nl> + if ( XmlNodeRef changedObject = FindObjectByGuid ( pObject - > GetIdInPrefab ( ) , false ) ) <nl> { <nl> / / See if we already have this object as part of the instanced prefab <nl> std : : vector < CBaseObject * > descendants ; <nl> pPrefabObject - > GetAllPrefabFlagedDescendants ( descendants ) ; <nl> - CBaseObject * pModified = FindObjectByPrefabGuid ( descendants , pObj - > GetIdInPrefab ( ) ) ; <nl> + CBaseObject * pModified = FindObjectByPrefabGuid ( descendants , pObject - > GetIdInPrefab ( ) ) ; <nl> if ( pModified ) <nl> { <nl> SObjectChangedContext correctedContext = context ; <nl> void CPrefabItem : : ModifyInstancedPrefab ( CSelectionGroup & objectsInPrefabAsFlatSe <nl> } <nl> / / Clone the objects , fix the flags and add it to the current item , this works only for TOP LEVEL ITEMS , <nl> / / groups will call modify on themselves and regenerate all the objects inside them if something is added <nl> - CObjectArchive loadAr ( pObjManager , changedObject , true ) ; <nl> + CObjectArchive loadAr ( pObjectManager , changedObject , true ) ; <nl> loadAr . EnableProgressBar ( false ) ; <nl> <nl> / / PrefabGUID - > GUID <nl> void CPrefabItem : : ModifyInstancedPrefab ( CSelectionGroup & objectsInPrefabAsFlatSe <nl> } <nl> } <nl> } <nl> - else if ( CBaseObject * const pObj = objectsInPrefabAsFlatSelection . GetObjectByGuidInPrefab ( context . m_modifiedObjectGuidInPrefab ) ) <nl> + else if ( CBaseObject * const pObject = objectsInPrefabAsFlatSelection . GetObjectByGuidInPrefab ( context . m_modifiedObjectGuidInPrefab ) ) <nl> { <nl> + / / We update the state of all members in the top level of the prefab , members in the lower level are updated by their parent ( prefabs / group ) serialize method <nl> if ( context . m_operation = = eOCOT_Modify ) <nl> { <nl> - if ( XmlNodeRef changedObject = FindObjectByGuidInFlattenedNodes ( objects , pObj - > GetIdInPrefab ( ) , false ) ) <nl> + if ( XmlNodeRef changedObject = FindObjectByGuidInFlattenedNodes ( objects , pObject - > GetIdInPrefab ( ) , false ) ) <nl> { <nl> / / Deserialize the object and attach it to the prefab instance <nl> / / when this is sent to groups it will recreate the whole group as the CGroup : : Serialize deletes and regenerates all it ' s members <nl> / / Note that in this case no remapping is needed , especially for groups the GenerateGUIDsForObjectAndChildren function called on AddMember in archive resolve ( happens on archive destruction , aka end of this function ) will properly assign guids to this object and its children <nl> <nl> / / Build load archive <nl> - CObjectArchive loadAr ( pObjManager , changedObject , true ) ; <nl> + CObjectArchive loadAr ( pObjectManager , changedObject , true ) ; <nl> <nl> / / Load ids remapping info into the load archive <nl> for ( int j = 0 , count = guidMapping . size ( ) ; j < count ; + + j ) <nl> loadAr . RemapID ( guidMapping [ j ] . from , guidMapping [ j ] . to ) ; <nl> <nl> / / Set parent attr if we dont have any ( because we don ' t store this in the prefab XML since it is implicitly given ) <nl> - bool noParentIdAttr = false ; <nl> + <nl> if ( ! changedObject - > haveAttr ( " Parent " ) & & ! changedObject - > haveAttr ( " LinkedTo " ) ) <nl> { <nl> - noParentIdAttr = true ; <nl> + <nl> changedObject - > setAttr ( " Parent " , pPrefabObject - > GetId ( ) ) ; <nl> } <nl> <nl> / / Back - up flags before serializing . We need some flags to be persistent after serialization . Ex : Selection flags <nl> - auto flags = pObj - > GetFlags ( ) ; <nl> + auto flags = pObject - > GetFlags ( ) ; <nl> <nl> / / Load the object <nl> - pObj - > Serialize ( loadAr ) ; <nl> - pObj - > PostLoad ( loadAr ) ; <nl> + pObject - > Serialize ( loadAr ) ; <nl> + pObject - > PostLoad ( loadAr ) ; <nl> <nl> / / Set old flags <nl> - pObj - > SetFlags ( flags ) ; <nl> + pObject - > SetFlags ( flags ) ; <nl> <nl> - RegisterPrefabEventFlowNodes ( pObj ) ; <nl> + RegisterPrefabEventFlowNodes ( pObject ) ; <nl> <nl> - pPrefabObject - > SetObjectPrefabFlagAndLayer ( pObj ) ; <nl> + pPrefabObject - > SetObjectPrefabFlagAndLayer ( pObject ) ; <nl> <nl> / / Remove parent attribute if it is directly a child of the prefab <nl> - if ( noParentIdAttr ) <nl> + CryGUID parentId = CryGUID : : Null ( ) ; <nl> + changedObject - > getAttr ( " Parent " , parentId ) ; <nl> + if ( parentId = = pPrefabObject - > GetId ( ) ) <nl> + { <nl> changedObject - > delAttr ( " Parent " ) ; <nl> + } <nl> } <nl> } <nl> else if ( context . m_operation = = eOCOT_ModifyTransform ) <nl> { <nl> - if ( XmlNodeRef changedObject = FindObjectByGuidInFlattenedNodes ( objects , pObj - > GetIdInPrefab ( ) , false ) ) / / FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , false ) ) <nl> + if ( XmlNodeRef changedObject = FindObjectByGuidInFlattenedNodes ( objects , pObject - > GetIdInPrefab ( ) , false ) ) / / FindObjectByGuid ( pObj - > GetIdInPrefab ( ) , false ) ) <nl> { <nl> / / just reset the TM matrix <nl> - pObj - > SetLocalTM ( context . m_localTM , eObjectUpdateFlags_Undo ) ; <nl> + pObject - > SetLocalTM ( context . m_localTM , eObjectUpdateFlags_Undo ) ; <nl> } <nl> } <nl> else if ( context . m_operation = = eOCOT_Delete ) <nl> { <nl> - pObjManager - > DeleteObject ( pObj ) ; <nl> + pObjectManager - > DeleteObject ( pObject ) ; <nl> } <nl> } <nl> } <nl> mmm a / Code / Sandbox / EditorQt / Prefabs / PrefabItem . h <nl> ppp b / Code / Sandbox / EditorQt / Prefabs / PrefabItem . h <nl> class SANDBOX_API CPrefabItem : public CBaseLibraryItem <nl> / / ! Removes all XML child nodes in m_objectsNode , which has a Parent with the specified GUID <nl> void RemoveAllChildrenOf ( CryGUID guid ) ; <nl> <nl> - void SaveLinkedObjects ( CObjectArchive & ar , CBaseObject * pObj , bool bAllowOwnedByPrefab ) ; <nl> - void CollectLinkedObjects ( CBaseObject * pObj , std : : vector < CBaseObject * > & linkedObjects , CSelectionGroup & selection ) ; <nl> + void SaveLinkedObjects ( CObjectArchive & ar , CBaseObject * pObject , bool bAllowOwnedByPrefab ) ; <nl> + void CollectLinkedObjects ( CBaseObject * pObject , std : : vector < CBaseObject * > & linkedObjects , CSelectionGroup & selection ) ; <nl> private : <nl> XmlNodeRef m_objectsNode ; <nl> string m_PrefabClassName ; <nl>
|
! B ( Sandbox ) ( CE - 21378 ) Introduced common code path for prefabs and groups AddMember , fixed grammar inconstistencies , moved hierarchy checks function to groups , added a function to filter out members that cannot be added to a group . Changed instance modify code to make sure direct children of a group have the parent attribute removed after serialization . Fixed a bug where members of a group were missing deletion because of iterator invalidation in the m_children vector # savemebatman
|
CRYTEK/CRYENGINE
|
492e5c46c7d45e816520c7c9aeb08bde3a711ce5
|
2019-08-09T06:40:02Z
|
mmm a / dbms / src / Storages / MergeTree / MergeTreeDataMergerMutator . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataMergerMutator . cpp <nl> bool MergeTreeDataMergerMutator : : selectPartsToMerge ( <nl> parts . push_back ( part ) ; <nl> } <nl> <nl> - / / LOG_DEBUG ( log , " Selected " < < parts . size ( ) < < " parts from " < < parts . front ( ) - > name < < " to " < < parts . back ( ) - > name ) ; <nl> + LOG_DEBUG ( log , " Selected " < < parts . size ( ) < < " parts from " < < parts . front ( ) - > name < < " to " < < parts . back ( ) - > name ) ; <nl> future_part . assign ( std : : move ( parts ) ) ; <nl> return true ; <nl> } <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mergePartsToTempor <nl> total_size + = part - > bytes_on_disk ; <nl> if ( total_size > = data_settings - > min_merge_bytes_to_use_direct_io ) <nl> { <nl> - / / LOG_DEBUG ( log , " Will merge parts reading files in O_DIRECT " ) ; <nl> + LOG_DEBUG ( log , " Will merge parts reading files in O_DIRECT " ) ; <nl> read_with_direct_io = true ; <nl> <nl> break ; <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> <nl> LOG_DEBUG ( log , " All columns : " < < all_columns . toString ( ) ) ; <nl> <nl> - / / LOG_DEBUG ( log , " Commands for interpreter : " < < for_interpreter . size ( ) < < " commands for renames : " < < for_file_renames . size ( ) ) ; <nl> if ( ! for_interpreter . empty ( ) ) <nl> { <nl> interpreter . emplace ( storage_from_source_part , for_interpreter , context_for_reading , true ) ; <nl> in = interpreter - > execute ( table_lock_holder ) ; <nl> updated_header = interpreter - > getUpdatedHeader ( ) ; <nl> in - > setProgressCallback ( MergeProgressCallback ( merge_entry , watch_prev_elapsed , stage_progress ) ) ; <nl> - <nl> - / / LOG_DEBUG ( log , " Interpreter header : " < < in - > getHeader ( ) . dumpStructure ( ) ) ; <nl> } <nl> <nl> - / / LOG_DEBUG ( log , " Interpreter prepared " ) ; <nl> - <nl> auto new_data_part = data . createPart ( <nl> future_part . name , future_part . type , future_part . part_info , space_reservation - > getDisk ( ) , " tmp_mut_ " + future_part . name ) ; <nl> <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> <nl> IMergeTreeDataPart : : MinMaxIndex minmax_idx ; <nl> <nl> - / / LOG_WARNING ( log , " Starting to read columns with header : " < < updated_header . dumpStructure ( ) ) ; <nl> MergedBlockOutputStream out { <nl> new_data_part , <nl> new_data_part - > getColumns ( ) , <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> } <nl> <nl> <nl> - / / LOG_WARNING ( log , " Data read FINISHED " ) ; <nl> new_data_part - > partition . assign ( source_part - > partition ) ; <nl> new_data_part - > minmax_idx = std : : move ( minmax_idx ) ; <nl> <nl> in - > readSuffix ( ) ; <nl> out . writeSuffixAndFinalizePart ( new_data_part ) ; <nl> - <nl> - / / LOG_WARNING ( log , " SUFFIX WRITTEN " ) ; <nl> } <nl> else <nl> { <nl> MergeTreeData : : MutableDataPartPtr MergeTreeDataMergerMutator : : mutatePartToTempor <nl> for ( Poco : : DirectoryIterator dir_it ( source_part - > getFullPath ( ) ) ; dir_it ! = dir_end ; + + dir_it ) <nl> { <nl> if ( files_to_skip . count ( dir_it . name ( ) ) | | files_to_remove . count ( dir_it . name ( ) ) ) <nl> - { <nl> - / / LOG_DEBUG ( log , " Skipping file : " < < dir_it . path ( ) . toString ( ) ) ; <nl> continue ; <nl> - } <nl> <nl> Poco : : Path destination ( new_part_tmp_path ) ; <nl> destination . append ( dir_it . name ( ) ) ; <nl> <nl> - / / LOG_DEBUG ( log , " SRC : " < < dir_it . path ( ) . toString ( ) < < " DEST : " < < destination . toString ( ) ) ; <nl> - <nl> createHardLink ( dir_it . path ( ) . toString ( ) , destination . toString ( ) ) ; <nl> } <nl> <nl> mmm a / dbms / src / Storages / StorageMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageMergeTree . cpp <nl> void StorageMergeTree : : mutate ( const MutationCommands & commands , const Context & <nl> file_name = entry . file_name ; <nl> auto insertion = current_mutations_by_id . emplace ( file_name , std : : move ( entry ) ) ; <nl> current_mutations_by_version . emplace ( version , insertion . first - > second ) ; <nl> - LOG_DEBUG ( log , " CUrrent mutations by version size : " < < current_mutations_by_version . size ( ) ) ; <nl> } <nl> <nl> LOG_INFO ( log , " Added mutation : " < < file_name ) ; <nl> void StorageMergeTree : : mutate ( const MutationCommands & commands , const Context & <nl> std : : unique_lock lock ( mutation_wait_mutex ) ; <nl> mutation_wait_event . wait ( lock , check ) ; <nl> } <nl> - else <nl> - { <nl> - LOG_INFO ( log , " DONT WAIT FOR : " < < file_name < < " SYNC VER : " < < query_context . getSettingsRef ( ) . mutations_sync ) ; <nl> - } <nl> } <nl> <nl> namespace <nl> CancellationCode StorageMergeTree : : killMutation ( const String & mutation_id ) <nl> { <nl> to_kill . emplace ( std : : move ( it - > second ) ) ; <nl> current_mutations_by_id . erase ( it ) ; <nl> - LOG_DEBUG ( log , " REMOVING MUTATION BY VERSION " ) ; <nl> current_mutations_by_version . erase ( to_kill - > block_number ) ; <nl> } <nl> } <nl> BackgroundProcessingPoolTaskResult StorageMergeTree : : movePartsTask ( ) <nl> <nl> bool StorageMergeTree : : tryMutatePart ( ) <nl> { <nl> - / / LOG_DEBUG ( log , " Mutate part called " ) ; <nl> auto table_lock_holder = lockStructureForShare ( true , RWLockImpl : : NO_QUERY ) ; <nl> - / / LOG_DEBUG ( log , " Structure locked for share " ) ; <nl> size_t max_ast_elements = global_context . getSettingsRef ( ) . max_expanded_ast_elements ; <nl> - / / LOG_DEBUG ( log , " max ast elements received " ) ; <nl> <nl> FutureMergedMutatedPart future_part ; <nl> MutationCommands commands ; <nl> / / / You must call destructor with unlocked ` currently_processing_in_background_mutex ` . <nl> std : : optional < CurrentlyMergingPartsTagger > tagger ; <nl> { <nl> - / / LOG_DEBUG ( log , " Trying to get the lock " ) ; <nl> std : : lock_guard lock ( currently_processing_in_background_mutex ) ; <nl> <nl> if ( current_mutations_by_version . empty ( ) ) <nl> - { <nl> - / / LOG_DEBUG ( log , " Mutation by version empty " ) ; <nl> return false ; <nl> - } <nl> LOG_DEBUG ( log , " Looking at parts " ) ; <nl> <nl> auto mutations_end_it = current_mutations_by_version . end ( ) ; <nl> bool StorageMergeTree : : tryMutatePart ( ) <nl> commands . insert ( commands . end ( ) , it - > second . commands . begin ( ) , it - > second . commands . end ( ) ) ; <nl> } <nl> <nl> - LOG_DEBUG ( log , " TOtal commands size : " < < commands . size ( ) < < " for part : " < < part - > name ) ; <nl> auto new_part_info = part - > info ; <nl> new_part_info . mutation = current_mutations_by_version . rbegin ( ) - > first ; <nl> <nl> BackgroundProcessingPoolTaskResult StorageMergeTree : : mergeMutateTask ( ) <nl> / / / Clear old parts . It is unnecessary to do it more than once a second . <nl> if ( auto lock = time_after_previous_cleanup . compareAndRestartDeferred ( 1 ) ) <nl> { <nl> - / / LOG_DEBUG ( log , " LOCKING FOR SHARE " ) ; <nl> { <nl> / / / TODO : Implement tryLockStructureForShare . <nl> auto lock_structure = lockStructureForShare ( false , " " ) ; <nl> BackgroundProcessingPoolTaskResult StorageMergeTree : : mergeMutateTask ( ) <nl> clearOldTemporaryDirectories ( ) ; <nl> } <nl> <nl> - / / LOG_DEBUG ( log , " CLEARING OLD mUTATIONS " ) ; <nl> clearOldMutations ( ) ; <nl> } <nl> <nl> - / / LOG_DEBUG ( log , " Trying to merge " ) ; <nl> / / / TODO : read deduplicate option from table config <nl> if ( merge ( false / * aggressive * / , { } / * partition_id * / , false / * final * / , false / * deduplicate * / ) ) <nl> - { <nl> - / / LOG_DEBUG ( log , " SUccessfuly merged " ) ; <nl> return BackgroundProcessingPoolTaskResult : : SUCCESS ; <nl> - } <nl> <nl> <nl> - / / LOG_DEBUG ( log , " Trying to mutate " ) ; <nl> if ( tryMutatePart ( ) ) <nl> - { <nl> - / / LOG_DEBUG ( log , " SUccessfuly mutated " ) ; <nl> return BackgroundProcessingPoolTaskResult : : SUCCESS ; <nl> - } <nl> <nl> - / / LOG_DEBUG ( log , " Got error " ) ; <nl> return BackgroundProcessingPoolTaskResult : : ERROR ; <nl> } <nl> catch ( const Exception & e ) <nl> void StorageMergeTree : : clearOldMutations ( bool truncate ) <nl> { <nl> mutations_to_delete . push_back ( std : : move ( it - > second ) ) ; <nl> current_mutations_by_id . erase ( mutations_to_delete . back ( ) . file_name ) ; <nl> - LOG_DEBUG ( log , " ERASING OLD MUTATION " ) ; <nl> it = current_mutations_by_version . erase ( it ) ; <nl> } <nl> } <nl>
|
Remove garbage
|
ClickHouse/ClickHouse
|
13a0151cf391d2fed594b6a76991704b3d8bfda3
|
2020-03-18T09:34:05Z
|
mmm a / tensorflow / compiler / xla / tools / BUILD <nl> ppp b / tensorflow / compiler / xla / tools / BUILD <nl> tf_cc_binary ( <nl> # To run with MLIR GPU plugin enabled , pass - - define = with_mlir_gpu_support = true . <nl> tf_cc_binary ( <nl> name = " replay_computation_gpu " , <nl> + tags = [ " gpu " ] , <nl> deps = [ <nl> " : replay_computation_library " , <nl> " / / tensorflow / compiler / xla / service : gpu_plugin " , <nl>
|
Add gpu tag to replay_computation_gpu .
|
tensorflow/tensorflow
|
11bed638b14898cdde967f6b108e45732aa4798a
|
2020-01-22T11:26:20Z
|
mmm a / src / memory / Table . c <nl> ppp b / src / memory / Table . c <nl> void swTable_iterator_forward ( swTable * table ) <nl> int i = 0 ; <nl> for ( ; ; i + + ) <nl> { <nl> + if ( row = = NULL ) <nl> + { <nl> + table - > iterator - > collision_index = 0 ; <nl> + break ; <nl> + } <nl> if ( i = = table - > iterator - > collision_index ) <nl> { <nl> - if ( row = = NULL ) <nl> - { <nl> - table - > iterator - > collision_index = 0 ; <nl> - break ; <nl> - } <nl> - else <nl> - { <nl> - table - > iterator - > collision_index + + ; <nl> - table - > iterator - > row = row ; <nl> - return ; <nl> - } <nl> + table - > iterator - > collision_index + + ; <nl> + table - > iterator - > row = row ; <nl> + return ; <nl> } <nl> row = row - > next ; <nl> } <nl>
|
fixed
|
swoole/swoole-src
|
f0e739f7e3a0018ce5920434ad13cec1dbeed30a
|
2016-12-26T07:01:29Z
|
mmm a / contrib / verify - commits / gpg . sh <nl> ppp b / contrib / verify - commits / gpg . sh <nl> <nl> # ! / bin / sh <nl> - INPUT = $ ( < / dev / stdin ) <nl> + INPUT = $ ( cat / dev / stdin ) <nl> VALID = false <nl> REVSIG = false <nl> - IFS = $ ' \ n ' <nl> + IFS = ' <nl> + ' <nl> for LINE in $ ( echo " $ INPUT " | gpg - - trust - model always " $ @ " 2 > / dev / null ) ; do <nl> case " $ LINE " in <nl> " [ GNUPG : ] VALIDSIG " * ) <nl> for LINE in $ ( echo " $ INPUT " | gpg - - trust - model always " $ @ " 2 > / dev / null ) ; do <nl> " [ GNUPG : ] REVKEYSIG " * ) <nl> [ " $ BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG " ! = 1 ] & & exit 1 <nl> while read KEY ; do <nl> - case " $ LINE " in " [ GNUPG : ] REVKEYSIG $ { KEY : 24 : 40 } " * ) <nl> + case " $ LINE " in " [ GNUPG : ] REVKEYSIG $ { KEY # ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } " * ) <nl> REVSIG = true <nl> - GOODREVSIG = " [ GNUPG : ] GOODSIG $ { KEY : 24 : 40 } " <nl> - ; ; <nl> + GOODREVSIG = " [ GNUPG : ] GOODSIG $ { KEY # ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } " <nl> esac <nl> done < . / contrib / verify - commits / trusted - keys <nl> ; ; <nl> mmm a / contrib / verify - commits / verify - commits . sh <nl> ppp b / contrib / verify - commits / verify - commits . sh <nl> <nl> # ! / bin / sh <nl> + # Not technically POSIX - compliant due to use of " local " , but almost every <nl> + # shell anyone uses today supports it , so its probably fine <nl> <nl> DIR = $ ( dirname " $ 0 " ) <nl> <nl> echo " Please verify all commits in the following list are not evil : " <nl> git log " $ DIR " <nl> <nl> VERIFIED_ROOT = $ ( cat " $ { DIR } / trusted - git - root " ) <nl> - <nl> - IS_REVSIG_ALLOWED ( ) { <nl> - while read LINE ; do <nl> - [ " $ LINE " = " $ 1 " ] & & return 0 <nl> - done < " $ { DIR } / allow - revsig - commits " <nl> - return 1 <nl> - } <nl> + REVSIG_ALLOWED = $ ( cat " $ { DIR } / allow - revsig - commits " ) <nl> <nl> HAVE_FAILED = false <nl> IS_SIGNED ( ) { <nl> if [ $ 1 = $ VERIFIED_ROOT ] ; then <nl> return 0 ; <nl> fi <nl> - if IS_REVSIG_ALLOWED " $ 1 " ; then <nl> + if [ " $ { REVSIG_ALLOWED # * $ 1 } " ! = " $ REVSIG_ALLOWED " ] ; then <nl> export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG = 1 <nl> else <nl> export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG = 0 <nl> IS_SIGNED ( ) { <nl> if ! git - c " gpg . program = $ { DIR } / gpg . sh " verify - commit $ 1 > / dev / null 2 > & 1 ; then <nl> return 1 ; <nl> fi <nl> - local PARENTS = $ ( git show - s - - format = format : % P $ 1 ) <nl> + local PARENTS <nl> + PARENTS = $ ( git show - s - - format = format : % P $ 1 ) <nl> for PARENT in $ PARENTS ; do <nl> if IS_SIGNED $ PARENT > / dev / null ; then <nl> return 0 ; <nl>
|
Make verify - commits POSIX - compliant
|
bitcoin/bitcoin
|
f7d4a25fe6b1bd52e70fa0779d1cd145f32bd2ab
|
2016-05-21T09:26:06Z
|
mmm a / . github / mergeable . yml <nl> ppp b / . github / mergeable . yml <nl> mergeable : <nl> pull_requests : <nl> label : <nl> must_include : <nl> - regex : ` release notes : yes | release notes : no ` <nl> - message : ` Add release notes yes / no label . For yes , add lang label ` <nl> + regex : " release notes : yes | release notes : no " <nl> + message : " Add release notes yes / no label . For yes , add lang label " <nl>
|
fix space
|
grpc/grpc
|
ad2c5bee5859e790cd0707867dc12539cc2fbb00
|
2018-07-26T20:02:47Z
|
mmm a / fdbclient / DatabaseContext . h <nl> ppp b / fdbclient / DatabaseContext . h <nl> class DatabaseContext : public ReferenceCounted < DatabaseContext > , NonCopyable { <nl> <nl> Reference < ProxyInfo > getMasterProxies ( ) ; <nl> Future < Reference < ProxyInfo > > getMasterProxiesFuture ( ) ; <nl> - Future < Reference < ProxyInfo > > getMasterProxiesOrNever ( ) ; <nl> Future < Void > onMasterProxiesChanged ( ) ; <nl> <nl> / / Update the watch counter for the database <nl> mmm a / fdbclient / NativeAPI . actor . cpp <nl> ppp b / fdbclient / NativeAPI . actor . cpp <nl> Reference < ProxyInfo > DatabaseContext : : getMasterProxies ( ) { <nl> return masterProxies ; <nl> } <nl> <nl> - / / Gets the master proxies if available . If the ProxyInfo Reference is NULL , then return Never <nl> - Future < Reference < ProxyInfo > > DatabaseContext : : getMasterProxiesOrNever ( ) { <nl> - Reference < ProxyInfo > info = getMasterProxies ( ) ; <nl> - if ( ! info ) <nl> - return Never ( ) ; <nl> - else <nl> - return info ; <nl> - } <nl> - <nl> / / Actor which will wait until the ProxyInfo returned by the DatabaseContext cx is not NULL <nl> - ACTOR Future < Reference < ProxyInfo > > getMasterProxiesFuture ( DatabaseContext * cx ) { <nl> - state Reference < ProxyInfo > proxyInfo ; <nl> - loop { <nl> - choose { <nl> - when ( Void _ = wait ( cx - > onMasterProxiesChanged ( ) ) ) { } <nl> - when ( Reference < ProxyInfo > info = wait ( cx - > getMasterProxiesOrNever ( ) ) ) { <nl> - return info ; <nl> - } <nl> - } <nl> + ACTOR Future < Reference < ProxyInfo > > getMasterProxiesFuture ( DatabaseContext * cx ) { <nl> + loop { <nl> + Reference < ProxyInfo > proxies = cx - > getMasterProxies ( ) ; <nl> + if ( proxies ) <nl> + return proxies ; <nl> + Void _ = wait ( cx - > onMasterProxiesChanged ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / fdbserver / workloads / ConsistencyCheck . actor . cpp <nl> ppp b / fdbserver / workloads / ConsistencyCheck . actor . cpp <nl> struct ConsistencyCheckWorkload : TestWorkload <nl> } <nl> <nl> / / Get a list of key servers ; verify that the TLogs and master all agree about who the key servers are <nl> - state Promise < vector < pair < KeyRangeRef , vector < StorageServerInterface > > > > keyServerPromise ; <nl> + state Promise < vector < pair < KeyRange , vector < StorageServerInterface > > > > keyServerPromise ; <nl> bool keyServerResult = wait ( self - > getKeyServers ( cx , self , keyServerPromise ) ) ; <nl> if ( keyServerResult ) <nl> { <nl> - state vector < pair < KeyRangeRef , vector < StorageServerInterface > > > keyServers = keyServerPromise . getFuture ( ) . get ( ) ; <nl> + state vector < pair < KeyRange , vector < StorageServerInterface > > > keyServers = keyServerPromise . getFuture ( ) . get ( ) ; <nl> <nl> / / Get the locations of all the shards in the database <nl> state Promise < Standalone < VectorRef < KeyValueRef > > > keyLocationPromise ; <nl> struct ConsistencyCheckWorkload : TestWorkload <nl> / / Get a list of storage servers from the master and compares them with the TLogs . <nl> / / If this is a quiescent check , then each master proxy needs to respond , otherwise only one needs to respond . <nl> / / Returns false if there is a failure ( in this case , keyServersPromise will never be set ) <nl> - ACTOR Future < bool > getKeyServers ( Database cx , ConsistencyCheckWorkload * self , Promise < vector < pair < KeyRangeRef , vector < StorageServerInterface > > > > keyServersPromise ) <nl> + ACTOR Future < bool > getKeyServers ( Database cx , ConsistencyCheckWorkload * self , Promise < vector < pair < KeyRange , vector < StorageServerInterface > > > > keyServersPromise ) <nl> { <nl> - state vector < pair < KeyRangeRef , vector < StorageServerInterface > > > keyServers ; <nl> + state vector < pair < KeyRange , vector < StorageServerInterface > > > keyServers ; <nl> <nl> - loop <nl> - { <nl> - state Reference < ProxyInfo > proxyInfo = wait ( cx - > getMasterProxiesFuture ( ) ) ; <nl> + / / Try getting key server locations from the master proxies <nl> + state vector < Future < ErrorOr < GetKeyServerLocationsReply > > > keyServerLocationFutures ; <nl> + state Key begin = keyServersKeys . begin ; <nl> + state Key end = keyServersKeys . end ; <nl> + state int limitKeyServers = BUGGIFY ? 1 : 100 ; <nl> <nl> - / / Try getting key server locations from the master proxies <nl> - state vector < Future < ErrorOr < GetKeyServerLocationsReply > > > keyServerLocationFutures ; <nl> - state KeyRange keyServerRange = keyServersKeys ; <nl> - for ( int i = 0 ; i < proxyInfo - > size ( ) ; i + + ) <nl> - keyServerLocationFutures . push_back ( proxyInfo - > get ( i , & MasterProxyInterface : : getKeyServersLocations ) . getReplyUnlessFailedFor ( GetKeyServerLocationsRequest ( keyServerRange . begin , keyServerRange . end , 1000 , false , keyServerRange . arena ( ) ) , 2 , 0 ) ) ; <nl> + while ( begin < end ) { <nl> + state Reference < ProxyInfo > proxyInfo = wait ( cx - > getMasterProxiesFuture ( ) ) ; <nl> + keyServerLocationFutures . clear ( ) ; <nl> + for ( int i = 0 ; i < proxyInfo - > size ( ) ; i + + ) <nl> + keyServerLocationFutures . push_back ( proxyInfo - > get ( i , & MasterProxyInterface : : getKeyServersLocations ) . getReplyUnlessFailedFor ( GetKeyServerLocationsRequest ( begin , end , limitKeyServers , false , Arena ( ) ) , 2 , 0 ) ) ; <nl> <nl> + state bool keyServersInsertedForThisIteration = false ; <nl> choose { <nl> - when ( Void _ = wait ( waitForAll ( keyServerLocationFutures ) ) ) { <nl> - <nl> + when ( Void _ = wait ( waitForAll ( keyServerLocationFutures ) ) ) { <nl> / / Read the key server location results <nl> - state bool successful = true ; <nl> - for ( int i = 0 ; i < keyServerLocationFutures . size ( ) ; i + + ) <nl> + for ( int i = 0 ; i < keyServerLocationFutures . size ( ) ; i + + ) <nl> { <nl> ErrorOr < GetKeyServerLocationsReply > shards = keyServerLocationFutures [ i ] . get ( ) ; <nl> <nl> / / If performing quiescent check , then all master proxies should be reachable . Otherwise , only one needs to be reachable <nl> - if ( self - > performQuiescentChecks & & ! shards . present ( ) ) <nl> + if ( self - > performQuiescentChecks & & ! shards . present ( ) ) <nl> { <nl> TraceEvent ( " ConsistencyCheck_MasterProxyUnavailable " ) . detail ( " MasterProxyID " , proxyInfo - > getId ( i ) ) ; <nl> self - > testFailure ( " Master proxy unavailable " ) ; <nl> struct ConsistencyCheckWorkload : TestWorkload <nl> <nl> / / Get the list of shards if one was returned . If not doing a quiescent check , we can break if it is . <nl> / / If we are doing a quiescent check , then we only need to do this for the first shard . <nl> - if ( shards . present ( ) & & ( i = = 0 | | ! self - > performQuiescentChecks ) ) <nl> - { <nl> - keyServers = shards . get ( ) . results ; <nl> - if ( ! self - > performQuiescentChecks ) <nl> - break ; <nl> - } <nl> - <nl> - / / If none of the master proxies responded , then we will have to try again <nl> - else if ( i = = keyServerLocationFutures . size ( ) - 1 & & ! self - > performQuiescentChecks ) <nl> + if ( shards . present ( ) & & ! keyServersInsertedForThisIteration ) <nl> { <nl> - TraceEvent ( " ConsistencyCheck_NoMasterProxiesAvailable " ) ; <nl> + keyServers . insert ( keyServers . end ( ) , shards . get ( ) . results . begin ( ) , shards . get ( ) . results . end ( ) ) ; <nl> + keyServersInsertedForThisIteration = true ; <nl> + begin = shards . get ( ) . results . back ( ) . first . end ; <nl> <nl> - / / Retry ( continues outer loop ) <nl> - successful = false ; <nl> + if ( ! self - > performQuiescentChecks ) <nl> + break ; <nl> } <nl> - } <nl> - <nl> - / / If master proxy check and tlog check were successful <nl> - if ( successful ) <nl> - break ; <nl> + } / / End of For <nl> + } <nl> + when ( Void _ = wait ( cx - > onMasterProxiesChanged ( ) ) ) { } <nl> + } / / End of choose <nl> + <nl> + if ( ! keyServersInsertedForThisIteration ) / / Retry the entire workflow <nl> + Void _ = wait ( delay ( 1 . 0 ) ) ; <nl> <nl> - Void _ = wait ( delay ( 1 . 0 ) ) ; <nl> - } when ( Void _ = wait ( cx - > onMasterProxiesChanged ( ) ) ) { } <nl> - } <nl> - } <nl> + } / / End of while <nl> <nl> keyServersPromise . send ( keyServers ) ; <nl> return true ; <nl> struct ConsistencyCheckWorkload : TestWorkload <nl> <nl> / / Retrieves the locations of all shards in the database <nl> / / Returns false if there is a failure ( in this case , keyLocationPromise will never be set ) <nl> - ACTOR Future < bool > getKeyLocations ( Database cx , vector < pair < KeyRangeRef , vector < StorageServerInterface > > > shards , ConsistencyCheckWorkload * self , Promise < Standalone < VectorRef < KeyValueRef > > > keyLocationPromise ) <nl> + ACTOR Future < bool > getKeyLocations ( Database cx , vector < pair < KeyRange , vector < StorageServerInterface > > > shards , ConsistencyCheckWorkload * self , Promise < Standalone < VectorRef < KeyValueRef > > > keyLocationPromise ) <nl> { <nl> state Standalone < VectorRef < KeyValueRef > > keyLocations ; <nl> state Key beginKey = allKeys . begin ; <nl>
|
Merge pull request from etschannen / release - 5 . 1
|
apple/foundationdb
|
e6969741f21eb18b94cfda54e367b46b451a262f
|
2018-03-08T19:46:30Z
|
mmm a / cocos / base / CCEventDispatcher . cpp <nl> ppp b / cocos / base / CCEventDispatcher . cpp <nl> void EventDispatcher : : dispatchCustomEvent ( const std : : string & eventName , void * op <nl> dispatchEvent ( & ev ) ; <nl> } <nl> <nl> + bool EventDispatcher : : hasEventListener ( const EventListener : : ListenerID & listenerID ) const <nl> + { <nl> + return getListeners ( listenerID ) ! = nullptr ; <nl> + } <nl> <nl> void EventDispatcher : : dispatchTouchEvent ( EventTouch * event ) <nl> { <nl> void EventDispatcher : : sortEventListenersOfFixedPriority ( const EventListener : : Lis <nl> <nl> } <nl> <nl> - EventDispatcher : : EventListenerVector * EventDispatcher : : getListeners ( const EventListener : : ListenerID & listenerID ) <nl> + EventDispatcher : : EventListenerVector * EventDispatcher : : getListeners ( const EventListener : : ListenerID & listenerID ) const <nl> { <nl> auto iter = _listenerMap . find ( listenerID ) ; <nl> if ( iter ! = _listenerMap . end ( ) ) <nl> mmm a / cocos / base / CCEventDispatcher . h <nl> ppp b / cocos / base / CCEventDispatcher . h <nl> class CC_DLL EventDispatcher : public Ref <nl> * / <nl> void dispatchCustomEvent ( const std : : string & eventName , void * optionalUserData = nullptr ) ; <nl> <nl> + / * * Query whether the specified event listener id has been added . <nl> + * <nl> + * @ param listenerID The listenerID of the event listener id . <nl> + * <nl> + * @ return True if dispatching events is exist <nl> + * / <nl> + bool hasEventListener ( const EventListener : : ListenerID & listenerID ) const ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> / * * Constructor of EventDispatcher . <nl> class CC_DLL EventDispatcher : public Ref <nl> void forceAddEventListener ( EventListener * listener ) ; <nl> <nl> / * * Gets event the listener list for the event listener type . * / <nl> - EventListenerVector * getListeners ( const EventListener : : ListenerID & listenerID ) ; <nl> + EventListenerVector * getListeners ( const EventListener : : ListenerID & listenerID ) const ; <nl> <nl> / * * Update dirty flag * / <nl> void updateDirtyFlagForSceneGraph ( ) ; <nl> mmm a / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> ScriptingCore : : ScriptingCore ( ) <nl> , _global ( nullptr ) <nl> , _debugGlobal ( nullptr ) <nl> , _callFromScript ( false ) <nl> + , _finalizing ( nullptr ) <nl> { <nl> / / set utf8 strings internally ( we don ' t need utf16 ) <nl> / / XXX : Removed in SpiderMonkey 19 . 0 <nl> js_proxy_t * jsb_new_proxy ( void * nativeObj , JS : : HandleObject jsHandle ) <nl> / / The current solution keep the game running with a warning because it may cause memory leak as the native object may have been retained . <nl> auto existJSProxy = _js_native_global_map . find ( jsObj ) ; <nl> if ( existJSProxy ! = _js_native_global_map . end ( ) ) { <nl> - # if COCOS2D_DEBUG <nl> + # if COCOS2D_DEBUG > 1 <nl> CCLOG ( " jsbindings : Failed to remove proxy for native object : % p , force removing it , but it may cause memory leak " , existJSProxy - > second - > ptr ) ; <nl> # endif <nl> jsb_remove_proxy ( existJSProxy - > second ) ; <nl> mmm a / cocos / scripting / js - bindings / manual / ScriptingCore . h <nl> ppp b / cocos / scripting / js - bindings / manual / ScriptingCore . h <nl> class CC_JS_DLL ScriptingCore : public cocos2d : : ScriptEngineProtocol <nl> SimpleRunLoop * _runLoop ; <nl> bool _jsInited ; <nl> bool _needCleanup ; <nl> - <nl> bool _callFromScript ; <nl> + JSObject * _finalizing ; <nl> + <nl> ScriptingCore ( ) ; <nl> <nl> std : : chrono : : steady_clock : : time_point _engineStartTime ; <nl> class CC_JS_DLL ScriptingCore : public cocos2d : : ScriptEngineProtocol <nl> * / <nl> virtual void garbageCollect ( ) override ; <nl> <nl> + / * * <nl> + * Sets the js object that is being finalizing in the script engine , internal use only , please do not call this function <nl> + * / <nl> + void setFinalizing ( JSObject * finalizing ) { _finalizing = finalizing ; } ; <nl> + <nl> + / * * <nl> + * Gets the js object that is being finalizing in the script engine <nl> + * / <nl> + JSObject * getFinalizing ( ) { return _finalizing ; } ; <nl> + <nl> private : <nl> void string_report ( JS : : HandleValue val ) ; <nl> void initRegister ( ) ; <nl> mmm a / cocos / scripting / js - bindings / manual / cocos2d_specifics . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / cocos2d_specifics . cpp <nl> jsval anonEvaluate ( JSContext * cx , JS : : HandleObject thisObj , const char * string ) <nl> <nl> void js_add_object_reference ( JS : : HandleValue owner , JS : : HandleValue target ) <nl> { <nl> - if ( target . isPrimitive ( ) ) <nl> + if ( ! owner . isObject ( ) | | ! target . isObject ( ) ) <nl> { <nl> return ; <nl> } <nl> void js_add_object_reference ( JS : : HandleValue owner , JS : : HandleValue target ) <nl> } <nl> void js_remove_object_reference ( JS : : HandleValue owner , JS : : HandleValue target ) <nl> { <nl> - if ( target . isPrimitive ( ) ) <nl> + if ( ! owner . isObject ( ) | | ! target . isObject ( ) ) <nl> { <nl> return ; <nl> } <nl> void JSScheduleWrapper : : dump ( ) <nl> schedTarget_proxy_t * current , * tmp ; <nl> int nativeTargetsCount = 0 ; <nl> HASH_ITER ( hh , _schedObj_target_ht , current , tmp ) { <nl> - Ref * pObj = nullptr ; <nl> - CCARRAY_FOREACH ( current - > targets , pObj ) <nl> + auto targets = current - > targets ; <nl> + for ( const auto & pObj : * targets ) <nl> { <nl> CCLOG ( " js target ( % p ) , native target [ % d ] = ( % p ) " , current - > jsTargetObj , nativeTargetsCount , pObj ) ; <nl> nativeTargetsCount + + ; <nl> void JSScheduleWrapper : : dump ( ) <nl> schedFunc_proxy_t * current_func , * tmp_func ; <nl> int jsfuncTargetCount = 0 ; <nl> HASH_ITER ( hh , _schedFunc_target_ht , current_func , tmp_func ) { <nl> - Ref * pObj = nullptr ; <nl> - CCARRAY_FOREACH ( current_func - > targets , pObj ) <nl> + auto targets = current - > targets ; <nl> + for ( const auto & pObj : * targets ) <nl> { <nl> CCLOG ( " js func ( % p ) , native target [ % d ] = ( % p ) " , current_func - > jsfuncObj , jsfuncTargetCount , pObj ) ; <nl> jsfuncTargetCount + + ; <nl> bool js_CCNode_unschedule ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> <nl> auto targetArray = JSScheduleWrapper : : getTargetForSchedule ( args . get ( 0 ) ) ; <nl> if ( targetArray ) { <nl> - CCLOGINFO ( " unschedule target number : % d " , targetArray - > count ( ) ) ; <nl> + CCLOGINFO ( " unschedule target number : % ld " , static_cast < long > ( targetArray - > count ( ) ) ) ; <nl> <nl> for ( const auto & tmp : * targetArray ) <nl> { <nl> static bool jsb_FinalizeHook_constructor ( JSContext * cx , uint32_t argc , jsval * vp <nl> } <nl> void jsb_FinalizeHook_finalize ( JSFreeOp * fop , JSObject * obj ) <nl> { <nl> - JSContext * cx = ScriptingCore : : getInstance ( ) - > getGlobalContext ( ) ; <nl> + ScriptingCore * sc = ScriptingCore : : getInstance ( ) ; <nl> + JSContext * cx = sc - > getGlobalContext ( ) ; <nl> JS : : RootedObject jsobj ( cx , obj ) ; <nl> JSObject * ownerPtr = jsb_get_and_remove_hook_owner ( obj ) ; <nl> if ( ownerPtr ) <nl> void jsb_FinalizeHook_finalize ( JSFreeOp * fop , JSObject * obj ) <nl> jsproxy = jsb_get_js_proxy ( owner ) ; <nl> if ( jsproxy ) <nl> { <nl> + sc - > setFinalizing ( ownerPtr ) ; <nl> + <nl> cocos2d : : Ref * refObj = static_cast < cocos2d : : Ref * > ( jsproxy - > ptr ) ; <nl> nproxy = jsb_get_native_proxy ( jsproxy - > ptr ) ; <nl> jsb_remove_proxy ( nproxy , jsproxy ) ; <nl> void jsb_FinalizeHook_finalize ( JSFreeOp * fop , JSObject * obj ) <nl> CCLOG ( " A non ref object have registered finalize hook : % p " , nproxy - > ptr ) ; <nl> } <nl> # endif / / COCOS2D_DEBUG <nl> + sc - > setFinalizing ( nullptr ) ; <nl> } <nl> # if COCOS2D_DEBUG > 1 <nl> else { <nl> void register_cocos2dx_js_core ( JSContext * cx , JS : : HandleObject global ) <nl> JS_DefineFunction ( cx , tmpObj , " getDataFromFile " , js_cocos2dx_CCFileUtils_getDataFromFile , 1 , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> JS_DefineFunction ( cx , tmpObj , " writeDataToFile " , js_cocos2dx_CCFileUtils_writeDataToFile , 2 , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> <nl> + tmpObj . set ( jsb_cocos2d_EventDispatcher_prototype ) ; <nl> + JS_DefineFunction ( cx , tmpObj , " addCustomListener " , js_EventDispatcher_addCustomEventListener , 2 , JSPROP_PERMANENT | JSPROP_ENUMERATE ) ; <nl> + <nl> JS_GetProperty ( cx , ccObj , " EventListenerTouchOneByOne " , & tmpVal ) ; <nl> tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> JS_DefineFunction ( cx , tmpObj , " create " , js_EventListenerTouchOneByOne_create , 0 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> void register_cocos2dx_js_core ( JSContext * cx , JS : : HandleObject global ) <nl> tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> JS_DefineFunction ( cx , tmpObj , " create " , js_EventListenerKeyboard_create , 0 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> <nl> + JS_GetProperty ( cx , ccObj , " EventListenerAcceleration " , & tmpVal ) ; <nl> + tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> + JS_DefineFunction ( cx , tmpObj , " create " , js_EventListenerAcceleration_create , 1 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> + <nl> JS_GetProperty ( cx , ccObj , " EventListenerFocus " , & tmpVal ) ; <nl> tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> JS_DefineFunction ( cx , tmpObj , " create " , js_EventListenerFocus_create , 0 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> <nl> + JS_GetProperty ( cx , ccObj , " EventListenerCustom " , & tmpVal ) ; <nl> + tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> + JS_DefineFunction ( cx , tmpObj , " create " , js_EventListenerCustom_create , 2 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> + <nl> JS_GetProperty ( cx , ccObj , " BezierBy " , & tmpVal ) ; <nl> tmpObj = tmpVal . toObjectOrNull ( ) ; <nl> JS_DefineFunction ( cx , tmpObj , " create " , JSB_CCBezierBy_actionWithDuration , 2 , JSPROP_READONLY | JSPROP_PERMANENT ) ; <nl> mmm a / cocos / scripting / js - bindings / manual / js_manual_conversions . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / js_manual_conversions . cpp <nl> JSFunctionWrapper : : ~ JSFunctionWrapper ( ) <nl> { <nl> JS : : RootedValue ownerVal ( _cx , _owner ) ; <nl> <nl> - if ( ! ownerVal . isNullOrUndefined ( ) ) <nl> + if ( ! ownerVal . isNullOrUndefined ( ) & & ScriptingCore : : getInstance ( ) - > getFinalizing ( ) ! = ownerVal . toObjectOrNull ( ) ) <nl> { <nl> JS : : RootedValue thisVal ( _cx , OBJECT_TO_JSVAL ( _jsthis ) ) ; <nl> if ( ! thisVal . isNullOrUndefined ( ) ) <nl> mmm a / cocos / scripting / js - bindings / manual / jsb_event_dispatcher_manual . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / jsb_event_dispatcher_manual . cpp <nl> <nl> <nl> # include " scripting / js - bindings / manual / jsb_event_dispatcher_manual . h " <nl> <nl> + # include " base / CCEventDispatcher . h " <nl> # include " base / CCEventListenerFocus . h " <nl> # include " base / CCEventListenerKeyboard . h " <nl> # include " base / CCEventListenerMouse . h " <nl> + # include " base / CCEventListenerAcceleration . h " <nl> + # include " base / CCEventListenerCustom . h " <nl> + # include " base / CCEvent . h " <nl> + # include " base / CCEventCustom . h " <nl> # include " scripting / js - bindings / manual / ScriptingCore . h " <nl> # include " scripting / js - bindings / manual / cocos2d_specifics . hpp " <nl> <nl> bool js_EventListenerTouchOneByOne_create ( JSContext * cx , uint32_t argc , jsval * v <nl> ScriptingCore : : getInstance ( ) - > handleTouchEvent ( ret , EventTouch : : EventCode : : CANCELLED , touch , event ) ; <nl> } ; <nl> <nl> - jsval jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerTouchOneByOne > ( cx , ret ) ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerTouchOneByOne > ( cx , ret ) ) ) ; <nl> args . rval ( ) . set ( jsret ) ; <nl> return true ; <nl> } <nl> bool js_EventListenerTouchAllAtOnce_create ( JSContext * cx , uint32_t argc , jsval * <nl> ScriptingCore : : getInstance ( ) - > handleTouchesEvent ( ret , EventTouch : : EventCode : : CANCELLED , touches , event ) ; <nl> } ; <nl> <nl> - jsval jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerTouchAllAtOnce > ( cx , ret ) ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerTouchAllAtOnce > ( cx , ret ) ) ) ; <nl> args . rval ( ) . set ( jsret ) ; <nl> return true ; <nl> } <nl> bool js_EventListenerMouse_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> ScriptingCore : : getInstance ( ) - > handleMouseEvent ( ret , EventMouse : : MouseEventType : : MOUSE_SCROLL , event ) ; <nl> } ; <nl> <nl> - jsval jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerMouse > ( cx , ret ) ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerMouse > ( cx , ret ) ) ) ; <nl> args . rval ( ) . set ( jsret ) ; <nl> return true ; <nl> } <nl> bool js_EventListenerKeyboard_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> ScriptingCore : : getInstance ( ) - > handleKeyboardEvent ( ret , keyCode , false , event ) ; <nl> } ; <nl> <nl> - jsval jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerKeyboard > ( cx , ret ) ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerKeyboard > ( cx , ret ) ) ) ; <nl> args . rval ( ) . set ( jsret ) ; <nl> return true ; <nl> } <nl> bool js_EventListenerKeyboard_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> return false ; <nl> } <nl> <nl> + bool js_EventListenerAcceleration_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> + { <nl> + JS : : CallArgs args = JS : : CallArgsFromVp ( argc , vp ) ; <nl> + bool ok = true ; <nl> + if ( argc = = 1 ) { <nl> + std : : function < void ( Acceleration * , Event * ) > arg0 ; <nl> + do { <nl> + if ( JS_TypeOfValue ( cx , args . get ( 0 ) ) = = JSTYPE_FUNCTION ) <nl> + { <nl> + JS : : RootedObject jstarget ( cx , args . thisv ( ) . toObjectOrNull ( ) ) ; <nl> + std : : shared_ptr < JSFunctionWrapper > func ( new JSFunctionWrapper ( cx , jstarget , args . get ( 0 ) , args . thisv ( ) ) ) ; <nl> + auto lambda = [ = ] ( Acceleration * acc , Event * event ) - > void { <nl> + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> + jsval largv [ 2 ] ; <nl> + largv [ 0 ] = ccacceleration_to_jsval ( cx , * acc ) ; <nl> + if ( event ) { <nl> + js_type_class_t * typeClassEvent = js_get_type_from_native < Event > ( event ) ; <nl> + largv [ 1 ] = OBJECT_TO_JSVAL ( jsb_get_or_create_weak_jsobject ( cx , event , typeClassEvent , " cocos2d : : EventAcceleration " ) ) ; <nl> + } else { <nl> + largv [ 1 ] = JSVAL_NULL ; <nl> + } ; <nl> + JS : : RootedValue rval ( cx ) ; <nl> + bool succeed = func - > invoke ( 2 , & largv [ 0 ] , & rval ) ; <nl> + if ( ! succeed & & JS_IsExceptionPending ( cx ) ) { <nl> + JS_ReportPendingException ( cx ) ; <nl> + } <nl> + removeJSObject ( cx , event ) ; <nl> + } ; <nl> + arg0 = lambda ; <nl> + } <nl> + else <nl> + { <nl> + arg0 = nullptr ; <nl> + } <nl> + } while ( 0 ) ; <nl> + JSB_PRECONDITION2 ( ok , cx , false , " js_cocos2dx_EventListenerAcceleration_create : Error processing arguments " ) ; <nl> + <nl> + auto ret = EventListenerAcceleration : : create ( arg0 ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerAcceleration > ( cx , ret ) ) ) ; <nl> + args . rval ( ) . set ( jsret ) ; <nl> + return true ; <nl> + } <nl> + JS_ReportError ( cx , " js_cocos2dx_EventListenerAcceleration_create : wrong number of arguments " ) ; <nl> + return false ; <nl> + } <nl> + <nl> bool js_EventListenerFocus_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> { <nl> if ( argc = = 0 ) <nl> bool js_EventListenerFocus_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> ScriptingCore : : getInstance ( ) - > handleFocusEvent ( ret , widgetLoseFocus , widgetGetFocus ) ; <nl> } ; <nl> <nl> - jsval jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerFocus > ( cx , ret ) ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerFocus > ( cx , ret ) ) ) ; <nl> <nl> JS : : CallArgs args = JS : : CallArgsFromVp ( argc , vp ) ; <nl> args . rval ( ) . set ( jsret ) ; <nl> bool js_EventListenerFocus_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> JS_ReportError ( cx , " wrong number of arguments : % d , was expecting % d " , argc , 0 ) ; <nl> return false ; <nl> } <nl> + <nl> + bool js_EventListenerCustom_create ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> + { <nl> + JS : : CallArgs args = JS : : CallArgsFromVp ( argc , vp ) ; <nl> + bool ok = true ; <nl> + if ( argc = = 2 ) { <nl> + std : : string arg0 ; <nl> + std : : function < void ( cocos2d : : EventCustom * ) > arg1 ; <nl> + ok & = jsval_to_std_string ( cx , args . get ( 0 ) , & arg0 ) ; <nl> + do { <nl> + if ( JS_TypeOfValue ( cx , args . get ( 1 ) ) = = JSTYPE_FUNCTION ) <nl> + { <nl> + JS : : RootedObject jstarget ( cx , args . thisv ( ) . toObjectOrNull ( ) ) ; <nl> + std : : shared_ptr < JSFunctionWrapper > func ( new JSFunctionWrapper ( cx , jstarget , args . get ( 1 ) , args . thisv ( ) ) ) ; <nl> + auto lambda = [ = ] ( EventCustom * event ) - > void { <nl> + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> + jsval largv [ 1 ] ; <nl> + if ( event ) { <nl> + js_type_class_t * typeClassEvent = js_get_type_from_native < EventCustom > ( event ) ; <nl> + largv [ 0 ] = OBJECT_TO_JSVAL ( jsb_get_or_create_weak_jsobject ( cx , event , typeClassEvent , " cocos2d : : EventCustom " ) ) ; <nl> + } else { <nl> + largv [ 0 ] = JSVAL_NULL ; <nl> + } ; <nl> + JS : : RootedValue rval ( cx ) ; <nl> + bool succeed = func - > invoke ( 1 , & largv [ 0 ] , & rval ) ; <nl> + if ( ! succeed & & JS_IsExceptionPending ( cx ) ) { <nl> + JS_ReportPendingException ( cx ) ; <nl> + } <nl> + removeJSObject ( cx , event ) ; <nl> + } ; <nl> + arg1 = lambda ; <nl> + } <nl> + else <nl> + { <nl> + arg1 = nullptr ; <nl> + } <nl> + } while ( 0 ) <nl> + ; <nl> + JSB_PRECONDITION2 ( ok , cx , false , " js_cocos2dx_EventListenerCustom_create : Error processing arguments " ) ; <nl> + <nl> + auto ret = EventListenerCustom : : create ( arg0 , arg1 ) ; <nl> + JS : : RootedValue jsret ( cx , OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerCustom > ( cx , ret ) ) ) ; <nl> + args . rval ( ) . set ( jsret ) ; <nl> + return true ; <nl> + } <nl> + JS_ReportError ( cx , " js_cocos2dx_EventListenerCustom_create : wrong number of arguments " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + bool js_EventDispatcher_addCustomEventListener ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> + { <nl> + JS : : CallArgs args = JS : : CallArgsFromVp ( argc , vp ) ; <nl> + bool ok = true ; <nl> + JS : : RootedObject obj ( cx , args . thisv ( ) . toObjectOrNull ( ) ) ; <nl> + js_proxy_t * proxy = jsb_get_js_proxy ( obj ) ; <nl> + cocos2d : : EventDispatcher * cobj = ( cocos2d : : EventDispatcher * ) ( proxy ? proxy - > ptr : NULL ) ; <nl> + JSB_PRECONDITION2 ( cobj , cx , false , " js_cocos2dx_EventDispatcher_addCustomEventListener : Invalid Native Object " ) ; <nl> + if ( argc = = 2 ) { <nl> + std : : string arg0 ; <nl> + std : : function < void ( cocos2d : : EventCustom * ) > arg1 ; <nl> + ok & = jsval_to_std_string ( cx , args . get ( 0 ) , & arg0 ) ; <nl> + do { <nl> + if ( JS_TypeOfValue ( cx , args . get ( 1 ) ) = = JSTYPE_FUNCTION ) <nl> + { <nl> + JS : : RootedObject jstarget ( cx , args . thisv ( ) . toObjectOrNull ( ) ) ; <nl> + std : : shared_ptr < JSFunctionWrapper > func ( new JSFunctionWrapper ( cx , jstarget , args . get ( 1 ) , args . thisv ( ) ) ) ; <nl> + auto lambda = [ = ] ( cocos2d : : EventCustom * event ) - > void { <nl> + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> + jsval largv [ 1 ] ; <nl> + if ( event ) { <nl> + js_type_class_t * typeClassEvent = js_get_type_from_native < EventCustom > ( event ) ; <nl> + largv [ 0 ] = OBJECT_TO_JSVAL ( jsb_get_or_create_weak_jsobject ( cx , event , typeClassEvent , " cocos2d : : EventCustom " ) ) ; <nl> + } else { <nl> + largv [ 0 ] = JSVAL_NULL ; <nl> + } ; <nl> + JS : : RootedValue rval ( cx ) ; <nl> + bool succeed = func - > invoke ( 1 , & largv [ 0 ] , & rval ) ; <nl> + if ( ! succeed & & JS_IsExceptionPending ( cx ) ) { <nl> + JS_ReportPendingException ( cx ) ; <nl> + } <nl> + removeJSObject ( cx , event ) ; <nl> + } ; <nl> + arg1 = lambda ; <nl> + } <nl> + else <nl> + { <nl> + arg1 = nullptr ; <nl> + } <nl> + } while ( 0 ) ; <nl> + JSB_PRECONDITION2 ( ok , cx , false , " js_cocos2dx_EventDispatcher_addCustomEventListener : Error processing arguments " ) ; <nl> + cocos2d : : EventListenerCustom * ret = cobj - > addCustomEventListener ( arg0 , arg1 ) ; <nl> + JS : : RootedValue jsret ( cx ) ; <nl> + if ( ret ) { <nl> + jsret = OBJECT_TO_JSVAL ( js_get_or_create_jsobject < EventListenerCustom > ( cx , ret ) ) ; <nl> + args . rval ( ) . set ( jsret ) ; <nl> + } else { <nl> + jsret = JSVAL_NULL ; <nl> + } ; <nl> + args . rval ( ) . set ( jsret ) ; <nl> + return true ; <nl> + } <nl> + <nl> + JS_ReportError ( cx , " js_cocos2dx_EventDispatcher_addCustomEventListener : wrong number of arguments : % d , was expecting % d " , argc , 2 ) ; <nl> + return false ; <nl> + } <nl> \ No newline at end of file <nl> mmm a / cocos / scripting / js - bindings / manual / jsb_event_dispatcher_manual . h <nl> ppp b / cocos / scripting / js - bindings / manual / jsb_event_dispatcher_manual . h <nl> bool js_EventListenerTouchOneByOne_create ( JSContext * cx , uint32_t argc , jsval * v <nl> bool js_EventListenerTouchAllAtOnce_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> bool js_EventListenerKeyboard_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> bool js_EventListenerMouse_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> + bool js_EventListenerAcceleration_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> bool js_EventListenerFocus_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> + bool js_EventListenerCustom_create ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> + bool js_EventDispatcher_addCustomEventListener ( JSContext * cx , uint32_t argc , jsval * vp ) ; <nl> <nl> # endif / * defined ( __cocos2d_js_bindings__jsb_event_dispatcher__ ) * / <nl> mmm a / cocos / scripting / js - bindings / script / ccui / jsb_ccui_property_apis . js <nl> ppp b / cocos / scripting / js - bindings / script / ccui / jsb_ccui_property_apis . js <nl> cc . defineGetterSetter ( _proto , " insetRight " , _proto . getInsetRight , _proto . setInse <nl> cc . defineGetterSetter ( _proto , " insetBottom " , _proto . getInsetBottom , _proto . setInsetBottom ) ; <nl> <nl> _proto = cc . EditBox . prototype ; <nl> - cc . defineGetterSetter ( _proto , " font " , null , _proto . _setFont ) ; <nl> - cc . defineGetterSetter ( _proto , " fontName " , null , _proto . setFontName ) ; <nl> - cc . defineGetterSetter ( _proto , " fontSize " , null , _proto . setFontSize ) ; <nl> - cc . defineGetterSetter ( _proto , " string " , _proto . getString , _proto . setString ) ; <nl> - cc . defineGetterSetter ( _proto , " maxLength " , _proto . getMaxLength , _proto . setMaxLength ) ; <nl> + cc . defineGetterSetter ( _proto , ' font ' , null , _p . setFont ) ; <nl> + cc . defineGetterSetter ( _proto , ' fontName ' , null , _p . setFontName ) ; <nl> + cc . defineGetterSetter ( _proto , ' fontSize ' , null , _p . setFontSize ) ; <nl> + cc . defineGetterSetter ( _proto , ' fontColor ' , null , _p . setFontColor ) ; <nl> + cc . defineGetterSetter ( _proto , ' string ' , _p . getString , _p . setString ) ; <nl> + cc . defineGetterSetter ( _proto , ' maxLength ' , _p . getMaxLength , _p . setMaxLength ) ; <nl> + cc . defineGetterSetter ( _proto , ' placeholder ' , _p . getPlaceHolder , _p . setPlaceHolder ) ; <nl> + cc . defineGetterSetter ( _proto , ' placeholderFont ' , null , _p . setPlaceholderFont ) ; <nl> + cc . defineGetterSetter ( _proto , ' placeholderFontName ' , null , _p . setPlaceholderFontName ) ; <nl> + cc . defineGetterSetter ( _proto , ' placeholderFontSize ' , null , _p . setPlaceholderFontSize ) ; <nl> + cc . defineGetterSetter ( _proto , ' placeholderFontColor ' , null , _p . setPlaceholderFontColor ) ; <nl> + cc . defineGetterSetter ( _proto , ' inputFlag ' , null , _p . setInputFlag ) ; <nl> + cc . defineGetterSetter ( _proto , ' delegate ' , null , _p . setDelegate ) ; <nl> + cc . defineGetterSetter ( _proto , ' inputMode ' , null , _p . setInputMode ) ; <nl> + cc . defineGetterSetter ( _proto , ' returnType ' , null , _p . setReturnType ) ; <nl> <nl> _proto = ccui . ImageView . prototype ; <nl> cc . defineGetterSetter ( _proto , " anchorX " , _proto . _getAnchorX , _proto . _setAnchorX ) ; <nl> mmm a / cocos / scripting / js - bindings / script / ccui / jsb_cocos2d_ui . js <nl> ppp b / cocos / scripting / js - bindings / script / ccui / jsb_cocos2d_ui . js <nl> <nl> <nl> var ccui = ccui | | { } ; <nl> <nl> + <nl> cc . EditBox = ccui . EditBox ; <nl> delete ccui . EditBox ; <nl> <nl> + / * * <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . KEYBOARD_RETURNTYPE_DEFAULT = 0 ; <nl> + <nl> + / * * <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . KEYBOARD_RETURNTYPE_DONE = 1 ; <nl> + <nl> + / * * <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . KEYBOARD_RETURNTYPE_SEND = 2 ; <nl> + <nl> + / * * <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . KEYBOARD_RETURNTYPE_SEARCH = 3 ; <nl> + <nl> + / * * <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . KEYBOARD_RETURNTYPE_GO = 4 ; <nl> + <nl> + / * * <nl> + * The EditBox : : InputMode defines the type of text that the user is allowed * to enter . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_ANY = 0 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter an e - mail address . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_EMAILADDR = 1 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter an integer value . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_NUMERIC = 2 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter a phone number . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_PHONENUMBER = 3 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter a URL . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_URL = 4 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter a real number value . <nl> + * This extends kEditBoxInputModeNumeric by allowing a decimal point . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_DECIMAL = 5 ; <nl> + <nl> + / * * <nl> + * The user is allowed to enter any text , except for line breaks . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_MODE_SINGLELINE = 6 ; <nl> + <nl> + / * * <nl> + * Indicates that the text entered is confidential data that should be <nl> + * obscured whenever possible . This implies EDIT_BOX_INPUT_FLAG_SENSITIVE . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_FLAG_PASSWORD = 0 ; <nl> + <nl> + / * * <nl> + * Indicates that the text entered is sensitive data that the <nl> + * implementation must never store into a dictionary or table for use <nl> + * in predictive , auto - completing , or other accelerated input schemes . <nl> + * A credit card number is an example of sensitive data . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_FLAG_SENSITIVE = 1 ; <nl> + <nl> + / * * <nl> + * This flag is a hint to the implementation that during text editing , <nl> + * the initial letter of each word should be capitalized . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2 ; <nl> + <nl> + / * * <nl> + * This flag is a hint to the implementation that during text editing , <nl> + * the initial letter of each sentence should be capitalized . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3 ; <nl> + <nl> + / * * <nl> + * Capitalize all characters automatically . <nl> + * @ constant <nl> + * @ type Number <nl> + * / <nl> + cc . EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4 ; <nl> + <nl> + var _p = cc . EditBox . prototype ; <nl> + <nl> + _p . _setMaxLength = _p . setMaxLength ; <nl> + _p . setMaxLength = function ( maxLength ) { <nl> + if ( maxLength < 0 ) { <nl> + maxLength = 65535 ; <nl> + } <nl> + this . _setMaxLength ( maxLength ) ; <nl> + } ; <nl> + _p . setLineHeight = function ( ) { } ; <nl> + _p . setTabIndex = function ( ) { } ; <nl> + _p . getTabIndex = function ( ) { return - 1 ; } ; <nl> + _p . setFocus = function ( ) { } ; <nl> + _p . isFocused = function ( ) { return false ; } ; <nl> + _p . stayOnTop = function ( ) { } ; <nl> + <nl> + <nl> cc . Scale9Sprite = ccui . Scale9Sprite ; <nl> <nl> / / GUI <nl> mmm a / cocos / scripting / js - bindings / script / jsb_boot . js <nl> ppp b / cocos / scripting / js - bindings / script / jsb_boot . js <nl> cc . formatStr = function ( ) { <nl> <nl> / / Define singleton objects <nl> cc . director = cc . Director . getInstance ( ) ; <nl> + cc . director . _actionManager = cc . director . getActionManager ( ) ; <nl> + cc . director . _scheduler = cc . director . getScheduler ( ) ; <nl> cc . winSize = cc . director . getWinSize ( ) ; <nl> <nl> cc . view = cc . director . getOpenGLView ( ) ; <nl> var _initSys = function ( ) { <nl> * / <nl> sys . LANGUAGE_POLISH = " pl " ; <nl> <nl> + / * * <nl> + * Turkish language code <nl> + * @ constant <nl> + * @ default <nl> + * @ type { Number } <nl> + * / <nl> + sys . LANGUAGE_TURKISH = " tr " ; <nl> + <nl> + / * * <nl> + * Ukrainian language code <nl> + * @ constant <nl> + * @ default <nl> + * @ type { Number } <nl> + * / <nl> + sys . LANGUAGE_UKRAINIAN = " uk " ; <nl> + <nl> + / * * <nl> + * Romanian language code <nl> + * @ constant <nl> + * @ default <nl> + * @ type { Number } <nl> + * / <nl> + sys . LANGUAGE_ROMANIAN = " ro " ; <nl> + <nl> + / * * <nl> + * Bulgarian language code <nl> + * @ constant <nl> + * @ default <nl> + * @ type { Number } <nl> + * / <nl> + sys . LANGUAGE_BULGARIAN = " bg " ; <nl> + <nl> / * * <nl> * Unknown language code <nl> * @ memberof cc . sys <nl> var _initSys = function ( ) { <nl> case 12 : return sys . LANGUAGE_ARABIC ; <nl> case 13 : return sys . LANGUAGE_NORWEGIAN ; <nl> case 14 : return sys . LANGUAGE_POLISH ; <nl> + case 15 : return sys . LANGUAGE_TURKISH ; <nl> + case 16 : return sys . LANGUAGE_UKRAINIAN ; <nl> + case 17 : return sys . LANGUAGE_ROMANIAN ; <nl> + case 18 : return sys . LANGUAGE_BULGARIAN ; <nl> default : return sys . LANGUAGE_ENGLISH ; <nl> } <nl> } ) ( ) ; <nl> var _initSys = function ( ) { <nl> sys . _application . openURL ( url ) ; <nl> } ; <nl> <nl> + sys . now = function ( ) { <nl> + return Date . now ( ) ; <nl> + } ; <nl> + <nl> / / JS to Native bridges <nl> if ( window . JavascriptJavaBridge & & cc . sys . os = = cc . sys . OS_ANDROID ) { <nl> jsb . reflection = new JavascriptJavaBridge ( ) ; <nl> _initSys ( ) ; <nl> * / <nl> cc . _initDebugSetting = function ( mode ) { <nl> var ccGame = cc . game ; <nl> - var bakLog = cc . _cocosplayerLog | | cc . log | | log ; <nl> - cc . log = cc . warn = cc . error = cc . assert = function ( ) { } ; <nl> - if ( mode = = ccGame . DEBUG_MODE_NONE ) { <nl> - } else { <nl> - cc . error = function ( ) { <nl> - bakLog . call ( this , " ERROR : " + cc . formatStr . apply ( cc , arguments ) ) ; <nl> + var bakLog = cc . _cocosplayerLog | | console . log | | log ; <nl> + cc . log = cc . warn = cc . error = cc . assert = function ( ) { } ; <nl> + if ( mode > ccGame . DEBUG_MODE_NONE ) { <nl> + console . log = function ( ) { <nl> + bakLog ( cc . formatStr . apply ( null , arguments ) ) ; <nl> } ; <nl> - cc . assert = function ( cond , msg ) { <nl> + console . error = function ( ) { <nl> + bakLog ( " ERROR : " + cc . formatStr . apply ( cc , arguments ) ) ; <nl> + } ; <nl> + console . warn = function ( ) { <nl> + bakLog ( " WARN : " + cc . formatStr . apply ( cc , arguments ) ) ; <nl> + } ; <nl> + <nl> + cc . error = console . error ; <nl> + cc . assert = function ( cond , msg ) { <nl> if ( ! cond & & msg ) { <nl> var args = [ ] ; <nl> for ( var i = 1 ; i < arguments . length ; i + + ) <nl> args . push ( arguments [ i ] ) ; <nl> - bakLog ( " Assert : " + cc . formatStr . apply ( cc , args ) ) ; <nl> + console . log ( " Assert : " + cc . formatStr . apply ( cc , args ) ) ; <nl> } <nl> } ; <nl> - if ( mode ! = ccGame . DEBUG_MODE_ERROR & & mode ! = ccGame . DEBUG_MODE_ERROR_FOR_WEB_PAGE ) { <nl> - cc . warn = function ( ) { <nl> - bakLog . call ( this , " WARN : " + cc . formatStr . apply ( cc , arguments ) ) ; <nl> - } ; <nl> + if ( mode ! = ccGame . DEBUG_MODE_ERROR & & mode ! = ccGame . DEBUG_MODE_ERROR_FOR_WEB_PAGE ) { <nl> + cc . warn = console . warn ; <nl> } <nl> - if ( mode = = ccGame . DEBUG_MODE_INFO | | mode = = ccGame . DEBUG_MODE_INFO_FOR_WEB_PAGE ) { <nl> - cc . log = function ( ) { <nl> - bakLog . call ( this , cc . formatStr . apply ( cc , arguments ) ) ; <nl> - } ; <nl> + if ( mode = = ccGame . DEBUG_MODE_INFO | | mode = = ccGame . DEBUG_MODE_INFO_FOR_WEB_PAGE ) { <nl> + cc . log = console . log ; <nl> } <nl> } <nl> } ; <nl> mmm a / cocos / scripting / js - bindings / script / jsb_cocos2d . js <nl> ppp b / cocos / scripting / js - bindings / script / jsb_cocos2d . js <nl> cc . MENU_STATE_TRACKING_TOUCH = 1 ; <nl> cc . MENU_HANDLER_PRIORITY = - 128 ; <nl> cc . DEFAULT_PADDING = 5 ; <nl> <nl> - cc . Scheduler . PRIORITY_SYSTEM = - 2147483648 ; <nl> + cc . Scheduler . PRIORITY_SYSTEM = - 2147483648 ; <nl> + cc . Scheduler . PRIORITY_NON_SYSTEM = cc . Scheduler . PRIORITY_SYSTEM + 1 ; <nl> <nl> var _Class = cc . Texture2D ; <nl> <nl> cc . stencilBits = - 1 ; / / CCClippingNode . js <nl> <nl> cc . g_NumberOfDraws = 0 ; / / CCDirector . js <nl> <nl> - cc . PRIORITY_NON_SYSTEM = cc . PRIORITY_SYSTEM + 1 ; / / CCScheduler . js <nl> - <nl> cc . s_globalOrderOfArrival = 1 ; <nl> <nl> cc . Event . TOUCH = 0 ; / / CCEvent . js <nl> cc . DrawNode = cc . _DrawNode . extend ( { <nl> _drawColor : cc . color ( 255 , 255 , 255 , 255 ) , <nl> _lineWidth : 1 , <nl> <nl> + release : function ( ) { } , <nl> + <nl> setLineWidth : function ( width ) { <nl> this . _lineWidth = width ; <nl> } , <nl> _p . setNormalSpriteFrame = function ( frame ) { <nl> if ( frame [ 0 ] = = " # " ) <nl> frame = cc . spriteFrameCache . getSpriteFrame ( frame . substr ( 1 ) ) ; <nl> this . _setNormalSpriteFrame ( frame ) ; <nl> - } <nl> + } ; <nl> _p . setSelectedSpriteFrame = function ( frame ) { <nl> if ( frame [ 0 ] = = " # " ) <nl> frame = cc . spriteFrameCache . getSpriteFrame ( frame . substr ( 1 ) ) ; <nl> this . _setSelectedSpriteFrame ( frame ) ; <nl> - } <nl> + } ; <nl> _p . setDisabledSpriteFrame = function ( frame ) { <nl> if ( frame [ 0 ] = = " # " ) <nl> frame = cc . spriteFrameCache . getSpriteFrame ( frame . substr ( 1 ) ) ; <nl> this . _setDisabledSpriteFrame ( frame ) ; <nl> - } <nl> + } ; <nl> <nl> cc . MenuItemToggle . prototype . selectedItem = cc . MenuItemToggle . prototype . getSelectedItem ; <nl> <nl> cc . LabelTTF . prototype . _enableShadow = cc . LabelTTF . prototype . enableShadow ; <nl> cc . LabelTTF . prototype . enableShadow = function ( shadowColor , offset , blurRadius ) { <nl> var opacity = 1 ; <nl> this . _enableShadow ( offset , opacity , blurRadius ) ; <nl> - } <nl> + } ; <nl> <nl> cc . LabelTTF . prototype . setDrawMode = function ( ) { } ; <nl> <nl> _p . schedule = function ( callback , target , interval , repeat , delay , paused , key ) <nl> key = target . __instanceId + " " ; <nl> } <nl> this . _schedule ( callback , target , interval , repeat , delay , paused , key ) ; <nl> - } <nl> + } ; <nl> <nl> <nl> cc . _NodeGrid = cc . NodeGrid ; <nl> mmm a / tests / js - tests / src / DrawPrimitivesTest / DrawPrimitivesTest . js <nl> ppp b / tests / js - tests / src / DrawPrimitivesTest / DrawPrimitivesTest . js <nl> var DrawTestDemo = BaseTestLayer . extend ( { <nl> var DrawNewAPITest2 = DrawTestDemo . extend ( { <nl> _title : " cc . DrawNode " , <nl> _subtitle : " Testing cc . DrawNode API 2 " , <nl> - ctor : function ( ) { <nl> + onEnter : function ( ) { <nl> / / mmm - start0mmm - ctor <nl> this . _super ( ) ; <nl> var draw = new cc . DrawNode ( ) ; <nl> var DrawNewAPITest = DrawTestDemo . extend ( { <nl> _title : " cc . DrawNode " , <nl> _subtitle : " Testing cc . DrawNode API " , <nl> <nl> - ctor : function ( ) { <nl> + onEnter : function ( ) { <nl> / / mmm - start1mmm - ctor <nl> this . _super ( ) ; <nl> <nl> mmm a / tests / js - tests / src / ExtensionsTest / ExtensionsTest . js <nl> ppp b / tests / js - tests / src / ExtensionsTest / ExtensionsTest . js <nl> var extensionsTestItemNames = [ <nl> } <nl> ] ; <nl> <nl> - if ( ! cc . sys . isNative | | cc . sys . OS_LINUX ! = = cc . sys . os ) { <nl> + if ( ! cc . sys . isNative | | cc . sys . OS_LINUX ! = = cc . sys . os ) { <nl> extensionsTestItemNames . push ( { <nl> itemTitle : " EditBoxTest " , <nl> testScene : function ( ) { <nl> if ( cc . sys . isNative & & cc . sys . OS_IOS = = cc . sys . os ) { <nl> var testScene = pluginXSceneManager . currentPluginXScene ( ) ; <nl> cc . director . runScene ( testScene ) ; <nl> } <nl> - } ) <nl> + } ) ; <nl> } <nl> <nl> - if ( cc . sys . isNative & & cc . sys . OS_WINDOWS ! = cc . sys . os ) { <nl> + if ( cc . sys . isNative ) { <nl> extensionsTestItemNames . push ( { <nl> itemTitle : " AssetsManagerTest " , <nl> testScene : function ( ) { <nl> mmm a / tests / js - tests / src / SpineTest / SpineTest . js <nl> ppp b / tests / js - tests / src / SpineTest / SpineTest . js <nl> var SpineTestLayerNormal = SpineTestLayer . extend ( { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Make Spine ' s Animated skeleton Node <nl> / / You need ' json + atlas + image ' resource files to make it . <nl> - var spineBoy = sp . SkeletonAnimation . createWithJsonFile ( ' spine / spineboy . json ' , ' spine / spineboy . atlas ' ) ; <nl> + var spineBoy = sp . SkeletonAnimation . create ( ' spine / spineboy . json ' , ' spine / spineboy . atlas ' ) ; <nl> spineBoy . setPosition ( cc . p ( size . width / 2 , size . height / 2 - 150 ) ) ; <nl> spineBoy . setMix ( ' walk ' , ' jump ' , 0 . 2 ) ; <nl> spineBoy . setMix ( ' jump ' , ' run ' , 0 . 2 ) ; <nl> var SpineTestLayerFFD = SpineTestLayer . extend ( { <nl> ctor : function ( ) { <nl> this . _super ( cc . color ( 0 , 0 , 0 , 255 ) , cc . color ( 98 , 99 , 117 , 255 ) ) ; <nl> <nl> - var skeletonNode = sp . SkeletonAnimation . createWithJsonFile ( " spine / goblins . json " , " spine / goblins . atlas " , 1 . 5 ) ; <nl> + var skeletonNode = sp . SkeletonAnimation . create ( " spine / goblins . json " , " spine / goblins . atlas " , 1 . 5 ) ; <nl> skeletonNode . setAnimation ( 0 , " walk " , true ) ; <nl> skeletonNode . setSkin ( " goblin " ) ; <nl> <nl> var SpineTestPerformanceLayer = SpineTestLayer . extend ( { <nl> event : cc . EventListener . TOUCH_ONE_BY_ONE , <nl> onTouchBegan : function ( touch , event ) { <nl> var pos = self . convertToNodeSpace ( touch . getLocation ( ) ) ; <nl> - var skeletonNode = sp . SkeletonAnimation . createWithJsonFile ( " spine / goblins . json " , " spine / goblins . atlas " , 1 . 5 ) ; <nl> + var skeletonNode = sp . SkeletonAnimation . create ( " spine / goblins . json " , " spine / goblins . atlas " , 1 . 5 ) ; <nl> skeletonNode . setAnimation ( 0 , " walk " , true ) ; <nl> skeletonNode . setSkin ( " goblin " ) ; <nl> <nl> mmm a / tests / js - tests / src / tests_resources . js <nl> ppp b / tests / js - tests / src / tests_resources . js <nl> var ccbjs = " " ; <nl> / / so the respath will modify to res , <nl> if ( ! cc . sys . isNative ) <nl> { <nl> - cc . game . _loadConfig ( ) ; <nl> if ( cc . game . config [ cc . game . CONFIG_KEY . engineDir ] ! = = " frameworks / cocos2d - html5 " ) { <nl> ccbjs = " . . / . . / js - tests / resjs / " ; <nl> } <nl> mmm a / tools / bindings - generator <nl> ppp b / tools / bindings - generator <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 32404751d5399ccb0cd9df4b72b211506cade321 <nl> + Subproject commit e75034966263a44904405525526e9d09df179391 <nl> mmm a / tools / tojs / cocos2dx . ini <nl> ppp b / tools / tojs / cocos2dx . ini <nl> skip = Node : : [ ^ setPosition $ setGLServerState description getUserObject . * UserDat <nl> RenderTexture : : [ listenToBackground listenToForeground saveToFile ] , <nl> TextFieldTTF : : [ ( g | s ) etDelegate ] , <nl> EventListenerVector : : [ * ] , <nl> - EventListener ( Touch | Keyboard | Mouse | Focus ) . * : : [ create ] , <nl> + EventListener ( Touch | Keyboard | Mouse | Acceleration | Focus | Custom ) . * : : [ create ] , <nl> EventTouch : : [ ( s | g ) etTouches ] , <nl> EventKeyboard : : [ * ] , <nl> Device : : [ getTextureDataForText ] , <nl> - EventDispatcher : : [ dispatchCustomEvent ] , <nl> + EventDispatcher : : [ dispatchCustomEvent addCustomEventListener ] , <nl> EventCustom : : [ getUserData setUserData ] , <nl> Component : : [ serialize onAdd onRemove update ] , <nl> EventListenerCustom : : [ init ] , <nl> rename_functions = SpriteFrameCache : : [ addSpriteFramesWithFile = addSpriteFrames ge <nl> DrawNode : : [ drawQuadraticBezier = drawQuadBezier ] , <nl> FileUtils : : [ loadFilenameLookupDictionaryFromFile = loadFilenameLookup ] , <nl> SimpleAudioEngine : : [ preloadBackgroundMusic = preloadMusic setBackgroundMusicVolume = setMusicVolume getBackgroundMusicVolume = getMusicVolume playBackgroundMusic = playMusic stopBackgroundMusic = stopMusic pauseBackgroundMusic = pauseMusic resumeBackgroundMusic = resumeMusic rewindBackgroundMusic = rewindMusic isBackgroundMusicPlaying = isMusicPlaying willPlayBackgroundMusic = willPlayMusic ] , <nl> - EventDispatcher : : [ addCustomEventListener = addCustomListener removeEventListener = removeListener removeEventListenersForType = removeListeners removeEventListenersForTarget = removeListeners removeCustomEventListeners = removeCustomListeners removeAllEventListeners = removeAllListeners pauseEventListenersForTarget = pauseTarget resumeEventListenersForTarget = resumeTarget ] , <nl> + EventDispatcher : : [ removeEventListener = removeListener removeEventListenersForType = removeListeners removeEventListenersForTarget = removeListeners removeCustomEventListeners = removeCustomListeners removeAllEventListeners = removeAllListeners pauseEventListenersForTarget = pauseTarget resumeEventListenersForTarget = resumeTarget ] , <nl> EventMouse : : [ getMouseButton = getButton setMouseButton = setButton setCursorPosition = setLocation getCursorX = getLocationX getCursorY = getLocationY ] , <nl> Configuration : : [ getInfo = dumpInfo ] , <nl> ComponentContainer : : [ get = getComponent ] , <nl> LayerColor : : [ initWithColor = init ] , <nl> GLProgramCache : : [ getGLProgram = getProgram addGLProgram = addProgram reloadDefaultGLPrograms = reloadDefaultShaders loadDefaultGLPrograms = loadDefaultShaders ] , <nl> TextFieldTTF : : [ textFieldWithPlaceHolder = create ] , <nl> - Texture2D : : [ getGLProgram = getShaderProgram setGLProgram = setShaderProgram ] , <nl> + Texture2D : : [ getGLProgram = getShaderProgram setGLProgram = setShaderProgram releaseGLTexture = releaseTexture ] , <nl> Speed : : [ setSpeed = _setSpeed getSpeed = _getSpeed ] <nl> <nl> rename_classes = ParticleSystemQuad : : ParticleSystem , <nl> mmm a / web <nl> ppp b / web <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit e10208255f9eae2c25db5e04e395f4258406dbcd <nl> + Subproject commit 640431814638f732a4b886182820cc8a88a75e87 <nl>
|
Synchronize creator engine bug fixes and upgrade web engine ( )
|
cocos2d/cocos2d-x
|
5823f5792b4a7d06ae5fbd88bcd1a09f97a5b6d1
|
2016-12-14T01:27:47Z
|
mmm a / tensorflow / python / keras / distribute / keras_utils_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_utils_test . py <nl> def test_unsupported_features ( self , distribution , <nl> <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> exception_error_message = ( <nl> - ' ` validation_split ` argument is not supported when input ` x ` ' <nl> - ' is a dataset or a dataset iterator . + ' ) <nl> + ' ` validation_split ` argument is not supported when ' ) <nl> <nl> # Test with validation split <nl> with self . assertRaisesRegexp ( ValueError , exception_error_message ) : <nl> def test_unsupported_features ( self , distribution , <nl> # Test with sample weight . <nl> sample_weight = np . random . random ( ( 10 , ) ) <nl> with self . assertRaisesRegexp ( <nl> - ValueError , ' ` sample_weight ` argument is not supported when input ' <nl> - ' ` x ` is a dataset or a dataset iterator . ' ) : <nl> + ValueError , ' ` sample_weight ` argument is not supported when . * ' <nl> + ' dataset ' ) : <nl> model . fit ( <nl> dataset , <nl> epochs = 1 , <nl> mmm a / tensorflow / python / keras / engine / data_adapter . py <nl> ppp b / tensorflow / python / keras / engine / data_adapter . py <nl> <nl> scipy_sparse = None <nl> <nl> <nl> + try : <nl> + # In Python2 unicode is a scalar type <nl> + scalar_types = ( float , int , str , unicode ) <nl> + except NameError : <nl> + # In Python3 unicode is not present , it always uses string <nl> + scalar_types = ( float , int , str ) <nl> + <nl> + <nl> @ six . add_metaclass ( abc . ABCMeta ) <nl> class DataAdapter ( object ) : <nl> " " " Base class for input data adapter . <nl> class GenericArrayLikeDataAdapter ( TensorLikeDataAdapter ) : <nl> as Numpy , but it ignores any case where all the inputs are Tensors or Numpy <nl> arrays ( because that case is handled by the base TensorLikeDataAdapter ) . <nl> <nl> + It ignores scipy sparse matrices and Composite Tensors because those are <nl> + handled by the CompositeTensorDataAdapter . <nl> + <nl> It also does not handle lists / tuples of scalars , because those are handled <nl> by the ListsOfScalarsDataAdapter . <nl> " " " <nl> def _is_array_like ( v ) : <nl> hasattr ( v , " __len__ " ) <nl> ) <nl> <nl> - if not TensorLikeDataAdapter . can_handle ( x , y ) : <nl> + if ( not TensorLikeDataAdapter . can_handle ( x , y ) and <nl> + not CompositeTensorDataAdapter . can_handle ( x , y ) ) : <nl> return all ( _is_array_like ( v ) for v in flat_inputs ) <nl> else : <nl> return False <nl> def can_handle ( x , y = None ) : <nl> <nl> @ staticmethod <nl> def _is_list_of_scalars ( inp ) : <nl> - if isinstance ( inp , ( float , int , str ) ) : <nl> + if isinstance ( inp , scalar_types ) : <nl> return True <nl> if isinstance ( inp , ( list , tuple ) ) : <nl> return ListsOfScalarsDataAdapter . _is_list_of_scalars ( inp [ 0 ] ) <nl> mmm a / tensorflow / python / keras / engine / training . py <nl> ppp b / tensorflow / python / keras / engine / training . py <nl> def __init__ ( self , * args , * * kwargs ) : <nl> self . _compile_distribution = False <nl> <nl> self . _run_eagerly = None <nl> - self . _experimental_run_tf_function = False <nl> + self . _experimental_run_tf_function = ( <nl> + ops . executing_eagerly_outside_functions ( ) ) <nl> <nl> def get_weights ( self ) : <nl> " " " Retrieves the weights of the model . <nl> def compile ( self , <nl> ' Session arguments : % s ' % ( self . _function_kwargs , ) ) <nl> <nl> self . _set_optimizer ( optimizer ) <nl> - is_any_optimizer_v1 = any ( isinstance ( opt , optimizers . Optimizer ) <nl> - for opt in nest . flatten ( self . optimizer ) ) <nl> + is_any_keras_optimizer_v1 = any ( <nl> + ( isinstance ( opt , optimizers . Optimizer ) <nl> + and not isinstance ( opt , optimizers . TFOptimizer ) <nl> + ) for opt in nest . flatten ( self . optimizer ) ) <nl> + <nl> + if is_any_keras_optimizer_v1 and ops . executing_eagerly_outside_functions ( ) : <nl> + raise ValueError ( ' ` tf . compat . v1 . keras ` Optimizer ( ' , optimizer , ' ) is ' <nl> + ' not supported when eager execution is enabled . Use a ' <nl> + ' ` tf . keras ` Optimizer instead , or disable eager ' <nl> + ' execution . ' ) <nl> <nl> if ( ( target_tensors is not None ) <nl> - or is_any_optimizer_v1 <nl> or not ops . executing_eagerly_outside_functions ( ) ) : <nl> # Fallback out of things that aren ' t supported with v2 loops <nl> self . _experimental_run_tf_function = False <nl> def _convert_scipy_sparse_tensor ( value , expected_input ) : <nl> " " " <nl> if issparse is not None and issparse ( value ) : <nl> if ops . is_dense_tensor_like ( expected_input ) : <nl> + if ops . executing_eagerly_outside_functions ( ) : <nl> + # In TF2 we do not silently densify sparse matrices . <nl> + raise ValueError ( ' A SciPy sparse matrix was passed to a model ' <nl> + ' that expects dense inputs . Please densify your ' <nl> + ' inputs first , such as by calling ` x . toarray ( ) . ' ) <nl> return value . toarray ( ) <nl> else : <nl> sparse_coo = value . tocoo ( ) <nl> mmm a / tensorflow / python / keras / engine / training_eager . py <nl> ppp b / tensorflow / python / keras / engine / training_eager . py <nl> def _model_loss ( model , <nl> weights = mask <nl> else : <nl> # Update dimensions of weights to match with mask if possible . <nl> + weights = math_ops . cast ( weights , outs [ i ] . dtype ) <nl> mask , _ , weights = ( <nl> tf_losses_utils . squeeze_or_expand_dimensions ( <nl> mask , sample_weight = weights ) ) <nl> mmm a / tensorflow / python / keras / engine / training_test . py <nl> ppp b / tensorflow / python / keras / engine / training_test . py <nl> def test_fit_on_arrays ( self ) : <nl> input_a_np = np . random . random ( ( 10 , 3 ) ) <nl> input_b_np = np . random . random ( ( 10 , 4 ) ) <nl> <nl> - model . fit ( [ np . ndarray . tolist ( input_a_np ) ] , [ np . ndarray . tolist ( input_b_np ) ] , <nl> - epochs = 2 , <nl> - batch_size = 5 , <nl> - verbose = 2 ) <nl> + # Test execution on inputs that are lists of scalars . <nl> + # TF2 and TF1 have slightly different semantics : <nl> + if ( testing_utils . should_run_tf_function ( ) <nl> + or testing_utils . should_run_eagerly ( ) ) : <nl> + # In TF2 to avoid any ambiguity when there are nested lists <nl> + # the entire input gets converted to a <nl> + # single numpy array ( & it only works in the case of a single io model ) <nl> + model . fit ( np . ndarray . tolist ( input_a_np ) , <nl> + np . ndarray . tolist ( input_b_np ) , <nl> + epochs = 2 , <nl> + batch_size = 5 , <nl> + verbose = 2 ) <nl> + else : <nl> + # In TF1 there was logic to try disambiguating between the individual <nl> + # inputs when lists are nested . This allowed multi - io functional models <nl> + # to support lists of scalars as input , but it caused ambiguity issues <nl> + # for subclass models & made it trickier to pass multi - dimensional inputs <nl> + # as lists of scalars to single io models . This was an excessive amount <nl> + # of complexity for what boiled down to a convenience method we were <nl> + # mainly just using for writing tests . <nl> + model . fit ( [ np . ndarray . tolist ( input_a_np ) ] , <nl> + [ np . ndarray . tolist ( input_b_np ) ] , <nl> + epochs = 2 , <nl> + batch_size = 5 , <nl> + verbose = 2 ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_evaluate_predict_on_arrays ( self ) : <nl> def get_config ( self ) : <nl> model = MyModel ( ) <nl> self . assertIn ( ' { " a " : { } } ' , model . to_json ( ) ) <nl> <nl> - @ keras_parameterized . run_all_keras_modes <nl> + @ keras_parameterized . run_all_keras_modes ( always_skip_v1 = True ) <nl> def test_training_on_sparse_data_with_dense_placeholders ( self ) : <nl> - # TODO ( kaftan ) Test seems to not work , file ticket <nl> - if testing_utils . should_run_eagerly ( ) and context . executing_eagerly ( ) : <nl> - self . skipTest ( ' Skipping running model eagerly . ' ) <nl> - <nl> if scipy_sparse is None : <nl> return <nl> <nl> def test_training_on_sparse_data_with_dense_placeholders ( self ) : <nl> out1 = keras . layers . Dropout ( 0 . 5 , name = ' dropout ' ) ( in1 ) <nl> out2 = keras . layers . Dense ( 4 , name = ' dense_1 ' ) ( in2 ) <nl> model = keras . Model ( [ in1 , in2 ] , [ out1 , out2 ] ) <nl> - model . predict ( test_inputs , batch_size = 2 ) <nl> - optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) <nl> + model . experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> + <nl> + with self . assertRaisesRegexp ( ValueError , ' Please densify ' ) : <nl> + model . predict ( test_inputs , batch_size = 2 ) <nl> + optimizer = ' rmsprop ' <nl> model . compile ( <nl> optimizer , <nl> ' mse ' , <nl> metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + <nl> + with self . assertRaisesRegexp ( ValueError , ' Please densify ' ) : <nl> + model . fit ( test_inputs , test_outputs , <nl> + epochs = 1 , batch_size = 2 ) <nl> + <nl> + with self . assertRaisesRegexp ( ValueError , ' Please densify ' ) : <nl> + model . evaluate ( test_inputs , test_outputs , batch_size = 2 ) <nl> + <nl> + @ tf_test_util . run_deprecated_v1 <nl> + def test_training_on_sparse_data_with_dense_placeholders_v1 ( self ) : <nl> + if scipy_sparse is None : <nl> + return <nl> + <nl> + test_inputs = [ <nl> + scipy_sparse . random ( 6 , 3 , density = 0 . 25 ) . tocsr ( ) for _ in range ( 2 ) <nl> + ] <nl> + test_outputs = [ <nl> + scipy_sparse . random ( 6 , i , density = 0 . 25 ) . tocsr ( ) for i in range ( 3 , 5 ) <nl> + ] <nl> + in1 = keras . layers . Input ( shape = ( 3 , ) ) <nl> + in2 = keras . layers . Input ( shape = ( 3 , ) ) <nl> + out1 = keras . layers . Dropout ( 0 . 5 , name = ' dropout ' ) ( in1 ) <nl> + out2 = keras . layers . Dense ( 4 , name = ' dense_1 ' ) ( in2 ) <nl> + model = keras . Model ( [ in1 , in2 ] , [ out1 , out2 ] ) <nl> + model . predict ( test_inputs , batch_size = 2 ) <nl> + optimizer = ' rmsprop ' <nl> + model . compile ( <nl> + optimizer , <nl> + ' mse ' , <nl> + metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] ) <nl> model . fit ( test_inputs , test_outputs , <nl> epochs = 1 , batch_size = 2 , validation_split = 0 . 5 ) <nl> model . evaluate ( test_inputs , test_outputs , batch_size = 2 ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_compile_with_sparse_placeholders ( self ) : <nl> - # TODO ( kaftan ) Test seems to not work , file ticket <nl> - if testing_utils . should_run_eagerly ( ) and context . executing_eagerly ( ) : <nl> - self . skipTest ( ' Skipping running model eagerly . ' ) <nl> - <nl> input_layer = keras . layers . Input ( shape = ( 10 , ) , sparse = True ) <nl> weights = variables_lib . Variable ( <nl> np . ones ( ( 10 , 1 ) ) . astype ( np . float32 ) , name = ' weights ' ) <nl> def test_compile_with_sparse_placeholders ( self ) : <nl> model = keras . Model ( [ input_layer ] , output_layer ) <nl> model . compile ( <nl> loss = ' binary_crossentropy ' , <nl> - optimizer = keras . optimizers . Adam ( lr = 0 . 0001 ) , <nl> + optimizer = ' adam ' , <nl> metrics = [ ' accuracy ' ] , <nl> run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> def test_gan_workflow ( self ) : <nl> <nl> class TestTrainingWithDataTensors ( keras_parameterized . TestCase ) : <nl> <nl> - @ keras_parameterized . run_all_keras_modes <nl> + @ tf_test_util . run_deprecated_v1 <nl> def test_training_and_eval_methods_on_symbolic_tensors_single_io ( self ) : <nl> - # TODO ( kaftan ) Test seems to not work , file ticket <nl> - if context . executing_eagerly ( ) : <nl> - self . skipTest ( ' Skipping eager execution . ' ) <nl> - <nl> x = keras . layers . Input ( shape = ( 3 , ) , name = ' input ' ) <nl> y = keras . layers . Dense ( 4 , name = ' dense ' ) ( x ) <nl> model = keras . Model ( x , y ) <nl> def test_training_and_eval_methods_on_symbolic_tensors_single_io ( self ) : <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] ) <nl> <nl> inputs = keras . backend . zeros ( shape = ( 10 , 3 ) ) <nl> targets = keras . backend . zeros ( shape = ( 10 , 4 ) ) <nl> def test_training_and_eval_methods_on_symbolic_tensors_single_io ( self ) : <nl> epochs = 1 , steps_per_epoch = 2 , verbose = 0 , <nl> validation_data = ( inputs , targets ) , validation_steps = 2 ) <nl> <nl> - @ keras_parameterized . run_all_keras_modes <nl> + @ tf_test_util . run_deprecated_v1 <nl> def test_training_and_eval_methods_on_symbolic_tensors_multi_io ( self ) : <nl> - # TODO ( kaftan ) Test seems to not work , file ticket <nl> - if context . executing_eagerly ( ) : <nl> - self . skipTest ( ' Skipping eager execution . ' ) <nl> - <nl> a = keras . layers . Input ( shape = ( 3 , ) , name = ' input_a ' ) <nl> b = keras . layers . Input ( shape = ( 3 , ) , name = ' input_b ' ) <nl> <nl> def test_training_and_eval_methods_on_symbolic_tensors_multi_io ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> - loss_weights = loss_weights , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + loss_weights = loss_weights ) <nl> <nl> input_a_tf = keras . backend . zeros ( shape = ( 10 , 3 ) ) <nl> input_b_tf = keras . backend . zeros ( shape = ( 10 , 3 ) ) <nl> def test_model_with_input_feed_tensor ( self ) : <nl> out = model . predict ( None , steps = 3 ) <nl> self . assertEqual ( out . shape , ( 10 * 3 , 4 ) ) <nl> <nl> + @ keras_parameterized . run_all_keras_modes <nl> def test_model_with_partial_loss ( self ) : <nl> with self . cached_session ( ) : <nl> a = keras . Input ( shape = ( 3 , ) , name = ' input_a ' ) <nl> def test_model_with_external_loss ( self ) : <nl> self . assertEqual ( out [ 0 ] . shape , ( 10 * 3 , 4 ) ) <nl> self . assertEqual ( out [ 1 ] . shape , ( 10 * 3 , 4 ) ) <nl> <nl> + @ keras_parameterized . run_all_keras_modes <nl> def test_target_tensors ( self ) : <nl> with self . cached_session ( ) : <nl> # single - output , as list <nl> def test_invalid_metrics ( self ) : <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_metrics_masking ( self ) : <nl> - if testing_utils . should_run_eagerly ( ) : <nl> - self . skipTest ( ' b / 120495761 ' ) <nl> - with self . cached_session ( ) : <nl> - np . random . seed ( 1337 ) <nl> - model = keras . models . Sequential ( ) <nl> - model . add ( keras . layers . Masking ( mask_value = 0 , input_shape = ( 2 , 1 ) ) ) <nl> - model . add ( <nl> - keras . layers . TimeDistributed ( <nl> - keras . layers . Dense ( 1 , kernel_initializer = ' ones ' ) ) ) <nl> - model . compile ( <nl> - RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> - loss = ' mse ' , <nl> - weighted_metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + np . random . seed ( 1337 ) <nl> + model = keras . models . Sequential ( ) <nl> + model . add ( keras . layers . Masking ( mask_value = 0 , input_shape = ( 2 , 1 ) ) ) <nl> + model . add ( <nl> + keras . layers . TimeDistributed ( <nl> + keras . layers . Dense ( 1 , kernel_initializer = ' ones ' ) ) ) <nl> + model . compile ( <nl> + RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> + loss = ' mse ' , <nl> + weighted_metrics = [ ' accuracy ' ] , <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> + experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> <nl> - # verify that masking is applied . <nl> - x = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 0 ] ] ] ) <nl> - y = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] ] ) <nl> - scores = model . train_on_batch ( x , y ) <nl> - self . assertArrayNear ( scores , [ 0 . 25 , 0 . 75 ] , 0 . 1 ) <nl> + # verify that masking is applied . <nl> + x = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 0 ] ] ] ) <nl> + y = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] ] ) <nl> + scores = model . train_on_batch ( x , y ) <nl> + self . assertArrayNear ( scores , [ 0 . 25 , 0 . 75 ] , 0 . 1 ) <nl> <nl> - # verify that masking is combined with sample weights . <nl> - w = np . array ( [ 3 , 2 , 4 ] ) <nl> - scores = model . train_on_batch ( x , y , sample_weight = w ) <nl> - self . assertArrayNear ( scores , [ 0 . 3328 , 0 . 8 ] , 0 . 001 ) <nl> + # verify that masking is combined with sample weights . <nl> + w = np . array ( [ 3 , 2 , 4 ] ) <nl> + scores = model . train_on_batch ( x , y , sample_weight = w ) <nl> + self . assertArrayNear ( scores , [ 0 . 3328 , 0 . 8 ] , 0 . 001 ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_add_metric_with_tensor_on_model ( self ) : <nl> mmm a / tensorflow / python / keras / engine / training_utils . py <nl> ppp b / tensorflow / python / keras / engine / training_utils . py <nl> def call_metric_function ( metric_fn , <nl> weights = mask <nl> else : <nl> # Update dimensions of weights to match with mask . <nl> + weights = math_ops . cast ( weights , dtype = y_pred . dtype ) <nl> mask , _ , weights = tf_losses_utils . squeeze_or_expand_dimensions ( <nl> mask , sample_weight = weights ) <nl> weights * = mask <nl> mmm a / tensorflow / python / keras / engine / training_v2_utils . py <nl> ppp b / tensorflow / python / keras / engine / training_v2_utils . py <nl> def predict_on_batch ( model , x ) : <nl> <nl> # If ` model . _distribution_strategy ` is True , then we are in a replica context <nl> # at this point . <nl> - inputs = training_utils . cast_if_floating_dtype ( inputs ) <nl> + inputs = training_utils . cast_to_model_input_dtypes ( inputs , model ) <nl> if isinstance ( inputs , collections . Sequence ) : <nl> # Unwrap lists with only one input , as we do when training on batch <nl> if len ( inputs ) = = 1 : <nl> mmm a / tensorflow / python / keras / layers / gru_test . py <nl> ppp b / tensorflow / python / keras / layers / gru_test . py <nl> def test_return_sequences_GRU ( self ) : <nl> ' return_sequences ' : True } , <nl> input_shape = ( num_samples , timesteps , embedding_dim ) ) <nl> <nl> + @ tf_test_util . run_v2_only <nl> def test_float64_GRU ( self ) : <nl> num_samples = 2 <nl> timesteps = 3 <nl> mmm a / tensorflow / python / keras / layers / gru_v2_test . py <nl> ppp b / tensorflow / python / keras / layers / gru_v2_test . py <nl> def test_return_sequences_GRU ( self ) : <nl> ' return_sequences ' : True } , <nl> input_shape = ( num_samples , timesteps , embedding_dim ) ) <nl> <nl> + @ test_util . run_v2_only <nl> def test_float64_GRU ( self ) : <nl> num_samples = 2 <nl> timesteps = 3 <nl> mmm a / tensorflow / python / keras / layers / lstm_test . py <nl> ppp b / tensorflow / python / keras / layers / lstm_test . py <nl> <nl> <nl> from tensorflow . python import keras <nl> from tensorflow . python . eager import context <nl> + from tensorflow . python . framework import test_util as tf_test_util <nl> from tensorflow . python . keras import keras_parameterized <nl> from tensorflow . python . keras import testing_utils <nl> from tensorflow . python . platform import test <nl> def test_return_sequences_LSTM ( self ) : <nl> ' return_sequences ' : True } , <nl> input_shape = ( num_samples , timesteps , embedding_dim ) ) <nl> <nl> + @ tf_test_util . run_v2_only <nl> def test_float64_LSTM ( self ) : <nl> num_samples = 2 <nl> timesteps = 3 <nl> mmm a / tensorflow / python / keras / layers / lstm_v2_test . py <nl> ppp b / tensorflow / python / keras / layers / lstm_v2_test . py <nl> def test_return_sequences_LSTM ( self ) : <nl> } , <nl> input_shape = ( num_samples , timesteps , embedding_dim ) ) <nl> <nl> + @ test_util . run_v2_only <nl> def test_float64_LSTM ( self ) : <nl> num_samples = 2 <nl> timesteps = 3 <nl> mmm a / tensorflow / python / keras / layers / recurrent_test . py <nl> ppp b / tensorflow / python / keras / layers / recurrent_test . py <nl> def make_model ( stateful = False , with_initial_state = False ) : <nl> input_layer , initial_state = initial_states ) <nl> model = keras . Model ( input_layer , rnn_output ) <nl> model . compile ( <nl> - optimizer = keras . optimizers . RMSprop ( ) , loss = ' mse ' , <nl> + optimizer = ' rmsprop ' , loss = ' mse ' , <nl> run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> return model <nl> mmm a / tensorflow / python / keras / layers / simplernn_test . py <nl> ppp b / tensorflow / python / keras / layers / simplernn_test . py <nl> <nl> <nl> from tensorflow . python import keras <nl> from tensorflow . python . eager import context <nl> + from tensorflow . python . framework import test_util as tf_test_util <nl> from tensorflow . python . keras import keras_parameterized <nl> from tensorflow . python . keras import testing_utils <nl> from tensorflow . python . platform import test <nl> def test_return_sequences_SimpleRNN ( self ) : <nl> ' return_sequences ' : True } , <nl> input_shape = ( num_samples , timesteps , embedding_dim ) ) <nl> <nl> + @ tf_test_util . run_v2_only <nl> def test_float64_SimpleRNN ( self ) : <nl> num_samples = 2 <nl> timesteps = 3 <nl> mmm a / tensorflow / python / keras / layers / wrappers_test . py <nl> ppp b / tensorflow / python / keras / layers / wrappers_test . py <nl> def test_TimeDistributed_with_mask_first_implementation ( self ) : <nl> layer = [ keras . layers . LSTM , <nl> keras . layers . Dense ] ) ) <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> + if testing_utils . should_run_tf_function ( ) : <nl> + self . skipTest ( ' b / 143103634 ' ) <nl> np . random . seed ( 100 ) <nl> layer = layer ( 4 ) <nl> ragged_data = ragged_factory_ops . constant ( <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> x_ragged = keras . Input ( shape = ( None , 2 , 1 ) , dtype = ' float32 ' , ragged = True ) <nl> y_ragged = keras . layers . TimeDistributed ( layer ) ( x_ragged ) <nl> model_1 = keras . models . Model ( x_ragged , y_ragged ) <nl> + model_1 . _experimental_run_tf_function = ( <nl> + testing_utils . should_run_tf_function ( ) ) <nl> + model_1 . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> output_ragged = model_1 . predict ( ragged_data , steps = 1 ) <nl> <nl> x_dense = keras . Input ( shape = ( None , 2 , 1 ) , dtype = ' float32 ' ) <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> y_dense = keras . layers . TimeDistributed ( layer ) ( masking ) <nl> model_2 = keras . models . Model ( x_dense , y_dense ) <nl> dense_data = ragged_data . to_tensor ( ) <nl> + model_2 . _experimental_run_tf_function = ( <nl> + testing_utils . should_run_tf_function ( ) ) <nl> + model_2 . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> output_dense = model_2 . predict ( dense_data , steps = 1 ) <nl> <nl> output_ragged = ragged_tensor . convert_to_tensor_or_ragged_tensor ( <nl> mmm a / tensorflow / python / keras / saving / hdf5_format_test . py <nl> ppp b / tensorflow / python / keras / saving / hdf5_format_test . py <nl> def test_sequential_weight_loading_group_name_with_incorrect_length ( self ) : <nl> name = ' d1 ' ) ) <nl> ref_model . add ( keras . layers . Dense ( num_classes , name = ' d2 ' ) ) <nl> ref_model . compile ( loss = keras . losses . MSE , <nl> - optimizer = keras . optimizers . RMSprop ( lr = 0 . 0001 ) , <nl> + optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . categorical_accuracy ] ) <nl> <nl> f_ref_model = h5py . File ( h5_path , ' w ' ) <nl> def test_sequential_weight_loading_group_name_with_incorrect_length ( self ) : <nl> input_dim = input_dim , name = ' d1 ' ) ) <nl> model . add ( keras . layers . Dense ( num_classes , name = ' d2 ' ) ) <nl> model . compile ( loss = keras . losses . MSE , <nl> - optimizer = keras . optimizers . RMSprop ( lr = 0 . 0001 ) , <nl> + optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . categorical_accuracy ] ) <nl> with self . assertRaisesRegexp ( ValueError , <nl> r ' Layer # 0 \ ( named \ " d1 \ " \ ) expects 1 ' <nl> mmm a / tensorflow / python / keras / saving / save_test . py <nl> ppp b / tensorflow / python / keras / saving / save_test . py <nl> def test_saving_with_dense_features ( self ) : <nl> <nl> model . compile ( <nl> loss = keras . losses . MSE , <nl> - optimizer = keras . optimizers . RMSprop ( lr = 0 . 0001 ) , <nl> + optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . categorical_accuracy ] ) <nl> <nl> config = model . to_json ( ) <nl> def test_saving_with_sequence_features ( self ) : <nl> <nl> model . compile ( <nl> loss = keras . losses . MSE , <nl> - optimizer = keras . optimizers . RMSprop ( lr = 0 . 0001 ) , <nl> + optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . categorical_accuracy ] ) <nl> <nl> config = model . to_json ( ) <nl>
|
Removes two Keras fallbacks to older v1 code :
|
tensorflow/tensorflow
|
83569dfad98f7137dcf38593722fd16674ae632e
|
2019-10-28T23:07:39Z
|
mmm a / src / array - iterator . js <nl> ppp b / src / array - iterator . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl> mmm a / src / collection - iterator . js <nl> ppp b / src / collection - iterator . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl> mmm a / src / harmony - classes . js <nl> ppp b / src / harmony - classes . js <nl> <nl> / / var $ Function = global . Function ; <nl> / / var $ Array = global . Array ; <nl> <nl> + " use strict " ; <nl> + <nl> <nl> ( function ( ) { <nl> function FunctionToMethod ( homeObject ) { <nl> mmm a / src / harmony - string . js <nl> ppp b / src / harmony - string . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl> / / in runtime . js : <nl> mmm a / src / harmony - templates . js <nl> ppp b / src / harmony - templates . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> var callSiteCache = new $ Map ; <nl> <nl> mmm a / src / harmony - tostring . js <nl> ppp b / src / harmony - tostring . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl> / / in runtime . js and symbol . js : <nl> mmm a / src / harmony - typedarray . js <nl> ppp b / src / harmony - typedarray . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl> / / in runtime . js : <nl> mmm a / src / liveedit - debugger . js <nl> ppp b / src / liveedit - debugger . js <nl> <nl> / / All unchanged functions have their positions updated accordingly . <nl> / / <nl> / / LiveEdit namespace is declared inside a single function constructor . <nl> + <nl> + " use strict " ; <nl> + <nl> Debug . LiveEdit = new function ( ) { <nl> <nl> / / Forward declaration for minifier . <nl> Debug . LiveEdit = new function ( ) { <nl> <nl> FunctionPatchabilityStatus . SymbolName = function ( code ) { <nl> var enumeration = FunctionPatchabilityStatus ; <nl> - for ( name in enumeration ) { <nl> + for ( var name in enumeration ) { <nl> if ( enumeration [ name ] = = code ) { <nl> return name ; <nl> } <nl> mmm a / src / string - iterator . js <nl> ppp b / src / string - iterator . 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> - ' use strict ' ; <nl> + " use strict " ; <nl> <nl> <nl> / / This file relies on the fact that the following declaration has been made <nl>
|
Consistently use " use strict " where possible .
|
v8/v8
|
f65a023fac30c4eccaa412c262f56c90f9124eb4
|
2014-12-10T14:41:05Z
|
mmm a / src / cpp / server / server_cc . cc <nl> ppp b / src / cpp / server / server_cc . cc <nl> namespace { <nl> / / max - threads set ) to the server builder . <nl> # define DEFAULT_MAX_SYNC_SERVER_THREADS INT_MAX <nl> <nl> + / / How many callback requests of each method should we pre - register at start <nl> + # define DEFAULT_CALLBACK_REQS_PER_METHOD 32 <nl> + <nl> class DefaultGlobalCallbacks final : public Server : : GlobalCallbacks { <nl> public : <nl> ~ DefaultGlobalCallbacks ( ) override { } <nl> bool Server : : RegisterService ( const grpc : : string * host , Service * service ) { <nl> ( * it ) - > AddSyncMethod ( method , method_registration_tag ) ; <nl> } <nl> } else { <nl> - / / a callback method <nl> - auto * req = new CallbackRequest ( this , method , method_registration_tag ) ; <nl> - callback_reqs_ . emplace_back ( req ) ; <nl> + / / a callback method . Register at least some callback requests <nl> + / / TODO ( vjpai ) : Register these dynamically based on need <nl> + for ( int i = 0 ; i < DEFAULT_CALLBACK_REQS_PER_METHOD ; i + + ) { <nl> + auto * req = new CallbackRequest ( this , method , method_registration_tag ) ; <nl> + callback_reqs_ . emplace_back ( req ) ; <nl> + } <nl> / / Enqueue it so that it will be Request ' ed later once <nl> / / all request matchers are created at core server startup <nl> } <nl>
|
Merge pull request from vjpai / request
|
grpc/grpc
|
6eb888bc6c764021d0ab97fa1e1ccdcc461c3614
|
2018-11-08T21:32:10Z
|
mmm a / docs / root / intro / version_history . rst <nl> ppp b / docs / root / intro / version_history . rst <nl> Version history <nl> = = = = = = = = = = = = = = = = <nl> * access log : added FILTER_STATE : ref : ` access log formatters < config_access_log_format > ` and gRPC access logger . <nl> * access log : added a : ref : ` typed JSON logging mode < config_access_log_format_dictionaries > ` to output access logs in JSON format with non - string values <nl> + * access log : fixed UPSTREAM_LOCAL_ADDRESS : ref : ` access log formatters < config_access_log_format > ` to work for http requests <nl> * api : remove all support for v1 <nl> * api : added ability to specify ` mode ` for : ref : ` Pipe < envoy_api_field_core . Pipe . mode > ` . <nl> * buffer : remove old implementation <nl> mmm a / include / envoy / http / BUILD <nl> ppp b / include / envoy / http / BUILD <nl> envoy_cc_library ( <nl> " : metadata_interface " , <nl> " : protocol_interface " , <nl> " / / include / envoy / buffer : buffer_interface " , <nl> + " / / include / envoy / network : address_interface " , <nl> ] , <nl> ) <nl> <nl> mmm a / include / envoy / http / codec . h <nl> ppp b / include / envoy / http / codec . h <nl> <nl> # include " envoy / http / header_map . h " <nl> # include " envoy / http / metadata_interface . h " <nl> # include " envoy / http / protocol . h " <nl> + # include " envoy / network / address . h " <nl> <nl> namespace Envoy { <nl> namespace Http { <nl> class Stream { <nl> * not associated with every stream on the connection . <nl> * / <nl> virtual absl : : string_view responseDetails ( ) { return " " ; } <nl> + <nl> + / * <nl> + * @ return const Address : : InstanceConstSharedPtr & the local address of the connection associated <nl> + * with the stream . <nl> + * / <nl> + virtual const Network : : Address : : InstanceConstSharedPtr & connectionLocalAddress ( ) PURE ; <nl> } ; <nl> <nl> / * * <nl> mmm a / source / common / http / http1 / codec_impl . cc <nl> ppp b / source / common / http / http1 / codec_impl . cc <nl> void StreamEncoderImpl : : readDisable ( bool disable ) { connection_ . readDisable ( disa <nl> <nl> uint32_t StreamEncoderImpl : : bufferLimit ( ) { return connection_ . bufferLimit ( ) ; } <nl> <nl> + const Network : : Address : : InstanceConstSharedPtr & StreamEncoderImpl : : connectionLocalAddress ( ) { <nl> + return connection_ . connection ( ) . localAddress ( ) ; <nl> + } <nl> + <nl> static const char RESPONSE_PREFIX [ ] = " HTTP / 1 . 1 " ; <nl> static const char HTTP_10_RESPONSE_PREFIX [ ] = " HTTP / 1 . 0 " ; <nl> <nl> mmm a / source / common / http / http1 / codec_impl . h <nl> ppp b / source / common / http / http1 / codec_impl . h <nl> class StreamEncoderImpl : public StreamEncoder , <nl> void readDisable ( bool disable ) override ; <nl> uint32_t bufferLimit ( ) override ; <nl> absl : : string_view responseDetails ( ) override { return details_ ; } <nl> + const Network : : Address : : InstanceConstSharedPtr & connectionLocalAddress ( ) override ; <nl> <nl> void isResponseToHeadRequest ( bool value ) { is_response_to_head_request_ = value ; } <nl> void setDetails ( absl : : string_view details ) { details_ = details ; } <nl> mmm a / source / common / http / http2 / codec_impl . h <nl> ppp b / source / common / http / http2 / codec_impl . h <nl> class ConnectionImpl : public virtual Connection , protected Logger : : Loggable < Log <nl> void resetStream ( StreamResetReason reason ) override ; <nl> void readDisable ( bool disable ) override ; <nl> uint32_t bufferLimit ( ) override { return pending_recv_data_ . highWatermark ( ) ; } <nl> + const Network : : Address : : InstanceConstSharedPtr & connectionLocalAddress ( ) override { <nl> + return parent_ . connection_ . localAddress ( ) ; <nl> + } <nl> <nl> void setWriteBufferWatermarks ( uint32_t low_watermark , uint32_t high_watermark ) { <nl> pending_recv_data_ . setWatermarks ( low_watermark , high_watermark ) ; <nl> mmm a / source / common / router / router . cc <nl> ppp b / source / common / router / router . cc <nl> void Filter : : UpstreamRequest : : onPoolReady ( Http : : StreamEncoder & request_encoder , <nl> <nl> host - > outlierDetector ( ) . putResult ( Upstream : : Outlier : : Result : : LocalOriginConnectSuccess ) ; <nl> <nl> - / / TODO ( ggreenway ) : set upstream local address in the StreamInfo . <nl> onUpstreamHostSelected ( host ) ; <nl> request_encoder . getStream ( ) . addCallbacks ( * this ) ; <nl> <nl> + stream_info_ . setUpstreamLocalAddress ( request_encoder . getStream ( ) . connectionLocalAddress ( ) ) ; <nl> + parent_ . callbacks_ - > streamInfo ( ) . setUpstreamLocalAddress ( <nl> + request_encoder . getStream ( ) . connectionLocalAddress ( ) ) ; <nl> + <nl> stream_info_ . setUpstreamSslConnection ( info . downstreamSslConnection ( ) ) ; <nl> parent_ . callbacks_ - > streamInfo ( ) . setUpstreamSslConnection ( info . downstreamSslConnection ( ) ) ; <nl> <nl> mmm a / source / extensions / quic_listeners / quiche / envoy_quic_stream . h <nl> ppp b / source / extensions / quic_listeners / quiche / envoy_quic_stream . h <nl> class EnvoyQuicStream : public Http : : StreamEncoder , <nl> } <nl> void removeCallbacks ( Http : : StreamCallbacks & callbacks ) override { removeCallbacks_ ( callbacks ) ; } <nl> uint32_t bufferLimit ( ) override { return send_buffer_simulation_ . highWatermark ( ) ; } <nl> + const Network : : Address : : InstanceConstSharedPtr & connectionLocalAddress ( ) override { <nl> + return connection ( ) - > localAddress ( ) ; <nl> + } <nl> <nl> / / Needs to be called during quic stream creation before the stream receives <nl> / / any headers and data . <nl> new file mode 100644 <nl> index 00000000000 . . 13ed526adb1 <nl> mmm / dev / null <nl> ppp b / test / common / access_log / access_log_formatter_corpus / upstream_local_address <nl> <nl> + format : " % UPSTREAM_LOCAL_ADDRESS % " <nl> + stream_info { <nl> + upstream_local_address { <nl> + socket_address { <nl> + address : " 10 . 1 . 2 . 3 " , <nl> + port_value : 10001 <nl> + } <nl> + } <nl> + } <nl> mmm a / test / common / router / router_test . cc <nl> ppp b / test / common / router / router_test . cc <nl> class WatermarkTest : public RouterTest { <nl> EXPECT_CALL ( stream_ , addCallbacks ( _ ) ) . WillOnce ( Invoke ( [ & ] ( Http : : StreamCallbacks & callbacks ) { <nl> stream_callbacks_ = & callbacks ; <nl> } ) ) ; <nl> - EXPECT_CALL ( encoder_ , getStream ( ) ) . WillOnce ( ReturnRef ( stream_ ) ) ; <nl> + EXPECT_CALL ( encoder_ , getStream ( ) ) . WillRepeatedly ( ReturnRef ( stream_ ) ) ; <nl> EXPECT_CALL ( cm_ . conn_pool_ , newStream ( _ , _ ) ) <nl> . WillOnce ( Invoke ( <nl> [ & ] ( Http : : StreamDecoder & decoder , <nl> mmm a / test / common / router / router_upstream_log_test . cc <nl> ppp b / test / common / router / router_upstream_log_test . cc <nl> name : envoy . file_access_log <nl> " @ type " : type . googleapis . com / envoy . config . accesslog . v2 . FileAccessLog <nl> format : " % REQ ( : METHOD ) % % REQ ( X - ENVOY - ORIGINAL - PATH ? : PATH ) % % PROTOCOL % % RESPONSE_CODE % <nl> % RESPONSE_FLAGS % % BYTES_RECEIVED % % BYTES_SENT % % REQ ( : AUTHORITY ) % % UPSTREAM_HOST % <nl> - % RESP ( X - UPSTREAM - HEADER ) % % TRAILER ( X - TRAILER ) % \ n " <nl> + % UPSTREAM_LOCAL_ADDRESS % % RESP ( X - UPSTREAM - HEADER ) % % TRAILER ( X - TRAILER ) % \ n " <nl> path : " / dev / null " <nl> ) EOF " ; <nl> <nl> class RouterUpstreamLogTest : public testing : : Test { <nl> [ & ] ( Http : : StreamDecoder & decoder , <nl> Http : : ConnectionPool : : Callbacks & callbacks ) - > Http : : ConnectionPool : : Cancellable * { <nl> response_decoder = & decoder ; <nl> + EXPECT_CALL ( encoder . stream_ , connectionLocalAddress ( ) ) <nl> + . WillRepeatedly ( ReturnRef ( upstream_local_address1_ ) ) ; <nl> callbacks . onPoolReady ( encoder , context_ . cluster_manager_ . conn_pool_ . host_ , <nl> stream_info_ ) ; <nl> return nullptr ; <nl> class RouterUpstreamLogTest : public testing : : Test { <nl> void runWithRetry ( ) { <nl> NiceMock < Http : : MockStreamEncoder > encoder1 ; <nl> Http : : StreamDecoder * response_decoder = nullptr ; <nl> + <nl> EXPECT_CALL ( context_ . cluster_manager_ . conn_pool_ , newStream ( _ , _ ) ) <nl> . WillOnce ( Invoke ( <nl> [ & ] ( Http : : StreamDecoder & decoder , <nl> Http : : ConnectionPool : : Callbacks & callbacks ) - > Http : : ConnectionPool : : Cancellable * { <nl> response_decoder = & decoder ; <nl> + EXPECT_CALL ( encoder1 . stream_ , connectionLocalAddress ( ) ) <nl> + . WillRepeatedly ( ReturnRef ( upstream_local_address1_ ) ) ; <nl> callbacks . onPoolReady ( encoder1 , context_ . cluster_manager_ . conn_pool_ . host_ , <nl> stream_info_ ) ; <nl> return nullptr ; <nl> class RouterUpstreamLogTest : public testing : : Test { <nl> response_decoder = & decoder ; <nl> EXPECT_CALL ( context_ . cluster_manager_ . conn_pool_ . host_ - > outlier_detector_ , <nl> putResult ( Upstream : : Outlier : : Result : : LocalOriginConnectSuccess , _ ) ) ; <nl> + EXPECT_CALL ( encoder2 . stream_ , connectionLocalAddress ( ) ) <nl> + . WillRepeatedly ( ReturnRef ( upstream_local_address2_ ) ) ; <nl> callbacks . onPoolReady ( encoder2 , context_ . cluster_manager_ . conn_pool_ . host_ , <nl> stream_info_ ) ; <nl> return nullptr ; <nl> class RouterUpstreamLogTest : public testing : : Test { <nl> envoy : : api : : v2 : : core : : Locality upstream_locality_ ; <nl> Network : : Address : : InstanceConstSharedPtr host_address_ { <nl> Network : : Utility : : resolveUrl ( " tcp : / / 10 . 0 . 0 . 5 : 9211 " ) } ; <nl> + Network : : Address : : InstanceConstSharedPtr upstream_local_address1_ { <nl> + Network : : Utility : : resolveUrl ( " tcp : / / 10 . 0 . 0 . 5 : 10211 " ) } ; <nl> + Network : : Address : : InstanceConstSharedPtr upstream_local_address2_ { <nl> + Network : : Utility : : resolveUrl ( " tcp : / / 10 . 0 . 0 . 5 : 10212 " ) } ; <nl> Event : : MockTimer * response_timeout_ { } ; <nl> Event : : MockTimer * per_try_timeout_ { } ; <nl> <nl> TEST_F ( RouterUpstreamLogTest , LogSingleTry ) { <nl> run ( ) ; <nl> <nl> EXPECT_EQ ( output_ . size ( ) , 1U ) ; <nl> - EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 - - \ n " ) ; <nl> + EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 10 . 0 . 0 . 5 : 10211 - - \ n " ) ; <nl> } <nl> <nl> TEST_F ( RouterUpstreamLogTest , LogRetries ) { <nl> TEST_F ( RouterUpstreamLogTest , LogRetries ) { <nl> runWithRetry ( ) ; <nl> <nl> EXPECT_EQ ( output_ . size ( ) , 2U ) ; <nl> - EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 0 UT 0 0 host 10 . 0 . 0 . 5 : 9211 - - \ n " ) ; <nl> - EXPECT_EQ ( output_ . back ( ) , " GET / HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 - - \ n " ) ; <nl> + EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 0 UT 0 0 host 10 . 0 . 0 . 5 : 9211 10 . 0 . 0 . 5 : 10211 - - \ n " ) ; <nl> + EXPECT_EQ ( output_ . back ( ) , " GET / HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 10 . 0 . 0 . 5 : 10212 - - \ n " ) ; <nl> } <nl> <nl> TEST_F ( RouterUpstreamLogTest , LogFailure ) { <nl> TEST_F ( RouterUpstreamLogTest , LogFailure ) { <nl> run ( 503 , { } , { } , { } ) ; <nl> <nl> EXPECT_EQ ( output_ . size ( ) , 1U ) ; <nl> - EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 503 - 0 0 host 10 . 0 . 0 . 5 : 9211 - - \ n " ) ; <nl> + EXPECT_EQ ( output_ . front ( ) , " GET / HTTP / 1 . 0 503 - 0 0 host 10 . 0 . 0 . 5 : 9211 10 . 0 . 0 . 5 : 10211 - - \ n " ) ; <nl> } <nl> <nl> TEST_F ( RouterUpstreamLogTest , LogHeaders ) { <nl> TEST_F ( RouterUpstreamLogTest , LogHeaders ) { <nl> { { " x - trailer " , " value " } } ) ; <nl> <nl> EXPECT_EQ ( output_ . size ( ) , 1U ) ; <nl> - EXPECT_EQ ( output_ . front ( ) , " GET / foo HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 abcdef value \ n " ) ; <nl> + EXPECT_EQ ( output_ . front ( ) , <nl> + " GET / foo HTTP / 1 . 0 200 - 0 0 host 10 . 0 . 0 . 5 : 9211 10 . 0 . 0 . 5 : 10211 abcdef value \ n " ) ; <nl> } <nl> <nl> / / Test timestamps and durations are emitted . <nl> mmm a / test / fuzz / common . proto <nl> ppp b / test / fuzz / common . proto <nl> message StreamInfo { <nl> envoy . api . v2 . core . Metadata upstream_metadata = 4 ; <nl> string requested_server_name = 5 ; <nl> envoy . api . v2 . core . Address address = 6 ; <nl> + envoy . api . v2 . core . Address upstream_local_address = 7 ; <nl> } <nl> mmm a / test / fuzz / utility . h <nl> ppp b / test / fuzz / utility . h <nl> inline TestStreamInfo fromStreamInfo ( const test : : fuzz : : StreamInfo & stream_info ) <nl> auto address = stream_info . has_address ( ) <nl> ? Envoy : : Network : : Address : : resolveProtoAddress ( stream_info . address ( ) ) <nl> : Network : : Utility : : resolveUrl ( " tcp : / / 10 . 0 . 0 . 1 : 443 " ) ; <nl> - test_stream_info . upstream_local_address_ = address ; <nl> + auto upstream_local_address = <nl> + stream_info . has_upstream_local_address ( ) <nl> + ? Envoy : : Network : : Address : : resolveProtoAddress ( stream_info . upstream_local_address ( ) ) <nl> + : Network : : Utility : : resolveUrl ( " tcp : / / 10 . 0 . 0 . 1 : 10000 " ) ; <nl> + test_stream_info . upstream_local_address_ = upstream_local_address ; <nl> test_stream_info . downstream_local_address_ = address ; <nl> test_stream_info . downstream_direct_remote_address_ = address ; <nl> test_stream_info . downstream_remote_address_ = address ; <nl> mmm a / test / integration / integration_test . cc <nl> ppp b / test / integration / integration_test . cc <nl> TEST_P ( IntegrationTest , TestBind ) { <nl> address_string = " : : 1 " ; <nl> } <nl> config_helper_ . setSourceAddress ( address_string ) ; <nl> + useAccessLog ( " % UPSTREAM_LOCAL_ADDRESS % \ n " ) ; <nl> initialize ( ) ; <nl> <nl> codec_client_ = makeHttpConnection ( lookupPort ( " http " ) ) ; <nl> TEST_P ( IntegrationTest , TestBind ) { <nl> ASSERT_TRUE ( upstream_request_ - > waitForEndStream ( * dispatcher_ ) ) ; <nl> <nl> cleanupUpstreamAndDownstream ( ) ; <nl> + EXPECT_THAT ( waitForAccessLog ( access_log_name_ ) , HasSubstr ( address_string ) ) ; <nl> } <nl> <nl> TEST_P ( IntegrationTest , TestFailedBind ) { <nl> mmm a / test / mocks / http / stream . cc <nl> ppp b / test / mocks / http / stream . cc <nl> <nl> <nl> using testing : : _ ; <nl> using testing : : Invoke ; <nl> + using testing : : ReturnRef ; <nl> <nl> namespace Envoy { <nl> namespace Http { <nl> MockStream : : MockStream ( ) { <nl> callbacks - > onResetStream ( reason , absl : : string_view ( ) ) ; <nl> } <nl> } ) ) ; <nl> + <nl> + ON_CALL ( * this , connectionLocalAddress ( ) ) . WillByDefault ( ReturnRef ( connection_local_address_ ) ) ; <nl> } <nl> <nl> MockStream : : ~ MockStream ( ) = default ; <nl> mmm a / test / mocks / http / stream . h <nl> ppp b / test / mocks / http / stream . h <nl> class MockStream : public Stream { <nl> MOCK_METHOD1 ( readDisable , void ( bool disable ) ) ; <nl> MOCK_METHOD2 ( setWriteBufferWatermarks , void ( uint32_t , uint32_t ) ) ; <nl> MOCK_METHOD0 ( bufferLimit , uint32_t ( ) ) ; <nl> + MOCK_METHOD0 ( connectionLocalAddress , const Network : : Address : : InstanceConstSharedPtr & ( ) ) ; <nl> <nl> std : : list < StreamCallbacks * > callbacks_ { } ; <nl> + Network : : Address : : InstanceConstSharedPtr connection_local_address_ ; <nl> <nl> void runHighWatermarkCallbacks ( ) { <nl> for ( auto * callback : callbacks_ ) { <nl>
|
Make % UPSTREAM_LOCAL_ADDRESS % access - log format work for HTTP requests . ( )
|
envoyproxy/envoy
|
9ad469da374642c88d001cd6945d60e79537de30
|
2019-12-20T17:44:50Z
|
mmm a / xbmc / utils / SystemInfo . cpp <nl> ppp b / xbmc / utils / SystemInfo . cpp <nl> std : : string CSysInfo : : GetUserAgent ( ) <nl> StringUtils : : Replace ( OSXVersion , ' . ' , ' _ ' ) ; <nl> result + = OSXVersion ; <nl> # endif <nl> + # elif defined ( TARGET_ANDROID ) <nl> + result + = " Linux ; Android " ; <nl> + std : : string versionStr ( GetAndroidVersionString ( ) ) ; <nl> + const size_t verLen = versionStr . length ( ) ; <nl> + if ( verLen > = 2 & & versionStr . compare ( verLen - 2 , 2 , " . 0 " , 2 ) = = 0 ) <nl> + versionStr . erase ( verLen - 2 ) ; / / remove last " . 0 " if any <nl> + result + = versionStr ; <nl> + std : : string deviceInfo ( GetAndroidDeviceName ( ) ) ; <nl> + <nl> + char buildId [ PROP_VALUE_MAX ] ; <nl> + int propLen = __system_property_get ( " ro . build . id " , buildId ) ; <nl> + if ( propLen > 0 & & propLen < = PROP_VALUE_MAX ) <nl> + { <nl> + if ( ! deviceInfo . empty ( ) ) <nl> + deviceInfo + = " " ; <nl> + deviceInfo + = " Build / " ; <nl> + deviceInfo . append ( buildId , propLen ) ; <nl> + } <nl> + <nl> + if ( ! deviceInfo . empty ( ) ) <nl> + result + = " ; " + deviceInfo ; <nl> # elif defined ( TARGET_FREEBSD ) <nl> result + = " FreeBSD ; " ; <nl> result + = GetUnameVersion ( ) ; <nl>
|
SysInfo : : GetUserAgent : fix Android UserAgent string
|
xbmc/xbmc
|
582ef8b8ad343276fd44eb254bdb5659f5a31872
|
2014-05-19T20:14:25Z
|
mmm a / hphp / hack / hhi / collections / Map . hhi <nl> ppp b / hphp / hack / hhi / collections / Map . hhi <nl> final class Map < Tk , Tv > implements MutableMap < Tk , Tv > { <nl> / * * <nl> * Returns a Map containing the key / value pairs from the specified array . <nl> * / <nl> - public static function fromArray ( array $ arr ) : Map < Tk , Tv > ; <nl> + public static function fromArray ( array < Tk , Tv > $ arr ) : Map < Tk , Tv > ; <nl> <nl> public static function fromItems ( ? Traversable < Pair < Tk , Tv > > $ items ) <nl> : Map < Tk , Tv > ; <nl>
|
Add generics to Map : : fromArray
|
facebook/hhvm
|
31a88e85fb00206a883cfc8c5b78000d9c32dd0b
|
2015-04-20T02:00:45Z
|
mmm a / php / ext / google / protobuf / def . c <nl> ppp b / php / ext / google / protobuf / def . c <nl> static zend_function_entry descriptor_methods [ ] = { <nl> DEFINE_CLASS ( Descriptor , descriptor , " Google \ \ Protobuf \ \ Descriptor " ) ; <nl> <nl> static void descriptor_free_c ( Descriptor * self TSRMLS_DC ) { <nl> - if ( self - > layout ) { <nl> - free_layout ( self - > layout ) ; <nl> - } <nl> } <nl> <nl> static void descriptor_init_c_instance ( Descriptor * desc TSRMLS_DC ) { <nl> - desc - > msgdef = NULL ; <nl> - desc - > layout = NULL ; <nl> - desc - > klass = NULL ; <nl> + desc - > intern = NULL ; <nl> } <nl> <nl> PHP_METHOD ( Descriptor , getClass ) { <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> # if PHP_MAJOR_VERSION < 7 <nl> const char * classname = intern - > klass - > name ; <nl> # else <nl> PHP_METHOD ( Descriptor , getClass ) { <nl> } <nl> <nl> PHP_METHOD ( Descriptor , getFullName ) { <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> const char * fullname = upb_msgdef_fullname ( intern - > msgdef ) ; <nl> PHP_PROTO_RETVAL_STRINGL ( fullname , strlen ( fullname ) , 1 ) ; <nl> } <nl> PHP_METHOD ( Descriptor , getField ) { <nl> return ; <nl> } <nl> <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> int field_num = upb_msgdef_numfields ( intern - > msgdef ) ; <nl> if ( index < 0 | | index > = field_num ) { <nl> zend_error ( E_USER_ERROR , " Cannot get element at % ld . \ n " , index ) ; <nl> PHP_METHOD ( Descriptor , getField ) { <nl> } <nl> <nl> PHP_METHOD ( Descriptor , getFieldCount ) { <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> RETURN_LONG ( upb_msgdef_numfields ( intern - > msgdef ) ) ; <nl> } <nl> <nl> PHP_METHOD ( Descriptor , getOneofDecl ) { <nl> return ; <nl> } <nl> <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> int field_num = upb_msgdef_numoneofs ( intern - > msgdef ) ; <nl> if ( index < 0 | | index > = field_num ) { <nl> zend_error ( E_USER_ERROR , " Cannot get element at % ld . \ n " , index ) ; <nl> PHP_METHOD ( Descriptor , getOneofDecl ) { <nl> } <nl> <nl> PHP_METHOD ( Descriptor , getOneofDeclCount ) { <nl> - Descriptor * intern = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + Descriptor * desc = UNBOX ( Descriptor , getThis ( ) ) ; <nl> + DescriptorInternal * intern = desc - > intern ; <nl> RETURN_LONG ( upb_msgdef_numoneofs ( intern - > msgdef ) ) ; <nl> } <nl> <nl> static void enum_descriptor_free_c ( EnumDescriptor * self TSRMLS_DC ) { <nl> } <nl> <nl> static void enum_descriptor_init_c_instance ( EnumDescriptor * self TSRMLS_DC ) { <nl> - self - > enumdef = NULL ; <nl> - self - > klass = NULL ; <nl> + self - > intern = NULL ; <nl> } <nl> <nl> PHP_METHOD ( EnumDescriptor , getValue ) { <nl> PHP_METHOD ( EnumDescriptor , getValue ) { <nl> return ; <nl> } <nl> <nl> - EnumDescriptor * intern = UNBOX ( EnumDescriptor , getThis ( ) ) ; <nl> + EnumDescriptor * desc = UNBOX ( EnumDescriptor , getThis ( ) ) ; <nl> + EnumDescriptorInternal * intern = desc - > intern ; <nl> int field_num = upb_enumdef_numvals ( intern - > enumdef ) ; <nl> if ( index < 0 | | index > = field_num ) { <nl> zend_error ( E_USER_ERROR , " Cannot get element at % ld . \ n " , index ) ; <nl> PHP_METHOD ( EnumDescriptor , getValue ) { <nl> } <nl> <nl> PHP_METHOD ( EnumDescriptor , getValueCount ) { <nl> - EnumDescriptor * intern = UNBOX ( EnumDescriptor , getThis ( ) ) ; <nl> + EnumDescriptor * desc = UNBOX ( EnumDescriptor , getThis ( ) ) ; <nl> + EnumDescriptorInternal * intern = desc - > intern ; <nl> RETURN_LONG ( upb_enumdef_numvals ( intern - > enumdef ) ) ; <nl> } <nl> <nl> PHP_METHOD ( FieldDescriptor , getEnumType ) { <nl> return ; <nl> } <nl> const upb_enumdef * enumdef = upb_fielddef_enumsubdef ( intern - > fielddef ) ; <nl> - PHP_PROTO_HASHTABLE_VALUE desc = get_def_obj ( enumdef ) ; <nl> + PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj ( enumdef ) ; <nl> + <nl> + if ( desc_php = = NULL ) { <nl> + EnumDescriptorInternal * intern = get_enumdef_enumdesc ( enumdef ) ; <nl> <nl> # if PHP_MAJOR_VERSION < 7 <nl> - RETURN_ZVAL ( desc , 1 , 0 ) ; <nl> + MAKE_STD_ZVAL ( desc_php ) ; <nl> + ZVAL_OBJ ( desc_php , enum_descriptor_type - > create_object ( <nl> + enum_descriptor_type TSRMLS_CC ) ) ; <nl> + Z_DELREF_P ( desc_php ) ; <nl> # else <nl> - GC_ADDREF ( desc ) ; <nl> - RETURN_OBJ ( desc ) ; <nl> + desc_php = <nl> + enum_descriptor_type - > create_object ( enum_descriptor_type TSRMLS_CC ) ; <nl> + GC_DELREF ( desc_php ) ; <nl> + # endif <nl> + EnumDescriptor * desc = UNBOX_HASHTABLE_VALUE ( EnumDescriptor , desc_php ) ; <nl> + desc - > intern = intern ; <nl> + add_def_obj ( enumdef , desc_php ) ; <nl> + add_ce_obj ( intern - > klass , desc_php ) ; <nl> + } <nl> + <nl> + # if PHP_MAJOR_VERSION < 7 <nl> + RETURN_ZVAL ( desc_php , 1 , 0 ) ; <nl> + # else <nl> + GC_ADDREF ( desc_php ) ; <nl> + RETURN_OBJ ( desc_php ) ; <nl> # endif <nl> } <nl> <nl> PHP_METHOD ( FieldDescriptor , getMessageType ) { <nl> return ; <nl> } <nl> const upb_msgdef * msgdef = upb_fielddef_msgsubdef ( intern - > fielddef ) ; <nl> - PHP_PROTO_HASHTABLE_VALUE desc = get_def_obj ( msgdef ) ; <nl> + PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj ( msgdef ) ; <nl> + <nl> + if ( desc_php = = NULL ) { <nl> + DescriptorInternal * intern = get_msgdef_desc ( msgdef ) ; <nl> + <nl> + # if PHP_MAJOR_VERSION < 7 <nl> + MAKE_STD_ZVAL ( desc_php ) ; <nl> + ZVAL_OBJ ( desc_php , descriptor_type - > create_object ( <nl> + descriptor_type TSRMLS_CC ) ) ; <nl> + Z_DELREF_P ( desc_php ) ; <nl> + # else <nl> + desc_php = <nl> + descriptor_type - > create_object ( descriptor_type TSRMLS_CC ) ; <nl> + GC_DELREF ( desc_php ) ; <nl> + # endif <nl> + Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , desc_php ) ; <nl> + desc - > intern = intern ; <nl> + add_def_obj ( msgdef , desc_php ) ; <nl> + add_ce_obj ( intern - > klass , desc_php ) ; <nl> + } <nl> <nl> # if PHP_MAJOR_VERSION < 7 <nl> - RETURN_ZVAL ( desc , 1 , 0 ) ; <nl> + RETURN_ZVAL ( desc_php , 1 , 0 ) ; <nl> # else <nl> - GC_ADDREF ( desc ) ; <nl> - RETURN_OBJ ( desc ) ; <nl> + GC_ADDREF ( desc_php ) ; <nl> + RETURN_OBJ ( desc_php ) ; <nl> # endif <nl> } <nl> <nl> zval * internal_generated_pool_php ; <nl> zend_object * generated_pool_php ; <nl> zend_object * internal_generated_pool_php ; <nl> # endif <nl> - InternalDescriptorPool * generated_pool ; / / The actual generated pool <nl> + InternalDescriptorPoolImpl * generated_pool ; <nl> + InternalDescriptorPoolImpl generated_pool_impl ; / / The actual generated pool <nl> <nl> void init_generated_pool_once ( TSRMLS_D ) { <nl> if ( generated_pool = = NULL ) { <nl> void init_generated_pool_once ( TSRMLS_D ) { <nl> ZVAL_OBJ ( internal_generated_pool_php , <nl> internal_descriptor_pool_type - > create_object ( <nl> internal_descriptor_pool_type TSRMLS_CC ) ) ; <nl> - generated_pool = UNBOX ( InternalDescriptorPool , internal_generated_pool_php ) ; <nl> ZVAL_OBJ ( generated_pool_php , descriptor_pool_type - > create_object ( <nl> descriptor_pool_type TSRMLS_CC ) ) ; <nl> # else <nl> internal_generated_pool_php = internal_descriptor_pool_type - > create_object ( <nl> internal_descriptor_pool_type TSRMLS_CC ) ; <nl> - generated_pool = ( InternalDescriptorPool * ) ( ( char * ) internal_generated_pool_php - <nl> - XtOffsetOf ( InternalDescriptorPool , std ) ) ; <nl> generated_pool_php = <nl> descriptor_pool_type - > create_object ( descriptor_pool_type TSRMLS_CC ) ; <nl> # endif <nl> + generated_pool = & generated_pool_impl ; <nl> } <nl> } <nl> <nl> static void internal_descriptor_pool_init_c_instance ( <nl> InternalDescriptorPool * pool TSRMLS_DC ) { <nl> + pool - > intern = & generated_pool_impl ; <nl> + } <nl> + <nl> + static void internal_descriptor_pool_free_c ( <nl> + InternalDescriptorPool * pool TSRMLS_DC ) { <nl> + } <nl> + <nl> + void internal_descriptor_pool_impl_init ( <nl> + InternalDescriptorPoolImpl * pool TSRMLS_DC ) { <nl> pool - > symtab = upb_symtab_new ( ) ; <nl> pool - > fill_handler_cache = <nl> upb_handlercache_new ( add_handlers_for_message , NULL ) ; <nl> static void internal_descriptor_pool_init_c_instance ( <nl> pool - > json_fill_method_cache = upb_json_codecache_new ( ) ; <nl> } <nl> <nl> - static void internal_descriptor_pool_free_c ( <nl> - InternalDescriptorPool * pool TSRMLS_DC ) { <nl> + void internal_descriptor_pool_impl_destroy ( <nl> + InternalDescriptorPoolImpl * pool TSRMLS_DC ) { <nl> upb_symtab_free ( pool - > symtab ) ; <nl> upb_handlercache_free ( pool - > fill_handler_cache ) ; <nl> upb_handlercache_free ( pool - > pb_serialize_handler_cache ) ; <nl> static void fill_classname ( const char * fullname , <nl> static zend_class_entry * register_class ( const upb_filedef * file , <nl> const char * fullname , <nl> PHP_PROTO_HASHTABLE_VALUE desc_php , <nl> - bool use_nested_submsg TSRMLS_DC ) { <nl> + bool use_nested_submsg , <nl> + bool is_enum TSRMLS_DC ) { <nl> / / Prepend ' . ' to package name to make it absolute . In the 5 additional <nl> / / bytes allocated , one for ' . ' , one for trailing 0 , and 3 for ' GPB ' if <nl> / / given message is google . protobuf . Empty . <nl> static zend_class_entry * register_class ( const upb_filedef * file , <nl> } <nl> ret = PHP_PROTO_CE_UNREF ( pce ) ; <nl> add_ce_obj ( ret , desc_php ) ; <nl> - add_proto_obj ( fullname , desc_php ) ; <nl> + if ( is_enum ) { <nl> + EnumDescriptor * desc = UNBOX_HASHTABLE_VALUE ( EnumDescriptor , desc_php ) ; <nl> + add_ce_enumdesc ( ret , desc - > intern ) ; <nl> + add_proto_enumdesc ( fullname , desc - > intern ) ; <nl> + } else { <nl> + Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , desc_php ) ; <nl> + add_ce_desc ( ret , desc - > intern ) ; <nl> + add_proto_desc ( fullname , desc - > intern ) ; <nl> + } <nl> stringsink_uninit ( & namesink ) ; <nl> return ret ; <nl> } <nl> bool depends_on_descriptor ( const google_protobuf_FileDescriptorProto * file ) { <nl> <nl> const upb_filedef * parse_and_add_descriptor ( const char * data , <nl> PHP_PROTO_SIZE data_len , <nl> - InternalDescriptorPool * pool , <nl> + InternalDescriptorPoolImpl * pool , <nl> upb_arena * arena ) { <nl> size_t n ; <nl> google_protobuf_FileDescriptorSet * set ; <nl> const upb_filedef * parse_and_add_descriptor ( const char * data , <nl> <nl> if ( ! set ) { <nl> zend_error ( E_ERROR , " Failed to parse binary descriptor \ n " ) ; <nl> - return false ; <nl> + return NULL ; <nl> } <nl> <nl> files = google_protobuf_FileDescriptorSet_file ( set , & n ) ; <nl> <nl> if ( n ! = 1 ) { <nl> zend_error ( E_ERROR , " Serialized descriptors should have exactly one file " ) ; <nl> - return false ; <nl> + return NULL ; <nl> + } <nl> + <nl> + / / Check whether file has already been added . <nl> + upb_strview name = google_protobuf_FileDescriptorProto_name ( files [ 0 ] ) ; <nl> + / / TODO ( teboring ) : Needs another look up method which takes data and length . <nl> + file = upb_symtab_lookupfile2 ( pool - > symtab , name . data , name . size ) ; <nl> + if ( file ! = NULL ) { <nl> + return NULL ; <nl> } <nl> <nl> / / The PHP code generator currently special - cases descriptor . proto . It <nl> const upb_filedef * parse_and_add_descriptor ( const char * data , <nl> NULL ) { <nl> if ( ! parse_and_add_descriptor ( ( char * ) descriptor_proto , <nl> descriptor_proto_len , pool , arena ) ) { <nl> - return false ; <nl> + return NULL ; <nl> } <nl> } <nl> <nl> const upb_filedef * parse_and_add_descriptor ( const char * data , <nl> } <nl> <nl> void internal_add_generated_file ( const char * data , PHP_PROTO_SIZE data_len , <nl> - InternalDescriptorPool * pool , <nl> + InternalDescriptorPoolImpl * pool , <nl> bool use_nested_submsg TSRMLS_DC ) { <nl> int i ; <nl> upb_arena * arena ; <nl> void internal_add_generated_file ( const char * data , PHP_PROTO_SIZE data_len , <nl> for ( i = 0 ; i < upb_filedef_msgcount ( file ) ; i + + ) { <nl> const upb_msgdef * msgdef = upb_filedef_msg ( file , i ) ; <nl> CREATE_HASHTABLE_VALUE ( desc , desc_php , Descriptor , descriptor_type ) ; <nl> - desc - > msgdef = msgdef ; <nl> - desc - > pool = pool ; <nl> - add_def_obj ( desc - > msgdef , desc_php ) ; <nl> + desc - > intern = SYS_MALLOC ( DescriptorInternal ) ; <nl> + desc - > intern - > msgdef = msgdef ; <nl> + desc - > intern - > pool = pool ; <nl> + desc - > intern - > layout = NULL ; <nl> + desc - > intern - > klass = NULL ; <nl> + <nl> + add_def_obj ( desc - > intern - > msgdef , desc_php ) ; <nl> + add_msgdef_desc ( desc - > intern - > msgdef , desc - > intern ) ; <nl> <nl> / / Unlike other messages , MapEntry is shared by all map fields and doesn ' t <nl> / / have generated PHP class . <nl> void internal_add_generated_file ( const char * data , PHP_PROTO_SIZE data_len , <nl> continue ; <nl> } <nl> <nl> - desc - > klass = register_class ( file , upb_msgdef_fullname ( msgdef ) , desc_php , <nl> - use_nested_submsg TSRMLS_CC ) ; <nl> + desc - > intern - > klass = <nl> + register_class ( file , upb_msgdef_fullname ( msgdef ) , desc_php , <nl> + use_nested_submsg , false TSRMLS_CC ) ; <nl> <nl> - if ( desc - > klass = = NULL ) { <nl> + if ( desc - > intern - > klass = = NULL ) { <nl> return ; <nl> } <nl> <nl> void internal_add_generated_file ( const char * data , PHP_PROTO_SIZE data_len , <nl> for ( i = 0 ; i < upb_filedef_enumcount ( file ) ; i + + ) { <nl> const upb_enumdef * enumdef = upb_filedef_enum ( file , i ) ; <nl> CREATE_HASHTABLE_VALUE ( desc , desc_php , EnumDescriptor , enum_descriptor_type ) ; <nl> - desc - > enumdef = enumdef ; <nl> - add_def_obj ( desc - > enumdef , desc_php ) ; <nl> - desc - > klass = register_class ( file , upb_enumdef_fullname ( enumdef ) , desc_php , <nl> - use_nested_submsg TSRMLS_CC ) ; <nl> + desc - > intern = SYS_MALLOC ( EnumDescriptorInternal ) ; <nl> + desc - > intern - > enumdef = enumdef ; <nl> + desc - > intern - > klass = NULL ; <nl> + <nl> + add_def_obj ( desc - > intern - > enumdef , desc_php ) ; <nl> + add_enumdef_enumdesc ( desc - > intern - > enumdef , desc - > intern ) ; <nl> + desc - > intern - > klass = <nl> + register_class ( file , upb_enumdef_fullname ( enumdef ) , desc_php , <nl> + use_nested_submsg , true TSRMLS_CC ) ; <nl> <nl> - if ( desc - > klass = = NULL ) { <nl> + if ( desc - > intern - > klass = = NULL ) { <nl> return ; <nl> } <nl> } <nl> PHP_METHOD ( InternalDescriptorPool , internalAddGeneratedFile ) { <nl> } <nl> <nl> InternalDescriptorPool * pool = UNBOX ( InternalDescriptorPool , getThis ( ) ) ; <nl> - internal_add_generated_file ( data , data_len , pool , <nl> + internal_add_generated_file ( data , data_len , pool - > intern , <nl> use_nested_submsg TSRMLS_CC ) ; <nl> } <nl> <nl> PHP_METHOD ( DescriptorPool , getDescriptorByClassName ) { <nl> - DescriptorPool * public_pool = UNBOX ( DescriptorPool , getThis ( ) ) ; <nl> - InternalDescriptorPool * pool = public_pool - > intern ; <nl> - <nl> char * classname = NULL ; <nl> PHP_PROTO_SIZE classname_len ; <nl> <nl> PHP_METHOD ( DescriptorPool , getDescriptorByClassName ) { <nl> RETURN_NULL ( ) ; <nl> } <nl> <nl> - PHP_PROTO_HASHTABLE_VALUE desc = get_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> - if ( desc = = NULL ) { <nl> - RETURN_NULL ( ) ; <nl> + PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> + if ( desc_php = = NULL ) { <nl> + DescriptorInternal * intern = get_ce_desc ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> + if ( intern = = NULL ) { <nl> + RETURN_NULL ( ) ; <nl> + } <nl> + <nl> + # if PHP_MAJOR_VERSION < 7 <nl> + MAKE_STD_ZVAL ( desc_php ) ; <nl> + ZVAL_OBJ ( desc_php , descriptor_type - > create_object ( <nl> + descriptor_type TSRMLS_CC ) ) ; <nl> + Z_DELREF_P ( desc_php ) ; <nl> + # else <nl> + desc_php = <nl> + descriptor_type - > create_object ( descriptor_type TSRMLS_CC ) ; <nl> + GC_DELREF ( desc_php ) ; <nl> + # endif <nl> + Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , desc_php ) ; <nl> + desc - > intern = intern ; <nl> + add_def_obj ( intern - > msgdef , desc_php ) ; <nl> + add_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) , desc_php ) ; <nl> } <nl> <nl> - zend_class_entry * instance_ce = HASHTABLE_VALUE_CE ( desc ) ; <nl> + zend_class_entry * instance_ce = HASHTABLE_VALUE_CE ( desc_php ) ; <nl> <nl> if ( ! instanceof_function ( instance_ce , descriptor_type TSRMLS_CC ) ) { <nl> RETURN_NULL ( ) ; <nl> } <nl> <nl> # if PHP_MAJOR_VERSION < 7 <nl> - RETURN_ZVAL ( desc , 1 , 0 ) ; <nl> + RETURN_ZVAL ( desc_php , 1 , 0 ) ; <nl> # else <nl> - GC_ADDREF ( desc ) ; <nl> - RETURN_OBJ ( desc ) ; <nl> + GC_ADDREF ( desc_php ) ; <nl> + RETURN_OBJ ( desc_php ) ; <nl> # endif <nl> } <nl> <nl> PHP_METHOD ( DescriptorPool , getEnumDescriptorByClassName ) { <nl> - DescriptorPool * public_pool = UNBOX ( DescriptorPool , getThis ( ) ) ; <nl> - InternalDescriptorPool * pool = public_pool - > intern ; <nl> - <nl> char * classname = NULL ; <nl> PHP_PROTO_SIZE classname_len ; <nl> <nl> PHP_METHOD ( DescriptorPool , getEnumDescriptorByClassName ) { <nl> RETURN_NULL ( ) ; <nl> } <nl> <nl> - PHP_PROTO_HASHTABLE_VALUE desc = get_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> - if ( desc = = NULL ) { <nl> - RETURN_NULL ( ) ; <nl> + PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> + if ( desc_php = = NULL ) { <nl> + EnumDescriptorInternal * intern = get_ce_enumdesc ( PHP_PROTO_CE_UNREF ( pce ) ) ; <nl> + if ( intern = = NULL ) { <nl> + RETURN_NULL ( ) ; <nl> + } <nl> + <nl> + # if PHP_MAJOR_VERSION < 7 <nl> + MAKE_STD_ZVAL ( desc_php ) ; <nl> + ZVAL_OBJ ( desc_php , enum_descriptor_type - > create_object ( <nl> + enum_descriptor_type TSRMLS_CC ) ) ; <nl> + Z_DELREF_P ( desc_php ) ; <nl> + # else <nl> + desc_php = <nl> + enum_descriptor_type - > create_object ( enum_descriptor_type TSRMLS_CC ) ; <nl> + GC_DELREF ( desc_php ) ; <nl> + # endif <nl> + EnumDescriptor * desc = UNBOX_HASHTABLE_VALUE ( EnumDescriptor , desc_php ) ; <nl> + desc - > intern = intern ; <nl> + add_def_obj ( intern - > enumdef , desc_php ) ; <nl> + add_ce_obj ( PHP_PROTO_CE_UNREF ( pce ) , desc_php ) ; <nl> } <nl> <nl> - zend_class_entry * instance_ce = HASHTABLE_VALUE_CE ( desc ) ; <nl> + zend_class_entry * instance_ce = HASHTABLE_VALUE_CE ( desc_php ) ; <nl> <nl> if ( ! instanceof_function ( instance_ce , enum_descriptor_type TSRMLS_CC ) ) { <nl> RETURN_NULL ( ) ; <nl> } <nl> <nl> # if PHP_MAJOR_VERSION < 7 <nl> - RETURN_ZVAL ( desc , 1 , 0 ) ; <nl> + RETURN_ZVAL ( desc_php , 1 , 0 ) ; <nl> # else <nl> - GC_ADDREF ( desc ) ; <nl> - RETURN_OBJ ( desc ) ; <nl> + GC_ADDREF ( desc_php ) ; <nl> + RETURN_OBJ ( desc_php ) ; <nl> # endif <nl> } <nl> mmm a / php / ext / google / protobuf / encode_decode . c <nl> ppp b / php / ext / google / protobuf / encode_decode . c <nl> static void * appendsubmsg_handler ( void * closure , const void * hd ) { <nl> RepeatedField * intern = UNBOX ( RepeatedField , array ) ; <nl> <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> MessageHeader * submsg ; <nl> <nl> static void * appendwrappersubmsg_handler ( void * closure , const void * hd ) { <nl> RepeatedField * intern = UNBOX ( RepeatedField , array ) ; <nl> <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> MessageHeader * submsg ; <nl> wrapperfields_parseframe_t * frame = <nl> static void * submsg_handler ( void * closure , const void * hd ) { <nl> MessageHeader * msg = closure ; <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> zval * submsg_php ; <nl> MessageHeader * submsg ; <nl> static void * map_submsg_handler ( void * closure , const void * hd ) { <nl> MessageHeader * msg = closure ; <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> zval * submsg_php ; <nl> MessageHeader * submsg ; <nl> static void * map_wrapper_submsg_handler ( void * closure , const void * hd ) { <nl> MessageHeader * msg = closure ; <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> zval * submsg_php ; <nl> MessageHeader * submsg ; <nl> static void map_slot_init ( <nl> break ; <nl> } <nl> case UPB_TYPE_MESSAGE : { <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( value_msg ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( value_msg ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> MessageHeader * submsg ; <nl> # if PHP_MAJOR_VERSION < 7 <nl> static bool endmap_handler ( void * closure , const void * hd , upb_status * s ) { <nl> / / pass the handlerdata down to the sub - message handler setup . <nl> static map_handlerdata_t * new_map_handlerdata ( <nl> const upb_fielddef * field , <nl> - const upb_msgdef * mapentry_def , <nl> - Descriptor * desc ) { <nl> + const upb_msgdef * mapentry_def ) { <nl> const upb_fielddef * key_field ; <nl> const upb_fielddef * value_field ; <nl> / / TODO ( teboring ) : Use emalloc and efree . <nl> static void * oneofsubmsg_handler ( void * closure , const void * hd ) { <nl> const oneof_handlerdata_t * oneofdata = hd ; <nl> uint32_t oldcase = DEREF ( message_data ( msg ) , oneofdata - > case_ofs , uint32_t ) ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) oneofdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( oneofdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> zval * submsg_php ; <nl> MessageHeader * submsg ; <nl> static void * wrapper_submsg_handler ( void * closure , const void * hd ) { <nl> MessageHeader * msg = closure ; <nl> const submsg_handlerdata_t * submsgdata = hd ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) submsgdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> zval * submsg_php ; <nl> MessageHeader * submsg ; <nl> static void * wrapper_oneofsubmsg_handler ( void * closure , const void * hd ) { <nl> const oneof_handlerdata_t * oneofdata = hd ; <nl> uint32_t oldcase = DEREF ( message_data ( msg ) , oneofdata - > case_ofs , uint32_t ) ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) oneofdata - > md ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( oneofdata - > md ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> wrapperfields_parseframe_t * frame = <nl> ( wrapperfields_parseframe_t * ) malloc ( sizeof ( wrapperfields_parseframe_t ) ) ; <nl> static void add_handlers_for_singular_field ( upb_handlers * h , <nl> / / Adds handlers to a map field . <nl> static void add_handlers_for_mapfield ( upb_handlers * h , <nl> const upb_fielddef * fielddef , <nl> - size_t offset , <nl> - Descriptor * desc ) { <nl> + size_t offset ) { <nl> const upb_msgdef * map_msgdef = upb_fielddef_msgsubdef ( fielddef ) ; <nl> - map_handlerdata_t * hd = new_map_handlerdata ( fielddef , map_msgdef , desc ) ; <nl> + map_handlerdata_t * hd = new_map_handlerdata ( fielddef , map_msgdef ) ; <nl> upb_handlerattr attr = UPB_HANDLERATTR_INIT ; <nl> <nl> upb_handlers_addcleanup ( h , hd , free ) ; <nl> static void add_handlers_for_mapfield ( upb_handlers * h , <nl> } <nl> <nl> / / Adds handlers to a map - entry msgdef . <nl> - static void add_handlers_for_mapentry ( const upb_msgdef * msgdef , upb_handlers * h , <nl> - Descriptor * desc ) { <nl> + static void add_handlers_for_mapentry ( <nl> + const upb_msgdef * msgdef , upb_handlers * h ) { <nl> const upb_fielddef * key_field = map_entry_key ( msgdef ) ; <nl> const upb_fielddef * value_field = map_entry_value ( msgdef ) ; <nl> - map_handlerdata_t * hd = new_map_handlerdata ( 0 , msgdef , desc ) ; <nl> + map_handlerdata_t * hd = new_map_handlerdata ( 0 , msgdef ) ; <nl> upb_handlerattr attr = UPB_HANDLERATTR_INIT ; <nl> <nl> upb_handlers_addcleanup ( h , hd , free ) ; <nl> static bool strwrapper_end_handler ( void * closure , const void * hd ) { <nl> static void add_handlers_for_wrapper ( const upb_msgdef * msgdef , <nl> upb_handlers * h ) { <nl> const upb_fielddef * f = upb_msgdef_itof ( msgdef , 1 ) ; <nl> - Descriptor * desc ; <nl> + DescriptorInternal * desc ; <nl> size_t offset ; <nl> <nl> TSRMLS_FETCH ( ) ; <nl> - desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) msgdef ) ) ; <nl> + desc = get_msgdef_desc ( msgdef ) ; <nl> offset = desc - > layout - > fields [ upb_fielddef_index ( f ) ] . offset ; <nl> <nl> switch ( upb_msgdef_wellknowntype ( msgdef ) ) { <nl> static bool add_unknown_handler ( void * closure , const void * hd , const char * buf , <nl> void add_handlers_for_message ( const void * closure , upb_handlers * h ) { <nl> const upb_msgdef * msgdef = upb_handlers_msgdef ( h ) ; <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) msgdef ) ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( msgdef ) ; <nl> upb_msg_field_iter i ; <nl> <nl> / / If this is a mapentry message type , set up a special set of handlers and <nl> / / bail out of the normal ( user - defined ) message type handling . <nl> if ( upb_msgdef_mapentry ( msgdef ) ) { <nl> - add_handlers_for_mapentry ( msgdef , h , desc ) ; <nl> + add_handlers_for_mapentry ( msgdef , h ) ; <nl> return ; <nl> } <nl> <nl> void add_handlers_for_message ( const void * closure , upb_handlers * h ) { <nl> add_handlers_for_oneof_field ( h , desc - > msgdef , f , offset , <nl> oneof_case_offset , property_cache_index ) ; <nl> } else if ( is_map_field ( f ) ) { <nl> - add_handlers_for_mapfield ( h , f , offset , desc ) ; <nl> + add_handlers_for_mapfield ( h , f , offset ) ; <nl> } else if ( upb_fielddef_isseq ( f ) ) { <nl> add_handlers_for_repeated_field ( h , f , offset ) ; <nl> } else { <nl> void add_handlers_for_message ( const void * closure , upb_handlers * h ) { <nl> <nl> / / Constructs the handlers for filling a message ' s data into an in - memory <nl> / / object . <nl> - const upb_handlers * get_fill_handlers ( Descriptor * desc ) { <nl> + const upb_handlers * get_fill_handlers ( DescriptorInternal * desc ) { <nl> return upb_handlercache_get ( desc - > pool - > fill_handler_cache , desc - > msgdef ) ; <nl> } <nl> <nl> - static const upb_pbdecodermethod * msgdef_decodermethod ( Descriptor * desc ) { <nl> + static const upb_pbdecodermethod * msgdef_decodermethod ( DescriptorInternal * desc ) { <nl> return upb_pbcodecache_get ( desc - > pool - > fill_method_cache , desc - > msgdef ) ; <nl> } <nl> <nl> - static const upb_json_parsermethod * msgdef_jsonparsermethod ( Descriptor * desc ) { <nl> + static const upb_json_parsermethod * msgdef_jsonparsermethod ( DescriptorInternal * desc ) { <nl> return upb_json_codecache_get ( desc - > pool - > json_fill_method_cache , desc - > msgdef ) ; <nl> } <nl> <nl> static const upb_json_parsermethod * msgdef_jsonparsermethod ( Descriptor * desc ) { <nl> / / Serializing . <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - static void putmsg ( zval * msg , const Descriptor * desc , upb_sink sink , <nl> + static void putmsg ( zval * msg , const DescriptorInternal * desc , upb_sink sink , <nl> int depth , bool is_json TSRMLS_DC ) ; <nl> - static void putrawmsg ( MessageHeader * msg , const Descriptor * desc , <nl> + static void putrawmsg ( MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth , bool is_json , <nl> bool open_msg TSRMLS_DC ) ; <nl> static void putwrappervalue ( <nl> zval * value , const upb_fielddef * f , <nl> upb_sink sink , int depth , bool is_json TSRMLS_DC ) ; <nl> - static void putjsonany ( MessageHeader * msg , const Descriptor * desc , <nl> + static void putjsonany ( MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) ; <nl> static void putjsonlistvalue ( <nl> - MessageHeader * msg , const Descriptor * desc , <nl> + MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) ; <nl> static void putjsonstruct ( <nl> - MessageHeader * msg , const Descriptor * desc , <nl> + MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) ; <nl> <nl> static void putstr ( zval * str , const upb_fielddef * f , upb_sink sink , <nl> static void putmap ( zval * map , const upb_fielddef * f , upb_sink sink , <nl> upb_sink_endseq ( sink , getsel ( f , UPB_HANDLER_ENDSEQ ) ) ; <nl> } <nl> <nl> - static void putmsg ( zval * msg_php , const Descriptor * desc , upb_sink sink , <nl> + static void putmsg ( zval * msg_php , const DescriptorInternal * desc , upb_sink sink , <nl> int depth , bool is_json TSRMLS_DC ) { <nl> MessageHeader * msg = UNBOX ( MessageHeader , msg_php ) ; <nl> putrawmsg ( msg , desc , sink , depth , is_json , true TSRMLS_CC ) ; <nl> } <nl> <nl> static const upb_handlers * msgdef_json_serialize_handlers ( <nl> - Descriptor * desc , bool preserve_proto_fieldnames ) ; <nl> + DescriptorInternal * desc , bool preserve_proto_fieldnames ) ; <nl> <nl> - static void putjsonany ( MessageHeader * msg , const Descriptor * desc , <nl> + static void putjsonany ( MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) { <nl> upb_status status ; <nl> const upb_fielddef * type_field = upb_msgdef_itof ( desc - > msgdef , UPB_ANY_TYPE ) ; <nl> static void putjsonany ( MessageHeader * msg , const Descriptor * desc , <nl> value_len = Z_STRLEN_P ( value_php_str ) ; <nl> <nl> if ( value_len > 0 ) { <nl> - Descriptor * payload_desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( ( void * ) payload_type ) ) ; <nl> + DescriptorInternal * payload_desc = get_msgdef_desc ( payload_type ) ; <nl> zend_class_entry * payload_klass = payload_desc - > klass ; <nl> zval val ; <nl> upb_sink subsink ; <nl> static void putjsonany ( MessageHeader * msg , const Descriptor * desc , <nl> } <nl> <nl> static void putjsonlistvalue ( <nl> - MessageHeader * msg , const Descriptor * desc , <nl> + MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) { <nl> upb_status status ; <nl> upb_sink subsink ; <nl> static void putjsonlistvalue ( <nl> } <nl> <nl> static void putjsonstruct ( <nl> - MessageHeader * msg , const Descriptor * desc , <nl> + MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth TSRMLS_DC ) { <nl> upb_status status ; <nl> upb_sink subsink ; <nl> static void putjsonstruct ( <nl> upb_sink_endmsg ( sink , & status ) ; <nl> } <nl> <nl> - static void putrawmsg ( MessageHeader * msg , const Descriptor * desc , <nl> + static void putrawmsg ( MessageHeader * msg , const DescriptorInternal * desc , <nl> upb_sink sink , int depth , bool is_json , <nl> bool open_msg TSRMLS_DC ) { <nl> upb_msg_field_iter i ; <nl> static void putrawsubmsg ( MessageHeader * submsg , const upb_fielddef * f , <nl> upb_sink sink , int depth , bool is_json TSRMLS_DC ) { <nl> upb_sink subsink ; <nl> <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( upb_fielddef_msgsubdef ( f ) ) ) ; <nl> + const upb_msgdef * m = upb_fielddef_msgsubdef ( f ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( m ) ; <nl> <nl> upb_sink_startsubmsg ( sink , getsel ( f , UPB_HANDLER_STARTSUBMSG ) , & subsink ) ; <nl> putrawmsg ( submsg , subdesc , subsink , depth + 1 , is_json , true TSRMLS_CC ) ; <nl> static void putarray ( zval * array , const upb_fielddef * f , upb_sink sink , <nl> upb_sink_endseq ( sink , getsel ( f , UPB_HANDLER_ENDSEQ ) ) ; <nl> } <nl> <nl> - static const upb_handlers * msgdef_pb_serialize_handlers ( Descriptor * desc ) { <nl> + static const upb_handlers * msgdef_pb_serialize_handlers ( DescriptorInternal * desc ) { <nl> return upb_handlercache_get ( desc - > pool - > pb_serialize_handler_cache , <nl> desc - > msgdef ) ; <nl> } <nl> <nl> static const upb_handlers * msgdef_json_serialize_handlers ( <nl> - Descriptor * desc , bool preserve_proto_fieldnames ) { <nl> + DescriptorInternal * desc , bool preserve_proto_fieldnames ) { <nl> if ( preserve_proto_fieldnames ) { <nl> return upb_handlercache_get ( <nl> desc - > pool - > json_serialize_handler_preserve_cache , desc - > msgdef ) ; <nl> static const upb_handlers * msgdef_json_serialize_handlers ( <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> void serialize_to_string ( zval * val , zval * return_value TSRMLS_DC ) { <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( Z_OBJCE_P ( val ) ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( Z_OBJCE_P ( val ) ) ; <nl> <nl> stringsink sink ; <nl> stringsink_init ( & sink ) ; <nl> PHP_METHOD ( Message , serializeToString ) { <nl> serialize_to_string ( getThis ( ) , return_value TSRMLS_CC ) ; <nl> } <nl> <nl> - void merge_from_string ( const char * data , int data_len , Descriptor * desc , <nl> + void merge_from_string ( const char * data , int data_len , DescriptorInternal * desc , <nl> MessageHeader * msg ) { <nl> const upb_pbdecodermethod * method = msgdef_decodermethod ( desc ) ; <nl> const upb_handlers * h = upb_pbdecodermethod_desthandlers ( method ) ; <nl> void merge_from_string ( const char * data , int data_len , Descriptor * desc , <nl> } <nl> <nl> PHP_METHOD ( Message , mergeFromString ) { <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( Z_OBJCE_P ( getThis ( ) ) ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( Z_OBJCE_P ( getThis ( ) ) ) ; <nl> MessageHeader * msg = UNBOX ( MessageHeader , getThis ( ) ) ; <nl> <nl> char * data = NULL ; <nl> PHP_METHOD ( Message , mergeFromString ) { <nl> } <nl> <nl> PHP_METHOD ( Message , serializeToJsonString ) { <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( Z_OBJCE_P ( getThis ( ) ) ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( Z_OBJCE_P ( getThis ( ) ) ) ; <nl> <nl> zend_bool preserve_proto_fieldnames = false ; <nl> if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " | b " , <nl> PHP_METHOD ( Message , serializeToJsonString ) { <nl> } <nl> <nl> PHP_METHOD ( Message , mergeFromJsonString ) { <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( Z_OBJCE_P ( getThis ( ) ) ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( Z_OBJCE_P ( getThis ( ) ) ) ; <nl> MessageHeader * msg = UNBOX ( MessageHeader , getThis ( ) ) ; <nl> <nl> char * data = NULL ; <nl> static void discard_unknown_fields ( MessageHeader * msg ) { <nl> } <nl> <nl> / / Recursively discard unknown fields of submessages . <nl> - Descriptor * desc = msg - > descriptor ; <nl> + DescriptorInternal * desc = msg - > descriptor ; <nl> TSRMLS_FETCH ( ) ; <nl> for ( upb_msg_field_begin ( & it , desc - > msgdef ) ; <nl> ! upb_msg_field_done ( & it ) ; <nl> mmm a / php / ext / google / protobuf / message . c <nl> ppp b / php / ext / google / protobuf / message . c <nl> void * message_data ( MessageHeader * msg ) { <nl> <nl> void custom_data_init ( const zend_class_entry * ce , <nl> MessageHeader * intern PHP_PROTO_TSRMLS_DC ) { <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( ce ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( ce ) ; <nl> intern - > data = ALLOC_N ( uint8_t , desc - > layout - > size ) ; <nl> / / We wrap first so that everything in the message object is GC - rooted in <nl> / / case a collection happens during object creation in layout_init ( ) . <nl> void build_class_from_descriptor ( <nl> Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , php_descriptor ) ; <nl> <nl> / / Map entries don ' t have existing php class . <nl> - if ( upb_msgdef_mapentry ( desc - > msgdef ) ) { <nl> + if ( upb_msgdef_mapentry ( desc - > intern - > msgdef ) ) { <nl> return ; <nl> } <nl> <nl> - zend_class_entry * registered_ce = desc - > klass ; <nl> + zend_class_entry * registered_ce = desc - > intern - > klass ; <nl> <nl> - if ( desc - > layout = = NULL ) { <nl> - MessageLayout * layout = create_layout ( desc - > msgdef ) ; <nl> - desc - > layout = layout ; <nl> + if ( desc - > intern - > layout = = NULL ) { <nl> + MessageLayout * layout = create_layout ( desc - > intern - > msgdef ) ; <nl> + desc - > intern - > layout = layout ; <nl> } <nl> <nl> registered_ce - > create_object = message_create ; <nl> void Message_construct ( zval * msg , zval * array_wrapper ) { <nl> is_wrapper = is_wrapper_msg ( submsgdef ) ; <nl> <nl> if ( is_wrapper ) { <nl> - PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj ( submsgdef ) ; <nl> - Descriptor * subdesc = UNBOX_HASHTABLE_VALUE ( Descriptor , subdesc_php ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdef ) ; <nl> subklass = subdesc - > klass ; <nl> } <nl> } <nl> void Message_construct ( zval * msg , zval * array_wrapper ) { <nl> is_wrapper = is_wrapper_msg ( submsgdef ) ; <nl> <nl> if ( is_wrapper ) { <nl> - PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj ( submsgdef ) ; <nl> - Descriptor * subdesc = UNBOX_HASHTABLE_VALUE ( Descriptor , subdesc_php ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdef ) ; <nl> subklass = subdesc - > klass ; <nl> } <nl> } <nl> void Message_construct ( zval * msg , zval * array_wrapper ) { <nl> } <nl> } else if ( upb_fielddef_issubmsg ( field ) ) { <nl> const upb_msgdef * submsgdef = upb_fielddef_msgsubdef ( field ) ; <nl> - PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj ( submsgdef ) ; <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , desc_php ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( submsgdef ) ; <nl> <nl> CACHED_VALUE * cached = NULL ; <nl> if ( upb_fielddef_containingoneof ( field ) ) { <nl> PHP_METHOD ( Message , __construct ) { <nl> <nl> PHP_METHOD ( Message , clear ) { <nl> MessageHeader * msg = UNBOX ( MessageHeader , getThis ( ) ) ; <nl> - Descriptor * desc = msg - > descriptor ; <nl> + DescriptorInternal * desc = msg - > descriptor ; <nl> zend_class_entry * ce = desc - > klass ; <nl> <nl> zend_object_std_dtor ( & msg - > std TSRMLS_CC ) ; <nl> PHP_METHOD ( Any , unpack ) { <nl> } <nl> <nl> const char * fully_qualified_name = type_url + url_prefix_len ; <nl> - PHP_PROTO_HASHTABLE_VALUE desc_php = get_proto_obj ( fully_qualified_name ) ; <nl> - if ( desc_php = = NULL ) { <nl> + DescriptorInternal * desc = get_proto_desc ( fully_qualified_name ) ; <nl> + if ( desc = = NULL ) { <nl> zend_throw_exception ( <nl> NULL , " Specified message in any hasn ' t been added to descriptor pool " , <nl> 0 TSRMLS_CC ) ; <nl> return ; <nl> } <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , desc_php ) ; <nl> zend_class_entry * klass = desc - > klass ; <nl> ZVAL_OBJ ( return_value , klass - > create_object ( klass TSRMLS_CC ) ) ; <nl> MessageHeader * msg = UNBOX ( MessageHeader , return_value ) ; <nl> PHP_METHOD ( Any , pack ) { <nl> PHP_PROTO_FAKE_SCOPE_END ; <nl> <nl> / / Set type url . <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( Z_OBJCE_P ( val ) ) ) ; <nl> + DescriptorInternal * desc = get_ce_desc ( Z_OBJCE_P ( val ) ) ; <nl> const char * fully_qualified_name = upb_msgdef_fullname ( desc - > msgdef ) ; <nl> size_t type_url_len = <nl> strlen ( TYPE_URL_PREFIX ) + strlen ( fully_qualified_name ) + 1 ; <nl> PHP_METHOD ( Any , is ) { <nl> return ; <nl> } <nl> <nl> - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj ( klass ) ; <nl> - if ( desc_php = = NULL ) { <nl> + DescriptorInternal * desc = get_ce_desc ( klass ) ; <nl> + if ( desc = = NULL ) { <nl> RETURN_BOOL ( false ) ; <nl> } <nl> <nl> / / Create corresponded type url . <nl> - Descriptor * desc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_ce_obj ( klass ) ) ; <nl> const char * fully_qualified_name = upb_msgdef_fullname ( desc - > msgdef ) ; <nl> size_t type_url_len = <nl> strlen ( TYPE_URL_PREFIX ) + strlen ( fully_qualified_name ) + 1 ; <nl> mmm a / php / ext / google / protobuf / protobuf . c <nl> ppp b / php / ext / google / protobuf / protobuf . c <nl> <nl> <nl> # include < zend_hash . h > <nl> <nl> - ZEND_DECLARE_MODULE_GLOBALS ( protobuf ) <nl> static PHP_GINIT_FUNCTION ( protobuf ) ; <nl> static PHP_GSHUTDOWN_FUNCTION ( protobuf ) ; <nl> static PHP_RINIT_FUNCTION ( protobuf ) ; <nl> static PHP_MSHUTDOWN_FUNCTION ( protobuf ) ; <nl> / / Global map from upb { msg , enum } defs to wrapper Descriptor / EnumDescriptor <nl> / / instances . <nl> static HashTable * upb_def_to_php_obj_map ; <nl> + static upb_inttable upb_def_to_desc_map_persistent ; <nl> + static upb_inttable upb_def_to_enumdesc_map_persistent ; <nl> / / Global map from message / enum ' s php class entry to corresponding wrapper <nl> / / Descriptor / EnumDescriptor instances . <nl> static HashTable * ce_to_php_obj_map ; <nl> + static upb_inttable ce_to_desc_map_persistent ; <nl> + static upb_inttable ce_to_enumdesc_map_persistent ; <nl> / / Global map from message / enum ' s proto fully - qualified name to corresponding <nl> / / wrapper Descriptor / EnumDescriptor instances . <nl> - static HashTable * proto_to_php_obj_map ; <nl> - static HashTable * reserved_names ; <nl> + static upb_strtable proto_to_desc_map_persistent ; <nl> + static upb_strtable proto_to_enumdesc_map_persistent ; <nl> + <nl> + upb_strtable reserved_names ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Global maps . <nl> static bool exist_in_table ( const HashTable * t , const void * def ) { <nl> ( void * * ) & value ) = = SUCCESS ) ; <nl> } <nl> <nl> - static void add_to_list ( HashTable * t , void * value ) { <nl> - zval * pDest = NULL ; <nl> - php_proto_zend_hash_next_index_insert_mem ( t , & value , sizeof ( void * ) , <nl> - ( void * * ) & pDest ) ; <nl> - } <nl> - <nl> static void add_to_strtable ( HashTable * t , const char * key , int key_size , <nl> void * value ) { <nl> zval * pDest = NULL ; <nl> PHP_PROTO_HASHTABLE_VALUE get_def_obj ( const void * def ) { <nl> return ( PHP_PROTO_HASHTABLE_VALUE ) get_from_table ( upb_def_to_php_obj_map , def ) ; <nl> } <nl> <nl> + void add_msgdef_desc ( const upb_msgdef * m , DescriptorInternal * desc ) { <nl> + upb_inttable_insertptr ( & upb_def_to_desc_map_persistent , <nl> + m , upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + DescriptorInternal * get_msgdef_desc ( const upb_msgdef * m ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> + # endif <nl> + if ( ! upb_inttable_lookupptr ( & upb_def_to_desc_map_persistent , m , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> + } <nl> + <nl> + void add_enumdef_enumdesc ( const upb_enumdef * e , EnumDescriptorInternal * desc ) { <nl> + upb_inttable_insertptr ( & upb_def_to_enumdesc_map_persistent , <nl> + e , upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + EnumDescriptorInternal * get_enumdef_enumdesc ( const upb_enumdef * e ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> + # endif <nl> + if ( ! upb_inttable_lookupptr ( & upb_def_to_enumdesc_map_persistent , e , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> + } <nl> + <nl> void add_ce_obj ( const void * ce , PHP_PROTO_HASHTABLE_VALUE value ) { <nl> # if PHP_MAJOR_VERSION < 7 <nl> Z_ADDREF_P ( value ) ; <nl> PHP_PROTO_HASHTABLE_VALUE get_ce_obj ( const void * ce ) { <nl> return ( PHP_PROTO_HASHTABLE_VALUE ) get_from_table ( ce_to_php_obj_map , ce ) ; <nl> } <nl> <nl> + void add_ce_desc ( const zend_class_entry * ce , DescriptorInternal * desc ) { <nl> + upb_inttable_insertptr ( & ce_to_desc_map_persistent , <nl> + ce , upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + DescriptorInternal * get_ce_desc ( const zend_class_entry * ce ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> + # endif <nl> + if ( ! upb_inttable_lookupptr ( & ce_to_desc_map_persistent , ce , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> + } <nl> + <nl> + void add_ce_enumdesc ( const zend_class_entry * ce , EnumDescriptorInternal * desc ) { <nl> + upb_inttable_insertptr ( & ce_to_enumdesc_map_persistent , <nl> + ce , upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + EnumDescriptorInternal * get_ce_enumdesc ( const zend_class_entry * ce ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> + # endif <nl> + if ( ! upb_inttable_lookupptr ( & ce_to_enumdesc_map_persistent , ce , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> + } <nl> + <nl> bool class_added ( const void * ce ) { <nl> return exist_in_table ( ce_to_php_obj_map , ce ) ; <nl> } <nl> <nl> - void add_proto_obj ( const char * proto , PHP_PROTO_HASHTABLE_VALUE value ) { <nl> - # if PHP_MAJOR_VERSION < 7 <nl> - Z_ADDREF_P ( value ) ; <nl> - # else <nl> - GC_ADDREF ( value ) ; <nl> + void add_proto_desc ( const char * proto , DescriptorInternal * desc ) { <nl> + upb_strtable_insert ( & proto_to_desc_map_persistent , proto , <nl> + upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + DescriptorInternal * get_proto_desc ( const char * proto ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> # endif <nl> - add_to_strtable ( proto_to_php_obj_map , proto , strlen ( proto ) , value ) ; <nl> + if ( ! upb_strtable_lookup ( & proto_to_desc_map_persistent , proto , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> } <nl> <nl> - PHP_PROTO_HASHTABLE_VALUE get_proto_obj ( const char * proto ) { <nl> - return ( PHP_PROTO_HASHTABLE_VALUE ) get_from_strtable ( proto_to_php_obj_map , <nl> - proto , strlen ( proto ) ) ; <nl> + void add_proto_enumdesc ( const char * proto , EnumDescriptorInternal * desc ) { <nl> + upb_strtable_insert2 ( & proto_to_enumdesc_map_persistent , proto , <nl> + strlen ( proto ) , upb_value_ptr ( desc ) ) ; <nl> + } <nl> + <nl> + EnumDescriptorInternal * get_proto_enumdesc ( const char * proto ) { <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_PTR ; <nl> + # endif <nl> + if ( ! upb_strtable_lookupptr ( & proto_to_enumdesc_map_persistent , <nl> + proto , strlen ( proto ) , & v ) ) { <nl> + return NULL ; <nl> + } else { <nl> + return upb_value_getptr ( v ) ; <nl> + } <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> const char * const kReservedNames [ ] = { <nl> const int kReservedNamesSize = 73 ; <nl> <nl> bool is_reserved_name ( const char * name ) { <nl> - void * * value ; <nl> - return ( php_proto_zend_hash_find ( reserved_names , name , strlen ( name ) , <nl> - ( void * * ) & value ) = = SUCCESS ) ; <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_UINT64 ; <nl> + # endif <nl> + return upb_strtable_lookup2 ( & reserved_names , name , strlen ( name ) , & v ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> static void php_proto_hashtable_descriptor_release ( zval * value ) { <nl> } <nl> efree ( ptr ) ; <nl> } <nl> - # endif <nl> - <nl> - static PHP_RINIT_FUNCTION ( protobuf ) { <nl> - int i = 0 ; <nl> - <nl> - ALLOC_HASHTABLE ( upb_def_to_php_obj_map ) ; <nl> - zend_hash_init ( upb_def_to_php_obj_map , 16 , NULL , HASHTABLE_VALUE_DTOR , 0 ) ; <nl> <nl> - ALLOC_HASHTABLE ( ce_to_php_obj_map ) ; <nl> - zend_hash_init ( ce_to_php_obj_map , 16 , NULL , HASHTABLE_VALUE_DTOR , 0 ) ; <nl> + static void test_release ( void * value ) { <nl> + void * ptr = value ; <nl> + } <nl> + # endif <nl> <nl> - ALLOC_HASHTABLE ( proto_to_php_obj_map ) ; <nl> - zend_hash_init ( proto_to_php_obj_map , 16 , NULL , HASHTABLE_VALUE_DTOR , 0 ) ; <nl> + static initialize_persistent_descriptor_pool ( TSRMLS_D ) { <nl> + upb_inttable_init ( & upb_def_to_desc_map_persistent , UPB_CTYPE_PTR ) ; <nl> + upb_inttable_init ( & upb_def_to_enumdesc_map_persistent , UPB_CTYPE_PTR ) ; <nl> + upb_inttable_init ( & ce_to_desc_map_persistent , UPB_CTYPE_PTR ) ; <nl> + upb_inttable_init ( & ce_to_enumdesc_map_persistent , UPB_CTYPE_PTR ) ; <nl> + upb_strtable_init ( & proto_to_desc_map_persistent , UPB_CTYPE_PTR ) ; <nl> + upb_strtable_init ( & proto_to_enumdesc_map_persistent , UPB_CTYPE_PTR ) ; <nl> <nl> - ALLOC_HASHTABLE ( reserved_names ) ; <nl> - zend_hash_init ( reserved_names , 16 , NULL , NULL , 0 ) ; <nl> - for ( i = 0 ; i < kReservedNamesSize ; i + + ) { <nl> - php_proto_zend_hash_update ( reserved_names , kReservedNames [ i ] , <nl> - strlen ( kReservedNames [ i ] ) ) ; <nl> - } <nl> - <nl> - generated_pool = NULL ; <nl> - generated_pool_php = NULL ; <nl> - internal_generated_pool_php = NULL ; <nl> + internal_descriptor_pool_impl_init ( & generated_pool_impl TSRMLS_CC ) ; <nl> <nl> is_inited_file_any = false ; <nl> is_inited_file_api = false ; <nl> static PHP_RINIT_FUNCTION ( protobuf ) { <nl> is_inited_file_timestamp = false ; <nl> is_inited_file_type = false ; <nl> is_inited_file_wrappers = false ; <nl> + } <nl> + <nl> + static PHP_RINIT_FUNCTION ( protobuf ) { <nl> + ALLOC_HASHTABLE ( upb_def_to_php_obj_map ) ; <nl> + zend_hash_init ( upb_def_to_php_obj_map , 16 , NULL , HASHTABLE_VALUE_DTOR , 0 ) ; <nl> + <nl> + ALLOC_HASHTABLE ( ce_to_php_obj_map ) ; <nl> + zend_hash_init ( ce_to_php_obj_map , 16 , NULL , HASHTABLE_VALUE_DTOR , 0 ) ; <nl> + <nl> + generated_pool = NULL ; <nl> + generated_pool_php = NULL ; <nl> + internal_generated_pool_php = NULL ; <nl> + <nl> + if ( ! PROTOBUF_G ( keep_descriptor_pool_after_request ) ) { <nl> + initialize_persistent_descriptor_pool ( TSRMLS_C ) ; <nl> + } <nl> <nl> return 0 ; <nl> } <nl> <nl> + static void cleanup_desc_table ( upb_inttable * t ) { <nl> + upb_inttable_iter i ; <nl> + upb_value v ; <nl> + DescriptorInternal * desc ; <nl> + for ( upb_inttable_begin ( & i , t ) ; <nl> + ! upb_inttable_done ( & i ) ; <nl> + upb_inttable_next ( & i ) ) { <nl> + v = upb_inttable_iter_value ( & i ) ; <nl> + desc = upb_value_getptr ( v ) ; <nl> + if ( desc - > layout ) { <nl> + free_layout ( desc - > layout ) ; <nl> + } <nl> + SYS_FREE ( desc ) ; <nl> + } <nl> + } <nl> + <nl> + static void cleanup_enumdesc_table ( upb_inttable * t ) { <nl> + upb_inttable_iter i ; <nl> + upb_value v ; <nl> + EnumDescriptorInternal * desc ; <nl> + for ( upb_inttable_begin ( & i , t ) ; <nl> + ! upb_inttable_done ( & i ) ; <nl> + upb_inttable_next ( & i ) ) { <nl> + v = upb_inttable_iter_value ( & i ) ; <nl> + desc = upb_value_getptr ( v ) ; <nl> + SYS_FREE ( desc ) ; <nl> + } <nl> + } <nl> + <nl> + static cleanup_persistent_descriptor_pool ( TSRMLS_D ) { <nl> + / / Clean up <nl> + <nl> + / / Only needs to clean one map out of three ( def = > desc , ce = > desc , proto = > desc ) <nl> + cleanup_desc_table ( & upb_def_to_desc_map_persistent ) ; <nl> + cleanup_enumdesc_table ( & upb_def_to_enumdesc_map_persistent ) ; <nl> + <nl> + internal_descriptor_pool_impl_destroy ( & generated_pool_impl TSRMLS_CC ) ; <nl> + <nl> + upb_inttable_uninit ( & upb_def_to_desc_map_persistent ) ; <nl> + upb_inttable_uninit ( & upb_def_to_enumdesc_map_persistent ) ; <nl> + upb_inttable_uninit ( & ce_to_desc_map_persistent ) ; <nl> + upb_inttable_uninit ( & ce_to_enumdesc_map_persistent ) ; <nl> + upb_strtable_uninit ( & proto_to_desc_map_persistent ) ; <nl> + upb_strtable_uninit ( & proto_to_enumdesc_map_persistent ) ; <nl> + } <nl> + <nl> static PHP_RSHUTDOWN_FUNCTION ( protobuf ) { <nl> zend_hash_destroy ( upb_def_to_php_obj_map ) ; <nl> FREE_HASHTABLE ( upb_def_to_php_obj_map ) ; <nl> static PHP_RSHUTDOWN_FUNCTION ( protobuf ) { <nl> zend_hash_destroy ( ce_to_php_obj_map ) ; <nl> FREE_HASHTABLE ( ce_to_php_obj_map ) ; <nl> <nl> - zend_hash_destroy ( proto_to_php_obj_map ) ; <nl> - FREE_HASHTABLE ( proto_to_php_obj_map ) ; <nl> - <nl> - zend_hash_destroy ( reserved_names ) ; <nl> - FREE_HASHTABLE ( reserved_names ) ; <nl> - <nl> # if PHP_MAJOR_VERSION < 7 <nl> if ( generated_pool_php ! = NULL ) { <nl> zval_dtor ( generated_pool_php ) ; <nl> static PHP_RSHUTDOWN_FUNCTION ( protobuf ) { <nl> } <nl> # endif <nl> <nl> - is_inited_file_any = true ; <nl> - is_inited_file_api = true ; <nl> - is_inited_file_duration = true ; <nl> - is_inited_file_field_mask = true ; <nl> - is_inited_file_empty = true ; <nl> - is_inited_file_source_context = true ; <nl> - is_inited_file_struct = true ; <nl> - is_inited_file_timestamp = true ; <nl> - is_inited_file_type = true ; <nl> - is_inited_file_wrappers = true ; <nl> + if ( ! PROTOBUF_G ( keep_descriptor_pool_after_request ) ) { <nl> + cleanup_persistent_descriptor_pool ( TSRMLS_C ) ; <nl> + } <nl> <nl> return 0 ; <nl> } <nl> <nl> + static void reserved_names_init ( ) { <nl> + size_t i ; <nl> + upb_value v ; <nl> + # ifndef NDEBUG <nl> + v . ctype = UPB_CTYPE_UINT64 ; <nl> + # endif <nl> + for ( i = 0 ; i < kReservedNamesSize ; i + + ) { <nl> + upb_strtable_insert2 ( & reserved_names , kReservedNames [ i ] , <nl> + strlen ( kReservedNames [ i ] ) , v ) ; <nl> + } <nl> + } <nl> + <nl> + PHP_INI_BEGIN ( ) <nl> + STD_PHP_INI_ENTRY ( " protobuf . keep_descriptor_pool_after_request " , " 0 " , <nl> + PHP_INI_SYSTEM , OnUpdateBool , <nl> + keep_descriptor_pool_after_request , zend_protobuf_globals , <nl> + protobuf_globals ) <nl> + PHP_INI_END ( ) <nl> + <nl> static PHP_MINIT_FUNCTION ( protobuf ) { <nl> + REGISTER_INI_ENTRIES ( ) ; <nl> + <nl> + upb_strtable_init ( & reserved_names , UPB_CTYPE_UINT64 ) ; <nl> + reserved_names_init ( ) ; <nl> + <nl> + if ( PROTOBUF_G ( keep_descriptor_pool_after_request ) ) { <nl> + initialize_persistent_descriptor_pool ( TSRMLS_C ) ; <nl> + } <nl> + <nl> descriptor_pool_init ( TSRMLS_C ) ; <nl> descriptor_init ( TSRMLS_C ) ; <nl> enum_descriptor_init ( TSRMLS_C ) ; <nl> static PHP_MINIT_FUNCTION ( protobuf ) { <nl> } <nl> <nl> static PHP_MSHUTDOWN_FUNCTION ( protobuf ) { <nl> + if ( PROTOBUF_G ( keep_descriptor_pool_after_request ) ) { <nl> + cleanup_persistent_descriptor_pool ( TSRMLS_C ) ; <nl> + } <nl> + <nl> + upb_strtable_uninit ( & reserved_names ) ; <nl> + <nl> PEFREE ( message_handlers ) ; <nl> PEFREE ( repeated_field_handlers ) ; <nl> PEFREE ( repeated_field_iter_handlers ) ; <nl> mmm a / php / ext / google / protobuf / protobuf . h <nl> ppp b / php / ext / google / protobuf / protobuf . h <nl> <nl> LOWWERNAME # # _methods ) ; \ <nl> LOWWERNAME # # _type = zend_register_internal_class ( & class_type TSRMLS_CC ) ; \ <nl> LOWWERNAME # # _type - > create_object = LOWWERNAME # # _create ; \ <nl> - LOWWERNAME # # _handlers = PEMALLOC ( zend_object_handlers ) ; \ <nl> + LOWWERNAME # # _handlers = PEMALLOC ( zend_object_handlers , 1 ) ; \ <nl> memcpy ( LOWWERNAME # # _handlers , zend_get_std_object_handlers ( ) , \ <nl> sizeof ( zend_object_handlers ) ) ; <nl> # define PHP_PROTO_INIT_CLASS_END \ <nl> static inline int php_proto_zend_hash_get_current_data_ex ( HashTable * ht , <nl> LOWWERNAME # # _methods ) ; \ <nl> LOWWERNAME # # _type = zend_register_internal_class ( & class_type TSRMLS_CC ) ; \ <nl> LOWWERNAME # # _type - > create_object = LOWWERNAME # # _create ; \ <nl> - LOWWERNAME # # _handlers = PEMALLOC ( zend_object_handlers ) ; \ <nl> + LOWWERNAME # # _handlers = PEMALLOC ( zend_object_handlers , 1 ) ; \ <nl> memcpy ( LOWWERNAME # # _handlers , zend_get_std_object_handlers ( ) , \ <nl> sizeof ( zend_object_handlers ) ) ; \ <nl> LOWWERNAME # # _handlers - > free_obj = LOWWERNAME # # _free ; \ <nl> struct Api ; <nl> struct BoolValue ; <nl> struct BytesValue ; <nl> struct Descriptor ; <nl> + struct DescriptorInternal ; <nl> struct DescriptorPool ; <nl> struct DoubleValue ; <nl> struct Duration ; <nl> struct Enum ; <nl> struct EnumDescriptor ; <nl> + struct EnumDescriptorInternal ; <nl> struct EnumValue ; <nl> struct EnumValueDescriptor ; <nl> struct Field ; <nl> struct GPBEmpty ; <nl> struct Int32Value ; <nl> struct Int64Value ; <nl> struct InternalDescriptorPool ; <nl> + struct InternalDescriptorPoolImpl ; <nl> struct ListValue ; <nl> struct Map ; <nl> struct MapIter ; <nl> typedef struct Api Api ; <nl> typedef struct BoolValue BoolValue ; <nl> typedef struct BytesValue BytesValue ; <nl> typedef struct Descriptor Descriptor ; <nl> + typedef struct DescriptorInternal DescriptorInternal ; <nl> typedef struct DescriptorPool DescriptorPool ; <nl> typedef struct DoubleValue DoubleValue ; <nl> typedef struct Duration Duration ; <nl> typedef struct EnumDescriptor EnumDescriptor ; <nl> + typedef struct EnumDescriptorInternal EnumDescriptorInternal ; <nl> typedef struct Enum Enum ; <nl> typedef struct EnumValueDescriptor EnumValueDescriptor ; <nl> typedef struct EnumValue EnumValue ; <nl> typedef struct GPBEmpty GPBEmpty ; <nl> typedef struct Int32Value Int32Value ; <nl> typedef struct Int64Value Int64Value ; <nl> typedef struct InternalDescriptorPool InternalDescriptorPool ; <nl> + typedef struct InternalDescriptorPoolImpl InternalDescriptorPoolImpl ; <nl> typedef struct ListValue ListValue ; <nl> typedef struct MapIter MapIter ; <nl> typedef struct Map Map ; <nl> typedef struct Value Value ; <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> ZEND_BEGIN_MODULE_GLOBALS ( protobuf ) <nl> + zend_bool keep_descriptor_pool_after_request ; <nl> ZEND_END_MODULE_GLOBALS ( protobuf ) <nl> <nl> + ZEND_DECLARE_MODULE_GLOBALS ( protobuf ) <nl> + <nl> + # ifdef ZTS <nl> + # define PROTOBUF_G ( v ) TSRMG ( protobuf_globals_id , zend_protobuf_globals * , v ) <nl> + # else <nl> + # define PROTOBUF_G ( v ) ( protobuf_globals . v ) <nl> + # endif <nl> + <nl> / / Init module and PHP classes . <nl> void any_init ( TSRMLS_D ) ; <nl> void api_init ( TSRMLS_D ) ; <nl> void gpb_metadata_wrappers_init ( TSRMLS_D ) ; <nl> / / instances . <nl> void add_def_obj ( const void * def , PHP_PROTO_HASHTABLE_VALUE value ) ; <nl> PHP_PROTO_HASHTABLE_VALUE get_def_obj ( const void * def ) ; <nl> + void add_msgdef_desc ( const upb_msgdef * m , DescriptorInternal * desc ) ; <nl> + DescriptorInternal * get_msgdef_desc ( const upb_msgdef * m ) ; <nl> + void add_enumdef_enumdesc ( const upb_enumdef * e , EnumDescriptorInternal * desc ) ; <nl> + EnumDescriptorInternal * get_enumdef_enumdesc ( const upb_enumdef * e ) ; <nl> <nl> / / Global map from PHP class entries to wrapper Descriptor / EnumDescriptor <nl> / / instances . <nl> void add_ce_obj ( const void * ce , PHP_PROTO_HASHTABLE_VALUE value ) ; <nl> PHP_PROTO_HASHTABLE_VALUE get_ce_obj ( const void * ce ) ; <nl> bool class_added ( const void * ce ) ; <nl> + void add_ce_desc ( const zend_class_entry * ce , DescriptorInternal * desc ) ; <nl> + DescriptorInternal * get_ce_desc ( const zend_class_entry * ce ) ; <nl> + void add_ce_enumdesc ( const zend_class_entry * ce , EnumDescriptorInternal * desc ) ; <nl> + EnumDescriptorInternal * get_ce_enumdesc ( const zend_class_entry * ce ) ; <nl> <nl> / / Global map from message / enum ' s proto fully - qualified name to corresponding <nl> / / wrapper Descriptor / EnumDescriptor instances . <nl> - void add_proto_obj ( const char * proto , PHP_PROTO_HASHTABLE_VALUE value ) ; <nl> - PHP_PROTO_HASHTABLE_VALUE get_proto_obj ( const char * proto ) ; <nl> + void add_proto_desc ( const char * proto , DescriptorInternal * desc ) ; <nl> + DescriptorInternal * get_proto_desc ( const char * proto ) ; <nl> + void add_proto_enumdesc ( const char * proto , EnumDescriptorInternal * desc ) ; <nl> + EnumDescriptorInternal * get_proto_enumdesc ( const char * proto ) ; <nl> <nl> extern zend_class_entry * map_field_type ; <nl> extern zend_class_entry * repeated_field_type ; <nl> extern zend_class_entry * repeated_field_type ; <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> PHP_PROTO_WRAP_OBJECT_START ( DescriptorPool ) <nl> - InternalDescriptorPool * intern ; <nl> + InternalDescriptorPoolImpl * intern ; <nl> PHP_PROTO_WRAP_OBJECT_END <nl> <nl> PHP_METHOD ( DescriptorPool , getGeneratedPool ) ; <nl> PHP_METHOD ( DescriptorPool , getDescriptorByClassName ) ; <nl> PHP_METHOD ( DescriptorPool , getEnumDescriptorByClassName ) ; <nl> <nl> - PHP_PROTO_WRAP_OBJECT_START ( InternalDescriptorPool ) <nl> + struct InternalDescriptorPoolImpl { <nl> upb_symtab * symtab ; <nl> upb_handlercache * fill_handler_cache ; <nl> upb_handlercache * pb_serialize_handler_cache ; <nl> PHP_PROTO_WRAP_OBJECT_START ( InternalDescriptorPool ) <nl> upb_handlercache * json_serialize_handler_preserve_cache ; <nl> upb_pbcodecache * fill_method_cache ; <nl> upb_json_codecache * json_fill_method_cache ; <nl> + } ; <nl> + <nl> + PHP_PROTO_WRAP_OBJECT_START ( InternalDescriptorPool ) <nl> + InternalDescriptorPoolImpl * intern ; <nl> PHP_PROTO_WRAP_OBJECT_END <nl> <nl> PHP_METHOD ( InternalDescriptorPool , getGeneratedPool ) ; <nl> PHP_METHOD ( InternalDescriptorPool , internalAddGeneratedFile ) ; <nl> <nl> void internal_add_generated_file ( const char * data , PHP_PROTO_SIZE data_len , <nl> - InternalDescriptorPool * pool , <nl> + InternalDescriptorPoolImpl * pool , <nl> bool use_nested_submsg TSRMLS_DC ) ; <nl> void init_generated_pool_once ( TSRMLS_D ) ; <nl> void add_handlers_for_message ( const void * closure , upb_handlers * h ) ; <nl> extern zend_object * internal_generated_pool_php ; <nl> void descriptor_pool_free ( zend_object * object ) ; <nl> void internal_descriptor_pool_free ( zend_object * object ) ; <nl> # endif <nl> - extern InternalDescriptorPool * generated_pool ; / / The actual generated pool <nl> + extern InternalDescriptorPoolImpl * generated_pool ; <nl> + / / The actual generated pool <nl> + extern InternalDescriptorPoolImpl generated_pool_impl ; <nl> <nl> - PHP_PROTO_WRAP_OBJECT_START ( Descriptor ) <nl> - InternalDescriptorPool * pool ; <nl> + void internal_descriptor_pool_impl_init ( <nl> + InternalDescriptorPoolImpl * pool TSRMLS_DC ) ; <nl> + void internal_descriptor_pool_impl_destroy ( <nl> + InternalDescriptorPoolImpl * pool TSRMLS_DC ) ; <nl> + <nl> + struct DescriptorInternal { <nl> + InternalDescriptorPoolImpl * pool ; <nl> const upb_msgdef * msgdef ; <nl> MessageLayout * layout ; <nl> zend_class_entry * klass ; / / begins as NULL <nl> + } ; <nl> + <nl> + PHP_PROTO_WRAP_OBJECT_START ( Descriptor ) <nl> + DescriptorInternal * intern ; <nl> PHP_PROTO_WRAP_OBJECT_END <nl> <nl> PHP_METHOD ( Descriptor , getClass ) ; <nl> PHP_METHOD ( FieldDescriptor , getMessageType ) ; <nl> <nl> extern zend_class_entry * field_descriptor_type ; <nl> <nl> - PHP_PROTO_WRAP_OBJECT_START ( EnumDescriptor ) <nl> + struct EnumDescriptorInternal { <nl> const upb_enumdef * enumdef ; <nl> zend_class_entry * klass ; / / begins as NULL <nl> + } ; <nl> + <nl> + PHP_PROTO_WRAP_OBJECT_START ( EnumDescriptor ) <nl> + EnumDescriptorInternal * intern ; <nl> PHP_PROTO_WRAP_OBJECT_END <nl> <nl> PHP_METHOD ( EnumDescriptor , getValue ) ; <nl> struct MessageLayout { <nl> PHP_PROTO_WRAP_OBJECT_START ( MessageHeader ) <nl> void * data ; / / Point to the real message data . <nl> / / Place needs to be consistent with map_parse_frame_data_t . <nl> - Descriptor * descriptor ; / / Kept alive by self . class . descriptor reference . <nl> + DescriptorInternal * descriptor ; / / Kept alive by self . class . descriptor <nl> + / / reference . <nl> PHP_PROTO_WRAP_OBJECT_END <nl> <nl> MessageLayout * create_layout ( const upb_msgdef * msgdef ) ; <nl> PHP_METHOD ( Message , __construct ) ; <nl> const upb_pbdecodermethod * new_fillmsg_decodermethod ( Descriptor * desc , <nl> const void * owner ) ; <nl> void serialize_to_string ( zval * val , zval * return_value TSRMLS_DC ) ; <nl> - void merge_from_string ( const char * data , int data_len , Descriptor * desc , <nl> + void merge_from_string ( const char * data , int data_len , DescriptorInternal * desc , <nl> MessageHeader * msg ) ; <nl> <nl> PHP_METHOD ( Message , serializeToString ) ; <nl> size_t stringsink_string ( void * _sink , const void * hd , const char * ptr , <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> / / Memory management <nl> + # define SYS_MALLOC ( class_name ) ( class_name * ) malloc ( sizeof ( class_name ) ) <nl> + # define SYS_MALLOC_N ( class_name , n ) ( class_name * ) malloc ( sizeof ( class_name ) * n ) <nl> + # define SYS_FREE ( ptr ) free ( ptr ) <nl> # define ALLOC ( class_name ) ( class_name * ) emalloc ( sizeof ( class_name ) ) <nl> - # define PEMALLOC ( class_name ) ( class_name * ) pemalloc ( sizeof ( class_name ) , 1 ) <nl> + # define PEMALLOC ( class_name , persistent ) ( class_name * ) pemalloc ( sizeof ( class_name ) , persistent ) <nl> # define ALLOC_N ( class_name , n ) ( class_name * ) emalloc ( sizeof ( class_name ) * n ) <nl> # define FREE ( object ) efree ( object ) <nl> # define PEFREE ( object ) pefree ( object , 1 ) <nl> mmm a / php / ext / google / protobuf / storage . c <nl> ppp b / php / ext / google / protobuf / storage . c <nl> const upb_fielddef * map_entry_value ( const upb_msgdef * msgdef ) { <nl> const zend_class_entry * field_type_class ( <nl> const upb_fielddef * field PHP_PROTO_TSRMLS_DC ) { <nl> if ( upb_fielddef_type ( field ) = = UPB_TYPE_MESSAGE ) { <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( <nl> - Descriptor , get_def_obj ( upb_fielddef_msgsubdef ( field ) ) ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( upb_fielddef_msgsubdef ( field ) ) ; <nl> return desc - > klass ; <nl> } else if ( upb_fielddef_type ( field ) = = UPB_TYPE_ENUM ) { <nl> - EnumDescriptor * desc = UNBOX_HASHTABLE_VALUE ( <nl> - EnumDescriptor , get_def_obj ( upb_fielddef_enumsubdef ( field ) ) ) ; <nl> + EnumDescriptorInternal * desc = <nl> + get_enumdef_enumdesc ( upb_fielddef_enumsubdef ( field ) ) ; <nl> return desc - > klass ; <nl> } <nl> return NULL ; <nl> void * slot_memory ( MessageLayout * layout , const void * storage , <nl> } <nl> <nl> MessageLayout * create_layout ( const upb_msgdef * msgdef ) { <nl> - MessageLayout * layout = ALLOC ( MessageLayout ) ; <nl> + MessageLayout * layout = SYS_MALLOC ( MessageLayout ) ; <nl> int nfields = upb_msgdef_numfields ( msgdef ) ; <nl> upb_msg_field_iter it ; <nl> upb_msg_oneof_iter oit ; <nl> MessageLayout * create_layout ( const upb_msgdef * msgdef ) { <nl> layout - > empty_template = NULL ; <nl> <nl> TSRMLS_FETCH ( ) ; <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( msgdef ) ) ; <nl> - layout - > fields = ALLOC_N ( MessageField , nfields ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( msgdef ) ; <nl> + layout - > fields = SYS_MALLOC_N ( MessageField , nfields ) ; <nl> <nl> for ( upb_msg_field_begin ( & it , msgdef ) ; ! upb_msg_field_done ( & it ) ; <nl> upb_msg_field_next ( & it ) ) { <nl> MessageLayout * create_layout ( const upb_msgdef * msgdef ) { <nl> layout - > msgdef = msgdef ; <nl> <nl> / / Create the empty message template . <nl> - layout - > empty_template = ALLOC_N ( char , layout - > size ) ; <nl> + layout - > empty_template = SYS_MALLOC_N ( char , layout - > size ) ; <nl> memset ( layout - > empty_template , 0 , layout - > size ) ; <nl> <nl> return layout ; <nl> } <nl> <nl> void free_layout ( MessageLayout * layout ) { <nl> - FREE ( layout - > empty_template ) ; <nl> - FREE ( layout - > fields ) ; <nl> - FREE ( layout ) ; <nl> + SYS_FREE ( layout - > empty_template ) ; <nl> + SYS_FREE ( layout - > fields ) ; <nl> + SYS_FREE ( layout ) ; <nl> } <nl> <nl> void layout_init ( MessageLayout * layout , void * storage , <nl> zval * layout_get ( MessageLayout * layout , MessageHeader * header , <nl> const upb_msgdef * submsgdef = upb_fielddef_msgsubdef ( field ) ; <nl> const upb_fielddef * value_field = upb_msgdef_itof ( submsgdef , 1 ) ; <nl> MessageHeader * submsg ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( <nl> - Descriptor , get_def_obj ( ( void * ) submsgdef ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsgdef ) ; <nl> zend_class_entry * subklass = subdesc - > klass ; <nl> # if PHP_MAJOR_VERSION < 7 <nl> zval * val = NULL ; <nl> void layout_set ( MessageLayout * layout , MessageHeader * header , <nl> if ( upb_fielddef_descriptortype ( valuefield ) = = <nl> UPB_DESCRIPTOR_TYPE_MESSAGE ) { <nl> const upb_msgdef * submsg = upb_fielddef_msgsubdef ( valuefield ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( submsg ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsg ) ; <nl> subce = subdesc - > klass ; <nl> } <nl> check_map_field ( subce , upb_fielddef_descriptortype ( keyfield ) , <nl> void layout_set ( MessageLayout * layout , MessageHeader * header , <nl> } else { <nl> if ( upb_fielddef_type ( field ) = = UPB_TYPE_MESSAGE ) { <nl> const upb_msgdef * submsg = upb_fielddef_msgsubdef ( field ) ; <nl> - Descriptor * subdesc = <nl> - UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( submsg ) ) ; <nl> + DescriptorInternal * subdesc = get_msgdef_desc ( submsg ) ; <nl> subce = subdesc - > klass ; <nl> } <nl> <nl> void layout_set ( MessageLayout * layout , MessageHeader * header , <nl> zend_class_entry * ce = NULL ; <nl> if ( type = = UPB_TYPE_MESSAGE ) { <nl> const upb_msgdef * msg = upb_fielddef_msgsubdef ( field ) ; <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( msg ) ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( msg ) ; <nl> ce = desc - > klass ; <nl> } <nl> CACHED_VALUE * cache = find_zval_property ( header , field ) ; <nl> static void native_slot_merge ( <nl> break ; <nl> case UPB_TYPE_MESSAGE : { <nl> const upb_msgdef * msg = upb_fielddef_msgsubdef ( field ) ; <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( msg ) ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( msg ) ; <nl> ce = desc - > klass ; <nl> if ( native_slot_is_default ( type , to_memory ) ) { <nl> # if PHP_MAJOR_VERSION < 7 <nl> static void native_slot_merge_by_array ( const upb_fielddef * field , const void * fr <nl> } <nl> case UPB_TYPE_MESSAGE : { <nl> const upb_msgdef * msg = upb_fielddef_msgsubdef ( field ) ; <nl> - Descriptor * desc = UNBOX_HASHTABLE_VALUE ( Descriptor , get_def_obj ( msg ) ) ; <nl> + DescriptorInternal * desc = get_msgdef_desc ( upb_fielddef_msgsubdef ( field ) ) ; <nl> zend_class_entry * ce = desc - > klass ; <nl> # if PHP_MAJOR_VERSION < 7 <nl> MAKE_STD_ZVAL ( DEREF ( to_memory , zval * ) ) ; <nl> mmm a / php / ext / google / protobuf / upb . c <nl> ppp b / php / ext / google / protobuf / upb . c <nl> const upb_filedef * upb_symtab_lookupfile ( const upb_symtab * s , const char * name ) <nl> : NULL ; <nl> } <nl> <nl> + const upb_filedef * upb_symtab_lookupfile2 ( <nl> + const upb_symtab * s , const char * name , size_t len ) { <nl> + upb_value v ; <nl> + return upb_strtable_lookup2 ( & s - > files , name , len , & v ) ? <nl> + upb_value_getconstptr ( v ) : NULL ; <nl> + } <nl> + <nl> const upb_filedef * upb_symtab_addfile ( <nl> upb_symtab * s , const google_protobuf_FileDescriptorProto * file_proto , <nl> upb_status * status ) { <nl> mmm a / php / ext / google / protobuf / upb . h <nl> ppp b / php / ext / google / protobuf / upb . h <nl> const upb_msgdef * upb_symtab_lookupmsg2 ( <nl> const upb_symtab * s , const char * sym , size_t len ) ; <nl> const upb_enumdef * upb_symtab_lookupenum ( const upb_symtab * s , const char * sym ) ; <nl> const upb_filedef * upb_symtab_lookupfile ( const upb_symtab * s , const char * name ) ; <nl> + const upb_filedef * upb_symtab_lookupfile2 ( <nl> + const upb_symtab * s , const char * name , size_t len ) ; <nl> int upb_symtab_filecount ( const upb_symtab * s ) ; <nl> const upb_filedef * upb_symtab_addfile ( <nl> upb_symtab * s , const google_protobuf_FileDescriptorProto * file , <nl> mmm a / php / tests / test . sh <nl> ppp b / php / tests / test . sh <nl> do <nl> echo " " <nl> done <nl> <nl> + for t in " $ { tests [ @ ] } " <nl> + do <nl> + echo " * * * * * * * * * * * * * * * * * * * * * * * * * * * * " <nl> + echo " * $ t persistent " <nl> + echo " * * * * * * * * * * * * * * * * * * * * * * * * * * * * " <nl> + php - d protobuf . keep_descriptor_pool_after_request = 1 - dextension = . . / ext / google / protobuf / modules / protobuf . so ` which phpunit ` - - bootstrap autoload . php $ t <nl> + echo " " <nl> + done <nl> + <nl> # # Make sure to run the memory test in debug mode . <nl> # php - dextension = . . / ext / google / protobuf / modules / protobuf . so memory_leak_test . php <nl> <nl> export ZEND_DONT_UNLOAD_MODULES = 1 <nl> export USE_ZEND_ALLOC = 0 <nl> valgrind - - leak - check = yes php - dextension = . . / ext / google / protobuf / modules / protobuf . so memory_leak_test . php <nl> + valgrind - - leak - check = yes php - d protobuf . keep_descriptor_pool_after_request = 1 - dextension = . . / ext / google / protobuf / modules / protobuf . so memory_leak_test . php <nl> <nl> # TODO ( teboring ) : Only for debug ( phpunit has memory leak which blocks this beging used by <nl> # regresssion test . ) <nl>
|
Persistent Descriptor Pool ( )
|
protocolbuffers/protobuf
|
3cae867740e409d9b9fbc1224c35357a49ce0ce2
|
2019-11-18T21:13:25Z
|
mmm a / src / mongo / db / commands / SConscript <nl> ppp b / src / mongo / db / commands / SConscript <nl> env . Library ( <nl> ' $ BUILD_DIR / mongo / db / repl / repl_coordinator_interface ' , <nl> ' $ BUILD_DIR / mongo / executor / egress_tag_closer_manager ' , <nl> ' $ BUILD_DIR / mongo / executor / task_executor_pool ' , <nl> + ' $ BUILD_DIR / mongo / rpc / client_metadata ' , <nl> ' $ BUILD_DIR / mongo / s / sharding_legacy_api ' , <nl> ' $ BUILD_DIR / mongo / s / coreshard ' , <nl> ' $ BUILD_DIR / mongo / scripting / scripting_common ' , <nl> mmm a / src / mongo / db / commands / authentication_commands . cpp <nl> ppp b / src / mongo / db / commands / authentication_commands . cpp <nl> <nl> # include " mongo / db / commands / test_commands_enabled . h " <nl> # include " mongo / db / operation_context . h " <nl> # include " mongo / platform / random . h " <nl> + # include " mongo / rpc / metadata / client_metadata . h " <nl> + # include " mongo / rpc / metadata / client_metadata_ismaster . h " <nl> # include " mongo / stdx / memory . h " <nl> # include " mongo / transport / session . h " <nl> # include " mongo / util / concurrency / mutex . h " <nl> Status _authenticateX509 ( OperationContext * opCtx , const UserName & user , const BS <nl> " authentication . The current configuration does not allow " <nl> " x . 509 cluster authentication , check the - - clusterAuthMode flag " ) ; <nl> } <nl> + auto & clientMetadata = <nl> + ClientMetadataIsMasterState : : get ( opCtx - > getClient ( ) ) . getClientMetadata ( ) ; <nl> + if ( clientMetadata ) { <nl> + auto clientMetadataDoc = clientMetadata - > getDocument ( ) ; <nl> + auto driverName = clientMetadataDoc . getObjectField ( " driver " _sd ) <nl> + . getField ( " name " _sd ) <nl> + . checkAndGetStringData ( ) ; <nl> + if ( ! clientMetadata - > getApplicationName ( ) . empty ( ) | | <nl> + ( driverName ! = " MongoDB Internal Client " & & <nl> + driverName ! = " NetworkInterfaceTL " ) ) { <nl> + warning ( ) < < " Client isn ' t a mongod or mongos , but is connecting with a " <nl> + " certificate with cluster membership " ; <nl> + } <nl> + } <nl> + <nl> authorizationSession - > grantInternalAuthorization ( ) ; <nl> } <nl> / / Handle normal client authentication , only applies to client - server connections <nl>
|
SERVER - 38428 log warning when non - mongod client connects with cluster certificate
|
mongodb/mongo
|
6c0c3f30d261de356b9c57d56a478c301298025d
|
2019-02-01T20:03:56Z
|
mmm a / dlib / type_safe_union / type_safe_union_kernel . h <nl> ppp b / dlib / type_safe_union / type_safe_union_kernel . h <nl> namespace dlib <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> - namespace impl <nl> + namespace impl_tsu <nl> { <nl> struct serialize_helper <nl> { <nl> namespace dlib <nl> { <nl> / / save the type_identity <nl> serialize ( item . type_identity , out ) ; <nl> - item . apply_to_contents ( dlib : : impl : : serialize_helper ( out ) ) ; <nl> + item . apply_to_contents ( dlib : : impl_tsu : : serialize_helper ( out ) ) ; <nl> } <nl> catch ( serialization_error & e ) <nl> { <nl>
|
merged
|
davisking/dlib
|
95c074edc8b9f6be85fc1d77020e1b1f1fb9603d
|
2011-06-11T21:37:20Z
|
mmm a / lib / Sema / CSGen . cpp <nl> ppp b / lib / Sema / CSGen . cpp <nl> namespace { <nl> <nl> Type visitForcedCheckedCastExpr ( ForcedCheckedCastExpr * expr ) { <nl> auto & tc = CS . getTypeChecker ( ) ; <nl> - <nl> + auto fromExpr = expr - > getSubExpr ( ) ; <nl> + if ( ! fromExpr ) / / Either wasn ' t constructed correctly or wasn ' t folded . <nl> + return nullptr ; <nl> + <nl> / / Validate the resulting type . <nl> TypeResolutionOptions options = TR_AllowUnboundGenerics ; <nl> options | = TR_InExpression ; <nl> namespace { <nl> CS . getConstraintLocator ( expr ) ) ; <nl> expr - > getCastTypeLoc ( ) . setType ( toType , / * validated = * / true ) ; <nl> <nl> - auto fromType = expr - > getSubExpr ( ) - > getType ( ) ; <nl> - auto locator = CS . getConstraintLocator ( expr - > getSubExpr ( ) ) ; <nl> + auto fromType = fromExpr - > getType ( ) ; <nl> + auto locator = CS . getConstraintLocator ( fromExpr ) ; <nl> <nl> / / The source type can be checked - cast to the destination type . <nl> CS . addConstraint ( ConstraintKind : : CheckedCast , fromType , toType , locator ) ; <nl> namespace { <nl> <nl> Type visitConditionalCheckedCastExpr ( ConditionalCheckedCastExpr * expr ) { <nl> auto & tc = CS . getTypeChecker ( ) ; <nl> + auto fromExpr = expr - > getSubExpr ( ) ; <nl> + if ( ! fromExpr ) / / Either wasn ' t constructed correctly or wasn ' t folded . <nl> + return nullptr ; <nl> <nl> / / Validate the resulting type . <nl> TypeResolutionOptions options = TR_AllowUnboundGenerics ; <nl> namespace { <nl> CS . getConstraintLocator ( expr ) ) ; <nl> expr - > getCastTypeLoc ( ) . setType ( toType , / * validated = * / true ) ; <nl> <nl> - auto fromType = expr - > getSubExpr ( ) - > getType ( ) ; <nl> - auto locator = CS . getConstraintLocator ( expr - > getSubExpr ( ) ) ; <nl> + auto fromType = fromExpr - > getType ( ) ; <nl> + auto locator = CS . getConstraintLocator ( fromExpr ) ; <nl> CS . addConstraint ( ConstraintKind : : CheckedCast , fromType , toType , locator ) ; <nl> return OptionalType : : get ( toType ) ; <nl> } <nl> deleted file mode 100644 <nl> index 0d96a07b4dcc . . 000000000000 <nl> mmm a / validation - test / Sema / type_checker_crashers / rdar27464577 . swift <nl> ppp / dev / null <nl> <nl> - / / RUN : not - - crash % target - swift - frontend % s - parse <nl> - <nl> - _ = [ 1 ] . map { v - > T in return v as ? Int } <nl> new file mode 100644 <nl> index 000000000000 . . 0bec40a0cd93 <nl> mmm / dev / null <nl> ppp b / validation - test / Sema / type_checker_crashers_fixed / rdar27464577 . swift <nl> <nl> + / / RUN : not % target - swift - frontend % s - parse <nl> + <nl> + _ = [ 1 ] . map { v - > T in return v as ? Int } <nl>
|
[ TypeChecker ] Don ' t assume that cast expressions always have sub - expressions
|
apple/swift
|
351ae5bde99624155e4a9dc27ca46ab9bf46ca81
|
2016-11-17T07:58:03Z
|
mmm a / src / objects / contexts . cc <nl> ppp b / src / objects / contexts . cc <nl> int Context : : IntrinsicIndexForName ( Handle < String > string ) { <nl> <nl> # undef COMPARE_NAME <nl> <nl> - # define COMPARE_NAME ( index , type , name ) \ <nl> - if ( strncmp ( string , # name , length ) = = 0 ) return index ; <nl> + # define COMPARE_NAME ( index , type , name ) \ <nl> + { \ <nl> + const int name_length = static_cast < int > ( arraysize ( # name ) ) - 1 ; \ <nl> + if ( ( length = = name_length ) & & strncmp ( string , # name , name_length ) = = 0 ) \ <nl> + return index ; \ <nl> + } <nl> <nl> int Context : : IntrinsicIndexForName ( const unsigned char * unsigned_string , <nl> int length ) { <nl>
|
[ parser ] Fix intrinsic name matching
|
v8/v8
|
f2e7adf162dba1b32235de68f9f4595e55829b60
|
2019-11-27T14:03:56Z
|
mmm a / torch / testing / _internal / common_quantization . py <nl> ppp b / torch / testing / _internal / common_quantization . py <nl> def checkGraphModeFxOp ( self , model , inputs , quant_type , <nl> result = qgraph ( * inputs ) <nl> result_debug = qgraph_debug ( * inputs ) <nl> <nl> - # numeric match for debug option for dynamic <nl> - # quantized op is not needed right now <nl> - if quant_type ! = QuantType . DYNAMIC : <nl> - self . assertEqual ( ( result - result_debug ) . abs ( ) . max ( ) , 0 ) , \ <nl> - ' Expecting debug and non - debug option to produce identical result ' <nl> - <nl> qgraph_to_check = qgraph_debug if debug else qgraph <nl> if print_debug_info : <nl> print ( ) <nl>
|
[ quant ] [ test ] Remove numeric equivalence test for debug and non - debug option ( )
|
pytorch/pytorch
|
21fa877026f28779947ae38fea0540e5c79b22b1
|
2020-10-05T21:11:07Z
|
new file mode 100644 <nl> index 000000000000 . . c2527c0a02a4 <nl> mmm / dev / null <nl> ppp b / stdlib / core / RangeMirrors . swift . gyb <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + % import gyb <nl> + % MirrorDecl = gyb . parseTemplate ( " . . / common / Mirrors . gyb " ) <nl> + <nl> + % for Type in [ [ ' Range ' , ' ForwardIndex ' , ' startIndex ' , ' endIndex ' ] , \ <nl> + % [ ' RandomAccessRange ' , ' RandomAccessIndex ' , ' startIndex ' , ' endIndex ' ] , \ <nl> + % [ ' ReverseRange ' , ' BidirectionalIndex ' , ' _bounds . 0 ' , ' _bounds . 1 ' ] ] : <nl> + % Self = Type [ 0 ] <nl> + % Protocol = Type [ 1 ] <nl> + % StartIndex = Type [ 2 ] <nl> + % EndIndex = Type [ 3 ] <nl> + % Mirror = gyb . executeTemplate ( MirrorDecl , introspecteeType = Self , genericArgs = [ ' T ' ] , genericConstraints = { ' T ' : Protocol } , disposition = ' Struct ' ) <nl> + $ { Mirror } <nl> + @ public var count : Int { return 2 } <nl> + <nl> + @ public subscript ( i : Int ) - > ( String , Mirror ) { <nl> + switch i { <nl> + case 0 : return ( " startIndex " , reflect ( _value . $ { StartIndex } ) ) <nl> + case 1 : return ( " endIndex " , reflect ( _value . $ { EndIndex } ) ) <nl> + default : _preconditionFailure ( " cannot extract this child index " ) <nl> + } <nl> + } <nl> + <nl> + @ public var summary : String { <nl> + return " $ { Self } ( \ ( self [ 0 ] . 1 . summary ) , \ ( self [ 1 ] . 1 . summary ) ) " <nl> + } <nl> + <nl> + @ public var quickLookObject : QuickLookObject ? { return . Some ( . Text ( summary ) ) } <nl> + } <nl> + <nl>
|
Forgot to add the most important part of the patch to the previous commit .
|
apple/swift
|
314dbc6ed14f3a9a96053d99da4bf62e97367d87
|
2014-07-03T23:44:21Z
|
deleted file mode 100644 <nl> index 3e92dd1a811 . . 00000000000 <nl> mmm a / templates / tools / dockerfile / test / cxx_ubuntu1404_x64 / Dockerfile . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - # Copyright 2015 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> - FROM ubuntu : 14 . 04 <nl> - <nl> - < % include file = " . . / . . / apt_get_basic . include " / > <nl> - < % include file = " . . / . . / python_deps . include " / > <nl> - < % include file = " . . / . . / gcp_api_libraries . include " / > <nl> - < % include file = " . . / . . / cxx_deps . include " / > <nl> - < % include file = " . . / . . / run_tests_addons . include " / > <nl> - # Define the default command . <nl> - CMD [ " bash " ] <nl> deleted file mode 100644 <nl> index 08cff8d3b2a . . 00000000000 <nl> mmm a / tools / dockerfile / test / cxx_ubuntu1404_x64 / Dockerfile <nl> ppp / dev / null <nl> <nl> - # Copyright 2015 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> - FROM ubuntu : 14 . 04 <nl> - <nl> - # Install Git and basic packages . <nl> - RUN apt - get update & & apt - get install - y \ <nl> - autoconf \ <nl> - autotools - dev \ <nl> - build - essential \ <nl> - bzip2 \ <nl> - ccache \ <nl> - curl \ <nl> - dnsutils \ <nl> - gcc \ <nl> - gcc - multilib \ <nl> - git \ <nl> - golang \ <nl> - gyp \ <nl> - lcov \ <nl> - libc6 \ <nl> - libc6 - dbg \ <nl> - libc6 - dev \ <nl> - libgtest - dev \ <nl> - libtool \ <nl> - make \ <nl> - perl \ <nl> - strace \ <nl> - python - dev \ <nl> - python - setuptools \ <nl> - python - yaml \ <nl> - telnet \ <nl> - unzip \ <nl> - wget \ <nl> - zip & & apt - get clean <nl> - <nl> - # = = = = = = = = = = = = = = = = <nl> - # Build profiling <nl> - RUN apt - get update & & apt - get install - y time & & apt - get clean <nl> - <nl> - # = = = = = = = = = = = = = = = = = = = = <nl> - # Python dependencies <nl> - <nl> - # Install dependencies <nl> - <nl> - RUN apt - get update & & apt - get install - y \ <nl> - python - all - dev \ <nl> - python3 - all - dev \ <nl> - python - setuptools <nl> - <nl> - # Install Python packages from PyPI <nl> - RUN curl https : / / bootstrap . pypa . io / get - pip . py | python2 . 7 <nl> - RUN pip install - - upgrade pip = = 19 . 3 . 1 <nl> - RUN pip install virtualenv = = 16 . 7 . 9 <nl> - RUN pip install futures = = 2 . 2 . 0 enum34 = = 1 . 0 . 4 protobuf = = 3 . 5 . 2 . post1 six = = 1 . 10 . 0 twisted = = 17 . 5 . 0 <nl> - <nl> - # Google Cloud platform API libraries <nl> - RUN pip install - - upgrade google - api - python - client oauth2client <nl> - <nl> - # = = = = = = = = = = = = = = = = = <nl> - # C + + dependencies <nl> - RUN apt - get update & & apt - get - y install libgflags - dev libgtest - dev libc + + - dev clang & & apt - get clean <nl> - <nl> - <nl> - RUN mkdir / var / local / jenkins <nl> - <nl> - # Define the default command . <nl> - CMD [ " bash " ] <nl> mmm a / tools / run_tests / run_tests . py <nl> ppp b / tools / run_tests / run_tests . py <nl> def _compiler_options ( self , use_docker , compiler ) : <nl> return ( ' buster ' , [ ] ) <nl> elif compiler = = ' gcc_musl ' : <nl> return ( ' alpine ' , [ ] ) <nl> - elif compiler = = ' clang3 . 4 ' : <nl> - # on ubuntu1404 , clang - 3 . 4 alias doesn ' t exist , just use ' clang ' <nl> - return ( ' ubuntu1404 ' , self . _clang_make_options ( ) ) <nl> elif compiler = = ' clang3 . 5 ' : <nl> return ( ' jessie ' , self . _clang_make_options ( version_suffix = ' - 3 . 5 ' ) ) <nl> elif compiler = = ' clang3 . 6 ' : <nl> def isclose ( a , b , rel_tol = 1e - 09 , abs_tol = 0 . 0 ) : <nl> ' - - compiler ' , <nl> choices = [ <nl> ' default ' , ' gcc4 . 9 ' , ' gcc5 . 3 ' , ' gcc7 . 4 ' , ' gcc8 . 3 ' , ' gcc_musl ' , <nl> - ' clang3 . 4 ' , ' clang3 . 5 ' , ' clang3 . 6 ' , ' clang3 . 7 ' , ' clang7 . 0 ' , ' python2 . 7 ' , <nl> + ' clang3 . 5 ' , ' clang3 . 6 ' , ' clang3 . 7 ' , ' clang7 . 0 ' , ' python2 . 7 ' , <nl> ' python3 . 5 ' , ' python3 . 6 ' , ' python3 . 7 ' , ' python3 . 8 ' , ' pypy ' , ' pypy3 ' , <nl> ' python_alpine ' , ' all_the_cpythons ' , ' electron1 . 3 ' , ' electron1 . 6 ' , <nl> ' coreclr ' , ' cmake ' , ' cmake_vs2015 ' , ' cmake_vs2017 ' <nl>
|
remove clang3 . 4 portability test : ubuntu14 . 04 is EOL
|
grpc/grpc
|
847a4715e54e0e1a72b1fe08a625b879b3831a41
|
2020-08-03T17:18:39Z
|
mmm a / lib / libass / xbmc / Makefile . in <nl> ppp b / lib / libass / xbmc / Makefile . in <nl> DIRS = . . <nl> <nl> ifeq ( $ ( findstring osx , $ ( ARCH ) ) , osx ) <nl> $ ( SLIB ) : . . / libass / . libs / libass . dylib <nl> - $ ( CXX ) - bundle - flat_namespace - undefined suppress - shared - fPIC \ <nl> - - mmacosx - version - min = 10 . 4 - o $ @ . . / libass / . libs / * . o <nl> + $ ( CXX ) $ ( LDFLAGS ) - bundle - flat_namespace - undefined suppress - shared - fPIC \ <nl> + - lfontconfig - o $ @ . . / libass / . libs / * . o <nl> $ ( abs_top_srcdir ) / tools / Mach5 / wrapper . rb $ @ ; mv output . so $ @ <nl> chmod + x $ @ <nl> <nl>
|
[ osx ] sync to r34903 , fixed : our internal libass needs to be linked to fontconfig , broken since r34841
|
xbmc/xbmc
|
ac435e330d619d8c720135abfc889b76dff131f2
|
2010-10-21T01:29:40Z
|
mmm a / code / greedy_algorithms / src / prim_minimum_spanning_tree / prim_minimum_spanning_tree . c <nl> ppp b / code / greedy_algorithms / src / prim_minimum_spanning_tree / prim_minimum_spanning_tree . c <nl> find_min_edge ( int * k , int * l , int n , int c [ ] [ 1024 ] , int * e ) <nl> int i , j ; <nl> for ( i = 0 ; i < n ; + + i ) <nl> for ( j = 0 ; j < n ; + + j ) <nl> - if ( c [ i ] [ j ] < min ) <nl> - { <nl> + if ( c [ i ] [ j ] < min ) { <nl> min = c [ i ] [ j ] ; <nl> * k = i ; <nl> * l = j ; <nl> } <nl> - * e = * e - 1 ; <nl> + * e = * e - 1 ; <nl> return ( min ) ; <nl> } <nl> <nl> find_new_index ( int c [ ] [ 1024 ] , int near [ ] , int n , int * e ) <nl> int min = INT_MAX , index ; <nl> int i ; <nl> for ( i = 0 ; i < n ; + + i ) <nl> - { <nl> - if ( near [ i ] ! = 0 & & c [ i ] [ near [ i ] ] < min ) <nl> - { <nl> + if ( near [ i ] ! = 0 & & c [ i ] [ near [ i ] ] < min ) { <nl> min = c [ i ] [ near [ i ] ] ; <nl> index = i ; <nl> <nl> } <nl> - } <nl> * e = * e - 1 ; <nl> return ( index ) ; <nl> } <nl> main ( ) <nl> printf ( " Enter cost matrix : \ n " ) ; <nl> int i , j ; <nl> for ( i = 0 ; i < n ; + + i ) <nl> - for ( j = 0 ; j < n ; + + j ) <nl> - { <nl> + for ( j = 0 ; j < n ; + + j ) { <nl> scanf ( " % d " , & c [ i ] [ j ] ) ; <nl> - if ( c [ i ] [ j ] = = - 1 ) <nl> - { <nl> + if ( c [ i ] [ j ] = = - 1 ) { <nl> c [ i ] [ j ] = INT_MAX ; <nl> - - e ; <nl> } <nl> main ( ) <nl> t [ 0 ] [ 0 ] = k ; <nl> t [ 0 ] [ 1 ] = l ; <nl> <nl> - for ( i = 0 ; i < n ; + + i ) <nl> - { <nl> + for ( i = 0 ; i < n ; + + i ) { <nl> if ( c [ i ] [ l ] < c [ i ] [ k ] ) <nl> near [ i ] = l ; <nl> else <nl> main ( ) <nl> } <nl> near [ k ] = near [ l ] = 0 ; <nl> <nl> - for ( i = 1 ; i < n - 1 , e > 0 ; + + i ) <nl> - { <nl> + for ( i = 1 ; i < n - 1 , e > 0 ; + + i ) { <nl> int index = find_new_index ( c , near , n , & e ) ; <nl> t [ i ] [ 0 ] = index ; <nl> t [ i ] [ 1 ] = near [ index ] ; <nl> main ( ) <nl> <nl> if ( i ! = n - 1 ) <nl> printf ( " There is no spanning tree \ n " ) ; <nl> - else <nl> - { <nl> + else { <nl> printf ( " Minimum Spanning Tree : - \ n " ) ; <nl> <nl> for ( i = 0 ; i < n - 1 ; + + i ) <nl>
|
Minor changes according to Style Guide
|
OpenGenus/cosmos
|
5b77ed9e189b55631c241481775c0337be00c595
|
2018-04-01T06:42:36Z
|
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> const char * ImFont : : CalcWordWrapPositionA ( float scale , const char * text , const c <nl> const char * s = text ; <nl> while ( s < text_end ) <nl> { <nl> - unsigned int c ; <nl> - const char * next_s = s + ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> + unsigned int c = ( unsigned int ) * s ; <nl> + const char * next_s ; <nl> + if ( c < 0x80 ) <nl> + next_s = s + 1 ; <nl> + else <nl> + next_s = s + ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> <nl> if ( c = = ' \ n ' ) <nl> { <nl> ImVec2 ImFont : : CalcTextSizeA ( float size , float max_width , float wrap_width , cons <nl> } <nl> <nl> / / Decode and advance source ( handle unlikely UTF - 8 decoding failure by skipping to the next byte ) <nl> - unsigned int c ; <nl> - s + = ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> + unsigned int c = ( unsigned int ) * s ; <nl> + if ( c < 0x80 ) <nl> + s + = 1 ; <nl> + else <nl> + s + = ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> <nl> if ( c = = ' \ n ' ) <nl> { <nl> void ImFont : : RenderText ( float size , ImVec2 pos , ImU32 col , const ImVec4 & clip_re <nl> } <nl> <nl> / / Decode and advance source ( handle unlikely UTF - 8 decoding failure by skipping to the next byte ) <nl> - unsigned int c ; <nl> - s + = ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> + unsigned int c = ( unsigned int ) * s ; <nl> + if ( c < 0x80 ) <nl> + s + = 1 ; <nl> + else <nl> + s + = ImTextCharFromUtf8 ( & c , s , text_end ) ; <nl> <nl> if ( c = = ' \ n ' ) <nl> { <nl>
|
CalcTextSize * ( ) more optimisation , fast - path for ascii .
|
ocornut/imgui
|
183a27fd70382c1aec50a4f9141b7b29d690a757
|
2015-02-11T12:31:04Z
|
mmm a / src / rdb_protocol / op . cc <nl> ppp b / src / rdb_protocol / op . cc <nl> op_term_t : : op_term_t ( compile_env_t * env , const raw_term_t & term , <nl> } <nl> arg_terms . init ( new arg_terms_t ( term , std : : move ( argspec ) , std : : move ( original_args ) ) ) ; <nl> <nl> - term . each_optarg ( [ & ] ( const raw_term_t & o , const std : : string & name ) { <nl> - rcheck_src ( o . bt ( ) , optargspec . contains ( name ) , <nl> + term . each_optarg ( [ & ] ( const raw_term_t & o , const std : : string & arg_name ) { <nl> + rcheck_src ( o . bt ( ) , optargspec . contains ( arg_name ) , <nl> base_exc_t : : LOGIC , <nl> - strprintf ( " Unrecognized optional argument ` % s ` . " , name . c_str ( ) ) ) ; <nl> + strprintf ( " Unrecognized optional argument ` % s ` . " , arg_name . c_str ( ) ) ) ; <nl> counted_t < const term_t > t = compile_term ( env , o ) ; <nl> - auto res = optargs . insert ( std : : make_pair ( name , std : : move ( t ) ) ) ; <nl> + auto res = optargs . insert ( std : : make_pair ( arg_name , std : : move ( t ) ) ) ; <nl> rcheck_src ( o . bt ( ) , res . second , <nl> base_exc_t : : LOGIC , <nl> - strprintf ( " Duplicate optional argument : % s " , name . c_str ( ) ) ) ; <nl> + strprintf ( " Duplicate optional argument : % s " , arg_name . c_str ( ) ) ) ; <nl> <nl> } ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / datum_terms . cc <nl> ppp b / src / rdb_protocol / terms / datum_terms . cc <nl> class make_obj_term_t : public term_t { <nl> base_exc_t : : LOGIC , <nl> " MAKE_OBJ term must not have any args . " ) ; <nl> <nl> - term . each_optarg ( [ & ] ( const raw_term_t & o , const std : : string & name ) { <nl> + term . each_optarg ( [ & ] ( const raw_term_t & o , const std : : string & arg_name ) { <nl> counted_t < const term_t > t = compile_term ( env , o ) ; <nl> - auto res = optargs . insert ( std : : make_pair ( name , std : : move ( t ) ) ) ; <nl> + auto res = optargs . insert ( std : : make_pair ( arg_name , std : : move ( t ) ) ) ; <nl> rcheck ( res . second , base_exc_t : : LOGIC , <nl> - strprintf ( " Duplicate object key : % s . " , name . c_str ( ) ) ) ; <nl> + strprintf ( " Duplicate object key : % s . " , arg_name . c_str ( ) ) ) ; <nl> } ) ; <nl> } <nl> <nl>
|
GCC4 . 9 compilation fix .
|
rethinkdb/rethinkdb
|
136e8da9e1544e32df915a3d24b75761aef778d9
|
2016-04-26T19:41:13Z
|
mmm a / src / core / lib / iomgr / error . cc <nl> ppp b / src / core / lib / iomgr / error . cc <nl> typedef struct { <nl> grpc_status_code code ; <nl> const char * msg ; <nl> } special_error_status_map ; <nl> - static special_error_status_map error_status_map [ ] = { <nl> + static const special_error_status_map error_status_map [ ] = { <nl> { GRPC_ERROR_NONE , GRPC_STATUS_OK , " " } , <nl> { GRPC_ERROR_CANCELLED , GRPC_STATUS_CANCELLED , " Cancelled " } , <nl> { GRPC_ERROR_OOM , GRPC_STATUS_RESOURCE_EXHAUSTED , " Out of memory " } , <nl> static special_error_status_map error_status_map [ ] = { <nl> bool grpc_error_get_int ( grpc_error * err , grpc_error_ints which , intptr_t * p ) { <nl> GPR_TIMER_SCOPE ( " grpc_error_get_int " , 0 ) ; <nl> if ( grpc_error_is_special ( err ) ) { <nl> - if ( which = = GRPC_ERROR_INT_GRPC_STATUS ) { <nl> - for ( size_t i = 0 ; i < GPR_ARRAY_SIZE ( error_status_map ) ; i + + ) { <nl> - if ( error_status_map [ i ] . error = = err ) { <nl> - if ( p ! = nullptr ) * p = error_status_map [ i ] . code ; <nl> - return true ; <nl> - } <nl> + for ( size_t i = 0 ; i < GPR_ARRAY_SIZE ( error_status_map ) ; i + + ) { <nl> + if ( error_status_map [ i ] . error = = err ) { <nl> + if ( which ! = GRPC_ERROR_INT_GRPC_STATUS ) return false ; <nl> + if ( p ! = nullptr ) * p = error_status_map [ i ] . code ; <nl> + return true ; <nl> } <nl> } <nl> - return false ; <nl> } <nl> uint8_t slot = err - > ints [ which ] ; <nl> if ( slot ! = UINT8_MAX ) { <nl> grpc_error * grpc_error_set_str ( grpc_error * src , grpc_error_strs which , <nl> bool grpc_error_get_str ( grpc_error * err , grpc_error_strs which , <nl> grpc_slice * str ) { <nl> if ( grpc_error_is_special ( err ) ) { <nl> - if ( which = = GRPC_ERROR_STR_GRPC_MESSAGE ) { <nl> - for ( size_t i = 0 ; i < GPR_ARRAY_SIZE ( error_status_map ) ; i + + ) { <nl> - if ( error_status_map [ i ] . error = = err ) { <nl> - * str = grpc_slice_from_static_string ( error_status_map [ i ] . msg ) ; <nl> - return true ; <nl> - } <nl> + for ( size_t i = 0 ; i < GPR_ARRAY_SIZE ( error_status_map ) ; i + + ) { <nl> + if ( error_status_map [ i ] . error = = err ) { <nl> + if ( which ! = GRPC_ERROR_STR_GRPC_MESSAGE ) return false ; <nl> + * str = grpc_slice_from_static_string ( error_status_map [ i ] . msg ) ; <nl> + return true ; <nl> } <nl> } <nl> - return false ; <nl> } <nl> uint8_t slot = err - > strs [ which ] ; <nl> if ( slot ! = UINT8_MAX ) { <nl>
|
Merge pull request from soheilhy / branch - optimization - err
|
grpc/grpc
|
c3db7d21ce1dfbd6f25bde500af62fd1c197928f
|
2018-09-26T21:00:03Z
|
mmm a / src / netbase . h <nl> ppp b / src / netbase . h <nl> <nl> # include < vector > <nl> <nl> extern int nConnectTimeout ; <nl> + extern bool fNameLookup ; <nl> <nl> # ifdef WIN32 <nl> / / In MSVC , this is defined as a macro , undefine it to prevent a compile and link error <nl> enum Network <nl> NET_MAX , <nl> } ; <nl> <nl> - extern int nConnectTimeout ; <nl> - extern bool fNameLookup ; <nl> - <nl> / * * IP address ( IPv6 , or IPv4 using mapped IPv6 range ( : : FFFF : 0 : 0 / 96 ) ) * / <nl> class CNetAddr <nl> { <nl>
|
remove dup of extern int nConnectTimeout ; in netbase
|
bitcoin/bitcoin
|
cb7a3edc3d60311752e8f76c0302ffd0a1fd0eb9
|
2014-05-31T10:04:34Z
|
mmm a / src / core / statistics / census_tracing . h <nl> ppp b / src / core / statistics / census_tracing . h <nl> trace_obj * census_get_trace_obj_locked ( census_op_id op_id ) ; <nl> void census_internal_lock_trace_store ( void ) ; <nl> void census_internal_unlock_trace_store ( void ) ; <nl> <nl> - / * Gets method tag name associated with the input trace object . * / <nl> + / * Gets method name associated with the input trace object . * / <nl> const char * census_get_trace_method_name ( const trace_obj * trace ) ; <nl> <nl> / * Returns an array of pointers to trace objects of currently active operations <nl> - and fills in number of active operations . Returns NULL if there ' s no active <nl> + and fills in number of active operations . Returns NULL if there are no active <nl> operations . <nl> Caller owns the returned objects . * / <nl> trace_obj * * census_get_active_ops ( int * num_active_ops ) ; <nl>
|
Update census_tracing . h
|
grpc/grpc
|
46c3be0156c60ed2767aeaf00cd0e46e27c8880c
|
2015-02-05T19:41:01Z
|
mmm a / src / video_core / shader / control_flow . cpp <nl> ppp b / src / video_core / shader / control_flow . cpp <nl> bool TryQuery ( CFGRebuildState & state ) { <nl> gather_labels ( q2 . ssy_stack , state . ssy_labels , block ) ; <nl> gather_labels ( q2 . pbk_stack , state . pbk_labels , block ) ; <nl> if ( std : : holds_alternative < SingleBranch > ( * block . branch ) ) { <nl> - const auto branch = std : : get_if < SingleBranch > ( block . branch . get ( ) ) ; <nl> + auto * branch = std : : get_if < SingleBranch > ( block . branch . get ( ) ) ; <nl> if ( ! branch - > condition . IsUnconditional ( ) ) { <nl> q2 . address = block . end + 1 ; <nl> state . queries . push_back ( q2 ) ; <nl> } <nl> <nl> - Query conditional_query { q2 } ; <nl> + auto & conditional_query = state . queries . emplace_back ( q2 ) ; <nl> if ( branch - > is_sync ) { <nl> if ( branch - > address = = unassigned_branch ) { <nl> branch - > address = conditional_query . ssy_stack . top ( ) ; <nl> bool TryQuery ( CFGRebuildState & state ) { <nl> conditional_query . pbk_stack . pop ( ) ; <nl> } <nl> conditional_query . address = branch - > address ; <nl> - state . queries . push_back ( std : : move ( conditional_query ) ) ; <nl> return true ; <nl> } <nl> - const auto multi_branch = std : : get_if < MultiBranch > ( block . branch . get ( ) ) ; <nl> + <nl> + const auto * multi_branch = std : : get_if < MultiBranch > ( block . branch . get ( ) ) ; <nl> for ( const auto & branch_case : multi_branch - > branches ) { <nl> - Query conditional_query { q2 } ; <nl> + auto & conditional_query = state . queries . emplace_back ( q2 ) ; <nl> conditional_query . address = branch_case . address ; <nl> - state . queries . push_back ( std : : move ( conditional_query ) ) ; <nl> } <nl> + <nl> return true ; <nl> } <nl> <nl>
|
control_flow : emplace elements in place within TryQuery ( )
|
yuzu-emu/yuzu
|
0dc6967ff1030e466e8e2da399079a28181c3c09
|
2020-09-23T02:54:36Z
|
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( cannot_use_nil_with_this_type , none , <nl> ERROR ( use_of_equal_instead_of_equality , none , <nl> " use of ' = ' in a boolean context , did you mean ' = = ' ? " , ( ) ) <nl> <nl> + ERROR ( experimental_conditional_conformances , none , <nl> + " conditional conformance of % 0 to % 1 depends on an experimental feature " <nl> + " ( SE - 0143 ) " , ( Type , Type ) ) <nl> <nl> ERROR ( protocol_does_not_conform_objc , none , <nl> " using % 0 as a concrete type conforming to protocol % 1 is not supported " , <nl> mmm a / include / swift / Basic / LangOptions . h <nl> ppp b / include / swift / Basic / LangOptions . h <nl> namespace swift { <nl> / / / was not compiled with - enable - testing . <nl> bool EnableTestableAttrRequiresTestableModule = true ; <nl> <nl> + / / / Whether SE - 0143 : Conditional Conformances are enabled . <nl> + bool EnableConditionalConformances = false ; <nl> + <nl> / / / <nl> / / / Flags for developers <nl> / / / <nl> mmm a / include / swift / Option / Options . td <nl> ppp b / include / swift / Option / Options . td <nl> def disable_swift_bridge_attr : Flag < [ " - " ] , " disable - swift - bridge - attr " > , <nl> Flags < [ FrontendOption , HelpHidden ] > , <nl> HelpText < " Disable using the swift bridge attribute " > ; <nl> <nl> + def enable_experimental_conditional_conformances : Flag < [ " - " ] , <nl> + " enable - experimental - conditional - conformances " > , <nl> + Flags < [ FrontendOption ] > , <nl> + HelpText < " Enable experimental implementation of SE - 0143 : Conditional Conformances " > ; <nl> + <nl> def enable_bridging_pch : Flag < [ " - " ] , " enable - bridging - pch " > , <nl> Flags < [ HelpHidden ] > , <nl> HelpText < " Enable automatic generation of bridging PCH files " > ; <nl> mmm a / lib / Driver / ToolChains . cpp <nl> ppp b / lib / Driver / ToolChains . cpp <nl> static void addCommonFrontendArgs ( const ToolChain & TC , <nl> options : : OPT_warn_swift3_objc_inference_complete ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_typo_correction_limit ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_app_extension ) ; <nl> + inputArgs . AddLastArg ( <nl> + arguments , <nl> + options : : OPT_enable_experimental_conditional_conformances ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_enable_testing ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_g_Group ) ; <nl> inputArgs . AddLastArg ( arguments , options : : OPT_import_underlying_module ) ; <nl> mmm a / lib / Frontend / CompilerInvocation . cpp <nl> ppp b / lib / Frontend / CompilerInvocation . cpp <nl> static bool ParseLangArgs ( LangOptions & Opts , ArgList & Args , <nl> Opts . EnableTargetOSChecking <nl> = A - > getOption ( ) . matches ( OPT_enable_target_os_checking ) ; <nl> } <nl> - <nl> + <nl> + Opts . EnableConditionalConformances | = <nl> + Args . hasArg ( OPT_enable_experimental_conditional_conformances ) ; <nl> Opts . EnableASTScopeLookup | = Args . hasArg ( OPT_enable_astscope_lookup ) ; <nl> Opts . DebugConstraintSolver | = Args . hasArg ( OPT_debug_constraints ) ; <nl> Opts . EnableConstraintPropagation | = Args . hasArg ( OPT_propagate_constraints ) ; <nl> mmm a / lib / Sema / TypeCheckProtocol . cpp <nl> ppp b / lib / Sema / TypeCheckProtocol . cpp <nl> void TypeChecker : : checkConformancesInContext ( DeclContext * dc , <nl> } <nl> } <nl> } <nl> + <nl> + / / If conditional conformances are disabled , complain about any that <nl> + / / occur . <nl> + if ( ! Context . LangOpts . EnableConditionalConformances ) { <nl> + for ( auto conformance : conformances ) { <nl> + auto normal = dyn_cast < NormalProtocolConformance > ( conformance ) ; <nl> + if ( ! normal ) continue ; <nl> + <nl> + if ( normal - > getConditionalRequirements ( ) . empty ( ) ) continue ; <nl> + <nl> + diagnose ( normal - > getLoc ( ) , diag : : experimental_conditional_conformances , <nl> + normal - > getType ( ) , normal - > getProtocol ( ) - > getDeclaredType ( ) ) ; <nl> + } <nl> + } <nl> } <nl> <nl> llvm : : TinyPtrVector < ValueDecl * > <nl> mmm a / stdlib / public / core / CMakeLists . txt <nl> ppp b / stdlib / public / core / CMakeLists . txt <nl> endif ( ) <nl> list ( APPEND swift_stdlib_compile_flags " - Xllvm " " - sil - inline - generics " ) <nl> list ( APPEND swift_stdlib_compile_flags " - Xllvm " " - sil - partial - specialization " ) <nl> list ( APPEND swift_stdlib_compile_flags " - Xfrontend " " - enable - sil - ownership " ) <nl> + list ( APPEND swift_stdlib_compile_flags <nl> + " - enable - experimental - conditional - conformances " ) <nl> <nl> if ( SWIFT_CHECK_ESSENTIAL_STDLIB ) <nl> add_swift_library ( swift_stdlib_essential $ { SWIFT_STDLIB_LIBRARY_BUILD_TYPES } IS_STDLIB IS_STDLIB_CORE <nl> mmm a / test / Generics / conditional_conformances . swift <nl> ppp b / test / Generics / conditional_conformances . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift - typecheck % s - verify <nl> - / / RUN : % target - typecheck - verify - swift - typecheck - debug - generic - signatures % s > % t . dump 2 > & 1 <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck % s - verify <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck - debug - generic - signatures % s > % t . dump 2 > & 1 <nl> / / RUN : % FileCheck % s < % t . dump <nl> <nl> protocol P1 { } <nl> mmm a / test / Generics / conditional_conformances_execute_smoke . swift <nl> ppp b / test / Generics / conditional_conformances_execute_smoke . swift <nl> <nl> - / / RUN : % target - run - simple - swift | % FileCheck % s <nl> + / / RUN : % empty - directory ( % t ) <nl> + / / RUN : % target - build - swift - enable - experimental - conditional - conformances % s - o % t / a . out <nl> + / / RUN : % target - run % t / a . out | % FileCheck % s <nl> <nl> / / Smoke test to see that various conditional conformances correctly execute <nl> <nl> mmm a / test / Generics / conditional_conformances_operators . swift <nl> ppp b / test / Generics / conditional_conformances_operators . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift - typecheck % s - verify <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck % s - verify <nl> <nl> / / rdar : / / problem / 35480952 <nl> <nl> mmm a / test / Generics / requirement_inference . swift <nl> ppp b / test / Generics / requirement_inference . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift - typecheck % s - verify <nl> - / / RUN : % target - typecheck - verify - swift - typecheck - debug - generic - signatures % s > % t . dump 2 > & 1 <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck % s - verify <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck - debug - generic - signatures % s > % t . dump 2 > & 1 <nl> / / RUN : % FileCheck % s < % t . dump <nl> <nl> protocol P1 { <nl> mmm a / test / IRGen / conditional_conformances . swift <nl> ppp b / test / IRGen / conditional_conformances . swift <nl> <nl> - / / RUN : % target - swift - frontend - emit - ir % S / . . / Inputs / conditional_conformance_basic_conformances . swift | % FileCheck % S / . . / Inputs / conditional_conformance_basic_conformances . swift <nl> - / / RUN : % target - swift - frontend - emit - ir % S / . . / Inputs / conditional_conformance_with_assoc . swift | % FileCheck % S / . . / Inputs / conditional_conformance_with_assoc . swift <nl> - / / RUN : % target - swift - frontend - emit - ir % S / . . / Inputs / conditional_conformance_subclass . swift | % FileCheck % S / . . / Inputs / conditional_conformance_subclass . swift <nl> - / / RUN : % target - swift - frontend - emit - ir % S / . . / Inputs / conditional_conformance_recursive . swift | % FileCheck % S / . . / Inputs / conditional_conformance_recursive . swift <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - emit - ir % S / . . / Inputs / conditional_conformance_basic_conformances . swift | % FileCheck % S / . . / Inputs / conditional_conformance_basic_conformances . swift <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - emit - ir % S / . . / Inputs / conditional_conformance_with_assoc . swift | % FileCheck % S / . . / Inputs / conditional_conformance_with_assoc . swift <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - emit - ir % S / . . / Inputs / conditional_conformance_subclass . swift | % FileCheck % S / . . / Inputs / conditional_conformance_subclass . swift <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - emit - ir % S / . . / Inputs / conditional_conformance_recursive . swift | % FileCheck % S / . . / Inputs / conditional_conformance_recursive . swift <nl> <nl> / / Too many pointer - sized integers in the IR <nl> / / REQUIRES : PTRSIZE = 64 <nl> mmm a / test / Interpreter / conditional_conformances . swift <nl> ppp b / test / Interpreter / conditional_conformances . swift <nl> <nl> / / RUN : % empty - directory ( % t ) <nl> / / The file that ' s ` main ` needs to be called that . <nl> / / RUN : cp % s % t / main . swift <nl> - / / RUN : % target - build - swift - D basic % t / main . swift % S / . . / Inputs / conditional_conformance_basic_conformances . swift - o % t / basic & & % target - run % t / basic <nl> - / / RUN : % target - build - swift - D with_assoc % t / main . swift % S / . . / Inputs / conditional_conformance_with_assoc . swift - o % t / with_assoc & & % target - run % t / with_assoc <nl> - / / RUN : % target - build - swift - D subclass % t / main . swift % S / . . / Inputs / conditional_conformance_subclass . swift - o % t / subclass & & % target - run % t / subclass <nl> + / / RUN : % target - build - swift - enable - experimental - conditional - conformances - D basic % t / main . swift % S / . . / Inputs / conditional_conformance_basic_conformances . swift - o % t / basic & & % target - run % t / basic <nl> + / / RUN : % target - build - swift - enable - experimental - conditional - conformances - D with_assoc % t / main . swift % S / . . / Inputs / conditional_conformance_with_assoc . swift - o % t / with_assoc & & % target - run % t / with_assoc <nl> + / / RUN : % target - build - swift - enable - experimental - conditional - conformances - D subclass % t / main . swift % S / . . / Inputs / conditional_conformance_subclass . swift - o % t / subclass & & % target - run % t / subclass <nl> <nl> / / REQUIRES : executable_test <nl> <nl> mmm a / test / Interpreter / conditional_conformances_modules . swift <nl> ppp b / test / Interpreter / conditional_conformances_modules . swift <nl> <nl> / / RUN : % empty - directory ( % t ) <nl> - / / RUN : % target - build - swift - dylib ( % t / libBasic . % target - dylib - extension ) % S / . . / Inputs / conditional_conformance_basic_conformances . swift - module - name Basic - emit - module - emit - module - path % t / Basic . swiftmodule <nl> - / / RUN : % target - build - swift - dylib ( % t / libWithAssoc . % target - dylib - extension ) % S / . . / Inputs / conditional_conformance_with_assoc . swift - module - name WithAssoc - emit - module - emit - module - path % t / WithAssoc . swiftmodule <nl> - / / RUN : % target - build - swift - dylib ( % t / libSubclass . % target - dylib - extension ) % S / . . / Inputs / conditional_conformance_subclass . swift - module - name Subclass - emit - module - emit - module - path % t / Subclass . swiftmodule <nl> + / / RUN : % target - build - swift - dylib ( % t / libBasic . % target - dylib - extension ) - enable - experimental - conditional - conformances % S / . . / Inputs / conditional_conformance_basic_conformances . swift - module - name Basic - emit - module - emit - module - path % t / Basic . swiftmodule <nl> + / / RUN : % target - build - swift - dylib ( % t / libWithAssoc . % target - dylib - extension ) - enable - experimental - conditional - conformances % S / . . / Inputs / conditional_conformance_with_assoc . swift - module - name WithAssoc - emit - module - emit - module - path % t / WithAssoc . swiftmodule <nl> + / / RUN : % target - build - swift - dylib ( % t / libSubclass . % target - dylib - extension ) - enable - experimental - conditional - conformances % S / . . / Inputs / conditional_conformance_subclass . swift - module - name Subclass - emit - module - emit - module - path % t / Subclass . swiftmodule <nl> / / RUN : % target - build - swift - I % t - L % t - lBasic - lWithAssoc - lSubclass % s - o % t / conditional_conformances_modules - Xlinker - rpath - Xlinker % t <nl> / / RUN : % target - run % t / conditional_conformances_modules % t / libBasic . % target - dylib - extension % t / libWithAssoc . % target - dylib - extension <nl> <nl> mmm a / test / Interpreter / conditional_conformances_smoke . swift <nl> ppp b / test / Interpreter / conditional_conformances_smoke . swift <nl> <nl> - / / RUN : % target - run - simple - swift | % FileCheck % s <nl> + / / RUN : % empty - directory ( % t ) <nl> + / / RUN : % target - build - swift - enable - experimental - conditional - conformances % s - o % t / a . out <nl> + / / RUN : % target - run % t / a . out | % FileCheck % s <nl> <nl> / / REQUIRES : executable_test <nl> <nl> mmm a / test / SIL / Parser / witness_tables . sil <nl> ppp b / test / SIL / Parser / witness_tables . sil <nl> <nl> - / / RUN : % target - sil - opt - assume - parsing - unqualified - ownership - sil % s - module - name = witness_tables | % target - sil - opt - assume - parsing - unqualified - ownership - sil - module - name = witness_tables | % FileCheck % s <nl> + / / RUN : % target - sil - opt - enable - experimental - conditional - conformances - assume - parsing - unqualified - ownership - sil % s - module - name = witness_tables | % target - sil - opt - enable - experimental - conditional - conformances - assume - parsing - unqualified - ownership - sil - module - name = witness_tables | % FileCheck % s <nl> <nl> protocol AssocReqt { <nl> func requiredMethod ( ) <nl> mmm a / test / SILGen / conditional_conformance . swift <nl> ppp b / test / SILGen / conditional_conformance . swift <nl> <nl> - / / RUN : % target - swift - frontend - emit - silgen - enable - sil - ownership % s | % FileCheck % s <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - emit - silgen - enable - sil - ownership % s | % FileCheck % s <nl> <nl> protocol P1 { <nl> func normal ( ) <nl> mmm a / test / SILOptimizer / devirt_conditional_conformance . swift <nl> ppp b / test / SILOptimizer / devirt_conditional_conformance . swift <nl> <nl> - / / RUN : % target - swift - frontend - O - Xllvm - sil - inline - generics = false - Xllvm - sil - disable - pass = GlobalOpt % s - emit - sil - sil - verify - all | % FileCheck % s <nl> + / / RUN : % target - swift - frontend - enable - experimental - conditional - conformances - O - Xllvm - sil - inline - generics = false - Xllvm - sil - disable - pass = GlobalOpt % s - emit - sil - sil - verify - all | % FileCheck % s <nl> <nl> <nl> public protocol Foo { <nl> mmm a / test / Sema / enum_equatable_conditional . swift <nl> ppp b / test / Sema / enum_equatable_conditional . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances <nl> <nl> struct NotEquatable { } <nl> <nl> mmm a / test / decl / ext / generic . swift <nl> ppp b / test / decl / ext / generic . swift <nl> func genericClassNotEquatable < T > ( _ gc : GenericClass < T > , x : T , y : T ) { <nl> <nl> extension Array where Element = = String { } <nl> <nl> - extension GenericClass : P3 where T : P3 { } <nl> + extension GenericClass : P3 where T : P3 { } / / expected - error { { conditional conformance of ' GenericClass < T > ' to ' P3 ' depends on an experimental feature ( SE - 0143 ) } } <nl> <nl> extension GenericClass where Self : P3 { } <nl> / / expected - error @ - 1 { { ' Self ' is only available in a protocol or as the result of a method in a class ; did you mean ' GenericClass ' ? } } { { 30 - 34 = GenericClass } } <nl> mmm a / test / decl / var / properties . swift <nl> ppp b / test / decl / var / properties . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift <nl> + / / RUN : % target - typecheck - verify - swift - enable - experimental - conditional - conformances - typecheck <nl> <nl> func markUsed < T > ( _ t : T ) { } <nl> <nl> mmm a / tools / sil - opt / SILOpt . cpp <nl> ppp b / tools / sil - opt / SILOpt . cpp <nl> AssumeUnqualifiedOwnershipWhenParsing ( <nl> " assume - parsing - unqualified - ownership - sil " , llvm : : cl : : Hidden , llvm : : cl : : init ( false ) , <nl> llvm : : cl : : desc ( " Assume all parsed functions have unqualified ownership " ) ) ; <nl> <nl> + static llvm : : cl : : opt < bool > <nl> + EnableExperimentalConditionalConformances ( <nl> + " enable - experimental - conditional - conformances " , llvm : : cl : : Hidden , <nl> + llvm : : cl : : init ( false ) , <nl> + llvm : : cl : : desc ( " Enable experimental implementation of SE - 0143 : Conditional Conformances " ) ) ; <nl> + <nl> / / / Regular expression corresponding to the value given in one of the <nl> / / / - pass - remarks * command line flags . Passes whose name matches this regexp <nl> / / / will emit a diagnostic . <nl> int main ( int argc , char * * argv ) { <nl> llvm : : Triple ( Target ) . isOSDarwin ( ) ; <nl> <nl> Invocation . getLangOptions ( ) . EnableSILOpaqueValues = EnableSILOpaqueValues ; <nl> - <nl> + Invocation . getLangOptions ( ) . EnableConditionalConformances | = <nl> + EnableExperimentalConditionalConformances ; <nl> Invocation . getLangOptions ( ) . OptimizationRemarkPassedPattern = <nl> createOptRemarkRegex ( PassRemarksPassed ) ; <nl> Invocation . getLangOptions ( ) . OptimizationRemarkMissedPattern = <nl>
|
[ SE - 0143 ] Put conditional conformances behind an " experimental " flag .
|
apple/swift
|
b59c30c1afe2ae29ee20f14328b3ecb012fc02d6
|
2017-11-29T00:01:51Z
|
mmm a / atom . gyp <nl> ppp b / atom . gyp <nl> <nl> ' product_name % ' : ' Electron ' , <nl> ' company_name % ' : ' GitHub , Inc ' , <nl> ' company_abbr % ' : ' github ' , <nl> - ' version % ' : ' 0 . 30 . 2 ' , <nl> + ' version % ' : ' 0 . 30 . 3 ' , <nl> } , <nl> ' includes ' : [ <nl> ' filenames . gypi ' , <nl> mmm a / atom / browser / resources / mac / Info . plist <nl> ppp b / atom / browser / resources / mac / Info . plist <nl> <nl> < key > CFBundleIconFile < / key > <nl> < string > atom . icns < / string > <nl> < key > CFBundleVersion < / key > <nl> - < string > 0 . 30 . 2 < / string > <nl> + < string > 0 . 30 . 3 < / string > <nl> < key > LSMinimumSystemVersion < / key > <nl> < string > 10 . 8 . 0 < / string > <nl> < key > NSMainNibFile < / key > <nl> mmm a / atom / browser / resources / win / atom . rc <nl> ppp b / atom / browser / resources / win / atom . rc <nl> END <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 0 , 30 , 2 , 0 <nl> - PRODUCTVERSION 0 , 30 , 2 , 0 <nl> + FILEVERSION 0 , 30 , 3 , 0 <nl> + PRODUCTVERSION 0 , 30 , 3 , 0 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " GitHub , Inc . " <nl> VALUE " FileDescription " , " Electron " <nl> - VALUE " FileVersion " , " 0 . 30 . 2 " <nl> + VALUE " FileVersion " , " 0 . 30 . 3 " <nl> VALUE " InternalName " , " electron . exe " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2015 GitHub , Inc . All rights reserved . " <nl> VALUE " OriginalFilename " , " electron . exe " <nl> VALUE " ProductName " , " Electron " <nl> - VALUE " ProductVersion " , " 0 . 30 . 2 " <nl> + VALUE " ProductVersion " , " 0 . 30 . 3 " <nl> VALUE " SquirrelAwareVersion " , " 1 " <nl> END <nl> END <nl> mmm a / atom / common / atom_version . h <nl> ppp b / atom / common / atom_version . h <nl> <nl> <nl> # define ATOM_MAJOR_VERSION 0 <nl> # define ATOM_MINOR_VERSION 30 <nl> - # define ATOM_PATCH_VERSION 2 <nl> + # define ATOM_PATCH_VERSION 3 <nl> <nl> # define ATOM_VERSION_IS_RELEASE 1 <nl> <nl>
|
Bump v0 . 30 . 3
|
electron/electron
|
0bf5effe58b06732da5e2d2a48f2a5a4a8fcda6f
|
2015-08-07T14:04:59Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.