diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / src / mongo / db / repl / apply_ops . cpp <nl> ppp b / src / mongo / db / repl / apply_ops . cpp <nl> <nl> # include " mongo / db / repl / replication_coordinator_global . h " <nl> # include " mongo / db / service_context . h " <nl> # include " mongo / rpc / get_status_from_command_result . h " <nl> + # include " mongo / util / fail_point_service . h " <nl> # include " mongo / util / log . h " <nl> <nl> namespace mongo { <nl> namespace { <nl> + <nl> + / / If enabled , causes loop in _applyOps ( ) to hang after applying current operation . <nl> + MONGO_FP_DECLARE ( applyOpsPauseBetweenOperations ) ; <nl> + <nl> / * * <nl> * Return true iff the applyOpsCmd can be executed in a single WriteUnitOfWork . <nl> * / <nl> Status _applyOps ( OperationContext * opCtx , <nl> } <nl> <nl> ( * numApplied ) + + ; <nl> + <nl> + if ( MONGO_FAIL_POINT ( applyOpsPauseBetweenOperations ) ) { <nl> + / / While holding a database lock under MMAPv1 , we would be implicitly holding the <nl> + / / flush lock here . This would prevent other threads from acquiring the global <nl> + / / lock or any database locks . We release all locks temporarily while the fail <nl> + / / point is enabled to allow other threads to make progress . <nl> + boost : : optional < Lock : : TempRelease > release ; <nl> + auto storageEngine = opCtx - > getServiceContext ( ) - > getGlobalStorageEngine ( ) ; <nl> + if ( storageEngine - > isMmapV1 ( ) & & ! opCtx - > lockState ( ) - > isW ( ) ) { <nl> + release . emplace ( opCtx - > lockState ( ) ) ; <nl> + } <nl> + MONGO_FAIL_POINT_PAUSE_WHILE_SET ( applyOpsPauseBetweenOperations ) ; <nl> + } <nl> } <nl> <nl> result - > append ( " applied " , * numApplied ) ; <nl>
|
SERVER - 29802 add applyOpsPauseBetweenOperations fail point
|
mongodb/mongo
|
948776e76550e4ddf4a3d0f50b729f15bef0a97b
|
2017-08-04T12:31:05Z
|
mmm a / DEPS <nl> ppp b / DEPS <nl> deps = { <nl> ' dep_type ' : ' cipd ' , <nl> } , <nl> ' v8 / test / wasm - js / data ' : <nl> - Var ( ' chromium_url ' ) + ' / external / github . com / WebAssembly / spec . git ' + ' @ ' + ' b568df78595ea6d6c6c6f6d6b931674900dd3f1d ' , <nl> + Var ( ' chromium_url ' ) + ' / external / github . com / WebAssembly / spec . git ' + ' @ ' + ' 024e273c28f602eb6696bce535f234ea44e02519 ' , <nl> ' v8 / third_party / perfetto ' : <nl> Var ( ' android_url ' ) + ' / platform / external / perfetto . git ' + ' @ ' + ' 10c98fe0cfae669f71610d97e9da94260a6da173 ' , <nl> ' v8 / third_party / protobuf ' : <nl>
|
Update wasm - spec .
|
v8/v8
|
d4e7e9e6945355f2b0dae960ab2f4a2cc3ac9fc9
|
2019-06-28T04:52:25Z
|
mmm a / hphp / hack / src / parser / coroutine / coroutine_lowerer . ml <nl> ppp b / hphp / hack / src / parser / coroutine / coroutine_lowerer . ml <nl> <nl> * ) <nl> <nl> module CoroutineMethodLowerer = Coroutine_method_lowerer <nl> + module CoroutineStateMachineGenerator = Coroutine_state_machine_generator <nl> module CoroutineSyntax = Coroutine_syntax <nl> module EditableSyntax = Full_fidelity_editable_syntax <nl> module List = Core_list <nl> open EditableSyntax <nl> * If the provided methodish declaration is for a coroutine , rewrites the <nl> * methodish declaration into a desugared coroutine implementation . <nl> * ) <nl> - let maybe_rewrite_method node = <nl> + let maybe_rewrite_method_and_generate_state_machine node = <nl> match syntax node with <nl> | MethodishDeclaration node - > <nl> - ( * TODO ( tingley ) : Using the MethodishDeclaration , generate the coroutine <nl> - state machine if the node is a coroutine . * ) <nl> - CoroutineMethodLowerer . maybe_rewrite_methodish_declaration node <nl> + Option . value_map <nl> + ( CoroutineMethodLowerer . maybe_rewrite_methodish_declaration node ) <nl> + ~ default : None <nl> + ~ f : ( fun method_node - > <nl> + Option . both <nl> + ( Some method_node ) <nl> + ( CoroutineStateMachineGenerator . generate_coroutine_state_machine <nl> + node ) <nl> + ) <nl> | _ - > <nl> ( * Irrelevant input . * ) <nl> None <nl> let maybe_rewrite_method node = <nl> * Transforms method nodes , accumulating all nodes . Accumulates whether at least <nl> * one node has been transformed . <nl> * ) <nl> - let rewrite_classish_body_element ( methods_acc , any_rewritten_acc ) node = <nl> + let rewrite_classish_body_element <nl> + ( methods_acc , state_machines_acc , any_rewritten_acc ) node = <nl> Option . value_map <nl> - ( maybe_rewrite_method node ) <nl> - ~ default : ( node : : methods_acc , any_rewritten_acc ) <nl> - ~ f : ( fun method_node - > method_node : : methods_acc , true ) <nl> + ( maybe_rewrite_method_and_generate_state_machine node ) <nl> + ~ default : ( node : : methods_acc , state_machines_acc , any_rewritten_acc ) <nl> + ~ f : ( fun ( method_node , state_machine_node ) - > <nl> + method_node : : methods_acc , <nl> + state_machine_node : : state_machines_acc , <nl> + true ) <nl> <nl> ( * * <nl> * Rewrites classish body elements . If at least one element is modified , then <nl> let rewrite_classish_body_element ( methods_acc , any_rewritten_acc ) node = <nl> let maybe_rewrite_classish_body_elements node = <nl> match syntax node with <nl> | SyntaxList syntax_list - > <nl> - let rewritten_nodes , any_rewritten = <nl> + let rewritten_nodes , state_machine_nodes , any_rewritten = <nl> List . fold <nl> ~ f : rewrite_classish_body_element <nl> - ~ init : ( [ ] , false ) <nl> + ~ init : ( [ ] , [ ] , false ) <nl> syntax_list in <nl> if any_rewritten then <nl> - Some ( make_list rewritten_nodes ) <nl> + Some ( make_list rewritten_nodes , state_machine_nodes ) <nl> else <nl> None <nl> | _ - > <nl> let maybe_rewrite_classish_body node = <nl> | ClassishBody ( { classish_body_elements ; _ ; } as node ) - > <nl> Option . map <nl> ( maybe_rewrite_classish_body_elements classish_body_elements ) <nl> - ( fun classish_body_elements - > <nl> - make_syntax { node with classish_body_elements ; } ) <nl> + ( fun ( classish_body_elements , state_machine_nodes ) - > <nl> + make_syntax { node with classish_body_elements ; } , <nl> + state_machine_nodes ) <nl> | _ - > <nl> ( * Unexpected or malformed input , so we won ' t transform the coroutine . * ) <nl> None <nl> <nl> ( * * <nl> * If the class contains at least one coroutine method , then those methods are <nl> - * rewritten . Otherwise , the class is not transformed . <nl> + * rewritten , and state machines are generated as necessary . Otherwise , the <nl> + * class is not transformed . <nl> * ) <nl> let maybe_rewrite_class node = <nl> let make_syntax node = make_syntax ( ClassishDeclaration node ) in <nl> let maybe_rewrite_class node = <nl> | ClassishDeclaration ( { classish_body ; _ ; } as class_node ) - > <nl> Option . map <nl> ( maybe_rewrite_classish_body classish_body ) <nl> - ~ f : ( fun classish_body - > <nl> - make_syntax { class_node with classish_body ; } ) <nl> + ~ f : ( fun ( classish_body , state_machine_nodes ) - > <nl> + make_syntax { class_node with classish_body ; } , <nl> + state_machine_nodes ) <nl> | _ - > <nl> ( * Irrelevant input . * ) <nl> None <nl> <nl> ( * * <nl> * Rewrites toplevel classes . The class nodes themselves are transformed <nl> - * directly . <nl> + * directly . Generated state machine nodes are collected and written alongside <nl> + * of the class nodes . <nl> * ) <nl> let rewrite_classes ( node_acc , any_rewritten_acc ) node = <nl> Option . value_map <nl> ( maybe_rewrite_class node ) <nl> ~ default : ( node : : node_acc , any_rewritten_acc ) <nl> - ~ f : ( fun node - > node : : node_acc , true ) <nl> + ~ f : ( fun ( node , state_machine_nodes ) - > <nl> + node : : ( state_machine_nodes @ node_acc ) , true ) <nl> <nl> ( * * <nl> - * Rewrites classes containing coroutine methods . <nl> + * Rewrites classes containing coroutine methods . Additional state machine <nl> + * classes may be generated alongside of the original class . <nl> * ) <nl> let maybe_rewrite_syntax_list node = <nl> match syntax node with <nl> new file mode 100644 <nl> index 00000000000 . . 24994a8a4aa <nl> mmm / dev / null <nl> ppp b / hphp / hack / src / parser / coroutine / coroutine_state_machine_generator . ml <nl> <nl> + ( * * <nl> + * Copyright ( c ) 2016 , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the " hack " directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * ) <nl> + <nl> + module CoroutineSyntax = Coroutine_syntax <nl> + module EditableSyntax = Full_fidelity_editable_syntax <nl> + <nl> + open EditableSyntax <nl> + open CoroutineSyntax <nl> + <nl> + let generate_constructor_body = <nl> + make_missing ( ) <nl> + <nl> + let generate_constructor_method { function_type ; _ ; } = <nl> + make_methodish_declaration_syntax <nl> + ( make_constructor_decl_header_syntax <nl> + constructor_member_name <nl> + [ make_continuation_parameter_syntax function_type ] ) <nl> + [ ] <nl> + <nl> + let generate_resume_body { methodish_function_body ; _ ; } = <nl> + let select_do_resume_syntax = <nl> + make_member_selection_expression_syntax this_syntax do_resume_member_name in <nl> + let call_do_resume_syntax = <nl> + make_function_call_expression_syntax <nl> + select_do_resume_syntax <nl> + [ coroutune_data_variable_syntax ; null_syntax ] in <nl> + [ make_expression_statement call_do_resume_syntax ] <nl> + <nl> + let generate_resume_method method_node = <nl> + make_methodish_declaration_syntax <nl> + ( make_function_decl_header_syntax <nl> + resume_member_name <nl> + [ coroutine_data_parameter_syntax ] <nl> + void_syntax ) <nl> + ( generate_resume_body method_node ) <nl> + <nl> + let generate_resume_with_exception_body _ = <nl> + let select_do_resume_syntax = <nl> + make_member_selection_expression_syntax this_syntax do_resume_member_name in <nl> + let call_do_resume_syntax = <nl> + make_function_call_expression_syntax <nl> + select_do_resume_syntax <nl> + [ null_syntax ; exception_variable_syntax ] in <nl> + [ make_expression_statement call_do_resume_syntax ] <nl> + <nl> + let generate_resume_with_exception_method method_node = <nl> + make_methodish_declaration_syntax <nl> + ( make_function_decl_header_syntax <nl> + resume_with_exception_member_name <nl> + [ exception_parameter_syntax ] <nl> + void_syntax ) <nl> + ( generate_resume_with_exception_body method_node ) <nl> + <nl> + let generate_do_resume_body _ = <nl> + [ throw_unimplemented_syntax " Coroutines are not yet implemented . " ] <nl> + <nl> + let generate_do_resume_method method_node = <nl> + make_methodish_declaration_syntax <nl> + ( make_function_decl_header_syntax <nl> + do_resume_member_name <nl> + [ coroutine_data_parameter_syntax ; nullable_exception_parameter_syntax ] <nl> + void_syntax ) <nl> + ( generate_do_resume_body method_node ) <nl> + <nl> + let generate_state_machine_body method_node header_node = <nl> + [ <nl> + generate_constructor_method header_node ; <nl> + generate_resume_method method_node ; <nl> + generate_resume_with_exception_method method_node ; <nl> + generate_do_resume_method method_node ; <nl> + ] <nl> + <nl> + ( * * <nl> + * If the provided methodish declaration is for a coroutine , rewrites the <nl> + * declaration header and the function body into a desugared coroutine <nl> + * implementation . <nl> + * ) <nl> + let generate_coroutine_state_machine <nl> + ( { methodish_function_decl_header ; _ ; } as method_node ) = <nl> + match syntax methodish_function_decl_header with <nl> + | FunctionDeclarationHeader <nl> + ( { function_name ; function_type ; _ ; } as header_node ) - > <nl> + Some ( <nl> + make_classish_declaration_syntax <nl> + ( make_state_machine_classname ( text function_name ) ) <nl> + [ make_continuation_type_syntax function_type ] <nl> + ( generate_state_machine_body method_node header_node ) <nl> + ) <nl> + | _ - > None <nl> mmm a / hphp / hack / src / parser / coroutine / coroutine_syntax . ml <nl> ppp b / hphp / hack / src / parser / coroutine / coroutine_syntax . ml <nl> let make_token_syntax <nl> <nl> ( * General syntaxes * ) <nl> <nl> + let left_brace_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . LeftBrace " { " <nl> + <nl> + let right_brace_syntax = <nl> + make_token_syntax <nl> + ~ space_before : true <nl> + ~ space_after : true <nl> + TokenKind . RightBrace " } " <nl> + <nl> let left_paren_syntax = <nl> make_token_syntax TokenKind . LeftParen " ( " <nl> <nl> let colon_colon_syntax = <nl> let semicolon_syntax = <nl> make_token_syntax TokenKind . Semicolon " ; " <nl> <nl> + let colon_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Colon " : " <nl> + <nl> + let nullable_syntax = <nl> + make_token_syntax TokenKind . Question " ? " <nl> + <nl> + let mixed_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Mixed " mixed " <nl> + <nl> + let void_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Void " void " <nl> + <nl> let null_syntax = <nl> make_token_syntax TokenKind . NullLiteral " null " <nl> <nl> + let class_keyword_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Class " class " <nl> + <nl> + let function_keyword_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Function " function " <nl> + <nl> + let implements_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Implements " implements " <nl> + <nl> let return_keyword_syntax = <nl> make_token_syntax ~ space_after : true TokenKind . Return " return " <nl> <nl> + let throw_keyword_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Throw " throw " <nl> + <nl> let new_keyword_syntax = <nl> make_token_syntax ~ space_after : true TokenKind . New " new " <nl> <nl> let member_selection_syntax = <nl> make_token_syntax TokenKind . MinusGreaterThan " - > " <nl> <nl> + let this_syntax = <nl> + make_token_syntax TokenKind . Variable " $ this " <nl> + <nl> + let exception_type_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Classname " Exception " <nl> + <nl> <nl> ( * Syntax creation functions * ) <nl> <nl> let rec delimit delimit_syntax = function <nl> let make_delimited_list delimit_syntax items = <nl> make_list ( delimit delimit_syntax items ) <nl> <nl> + <nl> + let make_nullable_type_specifier_syntax type_syntax = <nl> + make_nullable_type_specifier nullable_syntax type_syntax <nl> + <nl> + let make_string_literal_syntax string_literal = <nl> + make_literal_expression <nl> + ( make_token_syntax <nl> + TokenKind . DoubleQuotedStringLiteral <nl> + ( Printf . sprintf " \ " % s \ " " string_literal ) ) <nl> + <nl> let make_expression_statement expression_syntax = <nl> make_expression_statement expression_syntax semicolon_syntax <nl> <nl> + let make_compound_statement_syntax compound_statements = <nl> + make_compound_statement <nl> + left_brace_syntax <nl> + ( make_list compound_statements ) <nl> + right_brace_syntax <nl> + <nl> let make_return_statement_syntax expression_syntax = <nl> make_return_statement return_keyword_syntax expression_syntax semicolon_syntax <nl> <nl> + let make_throw_statement_syntax expression_syntax = <nl> + make_throw_statement throw_keyword_syntax expression_syntax semicolon_syntax <nl> + <nl> let make_object_creation_expression_syntax classname arguments = <nl> let classname_syntax = make_token_syntax TokenKind . Classname classname in <nl> let arguments_syntax = make_delimited_list comma_syntax arguments in <nl> let make_static_function_call_expression_syntax <nl> member_syntax in <nl> make_function_call_expression_syntax receiver_syntax argument_list <nl> <nl> - <nl> let make_member_selection_expression_syntax receiver_syntax member_name = <nl> let member_name_syntax = make_token_syntax TokenKind . Name member_name in <nl> make_member_selection_expression <nl> let make_generic_type_specifier_syntax classname generic_argument_list = <nl> right_angle_syntax in <nl> make_generic_type_specifier classname_syntax type_arguments_syntax <nl> <nl> + ( * TODO ( tingley ) : Determine if it ' s worth tightening visibility here . * ) <nl> + let make_classish_declaration_syntax classname implements_list classish_body = <nl> + let classname_syntax = <nl> + make_token_syntax ~ space_after : true TokenKind . Classname classname in <nl> + let implements_list_syntax = <nl> + make_delimited_list comma_syntax implements_list in <nl> + make_classish_declaration <nl> + ( * classish_attribute * ) ( make_missing ( ) ) <nl> + ( * classish_modifiers * ) ( make_missing ( ) ) <nl> + class_keyword_syntax <nl> + classname_syntax <nl> + ( * classish_type_parameters * ) ( make_missing ( ) ) <nl> + ( * classish_extends_keyword * ) ( make_missing ( ) ) <nl> + ( * classish_extends_list * ) ( make_missing ( ) ) <nl> + ( if is_missing implements_list_syntax then <nl> + make_missing ( ) <nl> + else <nl> + implements_syntax ) <nl> + implements_list_syntax <nl> + ( make_compound_statement_syntax classish_body ) <nl> + <nl> + ( * TODO ( tingley ) : Determine if it ' s worth tightening visibility here . * ) <nl> + let make_methodish_declaration_syntax <nl> + function_decl_header_syntax <nl> + function_body = <nl> + make_methodish_declaration <nl> + ( * methodish_attribute * ) ( make_missing ( ) ) <nl> + ( * methodish_modifiers * ) ( make_missing ( ) ) <nl> + function_decl_header_syntax <nl> + ( make_compound_statement_syntax function_body ) <nl> + ( * methodish_semicolon * ) ( make_missing ( ) ) <nl> + <nl> + let make_function_decl_header_syntax <nl> + name <nl> + parameter_list <nl> + return_type_syntax = <nl> + let name_syntax = make_token_syntax TokenKind . Name name in <nl> + let parameter_list_syntax = make_delimited_list comma_syntax parameter_list in <nl> + make_function_declaration_header <nl> + ( * function_async * ) ( make_missing ( ) ) <nl> + ( * function_coroutine * ) ( make_missing ( ) ) <nl> + function_keyword_syntax <nl> + ( * function_ampersand * ) ( make_missing ( ) ) <nl> + name_syntax <nl> + ( * function_type_parameter_list * ) ( make_missing ( ) ) <nl> + left_paren_syntax <nl> + parameter_list_syntax <nl> + right_paren_syntax <nl> + ( if is_missing return_type_syntax then make_missing ( ) else colon_syntax ) <nl> + return_type_syntax <nl> + ( * function_where_clause * ) ( make_missing ( ) ) <nl> + <nl> + let make_constructor_decl_header_syntax name parameter_list = <nl> + make_function_decl_header_syntax name parameter_list ( make_missing ( ) ) <nl> + <nl> <nl> ( * Coroutine - specific syntaxes * ) <nl> <nl> let continuation_variable = <nl> let continuation_variable_syntax = <nl> make_token_syntax TokenKind . Variable continuation_variable <nl> <nl> + let make_continuation_type_syntax return_type_syntax = <nl> + make_generic_type_specifier_syntax <nl> + " CoroutineContinuation " <nl> + [ return_type_syntax ] <nl> + <nl> let make_continuation_parameter_syntax return_type_syntax = <nl> - let continuation_type_syntax = <nl> - make_generic_type_specifier_syntax <nl> - " CoroutineContinuation " <nl> - [ return_type_syntax ] in <nl> make_parameter_declaration_syntax <nl> - continuation_type_syntax <nl> + ( make_continuation_type_syntax return_type_syntax ) <nl> continuation_variable <nl> <nl> let make_coroutine_result_type_syntax return_type_syntax = <nl> let suspended_member_name = <nl> let make_state_machine_classname coroutine_function_name = <nl> coroutine_function_name ^ " _GeneratedStateMachine " <nl> <nl> + let constructor_member_name = <nl> + " __construct " <nl> + <nl> let resume_member_name = <nl> " resume " <nl> + <nl> + let resume_with_exception_member_name = <nl> + " resumeWithException " <nl> + <nl> + let do_resume_member_name = <nl> + " doResume " <nl> + <nl> + let coroutune_data_variable = <nl> + " $ coroutineData " <nl> + <nl> + let coroutune_data_variable_syntax = <nl> + make_token_syntax TokenKind . Variable coroutune_data_variable <nl> + <nl> + let coroutune_data_type_syntax = <nl> + mixed_syntax <nl> + <nl> + let coroutine_data_parameter_syntax = <nl> + make_parameter_declaration_syntax <nl> + coroutune_data_type_syntax <nl> + coroutune_data_variable <nl> + <nl> + let exception_variable = <nl> + " $ exception " <nl> + <nl> + let exception_variable_syntax = <nl> + make_token_syntax TokenKind . Variable exception_variable <nl> + <nl> + let exception_parameter_syntax = <nl> + make_parameter_declaration_syntax <nl> + exception_type_syntax <nl> + exception_variable <nl> + <nl> + let nullable_exception_parameter_syntax = <nl> + make_parameter_declaration_syntax <nl> + ( make_nullable_type_specifier_syntax exception_type_syntax ) <nl> + exception_variable <nl> + <nl> + let throw_unimplemented_syntax reason = <nl> + let create_exception_syntax = <nl> + make_object_creation_expression_syntax <nl> + " NotImplementedException " <nl> + [ make_string_literal_syntax reason ] in <nl> + make_throw_statement_syntax create_exception_syntax <nl>
|
Implement basic coroutine state machine generation
|
facebook/hhvm
|
e87f1f0edea812d76b0e720e96ece75b436d5ae3
|
2017-04-21T16:47:00Z
|
mmm a / Telegram / SourceFiles / data / data_channel . cpp <nl> ppp b / Telegram / SourceFiles / data / data_channel . cpp <nl> void ChannelData : : setName ( const QString & newName , const QString & newUsername ) { <nl> updateNameDelayed ( newName . isEmpty ( ) ? name : newName , QString ( ) , newUsername ) ; <nl> } <nl> <nl> + void ChannelData : : setAccessHash ( uint64 accessHash ) { <nl> + access = accessHash ; <nl> + input = MTP_inputPeerChannel ( MTP_int ( bareId ( ) ) , MTP_long ( accessHash ) ) ; <nl> + inputChannel = MTP_inputChannel ( MTP_int ( bareId ( ) ) , MTP_long ( accessHash ) ) ; <nl> + } <nl> + <nl> void ChannelData : : setInviteLink ( const QString & newInviteLink ) { <nl> if ( newInviteLink ! = _inviteLink ) { <nl> _inviteLink = newInviteLink ; <nl> mmm a / Telegram / SourceFiles / data / data_channel . h <nl> ppp b / Telegram / SourceFiles / data / data_channel . h <nl> class ChannelData : public PeerData { <nl> void setPhoto ( PhotoId photoId , const MTPChatPhoto & photo ) ; <nl> <nl> void setName ( const QString & name , const QString & username ) ; <nl> + void setAccessHash ( uint64 accessHash ) ; <nl> <nl> void setFlags ( MTPDchannel : : Flags which ) { <nl> _flags . set ( which ) ; <nl> mmm a / Telegram / SourceFiles / data / data_chat_filters . cpp <nl> ppp b / Telegram / SourceFiles / data / data_chat_filters . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_user . h " <nl> # include " data / data_chat . h " <nl> # include " data / data_channel . h " <nl> + # include " data / data_session . h " <nl> + # include " main / main_session . h " <nl> + # include " apiwrap . h " <nl> <nl> namespace Data { <nl> <nl> ChatFilter : : ChatFilter ( <nl> + FilterId id , <nl> const QString & title , <nl> Flags flags , <nl> - base : : flat_set < not_null < History * > > always ) <nl> - : _title ( title ) <nl> + base : : flat_set < not_null < History * > > always , <nl> + base : : flat_set < not_null < History * > > never ) <nl> + : _id ( id ) <nl> + , _title ( title ) <nl> , _always ( std : : move ( always ) ) <nl> + , _never ( std : : move ( never ) ) <nl> , _flags ( flags ) { <nl> } <nl> <nl> + ChatFilter ChatFilter : : FromTL ( <nl> + const MTPDialogFilter & data , <nl> + not_null < Session * > owner ) { <nl> + return data . match ( [ & ] ( const MTPDdialogFilter & data ) { <nl> + const auto flags = ( data . is_contacts ( ) ? Flag : : Contacts : Flag ( 0 ) ) <nl> + | ( data . is_non_contacts ( ) ? Flag : : NonContacts : Flag ( 0 ) ) <nl> + | ( data . is_groups ( ) ? Flag : : Groups : Flag ( 0 ) ) <nl> + | ( data . is_broadcasts ( ) ? Flag : : Broadcasts : Flag ( 0 ) ) <nl> + | ( data . is_bots ( ) ? Flag : : Bots : Flag ( 0 ) ) <nl> + | ( data . is_exclude_muted ( ) ? Flag : : NoMuted : Flag ( 0 ) ) <nl> + | ( data . is_exclude_read ( ) ? Flag : : NoRead : Flag ( 0 ) ) <nl> + | ( data . is_exclude_archived ( ) ? Flag : : NoArchive : Flag ( 0 ) ) ; <nl> + auto & & to_histories = ranges : : view : : transform ( [ & ] ( <nl> + const MTPInputPeer & data ) { <nl> + const auto peer = data . match ( [ & ] ( const MTPDinputPeerUser & data ) { <nl> + const auto user = owner - > user ( data . vuser_id ( ) . v ) ; <nl> + user - > setAccessHash ( data . vaccess_hash ( ) . v ) ; <nl> + return ( PeerData * ) user ; <nl> + } , [ & ] ( const MTPDinputPeerChat & data ) { <nl> + return ( PeerData * ) owner - > chat ( data . vchat_id ( ) . v ) ; <nl> + } , [ & ] ( const MTPDinputPeerChannel & data ) { <nl> + const auto channel = owner - > channel ( data . vchannel_id ( ) . v ) ; <nl> + channel - > setAccessHash ( data . vaccess_hash ( ) . v ) ; <nl> + return ( PeerData * ) channel ; <nl> + } , [ & ] ( const auto & data ) { <nl> + return ( PeerData * ) nullptr ; <nl> + } ) ; <nl> + return peer ? owner - > history ( peer ) . get ( ) : nullptr ; <nl> + } ) | ranges : : view : : filter ( [ ] ( History * history ) { <nl> + return history ! = nullptr ; <nl> + } ) | ranges : : view : : transform ( [ ] ( History * history ) { <nl> + return not_null < History * > ( history ) ; <nl> + } ) ; <nl> + auto & & always = ranges : : view : : all ( <nl> + data . vinclude_peers ( ) . v <nl> + ) | to_histories ; <nl> + auto & & never = ranges : : view : : all ( <nl> + data . vexclude_peers ( ) . v <nl> + ) | to_histories ; <nl> + return ChatFilter ( <nl> + data . vid ( ) . v , <nl> + qs ( data . vtitle ( ) ) , <nl> + flags , <nl> + { always . begin ( ) , always . end ( ) } , <nl> + { never . begin ( ) , never . end ( ) } ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + MTPDialogFilter ChatFilter : : tl ( ) const { <nl> + using TLFlag = MTPDdialogFilter : : Flag ; <nl> + const auto flags = TLFlag ( 0 ) <nl> + | ( ( _flags & Flag : : Contacts ) ? TLFlag : : f_contacts : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : NonContacts ) ? TLFlag : : f_non_contacts : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : Groups ) ? TLFlag : : f_groups : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : Broadcasts ) ? TLFlag : : f_broadcasts : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : Bots ) ? TLFlag : : f_bots : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : NoMuted ) ? TLFlag : : f_exclude_muted : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : NoRead ) ? TLFlag : : f_exclude_read : TLFlag ( 0 ) ) <nl> + | ( ( _flags & Flag : : NoArchive ) <nl> + ? TLFlag : : f_exclude_archived <nl> + : TLFlag ( 0 ) ) ; <nl> + auto always = QVector < MTPInputPeer > ( ) ; <nl> + always . reserve ( _always . size ( ) ) ; <nl> + for ( const auto history : _always ) { <nl> + always . push_back ( history - > peer - > input ) ; <nl> + } <nl> + auto never = QVector < MTPInputPeer > ( ) ; <nl> + never . reserve ( _never . size ( ) ) ; <nl> + for ( const auto history : _never ) { <nl> + never . push_back ( history - > peer - > input ) ; <nl> + } <nl> + return MTP_dialogFilter ( <nl> + MTP_flags ( flags ) , <nl> + MTP_int ( _id ) , <nl> + MTP_string ( _title ) , <nl> + MTPstring ( ) , / / emoticon <nl> + MTP_vector < MTPInputPeer > ( ) , <nl> + MTP_vector < MTPInputPeer > ( always ) , <nl> + MTP_vector < MTPInputPeer > ( never ) ) ; <nl> + } <nl> + <nl> + FilterId ChatFilter : : id ( ) const { <nl> + return _id ; <nl> + } <nl> + <nl> QString ChatFilter : : title ( ) const { <nl> return _title ; <nl> } <nl> <nl> + ChatFilter : : Flags ChatFilter : : flags ( ) const { <nl> + return _flags ; <nl> + } <nl> + <nl> + const base : : flat_set < not_null < History * > > & ChatFilter : : always ( ) const { <nl> + return _always ; <nl> + } <nl> + <nl> + const base : : flat_set < not_null < History * > > & ChatFilter : : never ( ) const { <nl> + return _never ; <nl> + } <nl> + <nl> bool ChatFilter : : contains ( not_null < History * > history ) const { <nl> const auto flag = [ & ] { <nl> const auto peer = history - > peer ; <nl> if ( const auto user = peer - > asUser ( ) ) { <nl> - return user - > isBot ( ) ? Flag : : Bots : Flag : : Users ; <nl> + return user - > isBot ( ) <nl> + ? Flag : : Bots <nl> + : user - > isContact ( ) <nl> + ? Flag : : Contacts <nl> + : Flag : : NonContacts ; <nl> } else if ( const auto chat = peer - > asChat ( ) ) { <nl> - return Flag : : PrivateGroups ; <nl> + return Flag : : Groups ; <nl> } else if ( const auto channel = peer - > asChannel ( ) ) { <nl> if ( channel - > isBroadcast ( ) ) { <nl> return Flag : : Broadcasts ; <nl> - } else if ( channel - > isPublic ( ) ) { <nl> - return Flag : : PublicGroups ; <nl> } else { <nl> - return Flag : : PrivateGroups ; <nl> + return Flag : : Groups ; <nl> } <nl> } else { <nl> Unexpected ( " Peer type in ChatFilter : : contains . " ) ; <nl> } <nl> } ( ) ; <nl> - if ( history - > folder ( ) ) { <nl> + if ( _never . contains ( history ) ) { <nl> return false ; <nl> } <nl> return false <nl> | | ( ( _flags & flag ) <nl> & & ( ! ( _flags & Flag : : NoMuted ) | | ! history - > mute ( ) ) <nl> - & & ( ! ( _flags & Flag : : NoRead ) | | history - > unreadCountForBadge ( ) ) ) <nl> + & & ( ! ( _flags & Flag : : NoRead ) | | history - > unreadCountForBadge ( ) ) <nl> + & & ( ! ( _flags & Flag : : NoArchive ) <nl> + | | ( history - > folderKnown ( ) & & ! history - > folder ( ) ) ) ) <nl> | | _always . contains ( history ) ; <nl> } <nl> <nl> ChatFilters : : ChatFilters ( not_null < Session * > owner ) : _owner ( owner ) { <nl> using Flag = ChatFilter : : Flag ; <nl> - const auto all = Flag : : Users <nl> - | Flag : : SecretChats <nl> - | Flag : : PrivateGroups <nl> - | Flag : : PublicGroups <nl> + const auto all = Flag : : Contacts <nl> + | Flag : : NonContacts <nl> + | Flag : : Groups <nl> | Flag : : Broadcasts <nl> - | Flag : : Bots ; <nl> - _list . emplace ( <nl> - 1 , <nl> - ChatFilter ( " Unmuted Chats " , all | ChatFilter : : Flag : : NoMuted , { } ) ) ; <nl> - _list . emplace ( <nl> - 2 , <nl> - ChatFilter ( " Unread Chats " , all | ChatFilter : : Flag : : NoRead , { } ) ) ; <nl> + | Flag : : Bots <nl> + | Flag : : NoArchive ; <nl> + _list . push_back ( <nl> + ChatFilter ( 1 , " Unmuted " , all | Flag : : NoMuted , { } , { } ) ) ; <nl> + _list . push_back ( <nl> + ChatFilter ( 2 , " Unread " , all | Flag : : NoRead , { } , { } ) ) ; <nl> + } <nl> + <nl> + void ChatFilters : : load ( ) { <nl> + load ( false ) ; <nl> + } <nl> + <nl> + void ChatFilters : : load ( bool force ) { <nl> + if ( _loadRequestId & & ! force ) { <nl> + return ; <nl> + } <nl> + auto & api = _owner - > session ( ) . api ( ) ; <nl> + api . request ( _loadRequestId ) . cancel ( ) ; <nl> + _loadRequestId = api . request ( MTPmessages_GetDialogFilters ( <nl> + ) ) . done ( [ = ] ( const MTPVector < MTPDialogFilter > & result ) { <nl> + auto position = 0 ; <nl> + auto changed = false ; <nl> + for ( const auto & filter : result . v ) { <nl> + auto parsed = ChatFilter : : FromTL ( filter , _owner ) ; <nl> + const auto b = begin ( _list ) + position , e = end ( _list ) ; <nl> + const auto i = ranges : : find ( b , e , parsed . id ( ) , & ChatFilter : : id ) ; <nl> + if ( i = = e ) { <nl> + applyInsert ( std : : move ( parsed ) , position ) ; <nl> + changed = true ; <nl> + } else if ( i = = b ) { <nl> + if ( applyChange ( * b , std : : move ( parsed ) ) ) { <nl> + changed = true ; <nl> + } <nl> + } else { <nl> + std : : swap ( * i , * b ) ; <nl> + applyChange ( * b , std : : move ( parsed ) ) ; <nl> + changed = true ; <nl> + } <nl> + + + position ; <nl> + } <nl> + while ( position < _list . size ( ) ) { <nl> + applyRemove ( position ) ; <nl> + changed = true ; <nl> + } <nl> + if ( changed ) { <nl> + _listChanged . fire ( { } ) ; <nl> + } <nl> + _loadRequestId = 0 ; <nl> + } ) . fail ( [ = ] ( const RPCError & error ) { <nl> + _loadRequestId = 0 ; <nl> + } ) . send ( ) ; <nl> + } <nl> + <nl> + void ChatFilters : : apply ( const MTPUpdate & update ) { <nl> + update . match ( [ & ] ( const MTPDupdateDialogFilter & data ) { <nl> + if ( const auto filter = data . vfilter ( ) ) { <nl> + set ( ChatFilter : : FromTL ( * filter , _owner ) ) ; <nl> + } else { <nl> + remove ( data . vid ( ) . v ) ; <nl> + } <nl> + } , [ & ] ( const MTPDupdateDialogFilters & data ) { <nl> + load ( true ) ; <nl> + } , [ & ] ( const MTPDupdateDialogFilterOrder & data ) { <nl> + if ( applyOrder ( data . vorder ( ) . v ) ) { <nl> + _listChanged . fire ( { } ) ; <nl> + } else { <nl> + load ( true ) ; <nl> + } <nl> + } , [ ] ( auto & & ) { <nl> + Unexpected ( " Update in ChatFilters : : apply . " ) ; <nl> + } ) ; <nl> } <nl> <nl> - const base : : flat_map < FilterId , ChatFilter > & ChatFilters : : list ( ) const { <nl> + void ChatFilters : : set ( ChatFilter filter ) { <nl> + if ( ! filter . id ( ) ) { <nl> + return ; <nl> + } <nl> + const auto i = ranges : : find ( _list , filter . id ( ) , & ChatFilter : : id ) ; <nl> + if ( i = = end ( _list ) ) { <nl> + applyInsert ( std : : move ( filter ) , _list . size ( ) ) ; <nl> + _listChanged . fire ( { } ) ; <nl> + } else if ( applyChange ( * i , std : : move ( filter ) ) ) { <nl> + _listChanged . fire ( { } ) ; <nl> + } <nl> + } <nl> + <nl> + void ChatFilters : : applyInsert ( ChatFilter filter , int position ) { <nl> + Expects ( position > = 0 & & position < = _list . size ( ) ) ; <nl> + <nl> + _list . insert ( <nl> + begin ( _list ) + position , <nl> + ChatFilter ( filter . id ( ) , { } , { } , { } , { } ) ) ; <nl> + applyChange ( * ( begin ( _list ) + position ) , std : : move ( filter ) ) ; <nl> + } <nl> + <nl> + void ChatFilters : : remove ( FilterId id ) { <nl> + const auto i = ranges : : find ( _list , id , & ChatFilter : : id ) ; <nl> + if ( i = = end ( _list ) ) { <nl> + return ; <nl> + } <nl> + applyRemove ( i - begin ( _list ) ) ; <nl> + _listChanged . fire ( { } ) ; <nl> + } <nl> + <nl> + void ChatFilters : : applyRemove ( int position ) { <nl> + Expects ( position > = 0 & & position < _list . size ( ) ) ; <nl> + <nl> + const auto i = begin ( _list ) + position ; <nl> + applyChange ( * i , ChatFilter ( i - > id ( ) , { } , { } , { } , { } ) ) ; <nl> + _list . erase ( i ) ; <nl> + } <nl> + <nl> + bool ChatFilters : : applyChange ( ChatFilter & filter , ChatFilter & & updated ) { <nl> + const auto rulesChanged = ( filter . flags ( ) ! = updated . flags ( ) ) <nl> + | | ( filter . always ( ) ! = updated . always ( ) ) ; <nl> + if ( rulesChanged ) { <nl> + const auto list = _owner - > chatsList ( ) - > indexed ( ) ; <nl> + for ( const auto & entry : * list ) { <nl> + if ( const auto history = entry - > history ( ) ) { <nl> + const auto now = updated . contains ( history ) ; <nl> + const auto was = filter . contains ( history ) ; <nl> + if ( now ! = was ) { <nl> + if ( now ) { <nl> + history - > addToChatList ( filter . id ( ) ) ; <nl> + } else { <nl> + history - > removeFromChatList ( filter . id ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } else if ( filter . title ( ) = = updated . title ( ) ) { <nl> + return false ; <nl> + } <nl> + filter = std : : move ( updated ) ; <nl> + return true ; <nl> + } <nl> + <nl> + bool ChatFilters : : applyOrder ( const QVector < MTPint > & order ) { <nl> + if ( order . size ( ) ! = _list . size ( ) ) { <nl> + return false ; <nl> + } else if ( _list . empty ( ) ) { <nl> + return true ; <nl> + } <nl> + auto indices = ranges : : view : : all ( <nl> + _list <nl> + ) | ranges : : view : : transform ( <nl> + & ChatFilter : : id <nl> + ) | ranges : : to_vector ; <nl> + auto b = indices . begin ( ) , e = indices . end ( ) ; <nl> + for ( const auto id : order ) { <nl> + const auto i = ranges : : find ( b , e , id . v ) ; <nl> + if ( i = = e ) { <nl> + return false ; <nl> + } else if ( i ! = b ) { <nl> + std : : swap ( * i , * b ) ; <nl> + } <nl> + + + b ; <nl> + } <nl> + auto changed = false ; <nl> + auto begin = _list . begin ( ) , end = _list . end ( ) ; <nl> + for ( const auto id : order ) { <nl> + const auto i = ranges : : find ( begin , end , id . v , & ChatFilter : : id ) ; <nl> + Assert ( i ! = end ) ; <nl> + if ( i ! = begin ) { <nl> + changed = true ; <nl> + std : : swap ( * i , * begin ) ; <nl> + } <nl> + + + begin ; <nl> + } <nl> + if ( changed ) { <nl> + _listChanged . fire ( { } ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + const std : : vector < ChatFilter > & ChatFilters : : list ( ) const { <nl> return _list ; <nl> } <nl> <nl> + rpl : : producer < > ChatFilters : : changed ( ) const { <nl> + return _listChanged . events ( ) ; <nl> + } <nl> + <nl> void ChatFilters : : refreshHistory ( not_null < History * > history ) { <nl> _refreshHistoryRequests . fire_copy ( history ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_chat_filters . h <nl> ppp b / Telegram / SourceFiles / data / data_chat_filters . h <nl> class Session ; <nl> class ChatFilter final { <nl> public : <nl> enum class Flag : uchar { <nl> - Users = 0x01 , <nl> - SecretChats = 0x02 , <nl> - PrivateGroups = 0x04 , <nl> - PublicGroups = 0x08 , <nl> - Broadcasts = 0x10 , <nl> - Bots = 0x20 , <nl> - NoMuted = 0x40 , <nl> - NoRead = 0x80 , <nl> + Contacts = 0x01 , <nl> + NonContacts = 0x02 , <nl> + Groups = 0x04 , <nl> + Broadcasts = 0x08 , <nl> + Bots = 0x10 , <nl> + NoMuted = 0x20 , <nl> + NoRead = 0x40 , <nl> + NoArchive = 0x80 , <nl> } ; <nl> friend constexpr inline bool is_flag_type ( Flag ) { return true ; } ; <nl> using Flags = base : : flags < Flag > ; <nl> <nl> ChatFilter ( ) = default ; <nl> ChatFilter ( <nl> + FilterId id , <nl> const QString & title , <nl> Flags flags , <nl> - base : : flat_set < not_null < History * > > always ) ; <nl> + base : : flat_set < not_null < History * > > always , <nl> + base : : flat_set < not_null < History * > > never ) ; <nl> <nl> + [ [ nodiscard ] ] static ChatFilter FromTL ( <nl> + const MTPDialogFilter & data , <nl> + not_null < Session * > owner ) ; <nl> + [ [ nodiscard ] ] MTPDialogFilter tl ( ) const ; <nl> + <nl> + [ [ nodiscard ] ] FilterId id ( ) const ; <nl> [ [ nodiscard ] ] QString title ( ) const ; <nl> + [ [ nodiscard ] ] Flags flags ( ) const ; <nl> + [ [ nodiscard ] ] const base : : flat_set < not_null < History * > > & always ( ) const ; <nl> + [ [ nodiscard ] ] const base : : flat_set < not_null < History * > > & never ( ) const ; <nl> <nl> [ [ nodiscard ] ] bool contains ( not_null < History * > history ) const ; <nl> <nl> private : <nl> + FilterId _id = 0 ; <nl> QString _title ; <nl> base : : flat_set < not_null < History * > > _always ; <nl> + base : : flat_set < not_null < History * > > _never ; <nl> Flags _flags ; <nl> <nl> } ; <nl> class ChatFilters final { <nl> public : <nl> explicit ChatFilters ( not_null < Session * > owner ) ; <nl> <nl> - [ [ nodiscard ] ] const base : : flat_map < FilterId , ChatFilter > & list ( ) const ; <nl> + void load ( ) ; <nl> + void apply ( const MTPUpdate & update ) ; <nl> + void set ( ChatFilter filter ) ; <nl> + void remove ( FilterId id ) ; <nl> + [ [ nodiscard ] ] const std : : vector < ChatFilter > & list ( ) const ; <nl> + [ [ nodiscard ] ] rpl : : producer < > changed ( ) const ; <nl> <nl> void refreshHistory ( not_null < History * > history ) ; <nl> [ [ nodiscard ] ] auto refreshHistoryRequests ( ) const <nl> - > rpl : : producer < not_null < History * > > ; <nl> <nl> private : <nl> + void load ( bool force ) ; <nl> + bool applyOrder ( const QVector < MTPint > & order ) ; <nl> + bool applyChange ( ChatFilter & filter , ChatFilter & & updated ) ; <nl> + void applyInsert ( ChatFilter filter , int position ) ; <nl> + void applyRemove ( int position ) ; <nl> + <nl> const not_null < Session * > _owner ; <nl> <nl> - base : : flat_map < FilterId , ChatFilter > _list ; <nl> + std : : vector < ChatFilter > _list ; <nl> + rpl : : event_stream < > _listChanged ; <nl> rpl : : event_stream < not_null < History * > > _refreshHistoryRequests ; <nl> + mtpRequestId _loadRequestId = 0 ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / data / data_session . cpp <nl> ppp b / Telegram / SourceFiles / data / data_session . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_web_page . h " <nl> # include " data / data_game . h " <nl> # include " data / data_poll . h " <nl> + # include " data / data_chat_filters . h " <nl> # include " data / data_scheduled_messages . h " <nl> # include " data / data_cloud_themes . h " <nl> # include " data / data_streaming . h " <nl> Session : : Session ( not_null < Main : : Session * > session ) <nl> Local : : cacheBigFilePath ( ) , <nl> Local : : cacheBigFileSettings ( ) ) ) <nl> , _chatsList ( PinnedDialogsCountMaxValue ( session ) ) <nl> - , _chatsFilters ( this ) <nl> , _contactsList ( Dialogs : : SortMode : : Name ) <nl> , _contactsNoChatsList ( Dialogs : : SortMode : : Name ) <nl> , _selfDestructTimer ( [ = ] { checkSelfDestructItems ( ) ; } ) <nl> Session : : Session ( not_null < Main : : Session * > session ) <nl> } ) <nl> , _unmuteByFinishedTimer ( [ = ] { unmuteByFinished ( ) ; } ) <nl> , _groups ( this ) <nl> + , _chatsFilters ( std : : make_unique < ChatFilters > ( this ) ) <nl> , _scheduledMessages ( std : : make_unique < ScheduledMessages > ( this ) ) <nl> , _cloudThemes ( std : : make_unique < CloudThemes > ( session ) ) <nl> , _streaming ( std : : make_unique < Streaming > ( this ) ) <nl> not_null < PeerData * > Session : : processChat ( const MTPChat & data ) { <nl> const auto channel = this - > channel ( input . vchannel_id ( ) . v ) ; <nl> channel - > addFlags ( MTPDchannel : : Flag : : f_megagroup ) ; <nl> if ( ! channel - > access ) { <nl> - channel - > input = MTP_inputPeerChannel ( <nl> - input . vchannel_id ( ) , <nl> - input . vaccess_hash ( ) ) ; <nl> - channel - > inputChannel = * migratedTo ; <nl> - channel - > access = input . vaccess_hash ( ) . v ; <nl> + channel - > setAccessHash ( input . vaccess_hash ( ) . v ) ; <nl> } <nl> ApplyMigration ( chat , channel ) ; <nl> } , [ ] ( const MTPDinputChannelFromMessage & ) { <nl> not_null < PeerData * > Session : : processChat ( const MTPChat & data ) { <nl> if ( result - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> LOG ( ( " API Warning : not loaded minimal channel applied . " ) ) ; <nl> } <nl> - } else { <nl> - channel - > input = MTP_inputPeerChannel ( <nl> - data . vid ( ) , <nl> - MTP_long ( data . vaccess_hash ( ) . value_or_empty ( ) ) ) ; <nl> } <nl> <nl> const auto wasInChannel = channel - > amIn ( ) ; <nl> not_null < PeerData * > Session : : processChat ( const MTPChat & data ) { <nl> channel - > setRestrictions ( <nl> MTP_chatBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> } <nl> - const auto hash = data . vaccess_hash ( ) . value_or ( channel - > access ) ; <nl> - channel - > inputChannel = MTP_inputChannel ( <nl> - data . vid ( ) , <nl> - MTP_long ( hash ) ) ; <nl> - channel - > access = hash ; <nl> + channel - > setAccessHash ( <nl> + data . vaccess_hash ( ) . value_or ( channel - > access ) ) ; <nl> channel - > date = data . vdate ( ) . v ; <nl> if ( channel - > version ( ) < data . vversion ( ) . v ) { <nl> channel - > setVersion ( data . vversion ( ) . v ) ; <nl> not_null < PeerData * > Session : : processChat ( const MTPChat & data ) { <nl> } <nl> } , [ & ] ( const MTPDchannelForbidden & data ) { <nl> const auto channel = result - > asChannel ( ) ; <nl> - channel - > input = MTP_inputPeerChannel ( data . vid ( ) , data . vaccess_hash ( ) ) ; <nl> <nl> auto wasInChannel = channel - > amIn ( ) ; <nl> auto canViewAdmins = channel - > canViewAdmins ( ) ; <nl> auto canViewMembers = channel - > canViewMembers ( ) ; <nl> auto canAddMembers = channel - > canAddMembers ( ) ; <nl> <nl> - channel - > inputChannel = MTP_inputChannel ( data . vid ( ) , data . vaccess_hash ( ) ) ; <nl> - <nl> auto mask = mtpCastFlags ( MTPDchannelForbidden : : Flag : : f_broadcast | MTPDchannelForbidden : : Flag : : f_megagroup ) ; <nl> channel - > setFlags ( ( channel - > flags ( ) & ~ mask ) | ( mtpCastFlags ( data . vflags ( ) ) & mask ) | MTPDchannel_ClientFlag : : f_forbidden ) ; <nl> <nl> not_null < PeerData * > Session : : processChat ( const MTPChat & data ) { <nl> <nl> channel - > setName ( qs ( data . vtitle ( ) ) , QString ( ) ) ; <nl> <nl> - channel - > access = data . vaccess_hash ( ) . v ; <nl> + channel - > setAccessHash ( data . vaccess_hash ( ) . v ) ; <nl> channel - > setPhoto ( MTP_chatPhotoEmpty ( ) ) ; <nl> channel - > date = 0 ; <nl> channel - > setMembersCount ( 0 ) ; <nl> not_null < const Dialogs : : MainList * > Session : : chatsList ( <nl> return folder ? folder - > chatsList ( ) : & _chatsList ; <nl> } <nl> <nl> - not_null < ChatFilters * > Session : : chatsFilters ( ) { <nl> - return & _chatsFilters ; <nl> - } <nl> - <nl> - not_null < const ChatFilters * > Session : : chatsFilters ( ) const { <nl> - return & _chatsFilters ; <nl> - } <nl> - <nl> not_null < Dialogs : : IndexedList * > Session : : contactsList ( ) { <nl> return & _contactsList ; <nl> } <nl> auto Session : : refreshChatListEntry ( <nl> auto result = filterIdForResult <nl> ? RefreshChatListEntryResult ( ) <nl> : mainListResult ; <nl> - for ( const auto & [ filterId , filter ] : _chatsFilters . list ( ) ) { <nl> + for ( const auto & filter : _chatsFilters - > list ( ) ) { <nl> + const auto id = filter . id ( ) ; <nl> auto filterResult = RefreshChatListEntryResult ( ) ; <nl> if ( history & & filter . contains ( history ) ) { <nl> - filterResult . changed = ! entry - > inChatList ( filterId ) ; <nl> + filterResult . changed = ! entry - > inChatList ( id ) ; <nl> if ( filterResult . changed ) { <nl> - entry - > addToChatList ( filterId ) ; <nl> + entry - > addToChatList ( id ) ; <nl> } else { <nl> - filterResult . moved = entry - > adjustByPosInChatList ( filterId ) ; <nl> + filterResult . moved = entry - > adjustByPosInChatList ( id ) ; <nl> } <nl> - } else if ( entry - > inChatList ( filterId ) ) { <nl> - entry - > removeFromChatList ( filterId ) ; <nl> + } else if ( entry - > inChatList ( id ) ) { <nl> + entry - > removeFromChatList ( id ) ; <nl> filterResult . changed = true ; <nl> } <nl> - if ( filterId = = filterIdForResult ) { <nl> + if ( id = = filterIdForResult ) { <nl> result = filterResult ; <nl> } <nl> } <nl> void Session : : removeChatListEntry ( Dialogs : : Key key ) { <nl> <nl> const auto entry = key . entry ( ) ; <nl> entry - > removeFromChatList ( 0 ) ; <nl> - for ( const auto & [ filterId , filter ] : _chatsFilters . list ( ) ) { <nl> - entry - > removeFromChatList ( filterId ) ; <nl> + for ( const auto & filter : _chatsFilters - > list ( ) ) { <nl> + entry - > removeFromChatList ( filter . id ( ) ) ; <nl> } <nl> if ( _contactsList . contains ( key ) ) { <nl> if ( ! _contactsNoChatsList . contains ( key ) ) { <nl> mmm a / Telegram / SourceFiles / data / data_session . h <nl> ppp b / Telegram / SourceFiles / data / data_session . h <nl> For license and copyright information please follow this link : <nl> # include " dialogs / dialogs_main_list . h " <nl> # include " data / data_groups . h " <nl> # include " data / data_notify_settings . h " <nl> - # include " data / data_chat_filters . h " <nl> # include " history / history_location_manager . h " <nl> # include " base / timer . h " <nl> # include " base / flags . h " <nl> class Folder ; <nl> class LocationPoint ; <nl> class WallPaper ; <nl> class ScheduledMessages ; <nl> + class ChatFilters ; <nl> class CloudThemes ; <nl> class Streaming ; <nl> class MediaRotation ; <nl> class Session final { <nl> [ [ nodiscard ] ] const Groups & groups ( ) const { <nl> return _groups ; <nl> } <nl> + [ [ nodiscard ] ] ChatFilters & chatsFilters ( ) const { <nl> + return * _chatsFilters ; <nl> + } <nl> [ [ nodiscard ] ] ScheduledMessages & scheduledMessages ( ) const { <nl> return * _scheduledMessages ; <nl> } <nl> class Session final { <nl> Data : : Folder * folder = nullptr ) ; <nl> [ [ nodiscard ] ] not_null < const Dialogs : : MainList * > chatsList ( <nl> Data : : Folder * folder = nullptr ) const ; <nl> - [ [ nodiscard ] ] not_null < ChatFilters * > chatsFilters ( ) ; <nl> - [ [ nodiscard ] ] not_null < const ChatFilters * > chatsFilters ( ) const ; <nl> [ [ nodiscard ] ] not_null < Dialogs : : IndexedList * > contactsList ( ) ; <nl> [ [ nodiscard ] ] not_null < Dialogs : : IndexedList * > contactsNoChatsList ( ) ; <nl> <nl> class Session final { <nl> Stickers : : SavedGifs _savedGifs ; <nl> <nl> Dialogs : : MainList _chatsList ; <nl> - ChatFilters _chatsFilters ; <nl> Dialogs : : IndexedList _contactsList ; <nl> Dialogs : : IndexedList _contactsNoChatsList ; <nl> <nl> class Session final { <nl> int32 _wallpapersHash = 0 ; <nl> <nl> Groups _groups ; <nl> + std : : unique_ptr < ChatFilters > _chatsFilters ; <nl> std : : unique_ptr < ScheduledMessages > _scheduledMessages ; <nl> std : : unique_ptr < CloudThemes > _cloudThemes ; <nl> std : : unique_ptr < Streaming > _streaming ; <nl> mmm a / Telegram / SourceFiles / dialogs / dialogs_inner_widget . cpp <nl> ppp b / Telegram / SourceFiles / dialogs / dialogs_inner_widget . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_user . h " <nl> # include " data / data_peer_values . h " <nl> # include " data / data_histories . h " <nl> + # include " data / data_chat_filters . h " <nl> # include " base / unixtime . h " <nl> # include " lang / lang_keys . h " <nl> # include " mainwindow . h " <nl> InnerWidget : : InnerWidget ( <nl> refresh ( ) ; <nl> } , lifetime ( ) ) ; <nl> <nl> - session ( ) . settings ( ) . archiveCollapsedChanges ( <nl> + rpl : : merge ( <nl> + session ( ) . settings ( ) . archiveCollapsedChanges ( <nl> + ) | rpl : : map ( [ ] { return rpl : : empty_value ( ) ; } ) , <nl> + session ( ) . data ( ) . chatsFilters ( ) . changed ( ) <nl> ) | rpl : : start_with_next ( [ = ] { <nl> refreshWithCollapsedRows ( ) ; <nl> } , lifetime ( ) ) ; <nl> InnerWidget : : InnerWidget ( <nl> refresh ( ) ; <nl> } , lifetime ( ) ) ; <nl> <nl> - session ( ) . data ( ) . chatsFilters ( ) - > refreshHistoryRequests ( <nl> + session ( ) . data ( ) . chatsFilters ( ) . refreshHistoryRequests ( <nl> ) | rpl : : start_with_next ( [ = ] ( not_null < History * > history ) { <nl> if ( history - > inChatList ( ) <nl> - & & ! session ( ) . data ( ) . chatsFilters ( ) - > list ( ) . empty ( ) ) { <nl> + & & ! session ( ) . data ( ) . chatsFilters ( ) . list ( ) . empty ( ) ) { <nl> refreshDialog ( history ) ; <nl> } <nl> } , lifetime ( ) ) ; <nl> void InnerWidget : : refreshWithCollapsedRows ( bool toTop ) { <nl> <nl> _collapsedRows . clear ( ) ; <nl> if ( ! _openedFolder & & Global : : DialogsFiltersEnabled ( ) ) { <nl> + const auto & list = session ( ) . data ( ) . chatsFilters ( ) . list ( ) ; <nl> + if ( _filterId <nl> + & & ranges : : find ( list , _filterId , & Data : : ChatFilter : : id ) = = end ( list ) ) { <nl> + switchToFilter ( 0 ) ; <nl> + } <nl> if ( _filterId ) { <nl> _collapsedRows . push_back ( std : : make_unique < CollapsedRow > ( nullptr , 0 ) ) ; <nl> } else { <nl> - for ( const auto & [ filterId , filter ] : session ( ) . data ( ) . chatsFilters ( ) - > list ( ) ) { <nl> - _collapsedRows . push_back ( std : : make_unique < CollapsedRow > ( nullptr , filterId ) ) ; <nl> + for ( const auto & filter : session ( ) . data ( ) . chatsFilters ( ) . list ( ) ) { <nl> + _collapsedRows . push_back ( <nl> + std : : make_unique < CollapsedRow > ( nullptr , filter . id ( ) ) ) ; <nl> } <nl> } <nl> } <nl> void InnerWidget : : paintCollapsedRow ( <nl> ? row - > folder - > chatListName ( ) <nl> : _filterId <nl> ? ( narrow ? " Show " : tr : : lng_dialogs_show_all_chats ( tr : : now ) ) <nl> - : session ( ) . data ( ) . chatsFilters ( ) - > list ( ) . find ( <nl> - row - > filterId ) - > second . title ( ) ; <nl> + : ranges : : find ( <nl> + session ( ) . data ( ) . chatsFilters ( ) . list ( ) , <nl> + row - > filterId , <nl> + & Data : : ChatFilter : : id ) - > title ( ) ; <nl> const auto unread = row - > folder <nl> ? row - > folder - > chatListUnreadCount ( ) <nl> : _filterId <nl> void InnerWidget : : dragLeft ( ) { <nl> clearSelection ( ) ; <nl> } <nl> <nl> + FilterId InnerWidget : : filterId ( ) const { <nl> + return _filterId ; <nl> + } <nl> + <nl> + void InnerWidget : : closeFilter ( ) { <nl> + if ( _filterId ) { <nl> + switchToFilter ( 0 ) ; <nl> + } <nl> + } <nl> + <nl> void InnerWidget : : clearSelection ( ) { <nl> _mouseSelection = false ; <nl> _lastMousePosition = std : : nullopt ; <nl> bool InnerWidget : : chooseCollapsedRow ( ) { <nl> void InnerWidget : : switchToFilter ( FilterId filterId ) { <nl> clearSelection ( ) ; <nl> if ( ! Global : : DialogsFiltersEnabled ( ) <nl> - | | ! session ( ) . data ( ) . chatsFilters ( ) - > list ( ) . contains ( filterId ) ) { <nl> + | | ! ranges : : contains ( <nl> + session ( ) . data ( ) . chatsFilters ( ) . list ( ) , <nl> + filterId , <nl> + & Data : : ChatFilter : : id ) ) { <nl> filterId = 0 ; <nl> } <nl> Global : : SetDialogsFilterId ( filterId ) ; <nl> mmm a / Telegram / SourceFiles / dialogs / dialogs_inner_widget . h <nl> ppp b / Telegram / SourceFiles / dialogs / dialogs_inner_widget . h <nl> class InnerWidget <nl> const QVector < MTPPeer > & my , <nl> const QVector < MTPPeer > & result ) ; <nl> <nl> + [ [ nodiscard ] ] FilterId filterId ( ) const ; <nl> + void closeFilter ( ) ; <nl> + <nl> void clearSelection ( ) ; <nl> <nl> void changeOpenedFolder ( Data : : Folder * folder ) ; <nl> mmm a / Telegram / SourceFiles / dialogs / dialogs_widget . cpp <nl> ppp b / Telegram / SourceFiles / dialogs / dialogs_widget . cpp <nl> void Widget : : keyPressEvent ( QKeyEvent * e ) { <nl> if ( e - > key ( ) = = Qt : : Key_Escape ) { <nl> if ( _openedFolder ) { <nl> controller ( ) - > closeFolder ( ) ; <nl> + } else if ( _inner - > filterId ( ) ) { <nl> + _inner - > closeFilter ( ) ; <nl> } else { <nl> e - > ignore ( ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / history . cpp <nl> ppp b / Telegram / SourceFiles / history / history . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_session . h " <nl> # include " data / data_media_types . h " <nl> # include " data / data_channel_admins . h " <nl> + # include " data / data_chat_filters . h " <nl> # include " data / data_scheduled_messages . h " <nl> # include " data / data_folder . h " <nl> # include " data / data_photo . h " <nl> void History : : setUnreadMentionsCount ( int count ) { <nl> _unreadMentionsCount = count ; <nl> const auto has = ( count > 0 ) ; <nl> if ( has ! = had ) { <nl> - owner ( ) . chatsFilters ( ) - > refreshHistory ( this ) ; <nl> + owner ( ) . chatsFilters ( ) . refreshHistory ( this ) ; <nl> updateChatListEntry ( ) ; <nl> } <nl> } <nl> void History : : setUnreadCount ( int newUnreadCount ) { <nl> const auto wasForBadge = ( unreadCountForBadge ( ) > 0 ) ; <nl> _unreadCount = newUnreadCount ; <nl> if ( wasForBadge ! = ( unreadCountForBadge ( ) > 0 ) ) { <nl> - owner ( ) . chatsFilters ( ) - > refreshHistory ( this ) ; <nl> + owner ( ) . chatsFilters ( ) . refreshHistory ( this ) ; <nl> } <nl> <nl> if ( newUnreadCount = = 1 ) { <nl> void History : : setUnreadMark ( bool unread ) { <nl> _unreadMark = unread ; <nl> <nl> if ( inChatList ( ) & & noUnreadMessages ) { <nl> - owner ( ) . chatsFilters ( ) - > refreshHistory ( this ) ; <nl> + owner ( ) . chatsFilters ( ) . refreshHistory ( this ) ; <nl> updateChatListEntry ( ) ; <nl> } <nl> Notify : : peerUpdatedDelayed ( <nl> bool History : : changeMute ( bool newMute ) { <nl> _mute = newMute ; <nl> <nl> if ( inChatList ( ) ) { <nl> - owner ( ) . chatsFilters ( ) - > refreshHistory ( this ) ; <nl> + owner ( ) . chatsFilters ( ) . refreshHistory ( this ) ; <nl> updateChatListEntry ( ) ; <nl> } <nl> Notify : : peerUpdatedDelayed ( <nl> void History : : setFolderPointer ( Data : : Folder * folder ) { <nl> const auto wasInList = inChatList ( ) ; <nl> if ( wasInList ) { <nl> removeFromChatList ( 0 ) ; <nl> - for ( const auto & [ filterId , _ ] : owner ( ) . chatsFilters ( ) - > list ( ) ) { <nl> - removeFromChatList ( filterId ) ; <nl> + for ( const auto & filter : owner ( ) . chatsFilters ( ) . list ( ) ) { <nl> + removeFromChatList ( filter . id ( ) ) ; <nl> } <nl> } <nl> const auto was = _folder . value_or ( nullptr ) ; <nl> void History : : setFolderPointer ( Data : : Folder * folder ) { <nl> } <nl> if ( wasInList ) { <nl> addToChatList ( 0 ) ; <nl> - for ( const auto & [ filterId , filter ] : owner ( ) . chatsFilters ( ) - > list ( ) ) { <nl> + for ( const auto & filter : owner ( ) . chatsFilters ( ) . list ( ) ) { <nl> if ( filter . contains ( this ) ) { <nl> - addToChatList ( filterId ) ; <nl> + addToChatList ( filter . id ( ) ) ; <nl> } <nl> } <nl> owner ( ) . chatsListChanged ( was ) ; <nl> mmm a / Telegram / SourceFiles / history / history_widget . cpp <nl> ppp b / Telegram / SourceFiles / history / history_widget . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_channel . h " <nl> # include " data / data_chat . h " <nl> # include " data / data_user . h " <nl> + # include " data / data_chat_filters . h " <nl> # include " data / data_scheduled_messages . h " <nl> # include " data / data_file_origin . h " <nl> # include " data / data_histories . h " <nl> bool HistoryWidget : : notify_switchInlineBotButtonReceived ( const QString & query , U <nl> <nl> void HistoryWidget : : notify_userIsBotChanged ( UserData * user ) { <nl> if ( const auto history = session ( ) . data ( ) . history ( user ) ) { <nl> - session ( ) . data ( ) . chatsFilters ( ) - > refreshHistory ( history ) ; <nl> + session ( ) . data ( ) . chatsFilters ( ) . refreshHistory ( history ) ; <nl> } <nl> if ( _peer & & _peer = = user ) { <nl> _list - > notifyIsBotChanged ( ) ; <nl> mmm a / Telegram / SourceFiles / mainwidget . cpp <nl> ppp b / Telegram / SourceFiles / mainwidget . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_channel . h " <nl> # include " data / data_chat . h " <nl> # include " data / data_user . h " <nl> + # include " data / data_chat_filters . h " <nl> # include " data / data_scheduled_messages . h " <nl> # include " data / data_file_origin . h " <nl> # include " data / data_histories . h " <nl> void MainWidget : : feedUpdate ( const MTPUpdate & update ) { <nl> ptsUpdateAndApply ( data . vpts ( ) . v , data . vpts_count ( ) . v , update ) ; <nl> } break ; <nl> <nl> + case mtpc_updateDialogFilter : <nl> + case mtpc_updateDialogFilterOrder : <nl> + case mtpc_updateDialogFilters : { <nl> + session ( ) . data ( ) . chatsFilters ( ) . apply ( update ) ; <nl> + } break ; <nl> + <nl> / / Deleted messages . <nl> case mtpc_updateDeleteMessages : { <nl> auto & d = update . c_updateDeleteMessages ( ) ; <nl> mmm a / Telegram / lib_base <nl> ppp b / Telegram / lib_base <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 1720a5b4eebc794ff05d7223d79d42e00e39062e <nl> + Subproject commit 62d4145ba04d8b6205fe0413318bc5a0f19f9410 <nl>
|
Parse and apply cloud filters .
|
telegramdesktop/tdesktop
|
11d31ffc8458a36d453cc97a97e67aa138a73762
|
2020-03-27T16:36:01Z
|
mmm a / Marlin / language_es . h <nl> ppp b / Marlin / language_es . h <nl> <nl> # define MSG_BLTOUCH_SELFTEST _UxGT ( " BLTouch Auto - Prueba " ) <nl> # define MSG_BLTOUCH_RESET _UxGT ( " Reiniciar BLTouch " ) <nl> # define MSG_HOME _UxGT ( " Home " ) / / Used as MSG_HOME " " MSG_X MSG_Y MSG_Z " " MSG_FIRST <nl> - # define MSG_FIRST _UxGT ( " first " ) <nl> + # define MSG_FIRST _UxGT ( " inic . " ) <nl> # define MSG_ZPROBE_ZOFFSET _UxGT ( " Desfase Z " ) <nl> # define MSG_BABYSTEP_X _UxGT ( " Micropaso X " ) <nl> # define MSG_BABYSTEP_Y _UxGT ( " Micropaso Y " ) <nl> <nl> # define MSG_ENDSTOP_ABORT _UxGT ( " Cancelado - Endstop " ) <nl> # define MSG_HEATING_FAILED_LCD _UxGT ( " Error : al calentar " ) <nl> # define MSG_ERR_REDUNDANT_TEMP _UxGT ( " Error : temperatura " ) <nl> - # define MSG_THERMAL_RUNAWAY _UxGT ( " Error de temperatura " ) <nl> + # define MSG_THERMAL_RUNAWAY _UxGT ( " Error : temperatura " ) <nl> # define MSG_ERR_MAXTEMP _UxGT ( " Error : Temp Maxima " ) <nl> # define MSG_ERR_MINTEMP _UxGT ( " Error : Temp Minima " ) <nl> # define MSG_ERR_MAXTEMP_BED _UxGT ( " Error : Temp Max Plat " ) <nl> <nl> # define MSG_DAC_PERCENT _UxGT ( " Driver % " ) <nl> # define MSG_DAC_EEPROM_WRITE _UxGT ( " Escribe DAC EEPROM " ) <nl> <nl> - # define MSG_FILAMENT_CHANGE_HEADER _UxGT ( " PRINT PAUSED " ) <nl> - # define MSG_FILAMENT_CHANGE_OPTION_HEADER _UxGT ( " RESUME OPTIONS : " ) <nl> + # define MSG_FILAMENT_CHANGE_HEADER _UxGT ( " IMPR . PAUSADA " ) <nl> + # define MSG_FILAMENT_CHANGE_OPTION_HEADER _UxGT ( " OPC . REINICIO : " ) <nl> # define MSG_FILAMENT_CHANGE_OPTION_EXTRUDE _UxGT ( " Extruir mas " ) <nl> # define MSG_FILAMENT_CHANGE_OPTION_RESUME _UxGT ( " Resumir imp . " ) <nl> <nl>
|
Updates to language_es . h based on latest updates . ( )
|
MarlinFirmware/Marlin
|
ac959b12ee3697964805b43c6d0767dca2d39e28
|
2017-05-28T00:08:39Z
|
mmm a / libraries / chain / apply_context . cpp <nl> ppp b / libraries / chain / apply_context . cpp <nl> void apply_context : : schedule_deferred_transaction ( const uint128_t & sender_id , a <nl> " Replacing a deferred transaction is temporarily disabled . " ) ; <nl> <nl> / / TODO : The logic of the next line needs to be incorporated into the next hard fork . <nl> - / / trx_context . add_ram_usage ( ptr - > payer , - ( config : : billable_size_v < generated_transaction_object > + ptr - > packed_trx . size ( ) ) ) ; <nl> + / / add_ram_usage ( ptr - > payer , - ( config : : billable_size_v < generated_transaction_object > + ptr - > packed_trx . size ( ) ) ) ; <nl> <nl> d . modify < generated_transaction_object > ( * ptr , [ & ] ( auto & gtx ) { <nl> gtx . sender = receiver ; <nl>
|
Update commented out code to call correct add_ram_usage for hard fork
|
EOSIO/eos
|
529b11cef18113fbae2acea295d76f534141e257
|
2018-09-13T20:29:52Z
|
mmm a / src / mips / regexp - macro - assembler - mips . cc <nl> ppp b / src / mips / regexp - macro - assembler - mips . cc <nl> int RegExpMacroAssemblerMIPS : : stack_limit_slack ( ) { <nl> void RegExpMacroAssemblerMIPS : : AdvanceCurrentPosition ( int by ) { <nl> if ( by ! = 0 ) { <nl> __ Addu ( current_input_offset ( ) , <nl> - current_input_offset ( ) , Operand ( by * char_size ( ) ) ) ; <nl> + current_input_offset ( ) , Operand ( by * char_size ( ) ) ) ; <nl> } <nl> } <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckCharacterLT ( uc16 limit , Label * on_less ) { <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckCharacters ( Vector < const uc16 > str , <nl> - int cp_offset , <nl> - Label * on_failure , <nl> - bool check_end_of_string ) { <nl> + int cp_offset , <nl> + Label * on_failure , <nl> + bool check_end_of_string ) { <nl> if ( on_failure = = NULL ) { <nl> / / Instead of inlining a backtrack for each test , ( re ) use the global <nl> / / backtrack target . <nl> void RegExpMacroAssemblerMIPS : : CheckNotRegistersEqual ( int reg1 , <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckNotCharacter ( uint32_t c , <nl> - Label * on_not_equal ) { <nl> + Label * on_not_equal ) { <nl> BranchOrBacktrack ( on_not_equal , ne , current_character ( ) , Operand ( c ) ) ; <nl> } <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckCharacterAfterAnd ( uint32_t c , <nl> - uint32_t mask , <nl> - Label * on_equal ) { <nl> + uint32_t mask , <nl> + Label * on_equal ) { <nl> __ And ( a0 , current_character ( ) , Operand ( mask ) ) ; <nl> - BranchOrBacktrack ( on_equal , eq , a0 , Operand ( c ) ) ; <nl> + Operand rhs = ( c = = 0 ) ? Operand ( zero_reg ) : Operand ( c ) ; <nl> + BranchOrBacktrack ( on_equal , eq , a0 , rhs ) ; <nl> } <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckNotCharacterAfterAnd ( uint32_t c , <nl> - uint32_t mask , <nl> - Label * on_not_equal ) { <nl> + uint32_t mask , <nl> + Label * on_not_equal ) { <nl> __ And ( a0 , current_character ( ) , Operand ( mask ) ) ; <nl> - BranchOrBacktrack ( on_not_equal , ne , a0 , Operand ( c ) ) ; <nl> + Operand rhs = ( c = = 0 ) ? Operand ( zero_reg ) : Operand ( c ) ; <nl> + BranchOrBacktrack ( on_not_equal , ne , a0 , rhs ) ; <nl> } <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckBitInTable ( <nl> <nl> <nl> bool RegExpMacroAssemblerMIPS : : CheckSpecialCharacterClass ( uc16 type , <nl> - Label * on_no_match ) { <nl> + Label * on_no_match ) { <nl> / / Range checks ( c in min . . max ) are generally implemented by an unsigned <nl> / / ( c - min ) < = ( max - min ) check . <nl> switch ( type ) { <nl> void RegExpMacroAssemblerMIPS : : GoTo ( Label * to ) { <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : IfRegisterGE ( int reg , <nl> - int comparand , <nl> - Label * if_ge ) { <nl> + int comparand , <nl> + Label * if_ge ) { <nl> __ lw ( a0 , register_location ( reg ) ) ; <nl> BranchOrBacktrack ( if_ge , ge , a0 , Operand ( comparand ) ) ; <nl> } <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : IfRegisterLT ( int reg , <nl> - int comparand , <nl> - Label * if_lt ) { <nl> + int comparand , <nl> + Label * if_lt ) { <nl> __ lw ( a0 , register_location ( reg ) ) ; <nl> BranchOrBacktrack ( if_lt , lt , a0 , Operand ( comparand ) ) ; <nl> } <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : IfRegisterEqPos ( int reg , <nl> - Label * if_eq ) { <nl> + Label * if_eq ) { <nl> __ lw ( a0 , register_location ( reg ) ) ; <nl> BranchOrBacktrack ( if_eq , eq , a0 , Operand ( current_input_offset ( ) ) ) ; <nl> } <nl> RegExpMacroAssembler : : IrregexpImplementation <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : LoadCurrentCharacter ( int cp_offset , <nl> - Label * on_end_of_input , <nl> - bool check_bounds , <nl> - int characters ) { <nl> + Label * on_end_of_input , <nl> + bool check_bounds , <nl> + int characters ) { <nl> ASSERT ( cp_offset > = - 1 ) ; / / ^ and \ b can look behind one character . <nl> ASSERT ( cp_offset < ( 1 < < 30 ) ) ; / / Be sane ! ( And ensure negation works ) . <nl> if ( check_bounds ) { <nl> void RegExpMacroAssemblerMIPS : : PushCurrentPosition ( ) { <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : PushRegister ( int register_index , <nl> - StackCheckFlag check_stack_limit ) { <nl> + StackCheckFlag check_stack_limit ) { <nl> __ lw ( a0 , register_location ( register_index ) ) ; <nl> Push ( a0 ) ; <nl> if ( check_stack_limit ) CheckStackLimit ( ) ; <nl> void RegExpMacroAssemblerMIPS : : Succeed ( ) { <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : WriteCurrentPositionToRegister ( int reg , <nl> - int cp_offset ) { <nl> + int cp_offset ) { <nl> if ( cp_offset = = 0 ) { <nl> __ sw ( current_input_offset ( ) , register_location ( reg ) ) ; <nl> } else { <nl> MemOperand RegExpMacroAssemblerMIPS : : register_location ( int register_index ) { <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : CheckPosition ( int cp_offset , <nl> - Label * on_outside_input ) { <nl> + Label * on_outside_input ) { <nl> BranchOrBacktrack ( on_outside_input , <nl> ge , <nl> current_input_offset ( ) , <nl> void RegExpMacroAssemblerMIPS : : BranchOrBacktrack ( Label * to , <nl> } <nl> <nl> <nl> - void RegExpMacroAssemblerMIPS : : SafeCall ( Label * to , Condition cond , Register rs , <nl> - const Operand & rt ) { <nl> + void RegExpMacroAssemblerMIPS : : SafeCall ( Label * to , <nl> + Condition cond , <nl> + Register rs , <nl> + const Operand & rt ) { <nl> __ BranchAndLink ( to , cond , rs , rt ) ; <nl> } <nl> <nl> void RegExpMacroAssemblerMIPS : : CallCFunctionUsingStub ( <nl> <nl> <nl> void RegExpMacroAssemblerMIPS : : LoadCurrentCharacterUnchecked ( int cp_offset , <nl> - int characters ) { <nl> + int characters ) { <nl> Register offset = current_input_offset ( ) ; <nl> if ( cp_offset ! = 0 ) { <nl> __ Addu ( a0 , current_input_offset ( ) , Operand ( cp_offset * char_size ( ) ) ) ; <nl>
|
Port regexp microoptimizations to MIPS . Also fix some formatting . This includes http : / / codereview . chromium . org / 9965107 / from Daniel Kalmar
|
v8/v8
|
de169b7d43ae1a623518d0c56a64638156efce65
|
2012-04-12T07:45:25Z
|
mmm a / src / arm / stub - cache - arm . cc <nl> ppp b / src / arm / stub - cache - arm . cc <nl> void StubCompiler : : GenerateStoreField ( MacroAssembler * masm , <nl> Label exit ; <nl> <nl> / / Check that the map of the object hasn ' t changed . <nl> + CompareMapMode mode = transition . is_null ( ) ? ALLOW_ELEMENT_TRANSITION_MAPS <nl> + : REQUIRE_EXACT_MAP ; <nl> __ CheckMap ( receiver_reg , scratch , Handle < Map > ( object - > map ( ) ) , miss_label , <nl> - DO_SMI_CHECK , ALLOW_ELEMENT_TRANSITION_MAPS ) ; <nl> + DO_SMI_CHECK , mode ) ; <nl> <nl> / / Perform global security token check if needed . <nl> if ( object - > IsJSGlobalProxy ( ) ) { <nl> mmm a / src / ia32 / stub - cache - ia32 . cc <nl> ppp b / src / ia32 / stub - cache - ia32 . cc <nl> void StubCompiler : : GenerateStoreField ( MacroAssembler * masm , <nl> Register scratch , <nl> Label * miss_label ) { <nl> / / Check that the map of the object hasn ' t changed . <nl> + CompareMapMode mode = transition . is_null ( ) ? ALLOW_ELEMENT_TRANSITION_MAPS <nl> + : REQUIRE_EXACT_MAP ; <nl> __ CheckMap ( receiver_reg , Handle < Map > ( object - > map ( ) ) , <nl> - miss_label , DO_SMI_CHECK , ALLOW_ELEMENT_TRANSITION_MAPS ) ; <nl> + miss_label , DO_SMI_CHECK , mode ) ; <nl> <nl> / / Perform global security token check if needed . <nl> if ( object - > IsJSGlobalProxy ( ) ) { <nl> mmm a / src / mips / stub - cache - mips . cc <nl> ppp b / src / mips / stub - cache - mips . cc <nl> void StubCompiler : : GenerateStoreField ( MacroAssembler * masm , <nl> / / a0 : value . <nl> Label exit ; <nl> / / Check that the map of the object hasn ' t changed . <nl> + CompareMapMode mode = transition . is_null ( ) ? ALLOW_ELEMENT_TRANSITION_MAPS <nl> + : REQUIRE_EXACT_MAP ; <nl> __ CheckMap ( receiver_reg , scratch , Handle < Map > ( object - > map ( ) ) , miss_label , <nl> - DO_SMI_CHECK , ALLOW_ELEMENT_TRANSITION_MAPS ) ; <nl> + DO_SMI_CHECK , mode ) ; <nl> <nl> / / Perform global security token check if needed . <nl> if ( object - > IsJSGlobalProxy ( ) ) { <nl> mmm a / src / x64 / stub - cache - x64 . cc <nl> ppp b / src / x64 / stub - cache - x64 . cc <nl> void StubCompiler : : GenerateStoreField ( MacroAssembler * masm , <nl> Register scratch , <nl> Label * miss_label ) { <nl> / / Check that the map of the object hasn ' t changed . <nl> + CompareMapMode mode = transition . is_null ( ) ? ALLOW_ELEMENT_TRANSITION_MAPS <nl> + : REQUIRE_EXACT_MAP ; <nl> __ CheckMap ( receiver_reg , Handle < Map > ( object - > map ( ) ) , <nl> - miss_label , DO_SMI_CHECK , ALLOW_ELEMENT_TRANSITION_MAPS ) ; <nl> + miss_label , DO_SMI_CHECK , mode ) ; <nl> <nl> / / Perform global security token check if needed . <nl> if ( object - > IsJSGlobalProxy ( ) ) { <nl> new file mode 100644 <nl> index 00000000000 . . 3a99a7fa587 <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - crbug - 122271 . js <nl> <nl> + / / Copyright 2012 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + / / Flags : - - allow - natives - syntax <nl> + <nl> + / / Tests that ElementsKind transitions and regular transitions don ' t <nl> + / / interfere badly with each other . <nl> + <nl> + var a = [ 0 , 0 , 0 , 1 ] ; <nl> + var b = [ 0 , 0 , 0 , " one " ] ; <nl> + var c = [ 0 , 0 , 0 , 1 ] ; <nl> + c . foo = " baz " ; <nl> + <nl> + function foo ( array ) { <nl> + array . foo = " bar " ; <nl> + } <nl> + <nl> + assertTrue ( % HasFastSmiOnlyElements ( a ) ) ; <nl> + assertTrue ( % HasFastElements ( b ) ) ; <nl> + <nl> + foo ( a ) ; <nl> + foo ( b ) ; <nl> + <nl> + assertTrue ( % HasFastSmiOnlyElements ( a ) ) ; <nl> + assertTrue ( % HasFastElements ( b ) ) ; <nl>
|
Fix regular and ElementsKind transitions interfering with each other
|
v8/v8
|
14e181709b1739d109db429b1ec59bd95503c0f4
|
2012-04-12T12:30:32Z
|
mmm a / src / video_core / texture_cache / texture_cache . h <nl> ppp b / src / video_core / texture_cache / texture_cache . h <nl> class TextureCache { <nl> <nl> void ManageRenderTargetUnregister ( TSurface & surface ) { <nl> auto & maxwell3d = system . GPU ( ) . Maxwell3D ( ) ; <nl> - < < < < < < < HEAD <nl> const u32 index = surface - > GetRenderTarget ( ) ; <nl> if ( index = = DEPTH_RT ) { <nl> - maxwell3d . dirty_flags . zeta_buffer = true ; <nl> - = = = = = = = <nl> - u32 index = surface - > GetRenderTarget ( ) ; <nl> - if ( index = = 8 ) { <nl> maxwell3d . dirty . depth_buffer = true ; <nl> - > > > > > > > Maxwell3D : Rework the dirty system to be more consistant and scaleable <nl> } else { <nl> maxwell3d . dirty . render_target [ index ] = true ; <nl> } <nl>
|
Texture_Cache : Rebase Fixes
|
yuzu-emu/yuzu
|
7826f0afd934cd24310778dabc5211872def2cd3
|
2019-07-17T21:29:54Z
|
mmm a / tensorflow / cc / framework / scope . cc <nl> ppp b / tensorflow / cc / framework / scope . cc <nl> Scope : : Scope ( Graph * graph , Status * status , Scope : : NameMap * name_map , <nl> status_ ( status ) , <nl> name_map_ ( name_map ) , <nl> refiner_ ( refiner ) , <nl> - scope_used_ ( nullptr ) { } <nl> + scope_used_ ( nullptr ) , <nl> + colocation_constraints_ ( ) { } <nl> <nl> Scope Scope : : NewRootScope ( ) { <nl> Graph * graph = new Graph ( OpRegistry : : Global ( ) ) ; <nl>
|
Explicitely initialize the Scope : : colocation_constraints_
|
tensorflow/tensorflow
|
97c410c884865703e463742bb9b4a53c8588e4fd
|
2016-12-15T15:14:30Z
|
mmm a / tensorflow / core / distributed_runtime / rpc / eager / grpc_eager_service_impl . h <nl> ppp b / tensorflow / core / distributed_runtime / rpc / eager / grpc_eager_service_impl . h <nl> class GrpcEagerServiceImpl : public AsyncServiceInterface { <nl> local_impl_ . RunComponentFunction ( call_opts . get ( ) , & call - > request , <nl> & call - > response , <nl> [ call , call_opts ] ( const Status & s ) { <nl> + call - > ClearCancelCallback ( ) ; <nl> call - > SendResponse ( ToGrpcStatus ( s ) ) ; <nl> } ) ; <nl> } ) ; <nl>
|
Clear cancel callback when gRPC eager call returns with state .
|
tensorflow/tensorflow
|
18c43b7bd488f0216ce11127158df7084e26cdb4
|
2020-06-19T22:48:45Z
|
mmm a / vnpy / app / cta_strategy / converter . py <nl> ppp b / vnpy / app / cta_strategy / converter . py <nl> def is_convert_required ( self , vt_symbol : str ) : <nl> contract = self . main_engine . get_contract ( vt_symbol ) <nl> <nl> # Only contracts with long - short position mode requires convert <nl> - if not contract or not contract . net_position : <nl> - return True <nl> - else : <nl> + if not contract : <nl> + return False <nl> + elif contract . net_position : <nl> return False <nl> + else : <nl> + return True <nl> <nl> <nl> class PositionHolding : <nl>
|
[ Mod ] change logic of is_convert_required function
|
vnpy/vnpy
|
4cb5e485230c1ec79c9176eeb4ea6cbbfed735fd
|
2019-04-26T14:53:25Z
|
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_binary ( <nl> " grpc / src / compiler / schema_interface . h " , <nl> " src / flatc_main . cpp " , <nl> " src / idl_gen_cpp . cpp " , <nl> + " src / idl_gen_csharp . cpp " , <nl> " src / idl_gen_dart . cpp " , <nl> " src / idl_gen_general . cpp " , <nl> " src / idl_gen_go . cpp " , <nl> " src / idl_gen_grpc . cpp " , <nl> + " src / idl_gen_java . cpp " , <nl> " src / idl_gen_js_ts . cpp " , <nl> " src / idl_gen_json_schema . cpp " , <nl> " src / idl_gen_kotlin . cpp " , <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> set ( FlatBuffers_Library_SRCS <nl> set ( FlatBuffers_Compiler_SRCS <nl> $ { FlatBuffers_Library_SRCS } <nl> src / idl_gen_cpp . cpp <nl> + src / idl_gen_csharp . cpp <nl> src / idl_gen_dart . cpp <nl> src / idl_gen_general . cpp <nl> src / idl_gen_kotlin . cpp <nl> src / idl_gen_go . cpp <nl> + src / idl_gen_java . cpp <nl> src / idl_gen_js_ts . cpp <nl> src / idl_gen_php . cpp <nl> src / idl_gen_python . cpp <nl> mmm a / include / flatbuffers / idl . h <nl> ppp b / include / flatbuffers / idl . h <nl> extern bool GenerateBinary ( const Parser & parser , const std : : string & path , <nl> extern bool GenerateCPP ( const Parser & parser , const std : : string & path , <nl> const std : : string & file_name ) ; <nl> <nl> + / / Generate C # files from the definitions in the Parser object . <nl> + / / See idl_gen_csharp . cpp . <nl> + extern bool GenerateCSharp ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) ; <nl> + <nl> extern bool GenerateDart ( const Parser & parser , const std : : string & path , <nl> const std : : string & file_name ) ; <nl> <nl> + / / Generate Java files from the definitions in the Parser object . <nl> + / / See idl_gen_java . cpp . <nl> + extern bool GenerateJava ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) ; <nl> + <nl> / / Generate JavaScript or TypeScript code from the definitions in the Parser <nl> / / object . See idl_gen_js . <nl> extern bool GenerateJSTS ( const Parser & parser , const std : : string & path , <nl> mmm a / src / flatc_main . cpp <nl> ppp b / src / flatc_main . cpp <nl> int main ( int argc , const char * argv [ ] ) { <nl> { flatbuffers : : GenerateGo , " - g " , " - - go " , " Go " , true , <nl> flatbuffers : : GenerateGoGRPC , flatbuffers : : IDLOptions : : kGo , <nl> " Generate Go files for tables / structs " , flatbuffers : : GeneralMakeRule } , <nl> - { flatbuffers : : GenerateGeneral , " - j " , " - - java " , " Java " , true , <nl> + { flatbuffers : : GenerateJava , " - j " , " - - java " , " Java " , true , <nl> flatbuffers : : GenerateJavaGRPC , flatbuffers : : IDLOptions : : kJava , <nl> " Generate Java classes for tables / structs " , <nl> flatbuffers : : GeneralMakeRule } , <nl> int main ( int argc , const char * argv [ ] ) { <nl> flatbuffers : : IDLOptions : : kTs , <nl> " Generate TypeScript code for tables / structs " , <nl> flatbuffers : : JSTSMakeRule } , <nl> - { flatbuffers : : GenerateGeneral , " - n " , " - - csharp " , " C # " , true , nullptr , <nl> + { flatbuffers : : GenerateCSharp , " - n " , " - - csharp " , " C # " , true , nullptr , <nl> flatbuffers : : IDLOptions : : kCSharp , <nl> " Generate C # classes for tables / structs " , flatbuffers : : GeneralMakeRule } , <nl> { flatbuffers : : GeneratePython , " - p " , " - - python " , " Python " , true , nullptr , <nl> new file mode 100644 <nl> index 0000000000 . . 5045bd95d9 <nl> mmm / dev / null <nl> ppp b / src / idl_gen_csharp . cpp <nl> <nl> + / * <nl> + * Copyright 2014 Google Inc . All rights reserved . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * / <nl> + <nl> + / / independent from idl_parser , since this code is not needed for most clients <nl> + <nl> + # include " flatbuffers / code_generators . h " <nl> + # include " flatbuffers / flatbuffers . h " <nl> + # include " flatbuffers / idl . h " <nl> + # include " flatbuffers / util . h " <nl> + <nl> + # if defined ( FLATBUFFERS_CPP98_STL ) <nl> + # include < cctype > <nl> + # endif / / defined ( FLATBUFFERS_CPP98_STL ) <nl> + <nl> + namespace flatbuffers { <nl> + <nl> + static TypedFloatConstantGenerator CSharpFloatGen ( " Double . " , " Single . " , " NaN " , <nl> + " PositiveInfinity " , <nl> + " NegativeInfinity " ) ; <nl> + static CommentConfig comment_config = { <nl> + nullptr , <nl> + " / / / " , <nl> + nullptr , <nl> + } ; <nl> + <nl> + namespace csharp { <nl> + class CSharpGenerator : public BaseGenerator { <nl> + public : <nl> + CSharpGenerator ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) <nl> + : BaseGenerator ( parser , path , file_name , " " , " . " ) , <nl> + cur_name_space_ ( nullptr ) { } <nl> + <nl> + CSharpGenerator & operator = ( const CSharpGenerator & ) ; <nl> + <nl> + bool generate ( ) { <nl> + std : : string one_file_code ; <nl> + cur_name_space_ = parser_ . current_namespace_ ; <nl> + <nl> + for ( auto it = parser_ . enums_ . vec . begin ( ) ; it ! = parser_ . enums_ . vec . end ( ) ; <nl> + + + it ) { <nl> + std : : string enumcode ; <nl> + auto & enum_def = * * it ; <nl> + if ( ! parser_ . opts . one_file ) cur_name_space_ = enum_def . defined_namespace ; <nl> + GenEnum ( enum_def , & enumcode ) ; <nl> + if ( parser_ . opts . one_file ) { <nl> + one_file_code + = enumcode ; <nl> + } else { <nl> + if ( ! SaveType ( enum_def . name , * enum_def . defined_namespace , enumcode , <nl> + false ) ) <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + for ( auto it = parser_ . structs_ . vec . begin ( ) ; <nl> + it ! = parser_ . structs_ . vec . end ( ) ; + + it ) { <nl> + std : : string declcode ; <nl> + auto & struct_def = * * it ; <nl> + if ( ! parser_ . opts . one_file ) <nl> + cur_name_space_ = struct_def . defined_namespace ; <nl> + GenStruct ( struct_def , & declcode ) ; <nl> + if ( parser_ . opts . one_file ) { <nl> + one_file_code + = declcode ; <nl> + } else { <nl> + if ( ! SaveType ( struct_def . name , * struct_def . defined_namespace , declcode , <nl> + true ) ) <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + if ( parser_ . opts . one_file ) { <nl> + return SaveType ( file_name_ , * parser_ . current_namespace_ , one_file_code , <nl> + true ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + / / Save out the generated code for a single class while adding <nl> + / / declaration boilerplate . <nl> + bool SaveType ( const std : : string & defname , const Namespace & ns , <nl> + const std : : string & classcode , bool needs_includes ) const { <nl> + if ( ! classcode . length ( ) ) return true ; <nl> + <nl> + std : : string code = <nl> + " / / < auto - generated > \ n " <nl> + " / / " + <nl> + std : : string ( FlatBuffersGeneratedWarning ( ) ) + <nl> + " \ n " <nl> + " / / < / auto - generated > \ n \ n " ; <nl> + <nl> + std : : string namespace_name = FullNamespace ( " . " , ns ) ; <nl> + if ( ! namespace_name . empty ( ) ) { <nl> + code + = " namespace " + namespace_name + " \ n { \ n \ n " ; <nl> + } <nl> + if ( needs_includes ) { <nl> + code + = " using global : : System ; \ nusing global : : FlatBuffers ; \ n \ n " ; <nl> + } <nl> + code + = classcode ; <nl> + if ( ! namespace_name . empty ( ) ) { code + = " \ n } \ n " ; } <nl> + auto filename = NamespaceDir ( ns ) + defname + " . cs " ; <nl> + return SaveFile ( filename . c_str ( ) , code , false ) ; <nl> + } <nl> + <nl> + const Namespace * CurrentNameSpace ( ) const { return cur_name_space_ ; } <nl> + <nl> + std : : string GenTypeBasic ( const Type & type , bool enableLangOverrides ) const { <nl> + / / clang - format off <nl> + static const char * const csharp_typename [ ] = { <nl> + # define FLATBUFFERS_TD ( ENUM , IDLTYPE , \ <nl> + CTYPE , JTYPE , GTYPE , NTYPE , PTYPE , RTYPE , KTYPE ) \ <nl> + # NTYPE , <nl> + FLATBUFFERS_GEN_TYPES ( FLATBUFFERS_TD ) <nl> + # undef FLATBUFFERS_TD <nl> + } ; <nl> + / / clang - format on <nl> + <nl> + if ( enableLangOverrides ) { <nl> + if ( IsEnum ( type ) ) return WrapInNameSpace ( * type . enum_def ) ; <nl> + if ( type . base_type = = BASE_TYPE_STRUCT ) { <nl> + return " Offset < " + WrapInNameSpace ( * type . struct_def ) + " > " ; <nl> + } <nl> + } <nl> + <nl> + return csharp_typename [ type . base_type ] ; <nl> + } <nl> + <nl> + inline std : : string GenTypeBasic ( const Type & type ) const { <nl> + return GenTypeBasic ( type , true ) ; <nl> + } <nl> + <nl> + std : : string GenTypePointer ( const Type & type ) const { <nl> + switch ( type . base_type ) { <nl> + case BASE_TYPE_STRING : return " string " ; <nl> + case BASE_TYPE_VECTOR : return GenTypeGet ( type . VectorType ( ) ) ; <nl> + case BASE_TYPE_STRUCT : return WrapInNameSpace ( * type . struct_def ) ; <nl> + case BASE_TYPE_UNION : return " TTable " ; <nl> + default : return " Table " ; <nl> + } <nl> + } <nl> + <nl> + std : : string GenTypeGet ( const Type & type ) const { <nl> + return IsScalar ( type . base_type ) <nl> + ? GenTypeBasic ( type ) <nl> + : ( IsArray ( type ) ? GenTypeGet ( type . VectorType ( ) ) <nl> + : GenTypePointer ( type ) ) ; <nl> + } <nl> + <nl> + std : : string GenOffsetType ( const StructDef & struct_def ) const { <nl> + return " Offset < " + WrapInNameSpace ( struct_def ) + " > " ; <nl> + } <nl> + <nl> + std : : string GenOffsetConstruct ( const StructDef & struct_def , <nl> + const std : : string & variable_name ) const { <nl> + return " new Offset < " + WrapInNameSpace ( struct_def ) + " > ( " + variable_name + <nl> + " ) " ; <nl> + } <nl> + <nl> + / / Casts necessary to correctly read serialized data <nl> + std : : string DestinationCast ( const Type & type ) const { <nl> + if ( IsSeries ( type ) ) { <nl> + return DestinationCast ( type . VectorType ( ) ) ; <nl> + } else { <nl> + if ( IsEnum ( type ) ) return " ( " + WrapInNameSpace ( * type . enum_def ) + " ) " ; <nl> + } <nl> + return " " ; <nl> + } <nl> + <nl> + / / Cast statements for mutator method parameters . <nl> + / / In Java , parameters representing unsigned numbers need to be cast down to <nl> + / / their respective type . For example , a long holding an unsigned int value <nl> + / / would be cast down to int before being put onto the buffer . In C # , one cast <nl> + / / directly cast an Enum to its underlying type , which is essential before <nl> + / / putting it onto the buffer . <nl> + std : : string SourceCast ( const Type & type ) const { <nl> + if ( IsSeries ( type ) ) { <nl> + return SourceCast ( type . VectorType ( ) ) ; <nl> + } else { <nl> + if ( IsEnum ( type ) ) return " ( " + GenTypeBasic ( type , false ) + " ) " ; <nl> + } <nl> + return " " ; <nl> + } <nl> + <nl> + std : : string SourceCastBasic ( const Type & type ) const { <nl> + return IsScalar ( type . base_type ) ? SourceCast ( type ) : " " ; <nl> + } <nl> + <nl> + std : : string GenEnumDefaultValue ( const FieldDef & field ) const { <nl> + auto & value = field . value ; <nl> + FLATBUFFERS_ASSERT ( value . type . enum_def ) ; <nl> + auto & enum_def = * value . type . enum_def ; <nl> + auto enum_val = enum_def . FindByValue ( value . constant ) ; <nl> + return enum_val ? ( WrapInNameSpace ( enum_def ) + " . " + enum_val - > name ) <nl> + : value . constant ; <nl> + } <nl> + <nl> + std : : string GenDefaultValue ( const FieldDef & field , <nl> + bool enableLangOverrides ) const { <nl> + auto & value = field . value ; <nl> + if ( enableLangOverrides ) { <nl> + / / handles both enum case and vector of enum case <nl> + if ( value . type . enum_def ! = nullptr & & <nl> + value . type . base_type ! = BASE_TYPE_UNION ) { <nl> + return GenEnumDefaultValue ( field ) ; <nl> + } <nl> + } <nl> + <nl> + auto longSuffix = " " ; <nl> + switch ( value . type . base_type ) { <nl> + case BASE_TYPE_BOOL : return value . constant = = " 0 " ? " false " : " true " ; <nl> + case BASE_TYPE_ULONG : return value . constant ; <nl> + case BASE_TYPE_UINT : <nl> + case BASE_TYPE_LONG : return value . constant + longSuffix ; <nl> + default : <nl> + if ( IsFloat ( value . type . base_type ) ) <nl> + return CSharpFloatGen . GenFloatConstant ( field ) ; <nl> + else <nl> + return value . constant ; <nl> + } <nl> + } <nl> + <nl> + std : : string GenDefaultValue ( const FieldDef & field ) const { <nl> + return GenDefaultValue ( field , true ) ; <nl> + } <nl> + <nl> + std : : string GenDefaultValueBasic ( const FieldDef & field , <nl> + bool enableLangOverrides ) const { <nl> + auto & value = field . value ; <nl> + if ( ! IsScalar ( value . type . base_type ) ) { <nl> + if ( enableLangOverrides ) { <nl> + switch ( value . type . base_type ) { <nl> + case BASE_TYPE_STRING : return " default ( StringOffset ) " ; <nl> + case BASE_TYPE_STRUCT : <nl> + return " default ( Offset < " + WrapInNameSpace ( * value . type . struct_def ) + <nl> + " > ) " ; <nl> + case BASE_TYPE_VECTOR : return " default ( VectorOffset ) " ; <nl> + default : break ; <nl> + } <nl> + } <nl> + return " 0 " ; <nl> + } <nl> + return GenDefaultValue ( field , enableLangOverrides ) ; <nl> + } <nl> + <nl> + std : : string GenDefaultValueBasic ( const FieldDef & field ) const { <nl> + return GenDefaultValueBasic ( field , true ) ; <nl> + } <nl> + <nl> + void GenEnum ( EnumDef & enum_def , std : : string * code_ptr ) const { <nl> + std : : string & code = * code_ptr ; <nl> + if ( enum_def . generated ) return ; <nl> + <nl> + / / Generate enum definitions of the form : <nl> + / / public static ( final ) int name = value ; <nl> + / / In Java , we use ints rather than the Enum feature , because we want them <nl> + / / to map directly to how they ' re used in C / C + + and file formats . <nl> + / / That , and Java Enums are expensive , and not universally liked . <nl> + GenComment ( enum_def . doc_comment , code_ptr , & comment_config ) ; <nl> + <nl> + / / In C # this indicates enumeration values can be treated as bit flags . <nl> + if ( enum_def . attributes . Lookup ( " bit_flags " ) ) { <nl> + code + = " [ System . FlagsAttribute ] \ n " ; <nl> + } <nl> + if ( enum_def . attributes . Lookup ( " private " ) ) { <nl> + code + = " internal " ; <nl> + } else { <nl> + code + = " public " ; <nl> + } <nl> + code + = " enum " + enum_def . name ; <nl> + code + = " : " + GenTypeBasic ( enum_def . underlying_type , false ) ; <nl> + code + = " \ n { \ n " ; <nl> + for ( auto it = enum_def . Vals ( ) . begin ( ) ; it ! = enum_def . Vals ( ) . end ( ) ; + + it ) { <nl> + auto & ev = * * it ; <nl> + GenComment ( ev . doc_comment , code_ptr , & comment_config , " " ) ; <nl> + code + = " " ; <nl> + code + = ev . name + " = " ; <nl> + code + = enum_def . ToString ( ev ) ; <nl> + code + = " , \ n " ; <nl> + } <nl> + / / Close the class <nl> + code + = " } ; \ n \ n " ; <nl> + } <nl> + <nl> + / / Returns the function name that is able to read a value of the given type . <nl> + std : : string GenGetter ( const Type & type ) const { <nl> + switch ( type . base_type ) { <nl> + case BASE_TYPE_STRING : return " __p . __string " ; <nl> + case BASE_TYPE_STRUCT : return " __p . __struct " ; <nl> + case BASE_TYPE_UNION : return " __p . __union " ; <nl> + case BASE_TYPE_VECTOR : return GenGetter ( type . VectorType ( ) ) ; <nl> + case BASE_TYPE_ARRAY : return GenGetter ( type . VectorType ( ) ) ; <nl> + default : { <nl> + std : : string getter = " __p . bb . Get " ; <nl> + if ( type . base_type = = BASE_TYPE_BOOL ) { <nl> + getter = " 0 ! = " + getter ; <nl> + } else if ( GenTypeBasic ( type , false ) ! = " byte " ) { <nl> + getter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> + } <nl> + return getter ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Returns the function name that is able to read a value of the given type . <nl> + std : : string GenGetterForLookupByKey ( flatbuffers : : FieldDef * key_field , <nl> + const std : : string & data_buffer , <nl> + const char * num = nullptr ) const { <nl> + auto type = key_field - > value . type ; <nl> + auto dest_mask = " " ; <nl> + auto dest_cast = DestinationCast ( type ) ; <nl> + auto getter = data_buffer + " . Get " ; <nl> + if ( GenTypeBasic ( type , false ) ! = " byte " ) { <nl> + getter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> + } <nl> + getter = dest_cast + getter + " ( " + GenOffsetGetter ( key_field , num ) + " ) " + <nl> + dest_mask ; <nl> + return getter ; <nl> + } <nl> + <nl> + / / Direct mutation is only allowed for scalar fields . <nl> + / / Hence a setter method will only be generated for such fields . <nl> + std : : string GenSetter ( const Type & type ) const { <nl> + if ( IsScalar ( type . base_type ) ) { <nl> + std : : string setter = " __p . bb . Put " ; <nl> + if ( GenTypeBasic ( type , false ) ! = " byte " & & <nl> + type . base_type ! = BASE_TYPE_BOOL ) { <nl> + setter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> + } <nl> + return setter ; <nl> + } else { <nl> + return " " ; <nl> + } <nl> + } <nl> + <nl> + / / Returns the method name for use with add / put calls . <nl> + std : : string GenMethod ( const Type & type ) const { <nl> + return IsScalar ( type . base_type ) ? MakeCamel ( GenTypeBasic ( type , false ) ) <nl> + : ( IsStruct ( type ) ? " Struct " : " Offset " ) ; <nl> + } <nl> + <nl> + / / Recursively generate arguments for a constructor , to deal with nested <nl> + / / structs . <nl> + void GenStructArgs ( const StructDef & struct_def , std : : string * code_ptr , <nl> + const char * nameprefix , size_t array_count = 0 ) const { <nl> + std : : string & code = * code_ptr ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + const auto & field_type = field . value . type ; <nl> + const auto array_field = IsArray ( field_type ) ; <nl> + const auto & type = array_field ? field_type . VectorType ( ) : field_type ; <nl> + const auto array_cnt = array_field ? ( array_count + 1 ) : array_count ; <nl> + if ( IsStruct ( type ) ) { <nl> + / / Generate arguments for a struct inside a struct . To ensure names <nl> + / / don ' t clash , and to make it obvious these arguments are constructing <nl> + / / a nested struct , prefix the name with the field name . <nl> + GenStructArgs ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , array_cnt ) ; <nl> + } else { <nl> + code + = " , " ; <nl> + code + = GenTypeBasic ( type ) ; <nl> + if ( array_cnt > 0 ) { <nl> + code + = " [ " ; <nl> + for ( size_t i = 1 ; i < array_cnt ; i + + ) code + = " , " ; <nl> + code + = " ] " ; <nl> + } <nl> + code + = " " ; <nl> + code + = nameprefix ; <nl> + code + = MakeCamel ( field . name , true ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Recusively generate struct construction statements of the form : <nl> + / / builder . putType ( name ) ; <nl> + / / and insert manual padding . <nl> + void GenStructBody ( const StructDef & struct_def , std : : string * code_ptr , <nl> + const char * nameprefix , size_t index = 0 , <nl> + bool in_array = false ) const { <nl> + std : : string & code = * code_ptr ; <nl> + std : : string indent ( ( index + 1 ) * 2 , ' ' ) ; <nl> + code + = indent + " builder . Prep ( " ; <nl> + code + = NumToString ( struct_def . minalign ) + " , " ; <nl> + code + = NumToString ( struct_def . bytesize ) + " ) ; \ n " ; <nl> + for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> + it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + const auto & field_type = field . value . type ; <nl> + if ( field . padding ) { <nl> + code + = indent + " builder . Pad ( " ; <nl> + code + = NumToString ( field . padding ) + " ) ; \ n " ; <nl> + } <nl> + if ( IsStruct ( field_type ) ) { <nl> + GenStructBody ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index , <nl> + in_array ) ; <nl> + } else { <nl> + const auto & type = <nl> + IsArray ( field_type ) ? field_type . VectorType ( ) : field_type ; <nl> + const auto index_var = " _idx " + NumToString ( index ) ; <nl> + if ( IsArray ( field_type ) ) { <nl> + code + = indent + " for ( int " + index_var + " = " ; <nl> + code + = NumToString ( field_type . fixed_length ) ; <nl> + code + = " ; " + index_var + " > 0 ; " + index_var + " - - ) { \ n " ; <nl> + in_array = true ; <nl> + } <nl> + if ( IsStruct ( type ) ) { <nl> + GenStructBody ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index + 1 , <nl> + in_array ) ; <nl> + } else { <nl> + code + = IsArray ( field_type ) ? " " : " " ; <nl> + code + = indent + " builder . Put " ; <nl> + code + = GenMethod ( type ) + " ( " ; <nl> + code + = SourceCast ( type ) ; <nl> + auto argname = nameprefix + MakeCamel ( field . name , true ) ; <nl> + code + = argname ; <nl> + size_t array_cnt = index + ( IsArray ( field_type ) ? 1 : 0 ) ; <nl> + if ( array_cnt > 0 ) { <nl> + code + = " [ " ; <nl> + for ( size_t i = 0 ; in_array & & i < array_cnt ; i + + ) { <nl> + code + = " _idx " + NumToString ( i ) + " - 1 " ; <nl> + if ( i ! = ( array_cnt - 1 ) ) code + = " , " ; <nl> + } <nl> + code + = " ] " ; <nl> + } <nl> + code + = " ) ; \ n " ; <nl> + } <nl> + if ( IsArray ( field_type ) ) { code + = indent + " } \ n " ; } <nl> + } <nl> + } <nl> + } <nl> + std : : string GenOffsetGetter ( flatbuffers : : FieldDef * key_field , <nl> + const char * num = nullptr ) const { <nl> + std : : string key_offset = <nl> + " Table . __offset ( " + NumToString ( key_field - > value . offset ) + " , " ; <nl> + if ( num ) { <nl> + key_offset + = num ; <nl> + key_offset + = " . Value , builder . DataBuffer ) " ; <nl> + } else { <nl> + key_offset + = " bb . Length " ; <nl> + key_offset + = " - tableOffset , bb ) " ; <nl> + } <nl> + return key_offset ; <nl> + } <nl> + <nl> + std : : string GenLookupKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> + std : : string key_getter = " " ; <nl> + key_getter + = " int tableOffset = Table . " ; <nl> + key_getter + = " __indirect ( vectorLocation + 4 * ( start + middle ) " ; <nl> + key_getter + = " , bb ) ; \ n " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + key_getter + = " int comp = Table . " ; <nl> + key_getter + = " CompareStrings ( " ; <nl> + key_getter + = GenOffsetGetter ( key_field ) ; <nl> + key_getter + = " , byteKey , bb ) ; \ n " ; <nl> + } else { <nl> + auto get_val = GenGetterForLookupByKey ( key_field , " bb " ) ; <nl> + key_getter + = " int comp = " + get_val + " . CompareTo ( key ) ; \ n " ; <nl> + } <nl> + return key_getter ; <nl> + } <nl> + <nl> + std : : string GenKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> + std : : string key_getter = " " ; <nl> + auto data_buffer = " builder . DataBuffer " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + key_getter + = " Table . CompareStrings ( " ; <nl> + key_getter + = GenOffsetGetter ( key_field , " o1 " ) + " , " ; <nl> + key_getter + = GenOffsetGetter ( key_field , " o2 " ) + " , " + data_buffer + " ) " ; <nl> + } else { <nl> + auto field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o1 " ) ; <nl> + key_getter + = field_getter ; <nl> + field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o2 " ) ; <nl> + key_getter + = " . CompareTo ( " + field_getter + " ) " ; <nl> + } <nl> + return key_getter ; <nl> + } <nl> + <nl> + void GenStruct ( StructDef & struct_def , std : : string * code_ptr ) const { <nl> + if ( struct_def . generated ) return ; <nl> + std : : string & code = * code_ptr ; <nl> + <nl> + / / Generate a struct accessor class , with methods of the form : <nl> + / / public type name ( ) { return bb . getType ( i + offset ) ; } <nl> + / / or for tables of the form : <nl> + / / public type name ( ) { <nl> + / / int o = __offset ( offset ) ; return o ! = 0 ? bb . getType ( o + i ) : default ; <nl> + / / } <nl> + GenComment ( struct_def . doc_comment , code_ptr , & comment_config ) ; <nl> + if ( struct_def . attributes . Lookup ( " private " ) ) { <nl> + code + = " internal " ; <nl> + } else { <nl> + code + = " public " ; <nl> + } <nl> + if ( struct_def . attributes . Lookup ( " csharp_partial " ) ) { <nl> + / / generate a partial class for this C # struct / table <nl> + code + = " partial " ; <nl> + } <nl> + code + = " struct " + struct_def . name ; <nl> + code + = " : IFlatbufferObject " ; <nl> + code + = " \ n { \ n " ; <nl> + code + = " private " ; <nl> + code + = struct_def . fixed ? " Struct " : " Table " ; <nl> + code + = " __p ; \ n " ; <nl> + <nl> + code + = " public ByteBuffer ByteBuffer { get { return __p . bb ; } } \ n " ; <nl> + <nl> + if ( ! struct_def . fixed ) { <nl> + / / Generate verson check method . <nl> + / / Force compile time error if not using the same version runtime . <nl> + code + = " public static void ValidateVersion ( ) { " ; <nl> + code + = " FlatBufferConstants . " ; <nl> + code + = " FLATBUFFERS_1_11_1 ( ) ; " ; <nl> + code + = " } \ n " ; <nl> + <nl> + / / Generate a special accessor for the table that when used as the root <nl> + / / of a FlatBuffer <nl> + std : : string method_name = " GetRootAs " + struct_def . name ; <nl> + std : : string method_signature = <nl> + " public static " + struct_def . name + " " + method_name ; <nl> + <nl> + / / create convenience method that doesn ' t require an existing object <nl> + code + = method_signature + " ( ByteBuffer _bb ) " ; <nl> + code + = " { return " + method_name + " ( _bb , new " + struct_def . name + <nl> + " ( ) ) ; } \ n " ; <nl> + <nl> + / / create method that allows object reuse <nl> + code + = <nl> + method_signature + " ( ByteBuffer _bb , " + struct_def . name + " obj ) { " ; <nl> + code + = " return ( obj . __assign ( _bb . GetInt ( _bb . Position " ; <nl> + code + = " ) + _bb . Position " ; <nl> + code + = " , _bb ) ) ; } \ n " ; <nl> + if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> + if ( parser_ . file_identifier_ . length ( ) ) { <nl> + / / Check if a buffer has the identifier . <nl> + code + = " public static " ; <nl> + code + = " bool " + struct_def . name ; <nl> + code + = " BufferHasIdentifier ( ByteBuffer _bb ) { return " ; <nl> + code + = " Table . __has_identifier ( _bb , \ " " ; <nl> + code + = parser_ . file_identifier_ ; <nl> + code + = " \ " ) ; } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + / / Generate the __init method that sets the field in a pre - existing <nl> + / / accessor object . This is to allow object reuse . <nl> + code + = " public void __init ( int _i , ByteBuffer _bb ) " ; <nl> + code + = " { " ; <nl> + code + = " __p = new " ; <nl> + code + = struct_def . fixed ? " Struct " : " Table " ; <nl> + code + = " ( _i , _bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + code + = <nl> + " public " + struct_def . name + " __assign ( int _i , ByteBuffer _bb ) " ; <nl> + code + = " { __init ( _i , _bb ) ; return this ; } \ n \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + GenComment ( field . doc_comment , code_ptr , & comment_config , " " ) ; <nl> + std : : string type_name = GenTypeGet ( field . value . type ) ; <nl> + std : : string type_name_dest = GenTypeGet ( field . value . type ) ; <nl> + std : : string conditional_cast = " " ; <nl> + std : : string optional = " " ; <nl> + if ( ! struct_def . fixed & & <nl> + ( field . value . type . base_type = = BASE_TYPE_STRUCT | | <nl> + field . value . type . base_type = = BASE_TYPE_UNION | | <nl> + ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + ( field . value . type . element = = BASE_TYPE_STRUCT | | <nl> + field . value . type . element = = BASE_TYPE_UNION ) ) ) ) { <nl> + optional = " ? " ; <nl> + conditional_cast = " ( " + type_name_dest + optional + " ) " ; <nl> + } <nl> + std : : string dest_mask = " " ; <nl> + std : : string dest_cast = DestinationCast ( field . value . type ) ; <nl> + std : : string src_cast = SourceCast ( field . value . type ) ; <nl> + std : : string method_start = " public " + type_name_dest + optional + " " + <nl> + MakeCamel ( field . name , true ) ; <nl> + std : : string obj = " ( new " + type_name + " ( ) ) " ; <nl> + <nl> + / / Most field accessors need to retrieve and test the field offset first , <nl> + / / this is the prefix code for that : <nl> + auto offset_prefix = <nl> + IsArray ( field . value . type ) <nl> + ? " { return " <nl> + : ( " { int o = __p . __offset ( " + NumToString ( field . value . offset ) + <nl> + " ) ; return o ! = 0 ? " ) ; <nl> + / / Generate the accessors that don ' t do object reuse . <nl> + if ( field . value . type . base_type = = BASE_TYPE_STRUCT ) { <nl> + } else if ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + field . value . type . element = = BASE_TYPE_STRUCT ) { <nl> + } else if ( field . value . type . base_type = = BASE_TYPE_UNION | | <nl> + ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + field . value . type . VectorType ( ) . base_type = = BASE_TYPE_UNION ) ) { <nl> + method_start + = " < TTable > " ; <nl> + type_name = type_name_dest ; <nl> + } <nl> + std : : string getter = dest_cast + GenGetter ( field . value . type ) ; <nl> + code + = method_start ; <nl> + std : : string default_cast = " " ; <nl> + / / only create default casts for c # scalars or vectors of scalars <nl> + if ( ( IsScalar ( field . value . type . base_type ) | | <nl> + ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + IsScalar ( field . value . type . element ) ) ) ) { <nl> + / / For scalars , default value will be returned by GetDefaultValue ( ) . <nl> + / / If the scalar is an enum , GetDefaultValue ( ) returns an actual c # enum <nl> + / / that doesn ' t need to be casted . However , default values for enum <nl> + / / elements of vectors are integer literals ( " 0 " ) and are still casted <nl> + / / for clarity . <nl> + if ( field . value . type . enum_def = = nullptr | | <nl> + field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + default_cast = " ( " + type_name_dest + " ) " ; <nl> + } <nl> + } <nl> + std : : string member_suffix = " ; " ; <nl> + if ( IsScalar ( field . value . type . base_type ) ) { <nl> + code + = " { get " ; <nl> + member_suffix + = " } " ; <nl> + if ( struct_def . fixed ) { <nl> + code + = " { return " + getter ; <nl> + code + = " ( __p . bb_pos + " ; <nl> + code + = NumToString ( field . value . offset ) + " ) " ; <nl> + code + = dest_mask ; <nl> + } else { <nl> + code + = offset_prefix + getter ; <nl> + code + = " ( o + __p . bb_pos ) " + dest_mask ; <nl> + code + = " : " + default_cast ; <nl> + code + = GenDefaultValue ( field ) ; <nl> + } <nl> + } else { <nl> + switch ( field . value . type . base_type ) { <nl> + case BASE_TYPE_STRUCT : <nl> + code + = " { get " ; <nl> + member_suffix + = " } " ; <nl> + if ( struct_def . fixed ) { <nl> + code + = " { return " + obj + " . __assign ( " + " __p . " ; <nl> + code + = " bb_pos + " + NumToString ( field . value . offset ) + " , " ; <nl> + code + = " __p . bb ) " ; <nl> + } else { <nl> + code + = offset_prefix + conditional_cast ; <nl> + code + = obj + " . __assign ( " ; <nl> + code + = field . value . type . struct_def - > fixed <nl> + ? " o + __p . bb_pos " <nl> + : " __p . __indirect ( o + __p . bb_pos ) " ; <nl> + code + = " , __p . bb ) : null " ; <nl> + } <nl> + break ; <nl> + case BASE_TYPE_STRING : <nl> + code + = " { get " ; <nl> + member_suffix + = " } " ; <nl> + code + = offset_prefix + getter + " ( o + " + " __p . " ; <nl> + code + = " bb_pos ) : null " ; <nl> + break ; <nl> + case BASE_TYPE_ARRAY : FLATBUFFERS_FALLTHROUGH ( ) ; / / fall thru <nl> + case BASE_TYPE_VECTOR : { <nl> + auto vectortype = field . value . type . VectorType ( ) ; <nl> + if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> + conditional_cast = " ( TTable ? ) " ; <nl> + getter + = " < TTable > " ; <nl> + } <nl> + code + = " ( " ; <nl> + if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> + getter = obj + " . __assign " ; <nl> + } else if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> + } <nl> + code + = " int j ) " ; <nl> + const auto body = offset_prefix + conditional_cast + getter + " ( " ; <nl> + if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> + code + = " where TTable : struct , IFlatbufferObject " + body ; <nl> + } else { <nl> + code + = body ; <nl> + } <nl> + std : : string index = " __p . " ; <nl> + if ( IsArray ( field . value . type ) ) { <nl> + index + = " bb_pos + " + NumToString ( field . value . offset ) + " + " ; <nl> + } else { <nl> + index + = " __vector ( o ) + " ; <nl> + } <nl> + index + = " j * " + NumToString ( InlineSize ( vectortype ) ) ; <nl> + if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> + code + = vectortype . struct_def - > fixed <nl> + ? index <nl> + : " __p . __indirect ( " + index + " ) " ; <nl> + code + = " , __p . bb " ; <nl> + } else { <nl> + code + = index ; <nl> + } <nl> + code + = " ) " + dest_mask ; <nl> + if ( ! IsArray ( field . value . type ) ) { <nl> + code + = " : " ; <nl> + code + = <nl> + field . value . type . element = = BASE_TYPE_BOOL <nl> + ? " false " <nl> + : ( IsScalar ( field . value . type . element ) ? default_cast + " 0 " <nl> + : " null " ) ; <nl> + } <nl> + <nl> + break ; <nl> + } <nl> + case BASE_TYPE_UNION : <nl> + code + = " ( ) where TTable : struct , IFlatbufferObject " ; <nl> + code + = offset_prefix + " ( TTable ? ) " + getter ; <nl> + code + = " < TTable > ( o + __p . bb_pos ) : null " ; <nl> + break ; <nl> + default : FLATBUFFERS_ASSERT ( 0 ) ; <nl> + } <nl> + } <nl> + code + = member_suffix ; <nl> + code + = " } \ n " ; <nl> + if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + code + = " public int " + MakeCamel ( field . name , true ) ; <nl> + code + = " Length " ; <nl> + code + = " { get " ; <nl> + code + = offset_prefix ; <nl> + code + = " __p . __vector_len ( o ) : 0 ; " ; <nl> + code + = " } " ; <nl> + code + = " } \ n " ; <nl> + / / See if we should generate a by - key accessor . <nl> + if ( field . value . type . element = = BASE_TYPE_STRUCT & & <nl> + ! field . value . type . struct_def - > fixed ) { <nl> + auto & sd = * field . value . type . struct_def ; <nl> + auto & fields = sd . fields . vec ; <nl> + for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> + auto & key_field = * * kit ; <nl> + if ( key_field . key ) { <nl> + auto qualified_name = WrapInNameSpace ( sd ) ; <nl> + code + = " public " + qualified_name + " ? " ; <nl> + code + = MakeCamel ( field . name , true ) + " ByKey ( " ; <nl> + code + = GenTypeGet ( key_field . value . type ) + " key ) " ; <nl> + code + = offset_prefix ; <nl> + code + = qualified_name + " . __lookup_by_key ( " ; <nl> + code + = " __p . __vector ( o ) , key , " ; <nl> + code + = " __p . bb ) : null ; " ; <nl> + code + = " } \ n " ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + / / Generate a ByteBuffer accessor for strings & vectors of scalars . <nl> + if ( ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + IsScalar ( field . value . type . VectorType ( ) . base_type ) ) | | <nl> + field . value . type . base_type = = BASE_TYPE_STRING ) { <nl> + code + = " # if ENABLE_SPAN_T \ n " ; <nl> + code + = " public Span < " + GenTypeBasic ( field . value . type . VectorType ( ) ) + <nl> + " > Get " ; <nl> + code + = MakeCamel ( field . name , true ) ; <nl> + code + = " Bytes ( ) { return " ; <nl> + code + = " __p . __vector_as_span < " + <nl> + GenTypeBasic ( field . value . type . VectorType ( ) ) + " > ( " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = <nl> + " , " + NumToString ( SizeOf ( field . value . type . VectorType ( ) . base_type ) ) ; <nl> + code + = " ) ; } \ n " ; <nl> + code + = " # else \ n " ; <nl> + code + = " public ArraySegment < byte > ? Get " ; <nl> + code + = MakeCamel ( field . name , true ) ; <nl> + code + = " Bytes ( ) { return " ; <nl> + code + = " __p . __vector_as_arraysegment ( " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = " ) ; } \ n " ; <nl> + code + = " # endif \ n " ; <nl> + <nl> + / / For direct blockcopying the data into a typed array <nl> + code + = " public " ; <nl> + code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> + code + = " [ ] Get " ; <nl> + code + = MakeCamel ( field . name , true ) ; <nl> + code + = " Array ( ) { " ; <nl> + if ( IsEnum ( field . value . type . VectorType ( ) ) ) { <nl> + / / Since __vector_as_array does not work for enum types , <nl> + / / fill array using an explicit loop . <nl> + code + = " int o = __p . __offset ( " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = " ) ; if ( o = = 0 ) return null ; int p = " ; <nl> + code + = " __p . __vector ( o ) ; int l = " ; <nl> + code + = " __p . __vector_len ( o ) ; " ; <nl> + code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> + code + = " [ ] a = new " ; <nl> + code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> + code + = " [ l ] ; for ( int i = 0 ; i < l ; i + + ) { a [ i ] = " + getter ; <nl> + code + = " ( p + i * " ; <nl> + code + = NumToString ( InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> + code + = " ) ; } return a ; " ; <nl> + } else { <nl> + code + = " return " ; <nl> + code + = " __p . __vector_as_array < " ; <nl> + code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> + code + = " > ( " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = " ) ; " ; <nl> + } <nl> + code + = " } \ n " ; <nl> + } <nl> + / / generate object accessors if is nested_flatbuffer <nl> + if ( field . nested_flatbuffer ) { <nl> + auto nested_type_name = WrapInNameSpace ( * field . nested_flatbuffer ) ; <nl> + auto nested_method_name = <nl> + MakeCamel ( field . name , true ) + " As " + field . nested_flatbuffer - > name ; <nl> + auto get_nested_method_name = nested_method_name ; <nl> + get_nested_method_name = " Get " + nested_method_name ; <nl> + conditional_cast = " ( " + nested_type_name + " ? ) " ; <nl> + obj = " ( new " + nested_type_name + " ( ) ) " ; <nl> + code + = " public " + nested_type_name + " ? " ; <nl> + code + = get_nested_method_name + " ( " ; <nl> + code + = " ) { int o = __p . __offset ( " ; <nl> + code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> + code + = " return o ! = 0 ? " + conditional_cast + obj + " . __assign ( " ; <nl> + code + = " __p . " ; <nl> + code + = " __indirect ( __p . __vector ( o ) ) , " ; <nl> + code + = " __p . bb ) : null ; } \ n " ; <nl> + } <nl> + / / Generate mutators for scalar fields or vectors of scalars . <nl> + if ( parser_ . opts . mutable_buffer ) { <nl> + auto is_series = ( IsSeries ( field . value . type ) ) ; <nl> + const auto & underlying_type = <nl> + is_series ? field . value . type . VectorType ( ) : field . value . type ; <nl> + / / Boolean parameters have to be explicitly converted to byte <nl> + / / representation . <nl> + auto setter_parameter = underlying_type . base_type = = BASE_TYPE_BOOL <nl> + ? " ( byte ) ( " + field . name + " ? 1 : 0 ) " <nl> + : field . name ; <nl> + auto mutator_prefix = MakeCamel ( " mutate " , true ) ; <nl> + / / A vector mutator also needs the index of the vector element it should <nl> + / / mutate . <nl> + auto mutator_params = ( is_series ? " ( int j , " : " ( " ) + <nl> + GenTypeGet ( underlying_type ) + " " + field . name + <nl> + " ) { " ; <nl> + auto setter_index = <nl> + is_series <nl> + ? " __p . " + <nl> + ( IsArray ( field . value . type ) <nl> + ? " bb_pos + " + NumToString ( field . value . offset ) <nl> + : " __vector ( o ) " ) + <nl> + + " + j * " + NumToString ( InlineSize ( underlying_type ) ) <nl> + : ( struct_def . fixed <nl> + ? " __p . bb_pos + " + NumToString ( field . value . offset ) <nl> + : " o + __p . bb_pos " ) ; <nl> + if ( IsScalar ( underlying_type . base_type ) & & ! IsUnion ( field . value . type ) ) { <nl> + code + = " public " ; <nl> + code + = struct_def . fixed ? " void " : " bool " ; <nl> + code + = mutator_prefix + MakeCamel ( field . name , true ) ; <nl> + code + = mutator_params ; <nl> + if ( struct_def . fixed ) { <nl> + code + = GenSetter ( underlying_type ) + " ( " + setter_index + " , " ; <nl> + code + = src_cast + setter_parameter + " ) ; } \ n " ; <nl> + } else { <nl> + code + = " int o = __p . __offset ( " ; <nl> + code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> + code + = " if ( o ! = 0 ) { " + GenSetter ( underlying_type ) ; <nl> + code + = " ( " + setter_index + " , " + src_cast + setter_parameter + <nl> + " ) ; return true ; } else { return false ; } } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + if ( parser_ . opts . java_primitive_has_method & & <nl> + IsScalar ( field . value . type . base_type ) & & ! struct_def . fixed ) { <nl> + auto vt_offset_constant = " public static final int VT_ " + <nl> + MakeScreamingCamel ( field . name ) + " = " + <nl> + NumToString ( field . value . offset ) + " ; " ; <nl> + <nl> + code + = vt_offset_constant ; <nl> + code + = " \ n " ; <nl> + } <nl> + } <nl> + code + = " \ n " ; <nl> + flatbuffers : : FieldDef * key_field = nullptr ; <nl> + if ( struct_def . fixed ) { <nl> + / / create a struct constructor function <nl> + code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> + code + = " Create " ; <nl> + code + = struct_def . name + " ( FlatBufferBuilder builder " ; <nl> + GenStructArgs ( struct_def , code_ptr , " " ) ; <nl> + code + = " ) { \ n " ; <nl> + GenStructBody ( struct_def , code_ptr , " " ) ; <nl> + code + = " return " ; <nl> + code + = GenOffsetConstruct ( struct_def , " builder . Offset " ) ; <nl> + code + = " ; \ n } \ n " ; <nl> + } else { <nl> + / / Generate a method that creates a table in one go . This is only possible <nl> + / / when the table has no struct fields , since those have to be created <nl> + / / inline , and there ' s no way to do so in Java . <nl> + bool has_no_struct_fields = true ; <nl> + int num_fields = 0 ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + if ( IsStruct ( field . value . type ) ) { <nl> + has_no_struct_fields = false ; <nl> + } else { <nl> + num_fields + + ; <nl> + } <nl> + } <nl> + / / JVM specifications restrict default constructor params to be < 255 . <nl> + / / Longs and doubles take up 2 units , so we set the limit to be < 127 . <nl> + if ( has_no_struct_fields & & num_fields & & num_fields < 127 ) { <nl> + / / Generate a table constructor of the form : <nl> + / / public static int createName ( FlatBufferBuilder builder , args . . . ) <nl> + code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> + code + = " Create " + struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + code + = " , \ n " ; <nl> + code + = GenTypeBasic ( field . value . type ) ; <nl> + code + = " " ; <nl> + code + = field . name ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> + <nl> + code + = " = " ; <nl> + code + = GenDefaultValueBasic ( field ) ; <nl> + } <nl> + code + = " ) { \ n builder . " ; <nl> + code + = " StartTable ( " ; <nl> + code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; \ n " ; <nl> + for ( size_t size = struct_def . sortbysize ? sizeof ( largest_scalar_t ) : 1 ; <nl> + size ; size / = 2 ) { <nl> + for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> + it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( ! field . deprecated & & <nl> + ( ! struct_def . sortbysize | | <nl> + size = = SizeOf ( field . value . type . base_type ) ) ) { <nl> + code + = " " + struct_def . name + " . " ; <nl> + code + = " Add " ; <nl> + code + = MakeCamel ( field . name ) + " ( builder , " + field . name ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> + code + = " ) ; \ n " ; <nl> + } <nl> + } <nl> + } <nl> + code + = " return " + struct_def . name + " . " ; <nl> + code + = " End " + struct_def . name ; <nl> + code + = " ( builder ) ; \ n } \ n \ n " ; <nl> + } <nl> + / / Generate a set of static methods that allow table construction , <nl> + / / of the form : <nl> + / / public static void addName ( FlatBufferBuilder builder , short name ) <nl> + / / { builder . addShort ( id , name , default ) ; } <nl> + / / Unlike the Create function , these always work . <nl> + code + = " public static void Start " ; <nl> + code + = struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder ) { builder . " ; <nl> + code + = " StartTable ( " ; <nl> + code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; } \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + if ( field . key ) key_field = & field ; <nl> + code + = " public static void Add " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " ( FlatBufferBuilder builder , " ; <nl> + code + = GenTypeBasic ( field . value . type ) ; <nl> + auto argname = MakeCamel ( field . name , false ) ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) argname + = " Offset " ; <nl> + code + = " " + argname + " ) { builder . Add " ; <nl> + code + = GenMethod ( field . value . type ) + " ( " ; <nl> + code + = NumToString ( it - struct_def . fields . vec . begin ( ) ) + " , " ; <nl> + code + = SourceCastBasic ( field . value . type ) ; <nl> + code + = argname ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) & & <nl> + field . value . type . base_type ! = BASE_TYPE_UNION ) { <nl> + code + = " . Value " ; <nl> + } <nl> + code + = " , " ; <nl> + code + = GenDefaultValue ( field , false ) ; <nl> + code + = " ) ; } \ n " ; <nl> + if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + auto vector_type = field . value . type . VectorType ( ) ; <nl> + auto alignment = InlineAlignment ( vector_type ) ; <nl> + auto elem_size = InlineSize ( vector_type ) ; <nl> + if ( ! IsStruct ( vector_type ) ) { <nl> + code + = " public static VectorOffset " ; <nl> + code + = " Create " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , " ; <nl> + code + = GenTypeBasic ( vector_type ) + " [ ] data ) " ; <nl> + code + = " { builder . StartVector ( " ; <nl> + code + = NumToString ( elem_size ) ; <nl> + code + = " , data . Length , " ; <nl> + code + = NumToString ( alignment ) ; <nl> + code + = " ) ; for ( int i = data . " ; <nl> + code + = " Length - 1 ; i > = 0 ; i - - ) builder . " ; <nl> + code + = " Add " ; <nl> + code + = GenMethod ( vector_type ) ; <nl> + code + = " ( " ; <nl> + code + = SourceCastBasic ( vector_type ) ; <nl> + code + = " data [ i ] " ; <nl> + if ( ( vector_type . base_type = = BASE_TYPE_STRUCT | | <nl> + vector_type . base_type = = BASE_TYPE_STRING ) ) <nl> + code + = " . Value " ; <nl> + code + = " ) ; return " ; <nl> + code + = " builder . EndVector ( ) ; } \ n " ; <nl> + <nl> + code + = " public static VectorOffset " ; <nl> + code + = " Create " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " VectorBlock ( FlatBufferBuilder builder , " ; <nl> + code + = GenTypeBasic ( vector_type ) + " [ ] data ) " ; <nl> + code + = " { builder . StartVector ( " ; <nl> + code + = NumToString ( elem_size ) ; <nl> + code + = " , data . Length , " ; <nl> + code + = NumToString ( alignment ) ; <nl> + code + = " ) ; builder . Add ( data ) ; return builder . EndVector ( ) ; } \ n " ; <nl> + } <nl> + / / Generate a method to start a vector , data to be added manually <nl> + / / after . <nl> + code + = " public static void Start " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , int numElems ) " ; <nl> + code + = " { builder . StartVector ( " ; <nl> + code + = NumToString ( elem_size ) ; <nl> + code + = " , numElems , " + NumToString ( alignment ) ; <nl> + code + = " ) ; } \ n " ; <nl> + } <nl> + } <nl> + code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> + code + = " End " + struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder ) { \ n int o = builder . " ; <nl> + code + = " EndTable ( ) ; \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( ! field . deprecated & & field . required ) { <nl> + code + = " builder . Required ( o , " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = " ) ; / / " + field . name + " \ n " ; <nl> + } <nl> + } <nl> + code + = " return " + GenOffsetConstruct ( struct_def , " o " ) + " ; \ n } \ n " ; <nl> + if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> + std : : string size_prefix [ ] = { " " , " SizePrefixed " } ; <nl> + for ( int i = 0 ; i < 2 ; + + i ) { <nl> + code + = " public static void " ; <nl> + code + = " Finish " + size_prefix [ i ] + struct_def . name ; <nl> + code + = <nl> + " Buffer ( FlatBufferBuilder builder , " + GenOffsetType ( struct_def ) ; <nl> + code + = " offset ) { " ; <nl> + code + = " builder . Finish " + size_prefix [ i ] + " ( offset " ; <nl> + code + = " . Value " ; <nl> + <nl> + if ( parser_ . file_identifier_ . length ( ) ) <nl> + code + = " , \ " " + parser_ . file_identifier_ + " \ " " ; <nl> + code + = " ) ; } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + / / Only generate key compare function for table , <nl> + / / because ` key_field ` is not set for struct <nl> + if ( struct_def . has_key & & ! struct_def . fixed ) { <nl> + FLATBUFFERS_ASSERT ( key_field ) ; <nl> + code + = " \ n public static VectorOffset " ; <nl> + code + = " CreateSortedVectorOf " + struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder , " ; <nl> + code + = " Offset < " + struct_def . name + " > " ; <nl> + code + = " [ ] offsets ) { \ n " ; <nl> + code + = " Array . Sort ( offsets , ( Offset < " + struct_def . name + <nl> + " > o1 , Offset < " + struct_def . name + " > o2 ) = > " + <nl> + GenKeyGetter ( key_field ) ; <nl> + code + = " ) ; \ n " ; <nl> + code + = " return builder . CreateVectorOfTables ( offsets ) ; \ n } \ n " ; <nl> + <nl> + code + = " \ n public static " + struct_def . name + " ? " ; <nl> + code + = " __lookup_by_key ( " ; <nl> + code + = " int vectorLocation , " ; <nl> + code + = GenTypeGet ( key_field - > value . type ) ; <nl> + code + = " key , ByteBuffer bb ) { \ n " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + code + = " byte [ ] byteKey = " ; <nl> + code + = " System . Text . Encoding . UTF8 . GetBytes ( key ) ; \ n " ; <nl> + } <nl> + code + = " int span = " ; <nl> + code + = " bb . GetInt ( vectorLocation - 4 ) ; \ n " ; <nl> + code + = " int start = 0 ; \ n " ; <nl> + code + = " while ( span ! = 0 ) { \ n " ; <nl> + code + = " int middle = span / 2 ; \ n " ; <nl> + code + = GenLookupKeyGetter ( key_field ) ; <nl> + code + = " if ( comp > 0 ) { \ n " ; <nl> + code + = " span = middle ; \ n " ; <nl> + code + = " } else if ( comp < 0 ) { \ n " ; <nl> + code + = " middle + + ; \ n " ; <nl> + code + = " start + = middle ; \ n " ; <nl> + code + = " span - = middle ; \ n " ; <nl> + code + = " } else { \ n " ; <nl> + code + = " return " ; <nl> + code + = " new " + struct_def . name + " ( ) " ; <nl> + code + = " . __assign ( tableOffset , bb ) ; \ n " ; <nl> + code + = " } \ n } \ n " ; <nl> + code + = " return null ; \ n " ; <nl> + code + = " } \ n " ; <nl> + } <nl> + code + = " } ; \ n \ n " ; <nl> + } <nl> + <nl> + void GenVectorAccessObject ( StructDef & struct_def , <nl> + std : : string * code_ptr ) const { <nl> + auto & code = * code_ptr ; <nl> + / / Generate a vector of structs accessor class . <nl> + code + = " \ n " ; <nl> + code + = " " ; <nl> + if ( ! struct_def . attributes . Lookup ( " private " ) ) code + = " public " ; <nl> + code + = " static struct Vector : BaseVector \ n { \ n " ; <nl> + <nl> + / / Generate the __assign method that sets the field in a pre - existing <nl> + / / accessor object . This is to allow object reuse . <nl> + std : : string method_indent = " " ; <nl> + code + = method_indent + " public Vector " ; <nl> + code + = " __assign ( int _vector , int _element_size , ByteBuffer _bb ) { " ; <nl> + code + = " __reset ( _vector , _element_size , _bb ) ; return this ; } \ n \ n " ; <nl> + <nl> + auto type_name = struct_def . name ; <nl> + auto method_start = method_indent + " public " + type_name + " Get " ; <nl> + / / Generate the accessors that don ' t do object reuse . <nl> + code + = method_start + " ( int j ) { return Get " ; <nl> + code + = " ( new " + type_name + " ( ) , j ) ; } \ n " ; <nl> + code + = method_start + " ( " + type_name + " obj , int j ) { " ; <nl> + code + = " return obj . __assign ( " ; <nl> + code + = struct_def . fixed ? " __p . __element ( j ) " <nl> + : " __p . __indirect ( __p . __element ( j ) , bb ) " ; <nl> + code + = " , __p . bb ) ; } \ n " ; <nl> + / / See if we should generate a by - key accessor . <nl> + if ( ! struct_def . fixed ) { <nl> + auto & fields = struct_def . fields . vec ; <nl> + for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> + auto & key_field = * * kit ; <nl> + if ( key_field . key ) { <nl> + auto nullable_annotation = <nl> + parser_ . opts . gen_nullable ? " @ Nullable " : " " ; <nl> + code + = method_indent + nullable_annotation ; <nl> + code + = " public " + type_name + " ? " ; <nl> + code + = " GetByKey ( " ; <nl> + code + = GenTypeGet ( key_field . value . type ) + " key ) { " ; <nl> + code + = " return __lookup_by_key ( null , " ; <nl> + code + = " __p . __vector ( ) , key , " ; <nl> + code + = " __p . bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + code + = method_indent + nullable_annotation ; <nl> + code + = " public " + type_name + " ? " + " " ; <nl> + code + = " GetByKey ( " ; <nl> + code + = type_name + " ? obj , " ; <nl> + code + = GenTypeGet ( key_field . value . type ) + " key ) { " ; <nl> + code + = " return __lookup_by_key ( obj , " ; <nl> + code + = " __p . __vector ( ) , key , " ; <nl> + code + = " __p . bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + code + = " } \ n " ; <nl> + } <nl> + <nl> + / / This tracks the current namespace used to determine if a type need to be <nl> + / / prefixed by its namespace <nl> + const Namespace * cur_name_space_ ; <nl> + } ; <nl> + } / / namespace csharp <nl> + <nl> + bool GenerateCSharp ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) { <nl> + csharp : : CSharpGenerator generator ( parser , path , file_name ) ; <nl> + return generator . generate ( ) ; <nl> + } <nl> + <nl> + } / / namespace flatbuffers <nl> mmm a / src / idl_gen_general . cpp <nl> ppp b / src / idl_gen_general . cpp <nl> <nl> # endif / / defined ( FLATBUFFERS_CPP98_STL ) <nl> <nl> namespace flatbuffers { <nl> - <nl> - / / These arrays need to correspond to the IDLOptions : : k enum . <nl> - <nl> - struct LanguageParameters { <nl> - IDLOptions : : Language language ; <nl> - / / Whether function names in the language typically start with uppercase . <nl> - bool first_camel_upper ; <nl> - std : : string file_extension ; <nl> - std : : string string_type ; <nl> - std : : string bool_type ; <nl> - std : : string open_curly ; <nl> - std : : string accessor_type ; <nl> - std : : string const_decl ; <nl> - std : : string unsubclassable_decl ; <nl> - std : : string enum_decl ; <nl> - std : : string enum_separator ; <nl> - std : : string getter_prefix ; <nl> - std : : string getter_suffix ; <nl> - std : : string inheritance_marker ; <nl> - std : : string namespace_ident ; <nl> - std : : string namespace_begin ; <nl> - std : : string namespace_end ; <nl> - std : : string set_bb_byteorder ; <nl> - std : : string get_bb_position ; <nl> - std : : string get_fbb_offset ; <nl> - std : : string accessor_prefix ; <nl> - std : : string accessor_prefix_static ; <nl> - std : : string optional_suffix ; <nl> - std : : string includes ; <nl> - std : : string class_annotation ; <nl> - std : : string generated_type_annotation ; <nl> - CommentConfig comment_config ; <nl> - const FloatConstantGenerator * float_gen ; <nl> - } ; <nl> - <nl> - const LanguageParameters & GetLangParams ( IDLOptions : : Language lang ) { <nl> - static TypedFloatConstantGenerator CSharpFloatGen ( <nl> - " Double . " , " Single . " , " NaN " , " PositiveInfinity " , " NegativeInfinity " ) ; <nl> - <nl> - static TypedFloatConstantGenerator JavaFloatGen ( <nl> - " Double . " , " Float . " , " NaN " , " POSITIVE_INFINITY " , " NEGATIVE_INFINITY " ) ; <nl> - <nl> - static const LanguageParameters language_parameters [ ] = { <nl> - { IDLOptions : : kJava , <nl> - false , <nl> - " . java " , <nl> - " String " , <nl> - " boolean " , <nl> - " { \ n " , <nl> - " class " , <nl> - " final " , <nl> - " final " , <nl> - " final class " , <nl> - " ; \ n " , <nl> - " ( ) " , <nl> - " " , <nl> - " extends " , <nl> - " package " , <nl> - " ; " , <nl> - " " , <nl> - " _bb . order ( ByteOrder . LITTLE_ENDIAN ) ; " , <nl> - " position ( ) " , <nl> - " offset ( ) " , <nl> - " " , <nl> - " " , <nl> - " " , <nl> - " import java . nio . * ; \ nimport java . lang . * ; \ nimport " <nl> - " java . util . * ; \ nimport com . google . flatbuffers . * ; \ n " , <nl> - " \ n @ SuppressWarnings ( \ " unused \ " ) \ n " , <nl> - " \ n @ javax . annotation . Generated ( value = \ " flatc \ " ) \ n " , <nl> - { <nl> - " / * * " , <nl> - " * " , <nl> - " * / " , <nl> - } , <nl> - & JavaFloatGen } , <nl> - { IDLOptions : : kCSharp , <nl> - true , <nl> - " . cs " , <nl> - " string " , <nl> - " bool " , <nl> - " \ n { \ n " , <nl> - " struct " , <nl> - " readonly " , <nl> - " " , <nl> - " enum " , <nl> - " , \ n " , <nl> - " { get " , <nl> - " } " , <nl> - " : " , <nl> - " namespace " , <nl> - " \ n { " , <nl> - " \ n } \ n " , <nl> - " " , <nl> - " Position " , <nl> - " Offset " , <nl> - " __p . " , <nl> - " Table . " , <nl> - " ? " , <nl> - " using global : : System ; \ nusing global : : FlatBuffers ; \ n \ n " , <nl> - " " , <nl> - " " , <nl> - { <nl> - nullptr , <nl> - " / / / " , <nl> - nullptr , <nl> - } , <nl> - & CSharpFloatGen } , <nl> - } ; <nl> - <nl> - if ( lang = = IDLOptions : : kJava ) { <nl> - return language_parameters [ 0 ] ; <nl> - } else { <nl> - FLATBUFFERS_ASSERT ( lang = = IDLOptions : : kCSharp ) ; <nl> - return language_parameters [ 1 ] ; <nl> - } <nl> - } <nl> - <nl> - namespace general { <nl> - class GeneralGenerator : public BaseGenerator { <nl> - public : <nl> - GeneralGenerator ( const Parser & parser , const std : : string & path , <nl> - const std : : string & file_name ) <nl> - : BaseGenerator ( parser , path , file_name , " " , " . " ) , <nl> - lang_ ( GetLangParams ( parser_ . opts . lang ) ) , <nl> - cur_name_space_ ( nullptr ) { } <nl> - <nl> - GeneralGenerator & operator = ( const GeneralGenerator & ) ; <nl> - bool generate ( ) { <nl> - std : : string one_file_code ; <nl> - cur_name_space_ = parser_ . current_namespace_ ; <nl> - <nl> - for ( auto it = parser_ . enums_ . vec . begin ( ) ; it ! = parser_ . enums_ . vec . end ( ) ; <nl> - + + it ) { <nl> - std : : string enumcode ; <nl> - auto & enum_def = * * it ; <nl> - if ( ! parser_ . opts . one_file ) cur_name_space_ = enum_def . defined_namespace ; <nl> - GenEnum ( enum_def , & enumcode ) ; <nl> - if ( parser_ . opts . one_file ) { <nl> - one_file_code + = enumcode ; <nl> - } else { <nl> - if ( ! SaveType ( enum_def . name , * enum_def . defined_namespace , enumcode , <nl> - false ) ) <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - for ( auto it = parser_ . structs_ . vec . begin ( ) ; <nl> - it ! = parser_ . structs_ . vec . end ( ) ; + + it ) { <nl> - std : : string declcode ; <nl> - auto & struct_def = * * it ; <nl> - if ( ! parser_ . opts . one_file ) <nl> - cur_name_space_ = struct_def . defined_namespace ; <nl> - GenStruct ( struct_def , & declcode ) ; <nl> - if ( parser_ . opts . one_file ) { <nl> - one_file_code + = declcode ; <nl> - } else { <nl> - if ( ! SaveType ( struct_def . name , * struct_def . defined_namespace , declcode , <nl> - true ) ) <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - if ( parser_ . opts . one_file ) { <nl> - return SaveType ( file_name_ , * parser_ . current_namespace_ , one_file_code , <nl> - true ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - / / Save out the generated code for a single class while adding <nl> - / / declaration boilerplate . <nl> - bool SaveType ( const std : : string & defname , const Namespace & ns , <nl> - const std : : string & classcode , bool needs_includes ) const { <nl> - if ( ! classcode . length ( ) ) return true ; <nl> - <nl> - std : : string code ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code = <nl> - " / / < auto - generated > \ n " <nl> - " / / " + <nl> - std : : string ( FlatBuffersGeneratedWarning ( ) ) + <nl> - " \ n " <nl> - " / / < / auto - generated > \ n \ n " ; <nl> - } else { <nl> - code = " / / " + std : : string ( FlatBuffersGeneratedWarning ( ) ) + " \ n \ n " ; <nl> - } <nl> - <nl> - std : : string namespace_name = FullNamespace ( " . " , ns ) ; <nl> - if ( ! namespace_name . empty ( ) ) { <nl> - code + = lang_ . namespace_ident + namespace_name + lang_ . namespace_begin ; <nl> - code + = " \ n \ n " ; <nl> - } <nl> - if ( needs_includes ) { <nl> - code + = lang_ . includes ; <nl> - if ( parser_ . opts . gen_nullable ) { <nl> - code + = " \ nimport javax . annotation . Nullable ; \ n " ; <nl> - } <nl> - if ( parser_ . opts . java_checkerframework ) { <nl> - code + = " \ nimport org . checkerframework . dataflow . qual . Pure ; \ n " ; <nl> - } <nl> - code + = lang_ . class_annotation ; <nl> - } <nl> - if ( parser_ . opts . gen_generated ) { code + = lang_ . generated_type_annotation ; } <nl> - code + = classcode ; <nl> - if ( ! namespace_name . empty ( ) ) code + = lang_ . namespace_end ; <nl> - auto filename = NamespaceDir ( ns ) + defname + lang_ . file_extension ; <nl> - return SaveFile ( filename . c_str ( ) , code , false ) ; <nl> - } <nl> - <nl> - const Namespace * CurrentNameSpace ( ) const { return cur_name_space_ ; } <nl> - <nl> - std : : string FunctionStart ( char upper ) const { <nl> - return std : : string ( ) + ( lang_ . language = = IDLOptions : : kJava <nl> - ? static_cast < char > ( tolower ( upper ) ) <nl> - : upper ) ; <nl> - } <nl> - <nl> - std : : string GenNullableAnnotation ( const Type & t ) const { <nl> - return lang_ . language = = IDLOptions : : kJava & & parser_ . opts . gen_nullable & & <nl> - ! IsScalar ( DestinationType ( t , true ) . base_type ) & & <nl> - t . base_type ! = BASE_TYPE_VECTOR <nl> - ? " @ Nullable " <nl> - : " " ; <nl> - } <nl> - <nl> - std : : string GenPureAnnotation ( const Type & t ) const { <nl> - return lang_ . language = = IDLOptions : : kJava & & <nl> - parser_ . opts . java_checkerframework & & <nl> - ! IsScalar ( DestinationType ( t , true ) . base_type ) <nl> - ? " @ Pure " <nl> - : " " ; <nl> - } <nl> - <nl> - std : : string GenTypeBasic ( const Type & type , bool enableLangOverrides ) const { <nl> - / / clang - format off <nl> - static const char * const java_typename [ ] = { <nl> - # define FLATBUFFERS_TD ( ENUM , IDLTYPE , \ <nl> - CTYPE , JTYPE , GTYPE , NTYPE , PTYPE , RTYPE , KTYPE ) \ <nl> - # JTYPE , <nl> - FLATBUFFERS_GEN_TYPES ( FLATBUFFERS_TD ) <nl> - # undef FLATBUFFERS_TD <nl> - } ; <nl> - <nl> - static const char * const csharp_typename [ ] = { <nl> - # define FLATBUFFERS_TD ( ENUM , IDLTYPE , \ <nl> - CTYPE , JTYPE , GTYPE , NTYPE , PTYPE , RTYPE , KTYPE ) \ <nl> - # NTYPE , <nl> - FLATBUFFERS_GEN_TYPES ( FLATBUFFERS_TD ) <nl> - # undef FLATBUFFERS_TD <nl> - } ; <nl> - / / clang - format on <nl> - <nl> - if ( enableLangOverrides ) { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - if ( IsEnum ( type ) ) return WrapInNameSpace ( * type . enum_def ) ; <nl> - if ( type . base_type = = BASE_TYPE_STRUCT ) { <nl> - return " Offset < " + WrapInNameSpace ( * type . struct_def ) + " > " ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - return java_typename [ type . base_type ] ; <nl> - } else { <nl> - FLATBUFFERS_ASSERT ( lang_ . language = = IDLOptions : : kCSharp ) ; <nl> - return csharp_typename [ type . base_type ] ; <nl> - } <nl> - } <nl> - <nl> - std : : string GenTypeBasic ( const Type & type ) const { <nl> - return GenTypeBasic ( type , true ) ; <nl> - } <nl> - <nl> - std : : string GenTypePointer ( const Type & type ) const { <nl> - switch ( type . base_type ) { <nl> - case BASE_TYPE_STRING : return lang_ . string_type ; <nl> - case BASE_TYPE_VECTOR : return GenTypeGet ( type . VectorType ( ) ) ; <nl> - case BASE_TYPE_STRUCT : return WrapInNameSpace ( * type . struct_def ) ; <nl> - case BASE_TYPE_UNION : <nl> - / / Unions in C # use a generic Table - derived type for better type safety <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) return " TTable " ; <nl> - FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> - default : return " Table " ; <nl> - } <nl> - } <nl> - <nl> - std : : string GenTypeGet ( const Type & type ) const { <nl> - return IsScalar ( type . base_type ) <nl> - ? GenTypeBasic ( type ) <nl> - : ( IsArray ( type ) ? GenTypeGet ( type . VectorType ( ) ) <nl> - : GenTypePointer ( type ) ) ; <nl> - } <nl> - <nl> - / / Find the destination type the user wants to receive the value in ( e . g . <nl> - / / one size higher signed types for unsigned serialized values in Java ) . <nl> - Type DestinationType ( const Type & type , bool vectorelem ) const { <nl> - if ( lang_ . language ! = IDLOptions : : kJava ) return type ; <nl> - switch ( type . base_type ) { <nl> - / / We use int for both uchar / ushort , since that generally means less <nl> - / / casting than using short for uchar . <nl> - case BASE_TYPE_UCHAR : return Type ( BASE_TYPE_INT ) ; <nl> - case BASE_TYPE_USHORT : return Type ( BASE_TYPE_INT ) ; <nl> - case BASE_TYPE_UINT : return Type ( BASE_TYPE_LONG ) ; <nl> - case BASE_TYPE_ARRAY : <nl> - case BASE_TYPE_VECTOR : <nl> - if ( vectorelem ) return DestinationType ( type . VectorType ( ) , vectorelem ) ; <nl> - FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> - default : return type ; <nl> - } <nl> - } <nl> - <nl> - std : : string GenOffsetType ( const StructDef & struct_def ) const { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - return " Offset < " + WrapInNameSpace ( struct_def ) + " > " ; <nl> - } else { <nl> - return " int " ; <nl> - } <nl> - } <nl> - <nl> - std : : string GenOffsetConstruct ( const StructDef & struct_def , <nl> - const std : : string & variable_name ) const { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - return " new Offset < " + WrapInNameSpace ( struct_def ) + " > ( " + <nl> - variable_name + " ) " ; <nl> - } <nl> - return variable_name ; <nl> - } <nl> - <nl> - std : : string GenVectorOffsetType ( ) const { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - return " VectorOffset " ; <nl> - } else { <nl> - return " int " ; <nl> - } <nl> - } <nl> - <nl> - / / Generate destination type name <nl> - std : : string GenTypeNameDest ( const Type & type ) const { <nl> - return GenTypeGet ( DestinationType ( type , true ) ) ; <nl> - } <nl> - <nl> - / / Mask to turn serialized value into destination type value . <nl> - std : : string DestinationMask ( const Type & type , bool vectorelem ) const { <nl> - if ( lang_ . language ! = IDLOptions : : kJava ) return " " ; <nl> - switch ( type . base_type ) { <nl> - case BASE_TYPE_UCHAR : return " & 0xFF " ; <nl> - case BASE_TYPE_USHORT : return " & 0xFFFF " ; <nl> - case BASE_TYPE_UINT : return " & 0xFFFFFFFFL " ; <nl> - case BASE_TYPE_VECTOR : <nl> - if ( vectorelem ) return DestinationMask ( type . VectorType ( ) , vectorelem ) ; <nl> - FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> - default : return " " ; <nl> - } <nl> - } <nl> - <nl> - / / Casts necessary to correctly read serialized data <nl> - std : : string DestinationCast ( const Type & type ) const { <nl> - if ( IsSeries ( type ) ) { <nl> - return DestinationCast ( type . VectorType ( ) ) ; <nl> - } else { <nl> - switch ( lang_ . language ) { <nl> - case IDLOptions : : kJava : <nl> - / / Cast necessary to correctly read serialized unsigned values . <nl> - if ( type . base_type = = BASE_TYPE_UINT ) return " ( long ) " ; <nl> - break ; <nl> - <nl> - case IDLOptions : : kCSharp : <nl> - / / Cast from raw integral types to enum . <nl> - if ( IsEnum ( type ) ) return " ( " + WrapInNameSpace ( * type . enum_def ) + " ) " ; <nl> - break ; <nl> - <nl> - default : break ; <nl> - } <nl> - } <nl> - return " " ; <nl> - } <nl> - <nl> - / / Cast statements for mutator method parameters . <nl> - / / In Java , parameters representing unsigned numbers need to be cast down to <nl> - / / their respective type . For example , a long holding an unsigned int value <nl> - / / would be cast down to int before being put onto the buffer . In C # , one cast <nl> - / / directly cast an Enum to its underlying type , which is essential before <nl> - / / putting it onto the buffer . <nl> - std : : string SourceCast ( const Type & type , bool castFromDest ) const { <nl> - if ( IsSeries ( type ) ) { <nl> - return SourceCast ( type . VectorType ( ) , castFromDest ) ; <nl> - } else { <nl> - switch ( lang_ . language ) { <nl> - case IDLOptions : : kJava : <nl> - if ( castFromDest ) { <nl> - if ( type . base_type = = BASE_TYPE_UINT ) <nl> - return " ( int ) " ; <nl> - else if ( type . base_type = = BASE_TYPE_USHORT ) <nl> - return " ( short ) " ; <nl> - else if ( type . base_type = = BASE_TYPE_UCHAR ) <nl> - return " ( byte ) " ; <nl> - } <nl> - break ; <nl> - case IDLOptions : : kCSharp : <nl> - if ( IsEnum ( type ) ) return " ( " + GenTypeBasic ( type , false ) + " ) " ; <nl> - break ; <nl> - default : break ; <nl> - } <nl> - } <nl> - return " " ; <nl> - } <nl> - <nl> - std : : string SourceCast ( const Type & type ) const { <nl> - return SourceCast ( type , true ) ; <nl> - } <nl> - <nl> - std : : string SourceCastBasic ( const Type & type , bool castFromDest ) const { <nl> - return IsScalar ( type . base_type ) ? SourceCast ( type , castFromDest ) : " " ; <nl> - } <nl> - <nl> - std : : string SourceCastBasic ( const Type & type ) const { <nl> - return SourceCastBasic ( type , true ) ; <nl> - } <nl> - <nl> - std : : string GenEnumDefaultValue ( const FieldDef & field ) const { <nl> - auto & value = field . value ; <nl> - FLATBUFFERS_ASSERT ( value . type . enum_def ) ; <nl> - auto & enum_def = * value . type . enum_def ; <nl> - auto enum_val = enum_def . FindByValue ( value . constant ) ; <nl> - return enum_val ? ( WrapInNameSpace ( enum_def ) + " . " + enum_val - > name ) <nl> - : value . constant ; <nl> - } <nl> - <nl> - std : : string GenDefaultValue ( const FieldDef & field , <nl> - bool enableLangOverrides ) const { <nl> - auto & value = field . value ; <nl> - if ( enableLangOverrides ) { <nl> - / / handles both enum case and vector of enum case <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & <nl> - value . type . enum_def ! = nullptr & & <nl> - value . type . base_type ! = BASE_TYPE_UNION ) { <nl> - return GenEnumDefaultValue ( field ) ; <nl> - } <nl> - } <nl> - <nl> - auto longSuffix = lang_ . language = = IDLOptions : : kJava ? " L " : " " ; <nl> - switch ( value . type . base_type ) { <nl> - case BASE_TYPE_BOOL : return value . constant = = " 0 " ? " false " : " true " ; <nl> - case BASE_TYPE_ULONG : { <nl> - if ( lang_ . language ! = IDLOptions : : kJava ) return value . constant ; <nl> - / / Converts the ulong into its bits signed equivalent <nl> - uint64_t defaultValue = StringToUInt ( value . constant . c_str ( ) ) ; <nl> - return NumToString ( static_cast < int64_t > ( defaultValue ) ) + longSuffix ; <nl> - } <nl> - case BASE_TYPE_UINT : <nl> - case BASE_TYPE_LONG : return value . constant + longSuffix ; <nl> - default : <nl> - if ( IsFloat ( value . type . base_type ) ) <nl> - return lang_ . float_gen - > GenFloatConstant ( field ) ; <nl> - else <nl> - return value . constant ; <nl> - } <nl> - } <nl> - <nl> - std : : string GenDefaultValue ( const FieldDef & field ) const { <nl> - return GenDefaultValue ( field , true ) ; <nl> - } <nl> - <nl> - std : : string GenDefaultValueBasic ( const FieldDef & field , <nl> - bool enableLangOverrides ) const { <nl> - auto & value = field . value ; <nl> - if ( ! IsScalar ( value . type . base_type ) ) { <nl> - if ( enableLangOverrides ) { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - switch ( value . type . base_type ) { <nl> - case BASE_TYPE_STRING : return " default ( StringOffset ) " ; <nl> - case BASE_TYPE_STRUCT : <nl> - return " default ( Offset < " + <nl> - WrapInNameSpace ( * value . type . struct_def ) + " > ) " ; <nl> - case BASE_TYPE_VECTOR : return " default ( VectorOffset ) " ; <nl> - default : break ; <nl> - } <nl> - } <nl> - } <nl> - return " 0 " ; <nl> - } <nl> - return GenDefaultValue ( field , enableLangOverrides ) ; <nl> - } <nl> - <nl> - std : : string GenDefaultValueBasic ( const FieldDef & field ) const { <nl> - return GenDefaultValueBasic ( field , true ) ; <nl> - } <nl> - <nl> - void GenEnum ( EnumDef & enum_def , std : : string * code_ptr ) const { <nl> - std : : string & code = * code_ptr ; <nl> - if ( enum_def . generated ) return ; <nl> - <nl> - / / Generate enum definitions of the form : <nl> - / / public static ( final ) int name = value ; <nl> - / / In Java , we use ints rather than the Enum feature , because we want them <nl> - / / to map directly to how they ' re used in C / C + + and file formats . <nl> - / / That , and Java Enums are expensive , and not universally liked . <nl> - GenComment ( enum_def . doc_comment , code_ptr , & lang_ . comment_config ) ; <nl> - <nl> - / / In C # this indicates enumeration values can be treated as bit flags . <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & <nl> - enum_def . attributes . Lookup ( " bit_flags " ) ) { <nl> - code + = " [ System . FlagsAttribute ] \ n " ; <nl> - } <nl> - if ( enum_def . attributes . Lookup ( " private " ) ) { <nl> - / / For Java , we leave the enum unmarked to indicate package - private <nl> - / / For C # we mark the enum as internal <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { code + = " internal " ; } <nl> - } else { <nl> - code + = " public " ; <nl> - } <nl> - code + = lang_ . enum_decl + enum_def . name ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = lang_ . inheritance_marker + <nl> - GenTypeBasic ( enum_def . underlying_type , false ) ; <nl> - } <nl> - code + = lang_ . open_curly ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - code + = " private " + enum_def . name + " ( ) { } \ n " ; <nl> - } <nl> - for ( auto it = enum_def . Vals ( ) . begin ( ) ; it ! = enum_def . Vals ( ) . end ( ) ; + + it ) { <nl> - auto & ev = * * it ; <nl> - GenComment ( ev . doc_comment , code_ptr , & lang_ . comment_config , " " ) ; <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - code + = " public static " ; <nl> - code + = lang_ . const_decl ; <nl> - code + = GenTypeBasic ( enum_def . underlying_type , false ) ; <nl> - } <nl> - code + = ( lang_ . language = = IDLOptions : : kJava ) ? " " : " " ; <nl> - code + = ev . name + " = " ; <nl> - code + = enum_def . ToString ( ev ) ; <nl> - code + = lang_ . enum_separator ; <nl> - } <nl> - <nl> - / / Generate a generate string table for enum values . <nl> - / / We do not do that for C # where this functionality is native . <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - / / Problem is , if values are very sparse that could generate really big <nl> - / / tables . Ideally in that case we generate a map lookup instead , but for <nl> - / / the moment we simply don ' t output a table at all . <nl> - auto range = enum_def . Distance ( ) ; <nl> - / / Average distance between values above which we consider a table <nl> - / / " too sparse " . Change at will . <nl> - static const uint64_t kMaxSparseness = 5 ; <nl> - if ( range / static_cast < uint64_t > ( enum_def . size ( ) ) < kMaxSparseness ) { <nl> - code + = " \ n public static " ; <nl> - code + = lang_ . const_decl ; <nl> - code + = lang_ . string_type ; <nl> - code + = " [ ] names = { " ; <nl> - auto val = enum_def . Vals ( ) . front ( ) ; <nl> - for ( auto it = enum_def . Vals ( ) . begin ( ) ; it ! = enum_def . Vals ( ) . end ( ) ; <nl> - + + it ) { <nl> - auto ev = * it ; <nl> - for ( auto k = enum_def . Distance ( val , ev ) ; k > 1 ; - - k ) <nl> - code + = " \ " \ " , " ; <nl> - val = ev ; <nl> - code + = " \ " " + ( * it ) - > name + " \ " , " ; <nl> - } <nl> - code + = " } ; \ n \ n " ; <nl> - code + = " public static " ; <nl> - code + = lang_ . string_type ; <nl> - code + = " " + MakeCamel ( " name " , lang_ . first_camel_upper ) ; <nl> - code + = " ( int e ) { return names [ e " ; <nl> - if ( enum_def . MinValue ( ) - > IsNonZero ( ) ) <nl> - code + = " - " + enum_def . MinValue ( ) - > name ; <nl> - code + = " ] ; } \ n " ; <nl> - } <nl> - } <nl> - <nl> - / / Close the class <nl> - code + = " } " ; <nl> - / / Java does not need the closing semi - colon on class definitions . <nl> - code + = ( lang_ . language ! = IDLOptions : : kJava ) ? " ; " : " " ; <nl> - code + = " \ n \ n " ; <nl> - } <nl> - <nl> - / / Returns the function name that is able to read a value of the given type . <nl> - std : : string GenGetter ( const Type & type ) const { <nl> - switch ( type . base_type ) { <nl> - case BASE_TYPE_STRING : return lang_ . accessor_prefix + " __string " ; <nl> - case BASE_TYPE_STRUCT : return lang_ . accessor_prefix + " __struct " ; <nl> - case BASE_TYPE_UNION : return lang_ . accessor_prefix + " __union " ; <nl> - case BASE_TYPE_VECTOR : return GenGetter ( type . VectorType ( ) ) ; <nl> - case BASE_TYPE_ARRAY : return GenGetter ( type . VectorType ( ) ) ; <nl> - default : { <nl> - std : : string getter = <nl> - lang_ . accessor_prefix + " bb . " + FunctionStart ( ' G ' ) + " et " ; <nl> - if ( type . base_type = = BASE_TYPE_BOOL ) { <nl> - getter = " 0 ! = " + getter ; <nl> - } else if ( GenTypeBasic ( type , false ) ! = " byte " ) { <nl> - getter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> - } <nl> - return getter ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / Returns the function name that is able to read a value of the given type . <nl> - std : : string GenGetterForLookupByKey ( flatbuffers : : FieldDef * key_field , <nl> - const std : : string & data_buffer , <nl> - const char * num = nullptr ) const { <nl> - auto type = key_field - > value . type ; <nl> - auto dest_mask = DestinationMask ( type , true ) ; <nl> - auto dest_cast = DestinationCast ( type ) ; <nl> - auto getter = data_buffer + " . " + FunctionStart ( ' G ' ) + " et " ; <nl> - if ( GenTypeBasic ( type , false ) ! = " byte " ) { <nl> - getter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> - } <nl> - getter = dest_cast + getter + " ( " + GenOffsetGetter ( key_field , num ) + " ) " + <nl> - dest_mask ; <nl> - return getter ; <nl> - } <nl> - <nl> - / / Direct mutation is only allowed for scalar fields . <nl> - / / Hence a setter method will only be generated for such fields . <nl> - std : : string GenSetter ( const Type & type ) const { <nl> - if ( IsScalar ( type . base_type ) ) { <nl> - std : : string setter = <nl> - lang_ . accessor_prefix + " bb . " + FunctionStart ( ' P ' ) + " ut " ; <nl> - if ( GenTypeBasic ( type , false ) ! = " byte " & & <nl> - type . base_type ! = BASE_TYPE_BOOL ) { <nl> - setter + = MakeCamel ( GenTypeBasic ( type , false ) ) ; <nl> - } <nl> - return setter ; <nl> - } else { <nl> - return " " ; <nl> - } <nl> - } <nl> - <nl> - / / Returns the method name for use with add / put calls . <nl> - std : : string GenMethod ( const Type & type ) const { <nl> - return IsScalar ( type . base_type ) ? MakeCamel ( GenTypeBasic ( type , false ) ) <nl> - : ( IsStruct ( type ) ? " Struct " : " Offset " ) ; <nl> - } <nl> - <nl> - / / Recursively generate arguments for a constructor , to deal with nested <nl> - / / structs . <nl> - void GenStructArgs ( const StructDef & struct_def , std : : string * code_ptr , <nl> - const char * nameprefix , size_t array_count = 0 ) const { <nl> - std : : string & code = * code_ptr ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - const auto & field_type = field . value . type ; <nl> - const auto array_field = IsArray ( field_type ) ; <nl> - const auto & type = array_field ? field_type . VectorType ( ) <nl> - : DestinationType ( field_type , false ) ; <nl> - const auto array_cnt = array_field ? ( array_count + 1 ) : array_count ; <nl> - if ( IsStruct ( type ) ) { <nl> - / / Generate arguments for a struct inside a struct . To ensure names <nl> - / / don ' t clash , and to make it obvious these arguments are constructing <nl> - / / a nested struct , prefix the name with the field name . <nl> - GenStructArgs ( * field_type . struct_def , code_ptr , <nl> - ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , array_cnt ) ; <nl> - } else { <nl> - code + = " , " ; <nl> - code + = GenTypeBasic ( type ) ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - for ( size_t i = 0 ; i < array_cnt ; i + + ) code + = " [ ] " ; <nl> - } else if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - if ( array_cnt > 0 ) { <nl> - code + = " [ " ; <nl> - for ( size_t i = 1 ; i < array_cnt ; i + + ) code + = " , " ; <nl> - code + = " ] " ; <nl> - } <nl> - } else { <nl> - FLATBUFFERS_ASSERT ( 0 ) ; <nl> - } <nl> - code + = " " ; <nl> - code + = nameprefix ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / Recusively generate struct construction statements of the form : <nl> - / / builder . putType ( name ) ; <nl> - / / and insert manual padding . <nl> - void GenStructBody ( const StructDef & struct_def , std : : string * code_ptr , <nl> - const char * nameprefix , size_t index = 0 , <nl> - bool in_array = false ) const { <nl> - std : : string & code = * code_ptr ; <nl> - std : : string indent ( ( index + 1 ) * 2 , ' ' ) ; <nl> - code + = indent + " builder . " + FunctionStart ( ' P ' ) + " rep ( " ; <nl> - code + = NumToString ( struct_def . minalign ) + " , " ; <nl> - code + = NumToString ( struct_def . bytesize ) + " ) ; \ n " ; <nl> - for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> - it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - const auto & field_type = field . value . type ; <nl> - if ( field . padding ) { <nl> - code + = indent + " builder . " + FunctionStart ( ' P ' ) + " ad ( " ; <nl> - code + = NumToString ( field . padding ) + " ) ; \ n " ; <nl> - } <nl> - if ( IsStruct ( field_type ) ) { <nl> - GenStructBody ( * field_type . struct_def , code_ptr , <nl> - ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index , <nl> - in_array ) ; <nl> - } else { <nl> - const auto & type = <nl> - IsArray ( field_type ) ? field_type . VectorType ( ) : field_type ; <nl> - const auto index_var = " _idx " + NumToString ( index ) ; <nl> - if ( IsArray ( field_type ) ) { <nl> - code + = indent + " for ( int " + index_var + " = " ; <nl> - code + = NumToString ( field_type . fixed_length ) ; <nl> - code + = " ; " + index_var + " > 0 ; " + index_var + " - - ) { \ n " ; <nl> - in_array = true ; <nl> - } <nl> - if ( IsStruct ( type ) ) { <nl> - GenStructBody ( * field_type . struct_def , code_ptr , <nl> - ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index + 1 , <nl> - in_array ) ; <nl> - } else { <nl> - code + = IsArray ( field_type ) ? " " : " " ; <nl> - code + = indent + " builder . " + FunctionStart ( ' P ' ) + " ut " ; <nl> - code + = GenMethod ( type ) + " ( " ; <nl> - code + = SourceCast ( type ) ; <nl> - auto argname = <nl> - nameprefix + MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = argname ; <nl> - size_t array_cnt = index + ( IsArray ( field_type ) ? 1 : 0 ) ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - for ( size_t i = 0 ; in_array & & i < array_cnt ; i + + ) { <nl> - code + = " [ _idx " + NumToString ( i ) + " - 1 ] " ; <nl> - } <nl> - } else if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - if ( array_cnt > 0 ) { <nl> - code + = " [ " ; <nl> - for ( size_t i = 0 ; in_array & & i < array_cnt ; i + + ) { <nl> - code + = " _idx " + NumToString ( i ) + " - 1 " ; <nl> - if ( i ! = ( array_cnt - 1 ) ) code + = " , " ; <nl> - } <nl> - code + = " ] " ; <nl> - } <nl> - } else { <nl> - FLATBUFFERS_ASSERT ( 0 ) ; <nl> - } <nl> - code + = " ) ; \ n " ; <nl> - } <nl> - if ( IsArray ( field_type ) ) { code + = indent + " } \ n " ; } <nl> - } <nl> - } <nl> - } <nl> - <nl> - std : : string GenByteBufferLength ( const char * bb_name ) const { <nl> - std : : string bb_len = bb_name ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) <nl> - bb_len + = " . Length " ; <nl> - else <nl> - bb_len + = " . capacity ( ) " ; <nl> - return bb_len ; <nl> - } <nl> - <nl> - std : : string GenOffsetGetter ( flatbuffers : : FieldDef * key_field , <nl> - const char * num = nullptr ) const { <nl> - std : : string key_offset = " " ; <nl> - key_offset + = lang_ . accessor_prefix_static + " __offset ( " + <nl> - NumToString ( key_field - > value . offset ) + " , " ; <nl> - if ( num ) { <nl> - key_offset + = num ; <nl> - key_offset + = <nl> - ( lang_ . language = = IDLOptions : : kCSharp ? " . Value , builder . DataBuffer ) " <nl> - : " , _bb ) " ) ; <nl> - } else { <nl> - key_offset + = GenByteBufferLength ( " bb " ) ; <nl> - key_offset + = " - tableOffset , bb ) " ; <nl> - } <nl> - return key_offset ; <nl> - } <nl> - <nl> - std : : string GenLookupKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> - std : : string key_getter = " " ; <nl> - key_getter + = " int tableOffset = " + lang_ . accessor_prefix_static ; <nl> - key_getter + = " __indirect ( vectorLocation + 4 * ( start + middle ) " ; <nl> - key_getter + = " , bb ) ; \ n " ; <nl> - if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> - key_getter + = " int comp = " + lang_ . accessor_prefix_static ; <nl> - key_getter + = FunctionStart ( ' C ' ) + " ompareStrings ( " ; <nl> - key_getter + = GenOffsetGetter ( key_field ) ; <nl> - key_getter + = " , byteKey , bb ) ; \ n " ; <nl> - } else { <nl> - auto get_val = GenGetterForLookupByKey ( key_field , " bb " ) ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - key_getter + = " int comp = " + get_val + " . CompareTo ( key ) ; \ n " ; <nl> - } else { <nl> - key_getter + = GenTypeNameDest ( key_field - > value . type ) + " val = " ; <nl> - key_getter + = get_val + " ; \ n " ; <nl> - key_getter + = " int comp = val > key ? 1 : val < key ? - 1 : 0 ; \ n " ; <nl> - } <nl> - } <nl> - return key_getter ; <nl> - } <nl> - <nl> - std : : string GenKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> - std : : string key_getter = " " ; <nl> - auto data_buffer = <nl> - ( lang_ . language = = IDLOptions : : kCSharp ) ? " builder . DataBuffer " : " _bb " ; <nl> - if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> - if ( lang_ . language = = IDLOptions : : kJava ) key_getter + = " return " ; <nl> - key_getter + = lang_ . accessor_prefix_static ; <nl> - key_getter + = FunctionStart ( ' C ' ) + " ompareStrings ( " ; <nl> - key_getter + = GenOffsetGetter ( key_field , " o1 " ) + " , " ; <nl> - key_getter + = GenOffsetGetter ( key_field , " o2 " ) + " , " + data_buffer + " ) " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) key_getter + = " ; " ; <nl> - } else { <nl> - auto field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o1 " ) ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - key_getter + = field_getter ; <nl> - field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o2 " ) ; <nl> - key_getter + = " . CompareTo ( " + field_getter + " ) " ; <nl> - } else { <nl> - key_getter + = <nl> - " \ n " + GenTypeNameDest ( key_field - > value . type ) + " val_1 = " ; <nl> - key_getter + = <nl> - field_getter + " ; \ n " + GenTypeNameDest ( key_field - > value . type ) ; <nl> - key_getter + = " val_2 = " ; <nl> - field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o2 " ) ; <nl> - key_getter + = field_getter + " ; \ n " ; <nl> - key_getter + = <nl> - " return val_1 > val_2 ? 1 : val_1 < val_2 ? - 1 : 0 ; \ n " ; <nl> - } <nl> - } <nl> - return key_getter ; <nl> - } <nl> - <nl> - void GenStruct ( StructDef & struct_def , std : : string * code_ptr ) const { <nl> - if ( struct_def . generated ) return ; <nl> - std : : string & code = * code_ptr ; <nl> - <nl> - / / Generate a struct accessor class , with methods of the form : <nl> - / / public type name ( ) { return bb . getType ( i + offset ) ; } <nl> - / / or for tables of the form : <nl> - / / public type name ( ) { <nl> - / / int o = __offset ( offset ) ; return o ! = 0 ? bb . getType ( o + i ) : default ; <nl> - / / } <nl> - GenComment ( struct_def . doc_comment , code_ptr , & lang_ . comment_config ) ; <nl> - if ( struct_def . attributes . Lookup ( " private " ) ) { <nl> - / / For Java , we leave the struct unmarked to indicate package - private <nl> - / / For C # we mark the struct as internal <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { code + = " internal " ; } <nl> - } else { <nl> - code + = " public " ; <nl> - } <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & <nl> - struct_def . attributes . Lookup ( " csharp_partial " ) ) { <nl> - / / generate a partial class for this C # struct / table <nl> - code + = " partial " ; <nl> - } else { <nl> - code + = lang_ . unsubclassable_decl ; <nl> - } <nl> - code + = lang_ . accessor_type + struct_def . name ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " : IFlatbufferObject " ; <nl> - code + = lang_ . open_curly ; <nl> - code + = " private " ; <nl> - code + = struct_def . fixed ? " Struct " : " Table " ; <nl> - code + = " __p ; \ n " ; <nl> - <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " public ByteBuffer ByteBuffer { get { return __p . bb ; } } \ n " ; <nl> - } <nl> - <nl> - } else { <nl> - code + = lang_ . inheritance_marker ; <nl> - code + = struct_def . fixed ? " Struct " : " Table " ; <nl> - code + = lang_ . open_curly ; <nl> - } <nl> - <nl> - if ( ! struct_def . fixed ) { <nl> - / / Generate verson check method . <nl> - / / Force compile time error if not using the same version runtime . <nl> - code + = " public static void ValidateVersion ( ) { " ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) <nl> - code + = " FlatBufferConstants . " ; <nl> - else <nl> - code + = " Constants . " ; <nl> - code + = " FLATBUFFERS_1_11_1 ( ) ; " ; <nl> - code + = " } \ n " ; <nl> - <nl> - / / Generate a special accessor for the table that when used as the root <nl> - / / of a FlatBuffer <nl> - std : : string method_name = <nl> - FunctionStart ( ' G ' ) + " etRootAs " + struct_def . name ; <nl> - std : : string method_signature = <nl> - " public static " + struct_def . name + " " + method_name ; <nl> - <nl> - / / create convenience method that doesn ' t require an existing object <nl> - code + = method_signature + " ( ByteBuffer _bb ) " ; <nl> - code + = " { return " + method_name + " ( _bb , new " + struct_def . name + <nl> - " ( ) ) ; } \ n " ; <nl> - <nl> - / / create method that allows object reuse <nl> - code + = <nl> - method_signature + " ( ByteBuffer _bb , " + struct_def . name + " obj ) { " ; <nl> - code + = lang_ . set_bb_byteorder ; <nl> - code + = " return ( obj . __assign ( _bb . " + FunctionStart ( ' G ' ) + " etInt ( _bb . " ; <nl> - code + = lang_ . get_bb_position ; <nl> - code + = " ) + _bb . " ; <nl> - code + = lang_ . get_bb_position ; <nl> - code + = " , _bb ) ) ; } \ n " ; <nl> - if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> - if ( parser_ . file_identifier_ . length ( ) ) { <nl> - / / Check if a buffer has the identifier . <nl> - code + = " public static " ; <nl> - code + = lang_ . bool_type + struct_def . name ; <nl> - code + = " BufferHasIdentifier ( ByteBuffer _bb ) { return " ; <nl> - code + = lang_ . accessor_prefix_static + " __has_identifier ( _bb , \ " " ; <nl> - code + = parser_ . file_identifier_ ; <nl> - code + = " \ " ) ; } \ n " ; <nl> - } <nl> - } <nl> - } <nl> - / / Generate the __init method that sets the field in a pre - existing <nl> - / / accessor object . This is to allow object reuse . <nl> - code + = " public void __init ( int _i , ByteBuffer _bb ) " ; <nl> - code + = " { " ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " __p = new " ; <nl> - code + = struct_def . fixed ? " Struct " : " Table " ; <nl> - code + = " ( _i , _bb ) ; " ; <nl> - } else { <nl> - code + = " __reset ( _i , _bb ) ; " ; <nl> - } <nl> - code + = " } \ n " ; <nl> - code + = <nl> - " public " + struct_def . name + " __assign ( int _i , ByteBuffer _bb ) " ; <nl> - code + = " { __init ( _i , _bb ) ; return this ; } \ n \ n " ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( field . deprecated ) continue ; <nl> - GenComment ( field . doc_comment , code_ptr , & lang_ . comment_config , " " ) ; <nl> - std : : string type_name = GenTypeGet ( field . value . type ) ; <nl> - std : : string type_name_dest = GenTypeNameDest ( field . value . type ) ; <nl> - std : : string conditional_cast = " " ; <nl> - std : : string optional = " " ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & ! struct_def . fixed & & <nl> - ( field . value . type . base_type = = BASE_TYPE_STRUCT | | <nl> - field . value . type . base_type = = BASE_TYPE_UNION | | <nl> - ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> - ( field . value . type . element = = BASE_TYPE_STRUCT | | <nl> - field . value . type . element = = BASE_TYPE_UNION ) ) ) ) { <nl> - optional = lang_ . optional_suffix ; <nl> - conditional_cast = " ( " + type_name_dest + optional + " ) " ; <nl> - } <nl> - std : : string dest_mask = DestinationMask ( field . value . type , true ) ; <nl> - std : : string dest_cast = DestinationCast ( field . value . type ) ; <nl> - std : : string src_cast = SourceCast ( field . value . type ) ; <nl> - std : : string method_start = <nl> - " public " + <nl> - ( field . required ? " " : GenNullableAnnotation ( field . value . type ) ) + <nl> - GenPureAnnotation ( field . value . type ) + type_name_dest + optional + <nl> - " " + MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - std : : string obj = lang_ . language = = IDLOptions : : kCSharp <nl> - ? " ( new " + type_name + " ( ) ) " <nl> - : " obj " ; <nl> - <nl> - / / Most field accessors need to retrieve and test the field offset first , <nl> - / / this is the prefix code for that : <nl> - auto offset_prefix = <nl> - IsArray ( field . value . type ) <nl> - ? " { return " <nl> - : ( " { int o = " + lang_ . accessor_prefix + " __offset ( " + <nl> - NumToString ( field . value . offset ) + " ) ; return o ! = 0 ? " ) ; <nl> - / / Generate the accessors that don ' t do object reuse . <nl> - if ( field . value . type . base_type = = BASE_TYPE_STRUCT ) { <nl> - / / Calls the accessor that takes an accessor object with a new object . <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - code + = method_start + " ( ) { return " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " ( new " ; <nl> - code + = type_name + " ( ) ) ; } \ n " ; <nl> - } <nl> - } else if ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> - field . value . type . element = = BASE_TYPE_STRUCT ) { <nl> - / / Accessors for vectors of structs also take accessor objects , this <nl> - / / generates a variant without that argument . <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - code + = method_start + " ( int j ) { return " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " ( new " + type_name + " ( ) , j ) ; } \ n " ; <nl> - } <nl> - } else if ( field . value . type . base_type = = BASE_TYPE_UNION | | <nl> - ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> - field . value . type . VectorType ( ) . base_type = = BASE_TYPE_UNION ) ) { <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - / / Union types in C # use generic Table - derived type for better type <nl> - / / safety . <nl> - method_start + = " < TTable > " ; <nl> - type_name = type_name_dest ; <nl> - } <nl> - } <nl> - std : : string getter = dest_cast + GenGetter ( field . value . type ) ; <nl> - code + = method_start ; <nl> - std : : string default_cast = " " ; <nl> - / / only create default casts for c # scalars or vectors of scalars <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & <nl> - ( IsScalar ( field . value . type . base_type ) | | <nl> - ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> - IsScalar ( field . value . type . element ) ) ) ) { <nl> - / / For scalars , default value will be returned by GetDefaultValue ( ) . <nl> - / / If the scalar is an enum , GetDefaultValue ( ) returns an actual c # enum <nl> - / / that doesn ' t need to be casted . However , default values for enum <nl> - / / elements of vectors are integer literals ( " 0 " ) and are still casted <nl> - / / for clarity . <nl> - if ( field . value . type . enum_def = = nullptr | | <nl> - field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> - default_cast = " ( " + type_name_dest + " ) " ; <nl> - } <nl> - } <nl> - std : : string member_suffix = " ; " ; <nl> - if ( IsScalar ( field . value . type . base_type ) ) { <nl> - code + = lang_ . getter_prefix ; <nl> - member_suffix + = lang_ . getter_suffix ; <nl> - if ( struct_def . fixed ) { <nl> - code + = " { return " + getter ; <nl> - code + = " ( " + lang_ . accessor_prefix + " bb_pos + " ; <nl> - code + = NumToString ( field . value . offset ) + " ) " ; <nl> - code + = dest_mask ; <nl> - } else { <nl> - code + = offset_prefix + getter ; <nl> - code + = " ( o + " + lang_ . accessor_prefix + " bb_pos ) " + dest_mask ; <nl> - code + = " : " + default_cast ; <nl> - code + = GenDefaultValue ( field ) ; <nl> - } <nl> - } else { <nl> - switch ( field . value . type . base_type ) { <nl> - case BASE_TYPE_STRUCT : <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - code + = " ( " + type_name + " obj " + " ) " ; <nl> - } else { <nl> - code + = lang_ . getter_prefix ; <nl> - member_suffix + = lang_ . getter_suffix ; <nl> - } <nl> - if ( struct_def . fixed ) { <nl> - code + = " { return " + obj + " . __assign ( " + lang_ . accessor_prefix ; <nl> - code + = " bb_pos + " + NumToString ( field . value . offset ) + " , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) " ; <nl> - } else { <nl> - code + = offset_prefix + conditional_cast ; <nl> - code + = obj + " . __assign ( " ; <nl> - code + = field . value . type . struct_def - > fixed <nl> - ? " o + " + lang_ . accessor_prefix + " bb_pos " <nl> - : lang_ . accessor_prefix + " __indirect ( o + " + <nl> - lang_ . accessor_prefix + " bb_pos ) " ; <nl> - code + = " , " + lang_ . accessor_prefix + " bb ) : null " ; <nl> - } <nl> - break ; <nl> - case BASE_TYPE_STRING : <nl> - code + = lang_ . getter_prefix ; <nl> - member_suffix + = lang_ . getter_suffix ; <nl> - code + = offset_prefix + getter + " ( o + " + lang_ . accessor_prefix ; <nl> - code + = " bb_pos ) : null " ; <nl> - break ; <nl> - case BASE_TYPE_ARRAY : FLATBUFFERS_FALLTHROUGH ( ) ; / / fall thru <nl> - case BASE_TYPE_VECTOR : { <nl> - auto vectortype = field . value . type . VectorType ( ) ; <nl> - if ( vectortype . base_type = = BASE_TYPE_UNION & & <nl> - lang_ . language = = IDLOptions : : kCSharp ) { <nl> - conditional_cast = " ( TTable ? ) " ; <nl> - getter + = " < TTable > " ; <nl> - } <nl> - code + = " ( " ; <nl> - if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) <nl> - code + = type_name + " obj , " ; <nl> - getter = obj + " . __assign " ; <nl> - } else if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) <nl> - code + = type_name + " obj , " ; <nl> - } <nl> - code + = " int j ) " ; <nl> - const auto body = offset_prefix + conditional_cast + getter + " ( " ; <nl> - if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) <nl> - code + = body + " obj , " ; <nl> - else <nl> - code + = " where TTable : struct , IFlatbufferObject " + body ; <nl> - } else { <nl> - code + = body ; <nl> - } <nl> - auto index = lang_ . accessor_prefix ; <nl> - if ( IsArray ( field . value . type ) ) { <nl> - index + = " bb_pos + " + NumToString ( field . value . offset ) + " + " ; <nl> - } else { <nl> - index + = " __vector ( o ) + " ; <nl> - } <nl> - index + = " j * " + NumToString ( InlineSize ( vectortype ) ) ; <nl> - if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> - code + = vectortype . struct_def - > fixed <nl> - ? index <nl> - : lang_ . accessor_prefix + " __indirect ( " + index + " ) " ; <nl> - code + = " , " + lang_ . accessor_prefix + " bb " ; <nl> - } else { <nl> - code + = index ; <nl> - } <nl> - code + = " ) " + dest_mask ; <nl> - if ( ! IsArray ( field . value . type ) ) { <nl> - code + = " : " ; <nl> - code + = <nl> - field . value . type . element = = BASE_TYPE_BOOL <nl> - ? " false " <nl> - : ( IsScalar ( field . value . type . element ) ? default_cast + " 0 " <nl> - : " null " ) ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - case BASE_TYPE_UNION : <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " ( ) where TTable : struct , IFlatbufferObject " ; <nl> - code + = offset_prefix + " ( TTable ? ) " + getter ; <nl> - code + = <nl> - " < TTable > ( o + " + lang_ . accessor_prefix + " bb_pos ) : null " ; <nl> - } else { <nl> - code + = " ( " + type_name + " obj ) " + offset_prefix + getter ; <nl> - code + = " ( obj , o + " + lang_ . accessor_prefix + " bb_pos ) : null " ; <nl> - } <nl> - break ; <nl> - default : FLATBUFFERS_ASSERT ( 0 ) ; <nl> - } <nl> - } <nl> - code + = member_suffix ; <nl> - code + = " } \ n " ; <nl> - if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> - code + = <nl> - " public int " + MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " Length " ; <nl> - code + = lang_ . getter_prefix ; <nl> - code + = offset_prefix ; <nl> - code + = lang_ . accessor_prefix + " __vector_len ( o ) : 0 ; " ; <nl> - code + = lang_ . getter_suffix ; <nl> - code + = " } \ n " ; <nl> - / / See if we should generate a by - key accessor . <nl> - if ( field . value . type . element = = BASE_TYPE_STRUCT & & <nl> - ! field . value . type . struct_def - > fixed ) { <nl> - auto & sd = * field . value . type . struct_def ; <nl> - auto & fields = sd . fields . vec ; <nl> - for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> - auto & key_field = * * kit ; <nl> - if ( key_field . key ) { <nl> - auto qualified_name = WrapInNameSpace ( sd ) ; <nl> - code + = <nl> - " public " + qualified_name + lang_ . optional_suffix + " " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) + " ByKey ( " ; <nl> - code + = GenTypeNameDest ( key_field . value . type ) + " key ) " ; <nl> - code + = offset_prefix ; <nl> - code + = qualified_name + " . __lookup_by_key ( " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) code + = " null , " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( o ) , key , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) : null ; " ; <nl> - code + = " } \ n " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - code + = <nl> - " public " + qualified_name + lang_ . optional_suffix + " " ; <nl> - code + = <nl> - MakeCamel ( field . name , lang_ . first_camel_upper ) + " ByKey ( " ; <nl> - code + = qualified_name + lang_ . optional_suffix + " obj , " ; <nl> - code + = GenTypeNameDest ( key_field . value . type ) + " key ) " ; <nl> - code + = offset_prefix ; <nl> - code + = qualified_name + " . __lookup_by_key ( obj , " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( o ) , key , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) : null ; " ; <nl> - code + = " } \ n " ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - / / Generate the accessors for vector of structs with vector access object <nl> - if ( lang_ . language = = IDLOptions : : kJava & & <nl> - field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> - std : : string vector_type_name ; <nl> - const auto & element_base_type = field . value . type . VectorType ( ) . base_type ; <nl> - if ( IsScalar ( element_base_type ) ) { <nl> - vector_type_name = MakeCamel ( type_name , true ) + " Vector " ; <nl> - } else if ( element_base_type = = BASE_TYPE_STRING ) { <nl> - vector_type_name = " StringVector " ; <nl> - } else if ( element_base_type = = BASE_TYPE_UNION ) { <nl> - vector_type_name = " UnionVector " ; <nl> - } else { <nl> - vector_type_name = type_name + " . Vector " ; <nl> - } <nl> - auto vector_method_start = <nl> - GenNullableAnnotation ( field . value . type ) + " public " + <nl> - vector_type_name + optional + " " + <nl> - MakeCamel ( field . name , lang_ . first_camel_upper ) + " Vector " ; <nl> - code + = vector_method_start + " ( ) { return " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) + " Vector " ; <nl> - code + = " ( new " + vector_type_name + " ( ) ) ; } \ n " ; <nl> - code + = vector_method_start + " ( " + vector_type_name + " obj ) " ; <nl> - code + = offset_prefix + conditional_cast + obj + " . __assign " + " ( " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( o ) , " ; <nl> - if ( ! IsScalar ( element_base_type ) ) { <nl> - auto vectortype = field . value . type . VectorType ( ) ; <nl> - code + = NumToString ( InlineSize ( vectortype ) ) + " , " ; <nl> - } <nl> - code + = lang_ . accessor_prefix + " bb ) : null " + member_suffix + " } \ n " ; <nl> - } <nl> - / / Generate a ByteBuffer accessor for strings & vectors of scalars . <nl> - if ( ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> - IsScalar ( field . value . type . VectorType ( ) . base_type ) ) | | <nl> - field . value . type . base_type = = BASE_TYPE_STRING ) { <nl> - switch ( lang_ . language ) { <nl> - case IDLOptions : : kJava : <nl> - code + = " public ByteBuffer " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " AsByteBuffer ( ) { return " ; <nl> - code + = lang_ . accessor_prefix + " __vector_as_bytebuffer ( " ; <nl> - code + = NumToString ( field . value . offset ) + " , " ; <nl> - code + = <nl> - NumToString ( field . value . type . base_type = = BASE_TYPE_STRING <nl> - ? 1 <nl> - : InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> - code + = " ) ; } \ n " ; <nl> - code + = " public ByteBuffer " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " InByteBuffer ( ByteBuffer _bb ) { return " ; <nl> - code + = lang_ . accessor_prefix + " __vector_in_bytebuffer ( _bb , " ; <nl> - code + = NumToString ( field . value . offset ) + " , " ; <nl> - code + = <nl> - NumToString ( field . value . type . base_type = = BASE_TYPE_STRING <nl> - ? 1 <nl> - : InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> - code + = " ) ; } \ n " ; <nl> - break ; <nl> - case IDLOptions : : kCSharp : <nl> - code + = " # if ENABLE_SPAN_T \ n " ; <nl> - code + = " public Span < " + <nl> - GenTypeBasic ( field . value . type . VectorType ( ) ) + " > Get " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " Bytes ( ) { return " ; <nl> - code + = lang_ . accessor_prefix + " __vector_as_span < " + <nl> - GenTypeBasic ( field . value . type . VectorType ( ) ) + " > ( " ; <nl> - code + = NumToString ( field . value . offset ) ; <nl> - code + = " , " + NumToString ( <nl> - SizeOf ( field . value . type . VectorType ( ) . base_type ) ) ; <nl> - code + = " ) ; } \ n " ; <nl> - code + = " # else \ n " ; <nl> - code + = " public ArraySegment < byte > ? Get " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " Bytes ( ) { return " ; <nl> - code + = lang_ . accessor_prefix + " __vector_as_arraysegment ( " ; <nl> - code + = NumToString ( field . value . offset ) ; <nl> - code + = " ) ; } \ n " ; <nl> - code + = " # endif \ n " ; <nl> - <nl> - / / For direct blockcopying the data into a typed array <nl> - code + = " public " ; <nl> - code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> - code + = " [ ] Get " ; <nl> - code + = MakeCamel ( field . name , lang_ . first_camel_upper ) ; <nl> - code + = " Array ( ) { " ; <nl> - if ( IsEnum ( field . value . type . VectorType ( ) ) ) { <nl> - / / Since __vector_as_array does not work for enum types , <nl> - / / fill array using an explicit loop . <nl> - code + = " int o = " + lang_ . accessor_prefix + " __offset ( " ; <nl> - code + = NumToString ( field . value . offset ) ; <nl> - code + = " ) ; if ( o = = 0 ) return null ; int p = " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( o ) ; int l = " ; <nl> - code + = lang_ . accessor_prefix + " __vector_len ( o ) ; " ; <nl> - code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> - code + = " [ ] a = new " ; <nl> - code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> - code + = " [ l ] ; for ( int i = 0 ; i < l ; i + + ) { a [ i ] = " + getter ; <nl> - code + = " ( p + i * " ; <nl> - code + = NumToString ( InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> - code + = " ) ; } return a ; " ; <nl> - } else { <nl> - code + = " return " ; <nl> - code + = lang_ . accessor_prefix + " __vector_as_array < " ; <nl> - code + = GenTypeBasic ( field . value . type . VectorType ( ) ) ; <nl> - code + = " > ( " ; <nl> - code + = NumToString ( field . value . offset ) ; <nl> - code + = " ) ; " ; <nl> - } <nl> - code + = " } \ n " ; <nl> - break ; <nl> - default : break ; <nl> - } <nl> - } <nl> - / / generate object accessors if is nested_flatbuffer <nl> - if ( field . nested_flatbuffer ) { <nl> - auto nested_type_name = WrapInNameSpace ( * field . nested_flatbuffer ) ; <nl> - auto nested_method_name = <nl> - MakeCamel ( field . name , lang_ . first_camel_upper ) + " As " + <nl> - field . nested_flatbuffer - > name ; <nl> - auto get_nested_method_name = nested_method_name ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - get_nested_method_name = " Get " + nested_method_name ; <nl> - conditional_cast = <nl> - " ( " + nested_type_name + lang_ . optional_suffix + " ) " ; <nl> - } <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) { <nl> - code + = " public " + nested_type_name + lang_ . optional_suffix + " " ; <nl> - code + = nested_method_name + " ( ) { return " ; <nl> - code + = <nl> - get_nested_method_name + " ( new " + nested_type_name + " ( ) ) ; } \ n " ; <nl> - } else { <nl> - obj = " ( new " + nested_type_name + " ( ) ) " ; <nl> - } <nl> - code + = " public " + nested_type_name + lang_ . optional_suffix + " " ; <nl> - code + = get_nested_method_name + " ( " ; <nl> - if ( lang_ . language ! = IDLOptions : : kCSharp ) <nl> - code + = nested_type_name + " obj " ; <nl> - code + = " ) { int o = " + lang_ . accessor_prefix + " __offset ( " ; <nl> - code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> - code + = " return o ! = 0 ? " + conditional_cast + obj + " . __assign ( " ; <nl> - code + = lang_ . accessor_prefix ; <nl> - code + = " __indirect ( " + lang_ . accessor_prefix + " __vector ( o ) ) , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) : null ; } \ n " ; <nl> - } <nl> - / / Generate mutators for scalar fields or vectors of scalars . <nl> - if ( parser_ . opts . mutable_buffer ) { <nl> - auto is_series = ( IsSeries ( field . value . type ) ) ; <nl> - const auto & underlying_type = <nl> - is_series ? field . value . type . VectorType ( ) : field . value . type ; <nl> - / / Boolean parameters have to be explicitly converted to byte <nl> - / / representation . <nl> - auto setter_parameter = underlying_type . base_type = = BASE_TYPE_BOOL <nl> - ? " ( byte ) ( " + field . name + " ? 1 : 0 ) " <nl> - : field . name ; <nl> - auto mutator_prefix = MakeCamel ( " mutate " , lang_ . first_camel_upper ) ; <nl> - / / A vector mutator also needs the index of the vector element it should <nl> - / / mutate . <nl> - auto mutator_params = ( is_series ? " ( int j , " : " ( " ) + <nl> - GenTypeNameDest ( underlying_type ) + " " + <nl> - field . name + " ) { " ; <nl> - auto setter_index = <nl> - is_series <nl> - ? lang_ . accessor_prefix + <nl> - ( IsArray ( field . value . type ) <nl> - ? " bb_pos + " + NumToString ( field . value . offset ) <nl> - : " __vector ( o ) " ) + <nl> - + " + j * " + NumToString ( InlineSize ( underlying_type ) ) <nl> - : ( struct_def . fixed <nl> - ? lang_ . accessor_prefix + " bb_pos + " + <nl> - NumToString ( field . value . offset ) <nl> - : " o + " + lang_ . accessor_prefix + " bb_pos " ) ; <nl> - if ( IsScalar ( underlying_type . base_type ) & & ! IsUnion ( field . value . type ) ) { <nl> - code + = " public " ; <nl> - code + = struct_def . fixed ? " void " : lang_ . bool_type ; <nl> - code + = mutator_prefix + MakeCamel ( field . name , true ) ; <nl> - code + = mutator_params ; <nl> - if ( struct_def . fixed ) { <nl> - code + = GenSetter ( underlying_type ) + " ( " + setter_index + " , " ; <nl> - code + = src_cast + setter_parameter + " ) ; } \ n " ; <nl> - } else { <nl> - code + = " int o = " + lang_ . accessor_prefix + " __offset ( " ; <nl> - code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> - code + = " if ( o ! = 0 ) { " + GenSetter ( underlying_type ) ; <nl> - code + = " ( " + setter_index + " , " + src_cast + setter_parameter + <nl> - " ) ; return true ; } else { return false ; } } \ n " ; <nl> - } <nl> - } <nl> - } <nl> - if ( parser_ . opts . java_primitive_has_method & & <nl> - IsScalar ( field . value . type . base_type ) & & ! struct_def . fixed ) { <nl> - auto vt_offset_constant = " public static final int VT_ " + <nl> - MakeScreamingCamel ( field . name ) + " = " + <nl> - NumToString ( field . value . offset ) + " ; " ; <nl> - <nl> - code + = vt_offset_constant ; <nl> - code + = " \ n " ; <nl> - } <nl> - } <nl> - code + = " \ n " ; <nl> - flatbuffers : : FieldDef * key_field = nullptr ; <nl> - if ( struct_def . fixed ) { <nl> - / / create a struct constructor function <nl> - code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " ; <nl> - code + = struct_def . name + " ( FlatBufferBuilder builder " ; <nl> - GenStructArgs ( struct_def , code_ptr , " " ) ; <nl> - code + = " ) { \ n " ; <nl> - GenStructBody ( struct_def , code_ptr , " " ) ; <nl> - code + = " return " ; <nl> - code + = GenOffsetConstruct ( <nl> - struct_def , " builder . " + std : : string ( lang_ . get_fbb_offset ) ) ; <nl> - code + = " ; \ n } \ n " ; <nl> - } else { <nl> - / / Generate a method that creates a table in one go . This is only possible <nl> - / / when the table has no struct fields , since those have to be created <nl> - / / inline , and there ' s no way to do so in Java . <nl> - bool has_no_struct_fields = true ; <nl> - int num_fields = 0 ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( field . deprecated ) continue ; <nl> - if ( IsStruct ( field . value . type ) ) { <nl> - has_no_struct_fields = false ; <nl> - } else { <nl> - num_fields + + ; <nl> - } <nl> - } <nl> - / / JVM specifications restrict default constructor params to be < 255 . <nl> - / / Longs and doubles take up 2 units , so we set the limit to be < 127 . <nl> - if ( has_no_struct_fields & & num_fields & & num_fields < 127 ) { <nl> - / / Generate a table constructor of the form : <nl> - / / public static int createName ( FlatBufferBuilder builder , args . . . ) <nl> - code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " + struct_def . name ; <nl> - code + = " ( FlatBufferBuilder builder " ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( field . deprecated ) continue ; <nl> - code + = " , \ n " ; <nl> - code + = GenTypeBasic ( DestinationType ( field . value . type , false ) ) ; <nl> - code + = " " ; <nl> - code + = field . name ; <nl> - if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> - <nl> - / / Java doesn ' t have defaults , which means this method must always <nl> - / / supply all arguments , and thus won ' t compile when fields are added . <nl> - if ( lang_ . language ! = IDLOptions : : kJava ) { <nl> - code + = " = " ; <nl> - code + = GenDefaultValueBasic ( field ) ; <nl> - } <nl> - } <nl> - code + = " ) { \ n builder . " ; <nl> - code + = FunctionStart ( ' S ' ) + " tartTable ( " ; <nl> - code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; \ n " ; <nl> - for ( size_t size = struct_def . sortbysize ? sizeof ( largest_scalar_t ) : 1 ; <nl> - size ; size / = 2 ) { <nl> - for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> - it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( ! field . deprecated & & <nl> - ( ! struct_def . sortbysize | | <nl> - size = = SizeOf ( field . value . type . base_type ) ) ) { <nl> - code + = " " + struct_def . name + " . " ; <nl> - code + = FunctionStart ( ' A ' ) + " dd " ; <nl> - code + = MakeCamel ( field . name ) + " ( builder , " + field . name ; <nl> - if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> - code + = " ) ; \ n " ; <nl> - } <nl> - } <nl> - } <nl> - code + = " return " + struct_def . name + " . " ; <nl> - code + = FunctionStart ( ' E ' ) + " nd " + struct_def . name ; <nl> - code + = " ( builder ) ; \ n } \ n \ n " ; <nl> - } <nl> - / / Generate a set of static methods that allow table construction , <nl> - / / of the form : <nl> - / / public static void addName ( FlatBufferBuilder builder , short name ) <nl> - / / { builder . addShort ( id , name , default ) ; } <nl> - / / Unlike the Create function , these always work . <nl> - code + = " public static void " + FunctionStart ( ' S ' ) + " tart " ; <nl> - code + = struct_def . name ; <nl> - code + = " ( FlatBufferBuilder builder ) { builder . " ; <nl> - code + = FunctionStart ( ' S ' ) + " tartTable ( " ; <nl> - code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; } \ n " ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( field . deprecated ) continue ; <nl> - if ( field . key ) key_field = & field ; <nl> - code + = " public static void " + FunctionStart ( ' A ' ) + " dd " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " ( FlatBufferBuilder builder , " ; <nl> - code + = GenTypeBasic ( DestinationType ( field . value . type , false ) ) ; <nl> - auto argname = MakeCamel ( field . name , false ) ; <nl> - if ( ! IsScalar ( field . value . type . base_type ) ) argname + = " Offset " ; <nl> - code + = " " + argname + " ) { builder . " + FunctionStart ( ' A ' ) + " dd " ; <nl> - code + = GenMethod ( field . value . type ) + " ( " ; <nl> - code + = NumToString ( it - struct_def . fields . vec . begin ( ) ) + " , " ; <nl> - code + = SourceCastBasic ( field . value . type ) ; <nl> - code + = argname ; <nl> - if ( ! IsScalar ( field . value . type . base_type ) & & <nl> - field . value . type . base_type ! = BASE_TYPE_UNION & & <nl> - lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " . Value " ; <nl> - } <nl> - code + = " , " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) <nl> - code + = SourceCastBasic ( field . value . type ) ; <nl> - code + = GenDefaultValue ( field , false ) ; <nl> - code + = " ) ; } \ n " ; <nl> - if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> - auto vector_type = field . value . type . VectorType ( ) ; <nl> - auto alignment = InlineAlignment ( vector_type ) ; <nl> - auto elem_size = InlineSize ( vector_type ) ; <nl> - if ( ! IsStruct ( vector_type ) ) { <nl> - / / generate a method to create a vector from a java array . <nl> - if ( lang_ . language = = IDLOptions : : kJava & & <nl> - ( vector_type . base_type = = BASE_TYPE_CHAR | | <nl> - vector_type . base_type = = BASE_TYPE_UCHAR ) ) { <nl> - / / Handle byte [ ] and ByteBuffers separately for Java <nl> - code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " Vector ( FlatBufferBuilder builder , byte [ ] data ) " ; <nl> - code + = " { return builder . createByteVector ( data ) ; } \ n " ; <nl> - <nl> - code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " Vector ( FlatBufferBuilder builder , ByteBuffer data ) " ; <nl> - code + = " { return builder . createByteVector ( data ) ; } \ n " ; <nl> - } else { <nl> - code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " Vector ( FlatBufferBuilder builder , " ; <nl> - code + = GenTypeBasic ( vector_type ) + " [ ] data ) " ; <nl> - code + = " { builder . " + FunctionStart ( ' S ' ) + " tartVector ( " ; <nl> - code + = NumToString ( elem_size ) ; <nl> - code + = " , data . " + FunctionStart ( ' L ' ) + " ength , " ; <nl> - code + = NumToString ( alignment ) ; <nl> - code + = " ) ; for ( int i = data . " ; <nl> - code + = FunctionStart ( ' L ' ) + " ength - 1 ; i > = 0 ; i - - ) builder . " ; <nl> - code + = FunctionStart ( ' A ' ) + " dd " ; <nl> - code + = GenMethod ( vector_type ) ; <nl> - code + = " ( " ; <nl> - code + = SourceCastBasic ( vector_type , false ) ; <nl> - code + = " data [ i ] " ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp & & <nl> - ( vector_type . base_type = = BASE_TYPE_STRUCT | | <nl> - vector_type . base_type = = BASE_TYPE_STRING ) ) <nl> - code + = " . Value " ; <nl> - code + = " ) ; return " ; <nl> - code + = " builder . " + FunctionStart ( ' E ' ) + " ndVector ( ) ; } \ n " ; <nl> - / / For C # , include a block copy method signature . <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { <nl> - code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> - code + = FunctionStart ( ' C ' ) + " reate " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " VectorBlock ( FlatBufferBuilder builder , " ; <nl> - code + = GenTypeBasic ( vector_type ) + " [ ] data ) " ; <nl> - code + = " { builder . " + FunctionStart ( ' S ' ) + " tartVector ( " ; <nl> - code + = NumToString ( elem_size ) ; <nl> - code + = " , data . " + FunctionStart ( ' L ' ) + " ength , " ; <nl> - code + = NumToString ( alignment ) ; <nl> - code + = " ) ; builder . Add ( data ) ; return builder . EndVector ( ) ; } \ n " ; <nl> - } <nl> - } <nl> - } <nl> - / / Generate a method to start a vector , data to be added manually <nl> - / / after . <nl> - code + = " public static void " + FunctionStart ( ' S ' ) + " tart " ; <nl> - code + = MakeCamel ( field . name ) ; <nl> - code + = " Vector ( FlatBufferBuilder builder , int numElems ) " ; <nl> - code + = " { builder . " + FunctionStart ( ' S ' ) + " tartVector ( " ; <nl> - code + = NumToString ( elem_size ) ; <nl> - code + = " , numElems , " + NumToString ( alignment ) ; <nl> - code + = " ) ; } \ n " ; <nl> - } <nl> - } <nl> - code + = " public static " + GenOffsetType ( struct_def ) + " " ; <nl> - code + = FunctionStart ( ' E ' ) + " nd " + struct_def . name ; <nl> - code + = " ( FlatBufferBuilder builder ) { \ n int o = builder . " ; <nl> - code + = FunctionStart ( ' E ' ) + " ndTable ( ) ; \ n " ; <nl> - for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> - it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> - auto & field = * * it ; <nl> - if ( ! field . deprecated & & field . required ) { <nl> - code + = " builder . " + FunctionStart ( ' R ' ) + " equired ( o , " ; <nl> - code + = NumToString ( field . value . offset ) ; <nl> - code + = " ) ; / / " + field . name + " \ n " ; <nl> - } <nl> - } <nl> - code + = " return " + GenOffsetConstruct ( struct_def , " o " ) + " ; \ n } \ n " ; <nl> - if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> - std : : string size_prefix [ ] = { " " , " SizePrefixed " } ; <nl> - for ( int i = 0 ; i < 2 ; + + i ) { <nl> - code + = " public static void " ; <nl> - code + = <nl> - FunctionStart ( ' F ' ) + " inish " + size_prefix [ i ] + struct_def . name ; <nl> - code + = <nl> - " Buffer ( FlatBufferBuilder builder , " + GenOffsetType ( struct_def ) ; <nl> - code + = " offset ) { " ; <nl> - code + = " builder . " + FunctionStart ( ' F ' ) + " inish " + size_prefix [ i ] + <nl> - " ( offset " ; <nl> - if ( lang_ . language = = IDLOptions : : kCSharp ) { code + = " . Value " ; } <nl> - <nl> - if ( parser_ . file_identifier_ . length ( ) ) <nl> - code + = " , \ " " + parser_ . file_identifier_ + " \ " " ; <nl> - code + = " ) ; } \ n " ; <nl> - } <nl> - } <nl> - } <nl> - / / Only generate key compare function for table , <nl> - / / because ` key_field ` is not set for struct <nl> - if ( struct_def . has_key & & ! struct_def . fixed ) { <nl> - FLATBUFFERS_ASSERT ( key_field ) ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) { <nl> - code + = " \ n @ Override \ n protected int keysCompare ( " ; <nl> - code + = " Integer o1 , Integer o2 , ByteBuffer _bb ) { " ; <nl> - code + = GenKeyGetter ( key_field ) ; <nl> - code + = " } \ n " ; <nl> - } else { <nl> - code + = " \ n public static VectorOffset " ; <nl> - code + = " CreateSortedVectorOf " + struct_def . name ; <nl> - code + = " ( FlatBufferBuilder builder , " ; <nl> - code + = " Offset < " + struct_def . name + " > " ; <nl> - code + = " [ ] offsets ) { \ n " ; <nl> - code + = " Array . Sort ( offsets , ( Offset < " + struct_def . name + <nl> - " > o1 , Offset < " + struct_def . name + " > o2 ) = > " + <nl> - GenKeyGetter ( key_field ) ; <nl> - code + = " ) ; \ n " ; <nl> - code + = " return builder . CreateVectorOfTables ( offsets ) ; \ n } \ n " ; <nl> - } <nl> - <nl> - code + = " \ n public static " + struct_def . name + lang_ . optional_suffix ; <nl> - code + = " __lookup_by_key ( " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) <nl> - code + = struct_def . name + " obj , " ; <nl> - code + = " int vectorLocation , " ; <nl> - code + = GenTypeNameDest ( key_field - > value . type ) ; <nl> - code + = " key , ByteBuffer bb ) { \ n " ; <nl> - if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> - code + = " byte [ ] byteKey = " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) <nl> - code + = " key . getBytes ( Table . UTF8_CHARSET . get ( ) ) ; \ n " ; <nl> - else <nl> - code + = " System . Text . Encoding . UTF8 . GetBytes ( key ) ; \ n " ; <nl> - } <nl> - code + = " int span = " ; <nl> - code + = " bb . " + FunctionStart ( ' G ' ) + " etInt ( vectorLocation - 4 ) ; \ n " ; <nl> - code + = " int start = 0 ; \ n " ; <nl> - code + = " while ( span ! = 0 ) { \ n " ; <nl> - code + = " int middle = span / 2 ; \ n " ; <nl> - code + = GenLookupKeyGetter ( key_field ) ; <nl> - code + = " if ( comp > 0 ) { \ n " ; <nl> - code + = " span = middle ; \ n " ; <nl> - code + = " } else if ( comp < 0 ) { \ n " ; <nl> - code + = " middle + + ; \ n " ; <nl> - code + = " start + = middle ; \ n " ; <nl> - code + = " span - = middle ; \ n " ; <nl> - code + = " } else { \ n " ; <nl> - code + = " return " ; <nl> - if ( lang_ . language = = IDLOptions : : kJava ) <nl> - code + = " ( obj = = null ? new " + struct_def . name + " ( ) : obj ) " ; <nl> - else <nl> - code + = " new " + struct_def . name + " ( ) " ; <nl> - code + = " . __assign ( tableOffset , bb ) ; \ n " ; <nl> - code + = " } \ n } \ n " ; <nl> - code + = " return null ; \ n " ; <nl> - code + = " } \ n " ; <nl> - } <nl> - if ( lang_ . language = = IDLOptions : : kJava ) <nl> - GenVectorAccessObject ( struct_def , code_ptr ) ; <nl> - code + = " } " ; <nl> - / / Java does not need the closing semi - colon on class definitions . <nl> - code + = ( lang_ . language ! = IDLOptions : : kJava ) ? " ; " : " " ; <nl> - code + = " \ n \ n " ; <nl> - } <nl> - <nl> - void GenVectorAccessObject ( StructDef & struct_def , <nl> - std : : string * code_ptr ) const { <nl> - auto & code = * code_ptr ; <nl> - / / Generate a vector of structs accessor class . <nl> - code + = " \ n " ; <nl> - code + = " " ; <nl> - if ( ! struct_def . attributes . Lookup ( " private " ) ) code + = " public " ; <nl> - code + = " static " ; <nl> - code + = lang_ . unsubclassable_decl ; <nl> - code + = lang_ . accessor_type + " Vector " + lang_ . inheritance_marker ; <nl> - code + = " BaseVector " + lang_ . open_curly ; <nl> - <nl> - / / Generate the __assign method that sets the field in a pre - existing <nl> - / / accessor object . This is to allow object reuse . <nl> - std : : string method_indent = " " ; <nl> - code + = method_indent + " public Vector " ; <nl> - code + = " __assign ( int _vector , int _element_size , ByteBuffer _bb ) { " ; <nl> - code + = " __reset ( _vector , _element_size , _bb ) ; return this ; } \ n \ n " ; <nl> - <nl> - auto type_name = struct_def . name ; <nl> - auto method_start = <nl> - method_indent + " public " + type_name + " " + FunctionStart ( ' G ' ) + " et " ; <nl> - / / Generate the accessors that don ' t do object reuse . <nl> - code + = method_start + " ( int j ) { return " + FunctionStart ( ' G ' ) + " et " ; <nl> - code + = " ( new " + type_name + " ( ) , j ) ; } \ n " ; <nl> - code + = method_start + " ( " + type_name + " obj , int j ) { " ; <nl> - code + = " return obj . __assign ( " ; <nl> - auto index = lang_ . accessor_prefix + " __element ( j ) " ; <nl> - code + = struct_def . fixed <nl> - ? index <nl> - : lang_ . accessor_prefix + " __indirect ( " + index + " , bb ) " ; <nl> - code + = " , " + lang_ . accessor_prefix + " bb ) ; } \ n " ; <nl> - / / See if we should generate a by - key accessor . <nl> - if ( ! struct_def . fixed ) { <nl> - auto & fields = struct_def . fields . vec ; <nl> - for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> - auto & key_field = * * kit ; <nl> - if ( key_field . key ) { <nl> - auto nullable_annotation = <nl> - parser_ . opts . gen_nullable ? " @ Nullable " : " " ; <nl> - code + = method_indent + nullable_annotation ; <nl> - code + = " public " + type_name + lang_ . optional_suffix + " " ; <nl> - code + = FunctionStart ( ' G ' ) + " et " + " ByKey ( " ; <nl> - code + = GenTypeNameDest ( key_field . value . type ) + " key ) { " ; <nl> - code + = " return __lookup_by_key ( null , " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( ) , key , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) ; " ; <nl> - code + = " } \ n " ; <nl> - code + = method_indent + nullable_annotation ; <nl> - code + = " public " + type_name + lang_ . optional_suffix + " " ; <nl> - code + = FunctionStart ( ' G ' ) + " et " + " ByKey ( " ; <nl> - code + = type_name + lang_ . optional_suffix + " obj , " ; <nl> - code + = GenTypeNameDest ( key_field . value . type ) + " key ) { " ; <nl> - code + = " return __lookup_by_key ( obj , " ; <nl> - code + = lang_ . accessor_prefix + " __vector ( ) , key , " ; <nl> - code + = lang_ . accessor_prefix + " bb ) ; " ; <nl> - code + = " } \ n " ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - code + = " } \ n " ; <nl> - } <nl> - <nl> - const LanguageParameters & lang_ ; <nl> - / / This tracks the current namespace used to determine if a type need to be <nl> - / / prefixed by its namespace <nl> - const Namespace * cur_name_space_ ; <nl> - } ; <nl> - } / / namespace general <nl> - <nl> - bool GenerateGeneral ( const Parser & parser , const std : : string & path , <nl> - const std : : string & file_name ) { <nl> - general : : GeneralGenerator generator ( parser , path , file_name ) ; <nl> - return generator . generate ( ) ; <nl> - } <nl> - <nl> std : : string GeneralMakeRule ( const Parser & parser , const std : : string & path , <nl> const std : : string & file_name ) { <nl> FLATBUFFERS_ASSERT ( parser . opts . lang < = IDLOptions : : kMAX ) ; <nl> - const auto & lang = GetLangParams ( parser . opts . lang ) ; <nl> + <nl> + std : : string file_extension = <nl> + ( parser . opts . lang = = IDLOptions : : kJava ) ? " . java " : " . cs " ; <nl> <nl> std : : string make_rule ; <nl> <nl> std : : string GeneralMakeRule ( const Parser & parser , const std : : string & path , <nl> if ( ! make_rule . empty ( ) ) make_rule + = " " ; <nl> std : : string directory = <nl> BaseGenerator : : NamespaceDir ( parser , path , * enum_def . defined_namespace ) ; <nl> - make_rule + = directory + enum_def . name + lang . file_extension ; <nl> + make_rule + = directory + enum_def . name + file_extension ; <nl> } <nl> <nl> for ( auto it = parser . structs_ . vec . begin ( ) ; it ! = parser . structs_ . vec . end ( ) ; <nl> std : : string GeneralMakeRule ( const Parser & parser , const std : : string & path , <nl> if ( ! make_rule . empty ( ) ) make_rule + = " " ; <nl> std : : string directory = BaseGenerator : : NamespaceDir ( <nl> parser , path , * struct_def . defined_namespace ) ; <nl> - make_rule + = directory + struct_def . name + lang . file_extension ; <nl> + make_rule + = directory + struct_def . name + file_extension ; <nl> } <nl> <nl> make_rule + = " : " ; <nl> new file mode 100644 <nl> index 0000000000 . . 123ebddc6e <nl> mmm / dev / null <nl> ppp b / src / idl_gen_java . cpp <nl> <nl> + / * <nl> + * Copyright 2014 Google Inc . All rights reserved . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * / <nl> + <nl> + / / independent from idl_parser , since this code is not needed for most clients <nl> + <nl> + # include " flatbuffers / code_generators . h " <nl> + # include " flatbuffers / flatbuffers . h " <nl> + # include " flatbuffers / idl . h " <nl> + # include " flatbuffers / util . h " <nl> + <nl> + # if defined ( FLATBUFFERS_CPP98_STL ) <nl> + # include < cctype > <nl> + # endif / / defined ( FLATBUFFERS_CPP98_STL ) <nl> + <nl> + namespace flatbuffers { <nl> + namespace java { <nl> + <nl> + static TypedFloatConstantGenerator JavaFloatGen ( " Double . " , " Float . " , " NaN " , <nl> + " POSITIVE_INFINITY " , <nl> + " NEGATIVE_INFINITY " ) ; <nl> + <nl> + static CommentConfig comment_config = { <nl> + " / * * " , <nl> + " * " , <nl> + " * / " , <nl> + } ; <nl> + <nl> + class JavaGenerator : public BaseGenerator { <nl> + public : <nl> + JavaGenerator ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) <nl> + : BaseGenerator ( parser , path , file_name , " " , " . " ) , <nl> + cur_name_space_ ( nullptr ) { } <nl> + <nl> + JavaGenerator & operator = ( const JavaGenerator & ) ; <nl> + bool generate ( ) { <nl> + std : : string one_file_code ; <nl> + cur_name_space_ = parser_ . current_namespace_ ; <nl> + <nl> + for ( auto it = parser_ . enums_ . vec . begin ( ) ; it ! = parser_ . enums_ . vec . end ( ) ; <nl> + + + it ) { <nl> + std : : string enumcode ; <nl> + auto & enum_def = * * it ; <nl> + if ( ! parser_ . opts . one_file ) cur_name_space_ = enum_def . defined_namespace ; <nl> + GenEnum ( enum_def , & enumcode ) ; <nl> + if ( parser_ . opts . one_file ) { <nl> + one_file_code + = enumcode ; <nl> + } else { <nl> + if ( ! SaveType ( enum_def . name , * enum_def . defined_namespace , enumcode , <nl> + false ) ) <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + for ( auto it = parser_ . structs_ . vec . begin ( ) ; <nl> + it ! = parser_ . structs_ . vec . end ( ) ; + + it ) { <nl> + std : : string declcode ; <nl> + auto & struct_def = * * it ; <nl> + if ( ! parser_ . opts . one_file ) <nl> + cur_name_space_ = struct_def . defined_namespace ; <nl> + GenStruct ( struct_def , & declcode ) ; <nl> + if ( parser_ . opts . one_file ) { <nl> + one_file_code + = declcode ; <nl> + } else { <nl> + if ( ! SaveType ( struct_def . name , * struct_def . defined_namespace , declcode , <nl> + true ) ) <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + if ( parser_ . opts . one_file ) { <nl> + return SaveType ( file_name_ , * parser_ . current_namespace_ , one_file_code , <nl> + true ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + / / Save out the generated code for a single class while adding <nl> + / / declaration boilerplate . <nl> + bool SaveType ( const std : : string & defname , const Namespace & ns , <nl> + const std : : string & classcode , bool needs_includes ) const { <nl> + if ( ! classcode . length ( ) ) return true ; <nl> + <nl> + std : : string code ; <nl> + code = " / / " + std : : string ( FlatBuffersGeneratedWarning ( ) ) + " \ n \ n " ; <nl> + <nl> + std : : string namespace_name = FullNamespace ( " . " , ns ) ; <nl> + if ( ! namespace_name . empty ( ) ) { <nl> + code + = " package " + namespace_name + " ; " ; <nl> + code + = " \ n \ n " ; <nl> + } <nl> + if ( needs_includes ) { <nl> + code + = <nl> + " import java . nio . * ; \ nimport java . lang . * ; \ nimport " <nl> + " java . util . * ; \ nimport com . google . flatbuffers . * ; \ n " ; <nl> + if ( parser_ . opts . gen_nullable ) { <nl> + code + = " \ nimport javax . annotation . Nullable ; \ n " ; <nl> + } <nl> + if ( parser_ . opts . java_checkerframework ) { <nl> + code + = " \ nimport org . checkerframework . dataflow . qual . Pure ; \ n " ; <nl> + } <nl> + code + = " \ n @ SuppressWarnings ( \ " unused \ " ) \ n " ; <nl> + } <nl> + if ( parser_ . opts . gen_generated ) { <nl> + code + = " \ n @ javax . annotation . Generated ( value = \ " flatc \ " ) \ n " ; <nl> + } <nl> + code + = classcode ; <nl> + if ( ! namespace_name . empty ( ) ) code + = " " ; <nl> + auto filename = NamespaceDir ( ns ) + defname + " . java " ; <nl> + return SaveFile ( filename . c_str ( ) , code , false ) ; <nl> + } <nl> + <nl> + const Namespace * CurrentNameSpace ( ) const { return cur_name_space_ ; } <nl> + <nl> + std : : string GenNullableAnnotation ( const Type & t ) const { <nl> + return parser_ . opts . gen_nullable & & <nl> + ! IsScalar ( DestinationType ( t , true ) . base_type ) & & <nl> + t . base_type ! = BASE_TYPE_VECTOR <nl> + ? " @ Nullable " <nl> + : " " ; <nl> + } <nl> + <nl> + std : : string GenPureAnnotation ( const Type & t ) const { <nl> + return parser_ . opts . java_checkerframework & & <nl> + ! IsScalar ( DestinationType ( t , true ) . base_type ) <nl> + ? " @ Pure " <nl> + : " " ; <nl> + } <nl> + <nl> + std : : string GenTypeBasic ( const Type & type ) const { <nl> + / / clang - format off <nl> + static const char * const java_typename [ ] = { <nl> + # define FLATBUFFERS_TD ( ENUM , IDLTYPE , \ <nl> + CTYPE , JTYPE , GTYPE , NTYPE , PTYPE , RTYPE , KTYPE ) \ <nl> + # JTYPE , <nl> + FLATBUFFERS_GEN_TYPES ( FLATBUFFERS_TD ) <nl> + # undef FLATBUFFERS_TD <nl> + } ; <nl> + / / clang - format on <nl> + <nl> + return java_typename [ type . base_type ] ; <nl> + } <nl> + <nl> + std : : string GenTypePointer ( const Type & type ) const { <nl> + switch ( type . base_type ) { <nl> + case BASE_TYPE_STRING : return " String " ; <nl> + case BASE_TYPE_VECTOR : return GenTypeGet ( type . VectorType ( ) ) ; <nl> + case BASE_TYPE_STRUCT : return WrapInNameSpace ( * type . struct_def ) ; <nl> + case BASE_TYPE_UNION : FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> + default : return " Table " ; <nl> + } <nl> + } <nl> + <nl> + std : : string GenTypeGet ( const Type & type ) const { <nl> + return IsScalar ( type . base_type ) <nl> + ? GenTypeBasic ( type ) <nl> + : ( IsArray ( type ) ? GenTypeGet ( type . VectorType ( ) ) <nl> + : GenTypePointer ( type ) ) ; <nl> + } <nl> + <nl> + / / Find the destination type the user wants to receive the value in ( e . g . <nl> + / / one size higher signed types for unsigned serialized values in Java ) . <nl> + Type DestinationType ( const Type & type , bool vectorelem ) const { <nl> + switch ( type . base_type ) { <nl> + / / We use int for both uchar / ushort , since that generally means less <nl> + / / casting than using short for uchar . <nl> + case BASE_TYPE_UCHAR : return Type ( BASE_TYPE_INT ) ; <nl> + case BASE_TYPE_USHORT : return Type ( BASE_TYPE_INT ) ; <nl> + case BASE_TYPE_UINT : return Type ( BASE_TYPE_LONG ) ; <nl> + case BASE_TYPE_ARRAY : <nl> + case BASE_TYPE_VECTOR : <nl> + if ( vectorelem ) return DestinationType ( type . VectorType ( ) , vectorelem ) ; <nl> + FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> + default : return type ; <nl> + } <nl> + } <nl> + <nl> + std : : string GenOffsetType ( ) const { return " int " ; } <nl> + <nl> + std : : string GenOffsetConstruct ( const std : : string & variable_name ) const { <nl> + return variable_name ; <nl> + } <nl> + <nl> + std : : string GenVectorOffsetType ( ) const { return " int " ; } <nl> + <nl> + / / Generate destination type name <nl> + std : : string GenTypeNameDest ( const Type & type ) const { <nl> + return GenTypeGet ( DestinationType ( type , true ) ) ; <nl> + } <nl> + <nl> + / / Mask to turn serialized value into destination type value . <nl> + std : : string DestinationMask ( const Type & type , bool vectorelem ) const { <nl> + switch ( type . base_type ) { <nl> + case BASE_TYPE_UCHAR : return " & 0xFF " ; <nl> + case BASE_TYPE_USHORT : return " & 0xFFFF " ; <nl> + case BASE_TYPE_UINT : return " & 0xFFFFFFFFL " ; <nl> + case BASE_TYPE_VECTOR : <nl> + if ( vectorelem ) return DestinationMask ( type . VectorType ( ) , vectorelem ) ; <nl> + FLATBUFFERS_FALLTHROUGH ( ) ; / / else fall thru <nl> + default : return " " ; <nl> + } <nl> + } <nl> + <nl> + / / Casts necessary to correctly read serialized data <nl> + std : : string DestinationCast ( const Type & type ) const { <nl> + if ( IsSeries ( type ) ) { <nl> + return DestinationCast ( type . VectorType ( ) ) ; <nl> + } else { <nl> + / / Cast necessary to correctly read serialized unsigned values . <nl> + if ( type . base_type = = BASE_TYPE_UINT ) return " ( long ) " ; <nl> + } <nl> + return " " ; <nl> + } <nl> + <nl> + / / Cast statements for mutator method parameters . <nl> + / / In Java , parameters representing unsigned numbers need to be cast down to <nl> + / / their respective type . For example , a long holding an unsigned int value <nl> + / / would be cast down to int before being put onto the buffer . In C # , one cast <nl> + / / directly cast an Enum to its underlying type , which is essential before <nl> + / / putting it onto the buffer . <nl> + std : : string SourceCast ( const Type & type , bool castFromDest ) const { <nl> + if ( IsSeries ( type ) ) { <nl> + return SourceCast ( type . VectorType ( ) , castFromDest ) ; <nl> + } else { <nl> + if ( castFromDest ) { <nl> + if ( type . base_type = = BASE_TYPE_UINT ) <nl> + return " ( int ) " ; <nl> + else if ( type . base_type = = BASE_TYPE_USHORT ) <nl> + return " ( short ) " ; <nl> + else if ( type . base_type = = BASE_TYPE_UCHAR ) <nl> + return " ( byte ) " ; <nl> + } <nl> + } <nl> + return " " ; <nl> + } <nl> + <nl> + std : : string SourceCast ( const Type & type ) const { <nl> + return SourceCast ( type , true ) ; <nl> + } <nl> + <nl> + std : : string SourceCastBasic ( const Type & type , bool castFromDest ) const { <nl> + return IsScalar ( type . base_type ) ? SourceCast ( type , castFromDest ) : " " ; <nl> + } <nl> + <nl> + std : : string SourceCastBasic ( const Type & type ) const { <nl> + return SourceCastBasic ( type , true ) ; <nl> + } <nl> + <nl> + std : : string GenEnumDefaultValue ( const FieldDef & field ) const { <nl> + auto & value = field . value ; <nl> + FLATBUFFERS_ASSERT ( value . type . enum_def ) ; <nl> + auto & enum_def = * value . type . enum_def ; <nl> + auto enum_val = enum_def . FindByValue ( value . constant ) ; <nl> + return enum_val ? ( WrapInNameSpace ( enum_def ) + " . " + enum_val - > name ) <nl> + : value . constant ; <nl> + } <nl> + <nl> + std : : string GenDefaultValue ( const FieldDef & field ) const { <nl> + auto & value = field . value ; <nl> + auto longSuffix = " L " ; <nl> + switch ( value . type . base_type ) { <nl> + case BASE_TYPE_BOOL : return value . constant = = " 0 " ? " false " : " true " ; <nl> + case BASE_TYPE_ULONG : { <nl> + / / Converts the ulong into its bits signed equivalent <nl> + uint64_t defaultValue = StringToUInt ( value . constant . c_str ( ) ) ; <nl> + return NumToString ( static_cast < int64_t > ( defaultValue ) ) + longSuffix ; <nl> + } <nl> + case BASE_TYPE_UINT : <nl> + case BASE_TYPE_LONG : return value . constant + longSuffix ; <nl> + default : <nl> + if ( IsFloat ( value . type . base_type ) ) <nl> + return JavaFloatGen . GenFloatConstant ( field ) ; <nl> + else <nl> + return value . constant ; <nl> + } <nl> + } <nl> + <nl> + std : : string GenDefaultValueBasic ( const FieldDef & field ) const { <nl> + auto & value = field . value ; <nl> + if ( ! IsScalar ( value . type . base_type ) ) { return " 0 " ; } <nl> + return GenDefaultValue ( field ) ; <nl> + } <nl> + <nl> + void GenEnum ( EnumDef & enum_def , std : : string * code_ptr ) const { <nl> + std : : string & code = * code_ptr ; <nl> + if ( enum_def . generated ) return ; <nl> + <nl> + / / Generate enum definitions of the form : <nl> + / / public static ( final ) int name = value ; <nl> + / / In Java , we use ints rather than the Enum feature , because we want them <nl> + / / to map directly to how they ' re used in C / C + + and file formats . <nl> + / / That , and Java Enums are expensive , and not universally liked . <nl> + GenComment ( enum_def . doc_comment , code_ptr , & comment_config ) ; <nl> + <nl> + if ( enum_def . attributes . Lookup ( " private " ) ) { <nl> + / / For Java , we leave the enum unmarked to indicate package - private <nl> + / / For C # we mark the enum as internal <nl> + } else { <nl> + code + = " public " ; <nl> + } <nl> + code + = " final class " + enum_def . name ; <nl> + code + = " { \ n " ; <nl> + code + = " private " + enum_def . name + " ( ) { } \ n " ; <nl> + for ( auto it = enum_def . Vals ( ) . begin ( ) ; it ! = enum_def . Vals ( ) . end ( ) ; + + it ) { <nl> + auto & ev = * * it ; <nl> + GenComment ( ev . doc_comment , code_ptr , & comment_config , " " ) ; <nl> + code + = " public static final " ; <nl> + code + = GenTypeBasic ( enum_def . underlying_type ) ; <nl> + code + = " " ; <nl> + code + = ev . name + " = " ; <nl> + code + = enum_def . ToString ( ev ) ; <nl> + code + = " ; \ n " ; <nl> + } <nl> + <nl> + / / Generate a generate string table for enum values . <nl> + / / We do not do that for C # where this functionality is native . <nl> + / / Problem is , if values are very sparse that could generate really big <nl> + / / tables . Ideally in that case we generate a map lookup instead , but for <nl> + / / the moment we simply don ' t output a table at all . <nl> + auto range = enum_def . Distance ( ) ; <nl> + / / Average distance between values above which we consider a table <nl> + / / " too sparse " . Change at will . <nl> + static const uint64_t kMaxSparseness = 5 ; <nl> + if ( range / static_cast < uint64_t > ( enum_def . size ( ) ) < kMaxSparseness ) { <nl> + code + = " \ n public static final String " ; <nl> + code + = " [ ] names = { " ; <nl> + auto val = enum_def . Vals ( ) . front ( ) ; <nl> + for ( auto it = enum_def . Vals ( ) . begin ( ) ; it ! = enum_def . Vals ( ) . end ( ) ; <nl> + + + it ) { <nl> + auto ev = * it ; <nl> + for ( auto k = enum_def . Distance ( val , ev ) ; k > 1 ; - - k ) code + = " \ " \ " , " ; <nl> + val = ev ; <nl> + code + = " \ " " + ( * it ) - > name + " \ " , " ; <nl> + } <nl> + code + = " } ; \ n \ n " ; <nl> + code + = " public static " ; <nl> + code + = " String " ; <nl> + code + = " " + MakeCamel ( " name " , false ) ; <nl> + code + = " ( int e ) { return names [ e " ; <nl> + if ( enum_def . MinValue ( ) - > IsNonZero ( ) ) <nl> + code + = " - " + enum_def . MinValue ( ) - > name ; <nl> + code + = " ] ; } \ n " ; <nl> + } <nl> + <nl> + / / Close the class <nl> + code + = " } " ; <nl> + / / Java does not need the closing semi - colon on class definitions . <nl> + code + = " " ; <nl> + code + = " \ n \ n " ; <nl> + } <nl> + <nl> + / / Returns the function name that is able to read a value of the given type . <nl> + std : : string GenGetter ( const Type & type ) const { <nl> + switch ( type . base_type ) { <nl> + case BASE_TYPE_STRING : return " __string " ; <nl> + case BASE_TYPE_STRUCT : return " __struct " ; <nl> + case BASE_TYPE_UNION : return " __union " ; <nl> + case BASE_TYPE_VECTOR : return GenGetter ( type . VectorType ( ) ) ; <nl> + case BASE_TYPE_ARRAY : return GenGetter ( type . VectorType ( ) ) ; <nl> + default : { <nl> + std : : string getter = " bb . get " ; <nl> + if ( type . base_type = = BASE_TYPE_BOOL ) { <nl> + getter = " 0 ! = " + getter ; <nl> + } else if ( GenTypeBasic ( type ) ! = " byte " ) { <nl> + getter + = MakeCamel ( GenTypeBasic ( type ) ) ; <nl> + } <nl> + return getter ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Returns the function name that is able to read a value of the given type . <nl> + std : : string GenGetterForLookupByKey ( flatbuffers : : FieldDef * key_field , <nl> + const std : : string & data_buffer , <nl> + const char * num = nullptr ) const { <nl> + auto type = key_field - > value . type ; <nl> + auto dest_mask = DestinationMask ( type , true ) ; <nl> + auto dest_cast = DestinationCast ( type ) ; <nl> + auto getter = data_buffer + " . get " ; <nl> + if ( GenTypeBasic ( type ) ! = " byte " ) { <nl> + getter + = MakeCamel ( GenTypeBasic ( type ) ) ; <nl> + } <nl> + getter = dest_cast + getter + " ( " + GenOffsetGetter ( key_field , num ) + " ) " + <nl> + dest_mask ; <nl> + return getter ; <nl> + } <nl> + <nl> + / / Direct mutation is only allowed for scalar fields . <nl> + / / Hence a setter method will only be generated for such fields . <nl> + std : : string GenSetter ( const Type & type ) const { <nl> + if ( IsScalar ( type . base_type ) ) { <nl> + std : : string setter = " bb . put " ; <nl> + if ( GenTypeBasic ( type ) ! = " byte " & & type . base_type ! = BASE_TYPE_BOOL ) { <nl> + setter + = MakeCamel ( GenTypeBasic ( type ) ) ; <nl> + } <nl> + return setter ; <nl> + } else { <nl> + return " " ; <nl> + } <nl> + } <nl> + <nl> + / / Returns the method name for use with add / put calls . <nl> + std : : string GenMethod ( const Type & type ) const { <nl> + return IsScalar ( type . base_type ) ? MakeCamel ( GenTypeBasic ( type ) ) <nl> + : ( IsStruct ( type ) ? " Struct " : " Offset " ) ; <nl> + } <nl> + <nl> + / / Recursively generate arguments for a constructor , to deal with nested <nl> + / / structs . <nl> + void GenStructArgs ( const StructDef & struct_def , std : : string * code_ptr , <nl> + const char * nameprefix , size_t array_count = 0 ) const { <nl> + std : : string & code = * code_ptr ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + const auto & field_type = field . value . type ; <nl> + const auto array_field = IsArray ( field_type ) ; <nl> + const auto & type = array_field ? field_type . VectorType ( ) <nl> + : DestinationType ( field_type , false ) ; <nl> + const auto array_cnt = array_field ? ( array_count + 1 ) : array_count ; <nl> + if ( IsStruct ( type ) ) { <nl> + / / Generate arguments for a struct inside a struct . To ensure names <nl> + / / don ' t clash , and to make it obvious these arguments are constructing <nl> + / / a nested struct , prefix the name with the field name . <nl> + GenStructArgs ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , array_cnt ) ; <nl> + } else { <nl> + code + = " , " ; <nl> + code + = GenTypeBasic ( type ) ; <nl> + for ( size_t i = 0 ; i < array_cnt ; i + + ) code + = " [ ] " ; <nl> + code + = " " ; <nl> + code + = nameprefix ; <nl> + code + = MakeCamel ( field . name , false ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Recusively generate struct construction statements of the form : <nl> + / / builder . putType ( name ) ; <nl> + / / and insert manual padding . <nl> + void GenStructBody ( const StructDef & struct_def , std : : string * code_ptr , <nl> + const char * nameprefix , size_t index = 0 , <nl> + bool in_array = false ) const { <nl> + std : : string & code = * code_ptr ; <nl> + std : : string indent ( ( index + 1 ) * 2 , ' ' ) ; <nl> + code + = indent + " builder . prep ( " ; <nl> + code + = NumToString ( struct_def . minalign ) + " , " ; <nl> + code + = NumToString ( struct_def . bytesize ) + " ) ; \ n " ; <nl> + for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> + it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + const auto & field_type = field . value . type ; <nl> + if ( field . padding ) { <nl> + code + = indent + " builder . pad ( " ; <nl> + code + = NumToString ( field . padding ) + " ) ; \ n " ; <nl> + } <nl> + if ( IsStruct ( field_type ) ) { <nl> + GenStructBody ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index , <nl> + in_array ) ; <nl> + } else { <nl> + const auto & type = <nl> + IsArray ( field_type ) ? field_type . VectorType ( ) : field_type ; <nl> + const auto index_var = " _idx " + NumToString ( index ) ; <nl> + if ( IsArray ( field_type ) ) { <nl> + code + = indent + " for ( int " + index_var + " = " ; <nl> + code + = NumToString ( field_type . fixed_length ) ; <nl> + code + = " ; " + index_var + " > 0 ; " + index_var + " - - ) { \ n " ; <nl> + in_array = true ; <nl> + } <nl> + if ( IsStruct ( type ) ) { <nl> + GenStructBody ( * field_type . struct_def , code_ptr , <nl> + ( nameprefix + ( field . name + " _ " ) ) . c_str ( ) , index + 1 , <nl> + in_array ) ; <nl> + } else { <nl> + code + = IsArray ( field_type ) ? " " : " " ; <nl> + code + = indent + " builder . put " ; <nl> + code + = GenMethod ( type ) + " ( " ; <nl> + code + = SourceCast ( type ) ; <nl> + auto argname = nameprefix + MakeCamel ( field . name , false ) ; <nl> + code + = argname ; <nl> + size_t array_cnt = index + ( IsArray ( field_type ) ? 1 : 0 ) ; <nl> + for ( size_t i = 0 ; in_array & & i < array_cnt ; i + + ) { <nl> + code + = " [ _idx " + NumToString ( i ) + " - 1 ] " ; <nl> + } <nl> + code + = " ) ; \ n " ; <nl> + } <nl> + if ( IsArray ( field_type ) ) { code + = indent + " } \ n " ; } <nl> + } <nl> + } <nl> + } <nl> + <nl> + std : : string GenByteBufferLength ( const char * bb_name ) const { <nl> + std : : string bb_len = bb_name ; <nl> + bb_len + = " . capacity ( ) " ; <nl> + return bb_len ; <nl> + } <nl> + <nl> + std : : string GenOffsetGetter ( flatbuffers : : FieldDef * key_field , <nl> + const char * num = nullptr ) const { <nl> + std : : string key_offset = " " ; <nl> + key_offset + = " __offset ( " + NumToString ( key_field - > value . offset ) + " , " ; <nl> + if ( num ) { <nl> + key_offset + = num ; <nl> + key_offset + = " , _bb ) " ; <nl> + } else { <nl> + key_offset + = GenByteBufferLength ( " bb " ) ; <nl> + key_offset + = " - tableOffset , bb ) " ; <nl> + } <nl> + return key_offset ; <nl> + } <nl> + <nl> + std : : string GenLookupKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> + std : : string key_getter = " " ; <nl> + key_getter + = " int tableOffset = " ; <nl> + key_getter + = " __indirect ( vectorLocation + 4 * ( start + middle ) " ; <nl> + key_getter + = " , bb ) ; \ n " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + key_getter + = " int comp = " ; <nl> + key_getter + = " compareStrings ( " ; <nl> + key_getter + = GenOffsetGetter ( key_field ) ; <nl> + key_getter + = " , byteKey , bb ) ; \ n " ; <nl> + } else { <nl> + auto get_val = GenGetterForLookupByKey ( key_field , " bb " ) ; <nl> + key_getter + = GenTypeNameDest ( key_field - > value . type ) + " val = " ; <nl> + key_getter + = get_val + " ; \ n " ; <nl> + key_getter + = " int comp = val > key ? 1 : val < key ? - 1 : 0 ; \ n " ; <nl> + } <nl> + return key_getter ; <nl> + } <nl> + <nl> + std : : string GenKeyGetter ( flatbuffers : : FieldDef * key_field ) const { <nl> + std : : string key_getter = " " ; <nl> + auto data_buffer = " _bb " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + key_getter + = " return " ; <nl> + key_getter + = " " ; <nl> + key_getter + = " compareStrings ( " ; <nl> + key_getter + = GenOffsetGetter ( key_field , " o1 " ) + " , " ; <nl> + key_getter + = GenOffsetGetter ( key_field , " o2 " ) + " , " + data_buffer + " ) " ; <nl> + key_getter + = " ; " ; <nl> + } else { <nl> + auto field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o1 " ) ; <nl> + key_getter + = <nl> + " \ n " + GenTypeNameDest ( key_field - > value . type ) + " val_1 = " ; <nl> + key_getter + = <nl> + field_getter + " ; \ n " + GenTypeNameDest ( key_field - > value . type ) ; <nl> + key_getter + = " val_2 = " ; <nl> + field_getter = GenGetterForLookupByKey ( key_field , data_buffer , " o2 " ) ; <nl> + key_getter + = field_getter + " ; \ n " ; <nl> + key_getter + = " return val_1 > val_2 ? 1 : val_1 < val_2 ? - 1 : 0 ; \ n " ; <nl> + } <nl> + return key_getter ; <nl> + } <nl> + <nl> + void GenStruct ( StructDef & struct_def , std : : string * code_ptr ) const { <nl> + if ( struct_def . generated ) return ; <nl> + std : : string & code = * code_ptr ; <nl> + <nl> + / / Generate a struct accessor class , with methods of the form : <nl> + / / public type name ( ) { return bb . getType ( i + offset ) ; } <nl> + / / or for tables of the form : <nl> + / / public type name ( ) { <nl> + / / int o = __offset ( offset ) ; return o ! = 0 ? bb . getType ( o + i ) : default ; <nl> + / / } <nl> + GenComment ( struct_def . doc_comment , code_ptr , & comment_config ) ; <nl> + if ( struct_def . attributes . Lookup ( " private " ) ) { <nl> + / / For Java , we leave the struct unmarked to indicate package - private <nl> + / / For C # we mark the struct as internal <nl> + } else { <nl> + code + = " public " ; <nl> + } <nl> + code + = " final " ; <nl> + code + = " class " + struct_def . name ; <nl> + code + = " extends " ; <nl> + code + = struct_def . fixed ? " Struct " : " Table " ; <nl> + code + = " { \ n " ; <nl> + <nl> + if ( ! struct_def . fixed ) { <nl> + / / Generate verson check method . <nl> + / / Force compile time error if not using the same version runtime . <nl> + code + = " public static void ValidateVersion ( ) { " ; <nl> + code + = " Constants . " ; <nl> + code + = " FLATBUFFERS_1_11_1 ( ) ; " ; <nl> + code + = " } \ n " ; <nl> + <nl> + / / Generate a special accessor for the table that when used as the root <nl> + / / of a FlatBuffer <nl> + std : : string method_name = <nl> + " getRootAs " + struct_def . name ; <nl> + std : : string method_signature = <nl> + " public static " + struct_def . name + " " + method_name ; <nl> + <nl> + / / create convenience method that doesn ' t require an existing object <nl> + code + = method_signature + " ( ByteBuffer _bb ) " ; <nl> + code + = " { return " + method_name + " ( _bb , new " + struct_def . name + <nl> + " ( ) ) ; } \ n " ; <nl> + <nl> + / / create method that allows object reuse <nl> + code + = <nl> + method_signature + " ( ByteBuffer _bb , " + struct_def . name + " obj ) { " ; <nl> + code + = " _bb . order ( ByteOrder . LITTLE_ENDIAN ) ; " ; <nl> + code + = " return ( obj . __assign ( _bb . getInt ( _bb . " ; <nl> + code + = " position ( ) " ; <nl> + code + = " ) + _bb . " ; <nl> + code + = " position ( ) " ; <nl> + code + = " , _bb ) ) ; } \ n " ; <nl> + if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> + if ( parser_ . file_identifier_ . length ( ) ) { <nl> + / / Check if a buffer has the identifier . <nl> + code + = " public static " ; <nl> + code + = " boolean " + struct_def . name ; <nl> + code + = " BufferHasIdentifier ( ByteBuffer _bb ) { return " ; <nl> + code + = " __has_identifier ( _bb , \ " " ; <nl> + code + = parser_ . file_identifier_ ; <nl> + code + = " \ " ) ; } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + / / Generate the __init method that sets the field in a pre - existing <nl> + / / accessor object . This is to allow object reuse . <nl> + code + = " public void __init ( int _i , ByteBuffer _bb ) " ; <nl> + code + = " { " ; <nl> + code + = " __reset ( _i , _bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + code + = <nl> + " public " + struct_def . name + " __assign ( int _i , ByteBuffer _bb ) " ; <nl> + code + = " { __init ( _i , _bb ) ; return this ; } \ n \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + GenComment ( field . doc_comment , code_ptr , & comment_config , " " ) ; <nl> + std : : string type_name = GenTypeGet ( field . value . type ) ; <nl> + std : : string type_name_dest = GenTypeNameDest ( field . value . type ) ; <nl> + std : : string conditional_cast = " " ; <nl> + std : : string optional = " " ; <nl> + std : : string dest_mask = DestinationMask ( field . value . type , true ) ; <nl> + std : : string dest_cast = DestinationCast ( field . value . type ) ; <nl> + std : : string src_cast = SourceCast ( field . value . type ) ; <nl> + std : : string method_start = <nl> + " public " + <nl> + ( field . required ? " " : GenNullableAnnotation ( field . value . type ) ) + <nl> + GenPureAnnotation ( field . value . type ) + type_name_dest + optional + <nl> + " " + MakeCamel ( field . name , false ) ; <nl> + std : : string obj = " obj " ; <nl> + <nl> + / / Most field accessors need to retrieve and test the field offset first , <nl> + / / this is the prefix code for that : <nl> + auto offset_prefix = <nl> + IsArray ( field . value . type ) <nl> + ? " { return " <nl> + : ( " { int o = __offset ( " + NumToString ( field . value . offset ) + <nl> + " ) ; return o ! = 0 ? " ) ; <nl> + / / Generate the accessors that don ' t do object reuse . <nl> + if ( field . value . type . base_type = = BASE_TYPE_STRUCT ) { <nl> + / / Calls the accessor that takes an accessor object with a new object . <nl> + code + = method_start + " ( ) { return " ; <nl> + code + = MakeCamel ( field . name , false ) ; <nl> + code + = " ( new " ; <nl> + code + = type_name + " ( ) ) ; } \ n " ; <nl> + } else if ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + field . value . type . element = = BASE_TYPE_STRUCT ) { <nl> + / / Accessors for vectors of structs also take accessor objects , this <nl> + / / generates a variant without that argument . <nl> + code + = method_start + " ( int j ) { return " ; <nl> + code + = MakeCamel ( field . name , false ) ; <nl> + code + = " ( new " + type_name + " ( ) , j ) ; } \ n " ; <nl> + } <nl> + <nl> + std : : string getter = dest_cast + GenGetter ( field . value . type ) ; <nl> + code + = method_start ; <nl> + std : : string default_cast = " " ; <nl> + std : : string member_suffix = " ; " ; <nl> + if ( IsScalar ( field . value . type . base_type ) ) { <nl> + code + = " ( ) " ; <nl> + member_suffix + = " " ; <nl> + if ( struct_def . fixed ) { <nl> + code + = " { return " + getter ; <nl> + code + = " ( bb_pos + " ; <nl> + code + = NumToString ( field . value . offset ) + " ) " ; <nl> + code + = dest_mask ; <nl> + } else { <nl> + code + = offset_prefix + getter ; <nl> + code + = " ( o + bb_pos ) " + dest_mask ; <nl> + code + = " : " + default_cast ; <nl> + code + = GenDefaultValue ( field ) ; <nl> + } <nl> + } else { <nl> + switch ( field . value . type . base_type ) { <nl> + case BASE_TYPE_STRUCT : <nl> + code + = " ( " + type_name + " obj ) " ; <nl> + if ( struct_def . fixed ) { <nl> + code + = " { return " + obj + " . __assign ( " ; <nl> + code + = " bb_pos + " + NumToString ( field . value . offset ) + " , " ; <nl> + code + = " bb ) " ; <nl> + } else { <nl> + code + = offset_prefix + conditional_cast ; <nl> + code + = obj + " . __assign ( " ; <nl> + code + = field . value . type . struct_def - > fixed <nl> + ? " o + bb_pos " <nl> + : " __indirect ( o + bb_pos ) " ; <nl> + code + = " , bb ) : null " ; <nl> + } <nl> + break ; <nl> + case BASE_TYPE_STRING : <nl> + code + = " ( ) " ; <nl> + member_suffix + = " " ; <nl> + code + = offset_prefix + getter + " ( o + " ; <nl> + code + = " bb_pos ) : null " ; <nl> + break ; <nl> + case BASE_TYPE_ARRAY : FLATBUFFERS_FALLTHROUGH ( ) ; / / fall thru <nl> + case BASE_TYPE_VECTOR : { <nl> + auto vectortype = field . value . type . VectorType ( ) ; <nl> + code + = " ( " ; <nl> + if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> + code + = type_name + " obj , " ; <nl> + getter = obj + " . __assign " ; <nl> + } else if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> + code + = type_name + " obj , " ; <nl> + } <nl> + code + = " int j ) " ; <nl> + const auto body = offset_prefix + conditional_cast + getter + " ( " ; <nl> + if ( vectortype . base_type = = BASE_TYPE_UNION ) { <nl> + code + = body + " obj , " ; <nl> + } else { <nl> + code + = body ; <nl> + } <nl> + std : : string index ; <nl> + if ( IsArray ( field . value . type ) ) { <nl> + index + = " bb_pos + " + NumToString ( field . value . offset ) + " + " ; <nl> + } else { <nl> + index + = " __vector ( o ) + " ; <nl> + } <nl> + index + = " j * " + NumToString ( InlineSize ( vectortype ) ) ; <nl> + if ( vectortype . base_type = = BASE_TYPE_STRUCT ) { <nl> + code + = vectortype . struct_def - > fixed <nl> + ? index <nl> + : " __indirect ( " + index + " ) " ; <nl> + code + = " , bb " ; <nl> + } else { <nl> + code + = index ; <nl> + } <nl> + code + = " ) " + dest_mask ; <nl> + if ( ! IsArray ( field . value . type ) ) { <nl> + code + = " : " ; <nl> + code + = <nl> + field . value . type . element = = BASE_TYPE_BOOL <nl> + ? " false " <nl> + : ( IsScalar ( field . value . type . element ) ? default_cast + " 0 " <nl> + : " null " ) ; <nl> + } <nl> + <nl> + break ; <nl> + } <nl> + case BASE_TYPE_UNION : <nl> + code + = " ( " + type_name + " obj ) " + offset_prefix + getter ; <nl> + code + = " ( obj , o + bb_pos ) : null " ; <nl> + break ; <nl> + default : FLATBUFFERS_ASSERT ( 0 ) ; <nl> + } <nl> + } <nl> + code + = member_suffix ; <nl> + code + = " } \ n " ; <nl> + if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + code + = " public int " + MakeCamel ( field . name , false ) ; <nl> + code + = " Length " ; <nl> + code + = " ( ) " ; <nl> + code + = offset_prefix ; <nl> + code + = " __vector_len ( o ) : 0 ; " ; <nl> + code + = " " ; <nl> + code + = " } \ n " ; <nl> + / / See if we should generate a by - key accessor . <nl> + if ( field . value . type . element = = BASE_TYPE_STRUCT & & <nl> + ! field . value . type . struct_def - > fixed ) { <nl> + auto & sd = * field . value . type . struct_def ; <nl> + auto & fields = sd . fields . vec ; <nl> + for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> + auto & key_field = * * kit ; <nl> + if ( key_field . key ) { <nl> + auto qualified_name = WrapInNameSpace ( sd ) ; <nl> + code + = " public " + qualified_name + " " ; <nl> + code + = MakeCamel ( field . name , false ) + " ByKey ( " ; <nl> + code + = GenTypeNameDest ( key_field . value . type ) + " key ) " ; <nl> + code + = offset_prefix ; <nl> + code + = qualified_name + " . __lookup_by_key ( " ; <nl> + code + = " null , " ; <nl> + code + = " __vector ( o ) , key , " ; <nl> + code + = " bb ) : null ; " ; <nl> + code + = " } \ n " ; <nl> + code + = " public " + qualified_name + " " ; <nl> + code + = MakeCamel ( field . name , false ) + " ByKey ( " ; <nl> + code + = qualified_name + " obj , " ; <nl> + code + = GenTypeNameDest ( key_field . value . type ) + " key ) " ; <nl> + code + = offset_prefix ; <nl> + code + = qualified_name + " . __lookup_by_key ( obj , " ; <nl> + code + = " __vector ( o ) , key , " ; <nl> + code + = " bb ) : null ; " ; <nl> + code + = " } \ n " ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + / / Generate the accessors for vector of structs with vector access object <nl> + if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + std : : string vector_type_name ; <nl> + const auto & element_base_type = field . value . type . VectorType ( ) . base_type ; <nl> + if ( IsScalar ( element_base_type ) ) { <nl> + vector_type_name = MakeCamel ( type_name , true ) + " Vector " ; <nl> + } else if ( element_base_type = = BASE_TYPE_STRING ) { <nl> + vector_type_name = " StringVector " ; <nl> + } else if ( element_base_type = = BASE_TYPE_UNION ) { <nl> + vector_type_name = " UnionVector " ; <nl> + } else { <nl> + vector_type_name = type_name + " . Vector " ; <nl> + } <nl> + auto vector_method_start = GenNullableAnnotation ( field . value . type ) + <nl> + " public " + vector_type_name + optional + <nl> + " " + MakeCamel ( field . name , false ) + <nl> + " Vector " ; <nl> + code + = vector_method_start + " ( ) { return " ; <nl> + code + = MakeCamel ( field . name , false ) + " Vector " ; <nl> + code + = " ( new " + vector_type_name + " ( ) ) ; } \ n " ; <nl> + code + = vector_method_start + " ( " + vector_type_name + " obj ) " ; <nl> + code + = offset_prefix + conditional_cast + obj + " . __assign ( " ; <nl> + code + = " __vector ( o ) , " ; <nl> + if ( ! IsScalar ( element_base_type ) ) { <nl> + auto vectortype = field . value . type . VectorType ( ) ; <nl> + code + = NumToString ( InlineSize ( vectortype ) ) + " , " ; <nl> + } <nl> + code + = " bb ) : null " + member_suffix + " } \ n " ; <nl> + } <nl> + / / Generate a ByteBuffer accessor for strings & vectors of scalars . <nl> + if ( ( field . value . type . base_type = = BASE_TYPE_VECTOR & & <nl> + IsScalar ( field . value . type . VectorType ( ) . base_type ) ) | | <nl> + field . value . type . base_type = = BASE_TYPE_STRING ) { <nl> + code + = " public ByteBuffer " ; <nl> + code + = MakeCamel ( field . name , false ) ; <nl> + code + = " AsByteBuffer ( ) { return " ; <nl> + code + = " __vector_as_bytebuffer ( " ; <nl> + code + = NumToString ( field . value . offset ) + " , " ; <nl> + code + = NumToString ( field . value . type . base_type = = BASE_TYPE_STRING <nl> + ? 1 <nl> + : InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> + code + = " ) ; } \ n " ; <nl> + code + = " public ByteBuffer " ; <nl> + code + = MakeCamel ( field . name , false ) ; <nl> + code + = " InByteBuffer ( ByteBuffer _bb ) { return " ; <nl> + code + = " __vector_in_bytebuffer ( _bb , " ; <nl> + code + = NumToString ( field . value . offset ) + " , " ; <nl> + code + = NumToString ( field . value . type . base_type = = BASE_TYPE_STRING <nl> + ? 1 <nl> + : InlineSize ( field . value . type . VectorType ( ) ) ) ; <nl> + code + = " ) ; } \ n " ; <nl> + } <nl> + / / generate object accessors if is nested_flatbuffer <nl> + if ( field . nested_flatbuffer ) { <nl> + auto nested_type_name = WrapInNameSpace ( * field . nested_flatbuffer ) ; <nl> + auto nested_method_name = <nl> + MakeCamel ( field . name , false ) + " As " + field . nested_flatbuffer - > name ; <nl> + auto get_nested_method_name = nested_method_name ; <nl> + code + = " public " + nested_type_name + " " ; <nl> + code + = nested_method_name + " ( ) { return " ; <nl> + code + = <nl> + get_nested_method_name + " ( new " + nested_type_name + " ( ) ) ; } \ n " ; <nl> + code + = " public " + nested_type_name + " " ; <nl> + code + = get_nested_method_name + " ( " ; <nl> + code + = nested_type_name + " obj " ; <nl> + code + = " ) { int o = __offset ( " ; <nl> + code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> + code + = " return o ! = 0 ? " + conditional_cast + obj + " . __assign ( " ; <nl> + code + = " " ; <nl> + code + = " __indirect ( __vector ( o ) ) , " ; <nl> + code + = " bb ) : null ; } \ n " ; <nl> + } <nl> + / / Generate mutators for scalar fields or vectors of scalars . <nl> + if ( parser_ . opts . mutable_buffer ) { <nl> + auto is_series = ( IsSeries ( field . value . type ) ) ; <nl> + const auto & underlying_type = <nl> + is_series ? field . value . type . VectorType ( ) : field . value . type ; <nl> + / / Boolean parameters have to be explicitly converted to byte <nl> + / / representation . <nl> + auto setter_parameter = underlying_type . base_type = = BASE_TYPE_BOOL <nl> + ? " ( byte ) ( " + field . name + " ? 1 : 0 ) " <nl> + : field . name ; <nl> + auto mutator_prefix = MakeCamel ( " mutate " , false ) ; <nl> + / / A vector mutator also needs the index of the vector element it should <nl> + / / mutate . <nl> + auto mutator_params = ( is_series ? " ( int j , " : " ( " ) + <nl> + GenTypeNameDest ( underlying_type ) + " " + <nl> + field . name + " ) { " ; <nl> + auto setter_index = <nl> + is_series <nl> + ? ( IsArray ( field . value . type ) <nl> + ? " bb_pos + " + NumToString ( field . value . offset ) <nl> + : " __vector ( o ) " ) + <nl> + + " + j * " + NumToString ( InlineSize ( underlying_type ) ) <nl> + : ( struct_def . fixed <nl> + ? " bb_pos + " + NumToString ( field . value . offset ) <nl> + : " o + bb_pos " ) ; <nl> + if ( IsScalar ( underlying_type . base_type ) & & ! IsUnion ( field . value . type ) ) { <nl> + code + = " public " ; <nl> + code + = struct_def . fixed ? " void " : " boolean " ; <nl> + code + = mutator_prefix + MakeCamel ( field . name , true ) ; <nl> + code + = mutator_params ; <nl> + if ( struct_def . fixed ) { <nl> + code + = GenSetter ( underlying_type ) + " ( " + setter_index + " , " ; <nl> + code + = src_cast + setter_parameter + " ) ; } \ n " ; <nl> + } else { <nl> + code + = " int o = __offset ( " ; <nl> + code + = NumToString ( field . value . offset ) + " ) ; " ; <nl> + code + = " if ( o ! = 0 ) { " + GenSetter ( underlying_type ) ; <nl> + code + = " ( " + setter_index + " , " + src_cast + setter_parameter + <nl> + " ) ; return true ; } else { return false ; } } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + if ( parser_ . opts . java_primitive_has_method & & <nl> + IsScalar ( field . value . type . base_type ) & & ! struct_def . fixed ) { <nl> + auto vt_offset_constant = " public static final int VT_ " + <nl> + MakeScreamingCamel ( field . name ) + " = " + <nl> + NumToString ( field . value . offset ) + " ; " ; <nl> + <nl> + code + = vt_offset_constant ; <nl> + code + = " \ n " ; <nl> + } <nl> + } <nl> + code + = " \ n " ; <nl> + flatbuffers : : FieldDef * key_field = nullptr ; <nl> + if ( struct_def . fixed ) { <nl> + / / create a struct constructor function <nl> + code + = " public static " + GenOffsetType ( ) + " " ; <nl> + code + = " create " ; <nl> + code + = struct_def . name + " ( FlatBufferBuilder builder " ; <nl> + GenStructArgs ( struct_def , code_ptr , " " ) ; <nl> + code + = " ) { \ n " ; <nl> + GenStructBody ( struct_def , code_ptr , " " ) ; <nl> + code + = " return " ; <nl> + code + = GenOffsetConstruct ( " builder . " + std : : string ( " offset ( ) " ) ) ; <nl> + code + = " ; \ n } \ n " ; <nl> + } else { <nl> + / / Generate a method that creates a table in one go . This is only possible <nl> + / / when the table has no struct fields , since those have to be created <nl> + / / inline , and there ' s no way to do so in Java . <nl> + bool has_no_struct_fields = true ; <nl> + int num_fields = 0 ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + if ( IsStruct ( field . value . type ) ) { <nl> + has_no_struct_fields = false ; <nl> + } else { <nl> + num_fields + + ; <nl> + } <nl> + } <nl> + / / JVM specifications restrict default constructor params to be < 255 . <nl> + / / Longs and doubles take up 2 units , so we set the limit to be < 127 . <nl> + if ( has_no_struct_fields & & num_fields & & num_fields < 127 ) { <nl> + / / Generate a table constructor of the form : <nl> + / / public static int createName ( FlatBufferBuilder builder , args . . . ) <nl> + code + = " public static " + GenOffsetType ( ) + " " ; <nl> + code + = " create " + struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + code + = " , \ n " ; <nl> + code + = GenTypeBasic ( DestinationType ( field . value . type , false ) ) ; <nl> + code + = " " ; <nl> + code + = field . name ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> + } <nl> + code + = " ) { \ n builder . " ; <nl> + code + = " startTable ( " ; <nl> + code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; \ n " ; <nl> + for ( size_t size = struct_def . sortbysize ? sizeof ( largest_scalar_t ) : 1 ; <nl> + size ; size / = 2 ) { <nl> + for ( auto it = struct_def . fields . vec . rbegin ( ) ; <nl> + it ! = struct_def . fields . vec . rend ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( ! field . deprecated & & <nl> + ( ! struct_def . sortbysize | | <nl> + size = = SizeOf ( field . value . type . base_type ) ) ) { <nl> + code + = " " + struct_def . name + " . " ; <nl> + code + = " add " ; <nl> + code + = MakeCamel ( field . name ) + " ( builder , " + field . name ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) code + = " Offset " ; <nl> + code + = " ) ; \ n " ; <nl> + } <nl> + } <nl> + } <nl> + code + = " return " + struct_def . name + " . " ; <nl> + code + = " end " + struct_def . name ; <nl> + code + = " ( builder ) ; \ n } \ n \ n " ; <nl> + } <nl> + / / Generate a set of static methods that allow table construction , <nl> + / / of the form : <nl> + / / public static void addName ( FlatBufferBuilder builder , short name ) <nl> + / / { builder . addShort ( id , name , default ) ; } <nl> + / / Unlike the Create function , these always work . <nl> + code + = " public static void start " ; <nl> + code + = struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder ) { builder . " ; <nl> + code + = " startTable ( " ; <nl> + code + = NumToString ( struct_def . fields . vec . size ( ) ) + " ) ; } \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( field . deprecated ) continue ; <nl> + if ( field . key ) key_field = & field ; <nl> + code + = " public static void add " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " ( FlatBufferBuilder builder , " ; <nl> + code + = GenTypeBasic ( DestinationType ( field . value . type , false ) ) ; <nl> + auto argname = MakeCamel ( field . name , false ) ; <nl> + if ( ! IsScalar ( field . value . type . base_type ) ) argname + = " Offset " ; <nl> + code + = " " + argname + " ) { builder . add " ; <nl> + code + = GenMethod ( field . value . type ) + " ( " ; <nl> + code + = NumToString ( it - struct_def . fields . vec . begin ( ) ) + " , " ; <nl> + code + = SourceCastBasic ( field . value . type ) ; <nl> + code + = argname ; <nl> + code + = " , " ; <nl> + code + = SourceCastBasic ( field . value . type ) ; <nl> + code + = GenDefaultValue ( field ) ; <nl> + code + = " ) ; } \ n " ; <nl> + if ( field . value . type . base_type = = BASE_TYPE_VECTOR ) { <nl> + auto vector_type = field . value . type . VectorType ( ) ; <nl> + auto alignment = InlineAlignment ( vector_type ) ; <nl> + auto elem_size = InlineSize ( vector_type ) ; <nl> + if ( ! IsStruct ( vector_type ) ) { <nl> + / / generate a method to create a vector from a java array . <nl> + if ( ( vector_type . base_type = = BASE_TYPE_CHAR | | <nl> + vector_type . base_type = = BASE_TYPE_UCHAR ) ) { <nl> + / / Handle byte [ ] and ByteBuffers separately for Java <nl> + code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> + code + = " create " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , byte [ ] data ) " ; <nl> + code + = " { return builder . createByteVector ( data ) ; } \ n " ; <nl> + <nl> + code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> + code + = " create " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , ByteBuffer data ) " ; <nl> + code + = " { return builder . createByteVector ( data ) ; } \ n " ; <nl> + } else { <nl> + code + = " public static " + GenVectorOffsetType ( ) + " " ; <nl> + code + = " create " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , " ; <nl> + code + = GenTypeBasic ( vector_type ) + " [ ] data ) " ; <nl> + code + = " { builder . startVector ( " ; <nl> + code + = NumToString ( elem_size ) ; <nl> + code + = " , data . length , " ; <nl> + code + = NumToString ( alignment ) ; <nl> + code + = " ) ; for ( int i = data . " ; <nl> + code + = " length - 1 ; i > = 0 ; i - - ) builder . " ; <nl> + code + = " add " ; <nl> + code + = GenMethod ( vector_type ) ; <nl> + code + = " ( " ; <nl> + code + = SourceCastBasic ( vector_type , false ) ; <nl> + code + = " data [ i ] " ; <nl> + code + = " ) ; return " ; <nl> + code + = " builder . endVector ( ) ; } \ n " ; <nl> + } <nl> + } <nl> + / / Generate a method to start a vector , data to be added manually <nl> + / / after . <nl> + code + = " public static void start " ; <nl> + code + = MakeCamel ( field . name ) ; <nl> + code + = " Vector ( FlatBufferBuilder builder , int numElems ) " ; <nl> + code + = " { builder . startVector ( " ; <nl> + code + = NumToString ( elem_size ) ; <nl> + code + = " , numElems , " + NumToString ( alignment ) ; <nl> + code + = " ) ; } \ n " ; <nl> + } <nl> + } <nl> + code + = " public static " + GenOffsetType ( ) + " " ; <nl> + code + = " end " + struct_def . name ; <nl> + code + = " ( FlatBufferBuilder builder ) { \ n int o = builder . " ; <nl> + code + = " endTable ( ) ; \ n " ; <nl> + for ( auto it = struct_def . fields . vec . begin ( ) ; <nl> + it ! = struct_def . fields . vec . end ( ) ; + + it ) { <nl> + auto & field = * * it ; <nl> + if ( ! field . deprecated & & field . required ) { <nl> + code + = " builder . required ( o , " ; <nl> + code + = NumToString ( field . value . offset ) ; <nl> + code + = " ) ; / / " + field . name + " \ n " ; <nl> + } <nl> + } <nl> + code + = " return " + GenOffsetConstruct ( " o " ) + " ; \ n } \ n " ; <nl> + if ( parser_ . root_struct_def_ = = & struct_def ) { <nl> + std : : string size_prefix [ ] = { " " , " SizePrefixed " } ; <nl> + for ( int i = 0 ; i < 2 ; + + i ) { <nl> + code + = " public static void " ; <nl> + code + = " finish " + size_prefix [ i ] + struct_def . name ; <nl> + code + = " Buffer ( FlatBufferBuilder builder , " + GenOffsetType ( ) ; <nl> + code + = " offset ) { " ; <nl> + code + = " builder . finish " + size_prefix [ i ] + <nl> + " ( offset " ; <nl> + <nl> + if ( parser_ . file_identifier_ . length ( ) ) <nl> + code + = " , \ " " + parser_ . file_identifier_ + " \ " " ; <nl> + code + = " ) ; } \ n " ; <nl> + } <nl> + } <nl> + } <nl> + / / Only generate key compare function for table , <nl> + / / because ` key_field ` is not set for struct <nl> + if ( struct_def . has_key & & ! struct_def . fixed ) { <nl> + FLATBUFFERS_ASSERT ( key_field ) ; <nl> + code + = " \ n @ Override \ n protected int keysCompare ( " ; <nl> + code + = " Integer o1 , Integer o2 , ByteBuffer _bb ) { " ; <nl> + code + = GenKeyGetter ( key_field ) ; <nl> + code + = " } \ n " ; <nl> + <nl> + code + = " \ n public static " + struct_def . name ; <nl> + code + = " __lookup_by_key ( " ; <nl> + code + = struct_def . name + " obj , " ; <nl> + code + = " int vectorLocation , " ; <nl> + code + = GenTypeNameDest ( key_field - > value . type ) ; <nl> + code + = " key , ByteBuffer bb ) { \ n " ; <nl> + if ( key_field - > value . type . base_type = = BASE_TYPE_STRING ) { <nl> + code + = " byte [ ] byteKey = " ; <nl> + code + = " key . getBytes ( Table . UTF8_CHARSET . get ( ) ) ; \ n " ; <nl> + } <nl> + code + = " int span = " ; <nl> + code + = " bb . getInt ( vectorLocation - 4 ) ; \ n " ; <nl> + code + = " int start = 0 ; \ n " ; <nl> + code + = " while ( span ! = 0 ) { \ n " ; <nl> + code + = " int middle = span / 2 ; \ n " ; <nl> + code + = GenLookupKeyGetter ( key_field ) ; <nl> + code + = " if ( comp > 0 ) { \ n " ; <nl> + code + = " span = middle ; \ n " ; <nl> + code + = " } else if ( comp < 0 ) { \ n " ; <nl> + code + = " middle + + ; \ n " ; <nl> + code + = " start + = middle ; \ n " ; <nl> + code + = " span - = middle ; \ n " ; <nl> + code + = " } else { \ n " ; <nl> + code + = " return " ; <nl> + code + = " ( obj = = null ? new " + struct_def . name + " ( ) : obj ) " ; <nl> + code + = " . __assign ( tableOffset , bb ) ; \ n " ; <nl> + code + = " } \ n } \ n " ; <nl> + code + = " return null ; \ n " ; <nl> + code + = " } \ n " ; <nl> + } <nl> + GenVectorAccessObject ( struct_def , code_ptr ) ; <nl> + code + = " } " ; <nl> + code + = " \ n \ n " ; <nl> + } <nl> + <nl> + void GenVectorAccessObject ( StructDef & struct_def , <nl> + std : : string * code_ptr ) const { <nl> + auto & code = * code_ptr ; <nl> + / / Generate a vector of structs accessor class . <nl> + code + = " \ n " ; <nl> + code + = " " ; <nl> + if ( ! struct_def . attributes . Lookup ( " private " ) ) code + = " public " ; <nl> + code + = " static " ; <nl> + code + = " final " ; <nl> + code + = " class Vector extends " ; <nl> + code + = " BaseVector { \ n " ; <nl> + <nl> + / / Generate the __assign method that sets the field in a pre - existing <nl> + / / accessor object . This is to allow object reuse . <nl> + std : : string method_indent = " " ; <nl> + code + = method_indent + " public Vector " ; <nl> + code + = " __assign ( int _vector , int _element_size , ByteBuffer _bb ) { " ; <nl> + code + = " __reset ( _vector , _element_size , _bb ) ; return this ; } \ n \ n " ; <nl> + <nl> + auto type_name = struct_def . name ; <nl> + auto method_start = <nl> + method_indent + " public " + type_name + " get " ; <nl> + / / Generate the accessors that don ' t do object reuse . <nl> + code + = method_start + " ( int j ) { return get " ; <nl> + code + = " ( new " + type_name + " ( ) , j ) ; } \ n " ; <nl> + code + = method_start + " ( " + type_name + " obj , int j ) { " ; <nl> + code + = " return obj . __assign ( " ; <nl> + std : : string index = " __element ( j ) " ; <nl> + code + = struct_def . fixed ? index : " __indirect ( " + index + " , bb ) " ; <nl> + code + = " , bb ) ; } \ n " ; <nl> + / / See if we should generate a by - key accessor . <nl> + if ( ! struct_def . fixed ) { <nl> + auto & fields = struct_def . fields . vec ; <nl> + for ( auto kit = fields . begin ( ) ; kit ! = fields . end ( ) ; + + kit ) { <nl> + auto & key_field = * * kit ; <nl> + if ( key_field . key ) { <nl> + auto nullable_annotation = <nl> + parser_ . opts . gen_nullable ? " @ Nullable " : " " ; <nl> + code + = method_indent + nullable_annotation ; <nl> + code + = " public " + type_name + " " ; <nl> + code + = " getByKey ( " ; <nl> + code + = GenTypeNameDest ( key_field . value . type ) + " key ) { " ; <nl> + code + = " return __lookup_by_key ( null , " ; <nl> + code + = " __vector ( ) , key , " ; <nl> + code + = " bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + code + = method_indent + nullable_annotation ; <nl> + code + = " public " + type_name + " " ; <nl> + code + = " getByKey ( " ; <nl> + code + = type_name + " obj , " ; <nl> + code + = GenTypeNameDest ( key_field . value . type ) + " key ) { " ; <nl> + code + = " return __lookup_by_key ( obj , " ; <nl> + code + = " __vector ( ) , key , " ; <nl> + code + = " bb ) ; " ; <nl> + code + = " } \ n " ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + code + = " } \ n " ; <nl> + } <nl> + <nl> + / / This tracks the current namespace used to determine if a type need to be <nl> + / / prefixed by its namespace <nl> + const Namespace * cur_name_space_ ; <nl> + } ; <nl> + } / / namespace java <nl> + <nl> + bool GenerateJava ( const Parser & parser , const std : : string & path , <nl> + const std : : string & file_name ) { <nl> + java : : JavaGenerator generator ( parser , path , file_name ) ; <nl> + return generator . generate ( ) ; <nl> + } <nl> + <nl> + } / / namespace flatbuffers <nl>
|
[ C + + , C # , Java ] Separated C # and Java generators into their own classes ( )
|
google/flatbuffers
|
adbcbba5d14771e4e4f2d2377cc05b59d43c1764
|
2019-11-11T19:37:55Z
|
mmm a / ReactNative / ReactNative . csproj <nl> ppp b / ReactNative / ReactNative . csproj <nl> <nl> < Compile Include = " UIManager \ BorderedContentControl . cs " / > <nl> < Compile Include = " UIManager \ ColorHelpers . cs " / > <nl> < Compile Include = " UIManager \ CSSNodeExtensions . cs " / > <nl> + < Compile Include = " UIManager \ DependencyProperties . cs " / > <nl> < Compile Include = " UIManager \ Events \ IOnIntercepTextGotFocusEventListener . cs " / > <nl> < Compile Include = " UIManager \ Events \ IOnInterceptTextInputEventListener . cs " / > <nl> < Compile Include = " LifecycleState . cs " / > <nl> mmm a / ReactNative / UIManager / BorderedContentControl . cs <nl> ppp b / ReactNative / UIManager / BorderedContentControl . cs <nl> <nl> using Facebook . CSSLayout ; <nl> - using System . Diagnostics ; <nl> using System . Numerics ; <nl> using Windows . Foundation ; <nl> - using Windows . Foundation . Numerics ; <nl> using Windows . UI ; <nl> using Windows . UI . Xaml ; <nl> using Windows . UI . Xaml . Controls ; <nl> using Windows . UI . Xaml . Media ; <nl> - using Vector2 = System . Numerics . Vector2 ; <nl> <nl> namespace ReactNative . UIManager <nl> { <nl> / / / < summary > <nl> / / / A single child control for managing a border . <nl> / / / < / summary > <nl> - public class BorderedContentControl : ContentControl <nl> + public partial class BorderedContentControl : ContentControl <nl> { <nl> - # region DependencyProperties <nl> - public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty . Register ( " CornerRadius " , <nl> - typeof ( CornerRadius ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public CornerRadius CornerRadius <nl> - { <nl> - get { return ( CornerRadius ) GetValue ( CornerRadiusProperty ) ; } <nl> - set { SetValue ( CornerRadiusProperty , value ) ; } <nl> - } <nl> - # region Left Border <nl> - public static readonly DependencyProperty LeftBorderGeometryProperty = DependencyProperty . Register ( " LeftBorderGeometry " , <nl> - typeof ( GeometryGroup ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public GeometryGroup LeftBorderGeometry <nl> - { <nl> - get { return ( GeometryGroup ) GetValue ( LeftBorderGeometryProperty ) ; } <nl> - set { SetValue ( LeftBorderGeometryProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty LeftBorderThicknessProperty = DependencyProperty . Register ( " LeftBorderThickness " , <nl> - typeof ( double ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public double LeftBorderThickness <nl> - { <nl> - get { return ( double ) GetValue ( LeftBorderThicknessProperty ) ; } <nl> - set { SetValue ( LeftBorderThicknessProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty LeftBorderBrushProperty = DependencyProperty . Register ( " LeftBorderBrush " , <nl> - typeof ( Brush ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( new SolidColorBrush ( Colors . Black ) ) ) ; <nl> - <nl> - public Brush LeftBorderBrush <nl> - { <nl> - get { return ( Brush ) GetValue ( LeftBorderBrushProperty ) ; } <nl> - set { SetValue ( LeftBorderBrushProperty , value ) ; } <nl> - } <nl> - # endregion <nl> - <nl> - # region TopBorder <nl> - public static readonly DependencyProperty TopBorderGeometryProperty = DependencyProperty . Register ( " TopBorderGeometry " , <nl> - typeof ( GeometryGroup ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public GeometryGroup TopBorderGeometry <nl> - { <nl> - get { return ( GeometryGroup ) GetValue ( TopBorderGeometryProperty ) ; } <nl> - set { SetValue ( TopBorderGeometryProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty TopBorderThicknessProperty = DependencyProperty . Register ( " TopBorderThickness " , <nl> - typeof ( double ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public double TopBorderThickness <nl> - { <nl> - get { return ( double ) GetValue ( TopBorderThicknessProperty ) ; } <nl> - set { SetValue ( TopBorderThicknessProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty TopBorderBrushProperty = DependencyProperty . Register ( " TopBorderBrush " , <nl> - typeof ( Brush ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( new SolidColorBrush ( Colors . Black ) ) ) ; <nl> - <nl> - public Brush TopBorderBrush <nl> - { <nl> - get { return ( Brush ) GetValue ( TopBorderBrushProperty ) ; } <nl> - set { SetValue ( TopBorderBrushProperty , value ) ; } <nl> - } <nl> - # endregion <nl> - <nl> - # region RightBorder <nl> - public static readonly DependencyProperty RightBorderGeometryProperty = DependencyProperty . Register ( " RightBorderGeometry " , <nl> - typeof ( GeometryGroup ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public GeometryGroup RightBorderGeometry <nl> - { <nl> - get { return ( GeometryGroup ) GetValue ( RightBorderGeometryProperty ) ; } <nl> - set { SetValue ( RightBorderGeometryProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty RightBorderThicknessProperty = DependencyProperty . Register ( " RightBorderThickness " , <nl> - typeof ( double ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public double RightBorderThickness <nl> - { <nl> - get { return ( double ) GetValue ( RightBorderThicknessProperty ) ; } <nl> - set { SetValue ( RightBorderThicknessProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty RightBorderBrushProperty = DependencyProperty . Register ( " RightBorderBrush " , <nl> - typeof ( Brush ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( new SolidColorBrush ( Colors . Black ) ) ) ; <nl> - <nl> - public Brush RightBorderBrush <nl> - { <nl> - get { return ( Brush ) GetValue ( RightBorderBrushProperty ) ; } <nl> - set { SetValue ( RightBorderBrushProperty , value ) ; } <nl> - } <nl> - # endregion <nl> - <nl> - # region BottomBorder <nl> - public static readonly DependencyProperty BottomBorderGeometryProperty = DependencyProperty . Register ( " BottomBorderGeometry " , <nl> - typeof ( GeometryGroup ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public GeometryGroup BottomBorderGeometry <nl> - { <nl> - get { return ( GeometryGroup ) GetValue ( BottomBorderGeometryProperty ) ; } <nl> - set { SetValue ( BottomBorderGeometryProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty BottomBorderThicknessProperty = DependencyProperty . Register ( " BottomBorderThickness " , <nl> - typeof ( double ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( null ) ) ; <nl> - <nl> - public double BottomBorderThickness <nl> - { <nl> - get { return ( double ) GetValue ( BottomBorderThicknessProperty ) ; } <nl> - set { SetValue ( BottomBorderThicknessProperty , value ) ; } <nl> - } <nl> - <nl> - public static readonly DependencyProperty BottomBorderBrushProperty = DependencyProperty . Register ( " BottomBorderBrush " , <nl> - typeof ( Brush ) , <nl> - typeof ( BorderedContentControl ) , <nl> - new PropertyMetadata ( new SolidColorBrush ( Colors . Black ) ) ) ; <nl> - <nl> - public Brush BottomBorderBrush <nl> - { <nl> - get { return ( Brush ) GetValue ( BottomBorderBrushProperty ) ; } <nl> - set { SetValue ( BottomBorderBrushProperty , value ) ; } <nl> - } <nl> - # endregion <nl> - # endregion <nl> - <nl> / / / < summary > <nl> / / / Instantiates the < see cref = " BorderedContentControl " / > . <nl> / / / < / summary > <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> var leftGeometry = new GeometryGroup ( ) ; <nl> <nl> / / upper left lower corner <nl> - leftGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( upperLeftLowerPoint , <nl> + leftGeometry . Children . Add ( CreateCornerGeometry ( upperLeftLowerPoint , <nl> upperLeftUpperPoint , <nl> upperLeftCenterPoint , <nl> - CornerRadius . TopLeft , SweepDirection . Clockwise ) <nl> - } ) ; <nl> + CornerRadius . TopLeft , <nl> + SweepDirection . Clockwise ) ) ; <nl> <nl> leftGeometry . Children . Add ( new LineGeometry ( ) { StartPoint = upperLeftLowerPoint , <nl> EndPoint = lowerLeftUpperPoint <nl> } ) ; <nl> <nl> / / lower left upper half <nl> - leftGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( lowerLeftUpperPoint , <nl> + leftGeometry . Children . Add ( CreateCornerGeometry ( lowerLeftUpperPoint , <nl> lowerLeftLowerPoint , <nl> lowerLeftCenterPoint , <nl> - CornerRadius . BottomLeft , SweepDirection . Counterclockwise ) <nl> - } ) ; <nl> + CornerRadius . BottomLeft , <nl> + SweepDirection . Counterclockwise ) ) ; <nl> <nl> LeftBorderGeometry = leftGeometry ; <nl> <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> var topGeometry = new GeometryGroup ( ) ; <nl> <nl> / / upper left upper half <nl> - topGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( upperLeftUpperPoint , <nl> + topGeometry . Children . Add ( CreateCornerGeometry ( upperLeftUpperPoint , <nl> upperLeftLowerPoint , <nl> upperLeftCenterPoint , <nl> - CornerRadius . TopLeft , SweepDirection . Counterclockwise ) <nl> - } ) ; <nl> + CornerRadius . TopLeft , <nl> + SweepDirection . Counterclockwise ) ) ; <nl> <nl> topGeometry . Children . Add ( new LineGeometry ( ) <nl> { <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> } ) ; <nl> <nl> / / upper right upper half <nl> - topGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( upperRightUpperPoint , <nl> + topGeometry . Children . Add ( CreateCornerGeometry ( upperRightUpperPoint , <nl> upperRightLowerPoint , <nl> upperRightCenterPoint , <nl> - CornerRadius . TopRight , SweepDirection . Clockwise ) <nl> - } ) ; <nl> + CornerRadius . TopRight , <nl> + SweepDirection . Clockwise ) ) ; <nl> <nl> TopBorderGeometry = topGeometry ; <nl> <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> var rightGeometry = new GeometryGroup ( ) ; <nl> <nl> / / upper right lower half <nl> - rightGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( upperRightLowerPoint , <nl> + rightGeometry . Children . Add ( CreateCornerGeometry ( upperRightLowerPoint , <nl> upperRightUpperPoint , <nl> upperRightCenterPoint , <nl> - CornerRadius . TopRight , SweepDirection . Counterclockwise ) <nl> - } ) ; <nl> + CornerRadius . TopRight , <nl> + SweepDirection . Counterclockwise ) ) ; <nl> <nl> rightGeometry . Children . Add ( new LineGeometry ( ) <nl> { <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> } ) ; <nl> <nl> / / lower right upper half <nl> - rightGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( lowerRightUpperPoint , <nl> + rightGeometry . Children . Add ( CreateCornerGeometry ( lowerRightUpperPoint , <nl> lowerRigthLowerPoint , <nl> lowerRightCenterPoint , <nl> - CornerRadius . BottomRight , SweepDirection . Clockwise ) <nl> - } ) ; <nl> + CornerRadius . BottomRight , <nl> + SweepDirection . Clockwise ) ) ; <nl> <nl> RightBorderGeometry = rightGeometry ; <nl> <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> var bottomGeometry = new GeometryGroup ( ) ; <nl> <nl> / / lower right lower half <nl> - bottomGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( lowerRigthLowerPoint , <nl> + bottomGeometry . Children . Add ( CreateCornerGeometry ( lowerRigthLowerPoint , <nl> lowerRightUpperPoint , <nl> lowerRightCenterPoint , <nl> - CornerRadius . BottomRight , SweepDirection . Counterclockwise ) <nl> - } ) ; <nl> + CornerRadius . BottomRight , <nl> + SweepDirection . Counterclockwise ) ) ; <nl> <nl> bottomGeometry . Children . Add ( new LineGeometry ( ) <nl> { <nl> private void LayoutBorderGeometry ( Size newSize ) <nl> } ) ; <nl> <nl> / / lower left lower half <nl> - bottomGeometry . Children . Add ( new PathGeometry <nl> - { <nl> - Figures = CreateFiguresForCorner ( lowerLeftLowerPoint , <nl> + bottomGeometry . Children . Add ( CreateCornerGeometry ( lowerLeftLowerPoint , <nl> lowerLeftUpperPoint , <nl> lowerLeftCenterPoint , <nl> - CornerRadius . BottomLeft , SweepDirection . Clockwise ) <nl> - } ) ; <nl> + CornerRadius . BottomLeft , <nl> + SweepDirection . Clockwise ) ) ; <nl> <nl> BottomBorderGeometry = bottomGeometry ; <nl> } <nl> <nl> - private PathFigureCollection CreateFiguresForCorner ( Point startPoint , Point endPoint , Point centerPoint , double radius , SweepDirection sweepDirection ) <nl> + private PathGeometry CreateCornerGeometry ( Point startPoint , Point endPoint , Point centerPoint , double radius , SweepDirection sweepDirection ) <nl> { <nl> - var figures = new PathFigureCollection ( ) ; <nl> - var figure = new PathFigure ( ) { StartPoint = startPoint } ; <nl> + var geometry = new PathGeometry ( ) ; <nl> + <nl> + var figure = new PathFigure ( ) { StartPoint = startPoint } ; <nl> if ( radius > 0 ) <nl> { <nl> - figure . Segments . Add ( GetArcSegment ( startPoint , endPoint , centerPoint , radius , sweepDirection ) ) ; <nl> + figure . Segments . Add ( CreateArcSegment ( startPoint , endPoint , centerPoint , radius , sweepDirection ) ) ; <nl> } <nl> else <nl> { <nl> - figure . Segments . Add ( new LineSegment ( ) { Point = endPoint } ) ; <nl> - / / figure . Segments . Add ( new QuadraticBezierSegment ( ) { Point1 = startPoint , Point2 = endPoint } ) ; <nl> + figure . Segments . Add ( new LineSegment ( ) { Point = endPoint } ) ; <nl> } <nl> - figures . Add ( figure ) ; <nl> - return figures ; <nl> + geometry . Figures . Add ( figure ) ; <nl> + return geometry ; <nl> } <nl> <nl> - private ArcSegment GetArcSegment ( Point startPoint , Point endPoint , Point centerPoint , double radius , SweepDirection sweepDirection ) <nl> + private ArcSegment CreateArcSegment ( Point startPoint , Point endPoint , Point centerPoint , double radius , SweepDirection sweepDirection ) <nl> { <nl> return new ArcSegment ( ) <nl> { <nl>
|
some code review cleanup
|
microsoft/react-native-windows
|
4be9867875f2f2530a2075f51847c67b286c7fde
|
2016-05-25T15:30:11Z
|
mmm a / tensorflow / python / eager / def_function . py <nl> ppp b / tensorflow / python / eager / def_function . py <nl> <nl> from tensorflow . python . eager import lift_to_graph <nl> from tensorflow . python . framework import func_graph as func_graph_module <nl> from tensorflow . python . framework import ops <nl> + from tensorflow . python . ops import array_ops <nl> from tensorflow . python . ops import control_flow_ops <nl> from tensorflow . python . ops import math_ops <nl> from tensorflow . python . ops import resource_variable_ops <nl> def function_spec ( self ) : <nl> def _initialize_uninitialized_variables ( self , initializers ) : <nl> " " " Make and call a ` ConcreteFunction ` which initializes variables . " " " <nl> <nl> + if not initializers : <nl> + return <nl> + <nl> # Note : using defun here avoids an infinite recursion . <nl> @ function_lib . defun <nl> def initialize_variables ( ) : <nl> op_map = object_identity . ObjectIdentityDictionary ( ) <nl> - for v , init in initializers : <nl> + # Stack all the var_is_initialized values into one tensor and intepret the <nl> + # numpy value . This will reduce the number of RPCs between client and <nl> + # worker in the remote case . <nl> + with ops . init_scope ( ) : <nl> + var_is_initialized = [ ] <nl> + for v , _ in initializers : <nl> + var_is_initialized . append ( <nl> + resource_variable_ops . var_is_initialized_op ( v . handle ) ) <nl> + var_is_initialized = array_ops . stack ( var_is_initialized ) . numpy ( ) <nl> + <nl> + for ( v , init ) , is_initialized in zip ( initializers , var_is_initialized ) : <nl> with ops . init_scope ( ) : <nl> - if resource_variable_ops . var_is_initialized_op ( v . handle ) : <nl> - # Ignore variables which are already initialized at trace time . <nl> + if is_initialized : <nl> continue <nl> + <nl> op_map = lift_to_graph . lift_to_graph ( <nl> [ init ] , ops . get_default_graph ( ) , op_map = op_map ) <nl> v . assign ( op_map [ init ] , read_value = False ) <nl> mmm a / tensorflow / python / eager / remote_benchmarks_test . py <nl> ppp b / tensorflow / python / eager / remote_benchmarks_test . py <nl> def run_benchmark ( func , num_iters , execution_mode = None ) : <nl> return end - start <nl> <nl> <nl> + class Foo ( object ) : <nl> + <nl> + def __init__ ( self , num_vars ) : <nl> + self . _num_vars = num_vars <nl> + self . _v = [ ] <nl> + <nl> + def __call__ ( self , inputs ) : <nl> + if not self . _v : <nl> + for _ in range ( self . _num_vars ) : <nl> + self . _v . append ( variables . Variable ( <nl> + random_ops . random_uniform ( [ ] ) , shape = [ ] ) ) <nl> + for v in self . _v : <nl> + inputs = inputs * v <nl> + return inputs <nl> + <nl> + <nl> class RemoteWorkerMicroBenchmarks ( test . Benchmark ) : <nl> <nl> def __init__ ( self ) : <nl> def func ( ) : <nl> # executed when their corresponding device and manager are still available . <nl> gc . collect ( ) <nl> <nl> + def benchmark_create_vars_inside_function ( self ) : <nl> + remote . connect_to_remote_host ( self . _cached_server_target1 ) <nl> + <nl> + def func ( ) : <nl> + with ops . device ( " job : worker / replica : 0 / task : 0 / device : CPU : 0 " ) : <nl> + layer = Foo ( 50 ) <nl> + <nl> + @ def_function . function <nl> + def remote_func ( ) : <nl> + with ops . device ( " job : worker / replica : 0 / task : 0 / device : CPU : 0 " ) : <nl> + return layer ( random_ops . random_uniform ( [ ] ) ) <nl> + <nl> + return remote_func ( ) <nl> + <nl> + self . _run ( func , execution_mode = context . ASYNC , num_iters = 100 ) <nl> + # NOTE ( b / 136184459 ) : Force garbage collecting hanging resources before <nl> + # subsequent calls to set_server_def , to ensure the destroy resource ops are <nl> + # executed when their corresponding device and manager are still available . <nl> + gc . collect ( ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> test . main ( ) <nl>
|
Improves function tracing time of variables created inside functions . In _initialize_uninitialized_variables , pack all variable_is_initialized ops into one tensor and convert it to numpy in one call , instead of checking remote variable_is_initialized op for each variable which introduces a lot of blocking RPCs .
|
tensorflow/tensorflow
|
66f1ac58e430142dc058c2c69b27f14ea61d51be
|
2019-10-03T00:28:12Z
|
mmm a / src / compiler / js - call - reducer . cc <nl> ppp b / src / compiler / js - call - reducer . cc <nl> Reduction JSCallReducer : : ReduceFunctionPrototypeBind ( Node * node ) { <nl> : native_context ( ) . bound_function_without_constructor_map ( ) ; <nl> if ( ! map . prototype ( ) . equals ( prototype ) ) return NoChange ( ) ; <nl> <nl> - / / Make sure we can rely on the { receiver_maps } . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = graph ( ) - > NewNode ( <nl> - simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , receiver_maps ) , receiver , <nl> - effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , VectorSlotPair ( ) , receiver , effect , control ) ; <nl> <nl> / / Replace the { node } with a JSCreateBoundFunction . <nl> int const arity = std : : max ( 0 , node - > op ( ) - > ValueInputCount ( ) - 3 ) ; <nl> Reduction JSCallReducer : : ReduceArrayForEach ( <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> Reduction JSCallReducer : : ReduceArrayForEach ( <nl> return Replace ( jsgraph ( ) - > UndefinedConstant ( ) ) ; <nl> } <nl> <nl> + Node * JSCallReducer : : InsertMapChecksIfUnreliableReceiverMaps ( <nl> + NodeProperties : : InferReceiverMapsResult result , <nl> + ZoneHandleSet < Map > const & receiver_maps , VectorSlotPair const & feedback , <nl> + Node * receiver , Node * effect , Node * control ) { <nl> + if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> + effect = graph ( ) - > NewNode ( <nl> + simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , receiver_maps , feedback ) , <nl> + receiver , effect , control ) ; <nl> + } <nl> + return effect ; <nl> + } <nl> + <nl> Reduction JSCallReducer : : ReduceArrayReduce ( <nl> Node * node , ArrayReduceDirection direction , <nl> const SharedFunctionInfoRef & shared ) { <nl> Reduction JSCallReducer : : ReduceArrayReduce ( <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * original_length = effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSArrayLength ( PACKED_ELEMENTS ) ) , <nl> Reduction JSCallReducer : : ReduceArrayReduce ( <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceArrayMap ( Node * node , <nl> <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * original_length = effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSArrayLength ( kind ) ) , receiver , <nl> Reduction JSCallReducer : : ReduceArrayMap ( Node * node , <nl> jsgraph ( ) - > Constant ( JSArray : : kMaxFastArrayLength ) , effect , control ) ; <nl> <nl> / / Even though { JSCreateArray } is not marked as { kNoThrow } , we can elide the <nl> - / / exceptional projections because it cannot throw with the given parameters . <nl> + / / exceptional projections because it cannot throw with the given <nl> + / / parameters . <nl> Node * a = control = effect = graph ( ) - > NewNode ( <nl> javascript ( ) - > CreateArray ( 1 , MaybeHandle < AllocationSite > ( ) ) , <nl> array_constructor , array_constructor , original_length , context , <nl> Reduction JSCallReducer : : ReduceArrayMap ( Node * node , <nl> & check_fail , & control ) ; <nl> } <nl> <nl> - / / The array { a } should be HOLEY_SMI_ELEMENTS because we ' d only come into this <nl> - / / loop if the input array length is non - zero , and " new Array ( { x > 0 } ) " always <nl> - / / produces a HOLEY array . <nl> + / / The array { a } should be HOLEY_SMI_ELEMENTS because we ' d only come into <nl> + / / this loop if the input array length is non - zero , and " new Array ( { x > 0 } ) " <nl> + / / always produces a HOLEY array . <nl> MapRef holey_double_map = <nl> native_context ( ) . GetInitialJSArrayMap ( HOLEY_DOUBLE_ELEMENTS ) ; <nl> MapRef holey_map = native_context ( ) . GetInitialJSArrayMap ( HOLEY_ELEMENTS ) ; <nl> Reduction JSCallReducer : : ReduceArrayMap ( Node * node , <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceArrayFilter ( <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> Node * to = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * a ; / / Construct the output array . <nl> { <nl> Reduction JSCallReducer : : ReduceArrayFilter ( <nl> graph ( ) - > NewNode ( common ( ) - > Checkpoint ( ) , frame_state , effect , control ) ; <nl> } <nl> <nl> - / / We have to coerce callback_value to boolean , and only store the element in <nl> - / / a if it ' s true . The checkpoint above protects against the case that <nl> + / / We have to coerce callback_value to boolean , and only store the element <nl> + / / in a if it ' s true . The checkpoint above protects against the case that <nl> / / growing { a } fails . <nl> to = DoFilterPostCallbackWork ( packed_kind , & control , & effect , a , to , element , <nl> callback_value ) ; <nl> Reduction JSCallReducer : : ReduceArrayFilter ( <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceArrayFind ( Node * node , ArrayFindVariant variant , <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> Reduction JSCallReducer : : ReduceArrayFind ( Node * node , ArrayFindVariant variant , <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> void JSCallReducer : : RewirePostCallbackExceptionEdges ( Node * check_throw , <nl> Node * JSCallReducer : : SafeLoadElement ( ElementsKind kind , Node * receiver , <nl> Node * control , Node * * effect , Node * * k , <nl> const VectorSlotPair & feedback ) { <nl> - / / Make sure that the access is still in bounds , since the callback could have <nl> - / / changed the array ' s size . <nl> + / / Make sure that the access is still in bounds , since the callback could <nl> + / / have changed the array ' s size . <nl> Node * length = * effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSArrayLength ( kind ) ) , receiver , <nl> * effect , control ) ; <nl> * k = * effect = graph ( ) - > NewNode ( simplified ( ) - > CheckBounds ( feedback ) , * k , <nl> length , * effect , control ) ; <nl> <nl> - / / Reload the elements pointer before calling the callback , since the previous <nl> - / / callback might have resized the array causing the elements buffer to be <nl> - / / re - allocated . <nl> + / / Reload the elements pointer before calling the callback , since the <nl> + / / previous callback might have resized the array causing the elements <nl> + / / buffer to be re - allocated . <nl> Node * elements = * effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSObjectElements ( ) ) , receiver , <nl> * effect , control ) ; <nl> Reduction JSCallReducer : : ReduceArrayEvery ( Node * node , <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> } <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> - / / Make sure the map hasn ' t changed before we construct the output array . <nl> - effect = graph ( ) - > NewNode ( <nl> - simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , receiver_maps ) , receiver , <nl> - effect , control ) ; <nl> - <nl> Node * original_length = effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSArrayLength ( kind ) ) , receiver , <nl> effect , control ) ; <nl> Reduction JSCallReducer : : ReduceArrayEvery ( Node * node , <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceArrayIndexOfIncludes ( <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> } <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Callable const callable = search_variant = = SearchVariant : : kIndexOf <nl> ? GetCallableForArrayIndexOf ( kind , isolate ( ) ) <nl> Reduction JSCallReducer : : ReduceArrayIndexOfIncludes ( <nl> graph ( ) - > zone ( ) , callable . descriptor ( ) , <nl> callable . descriptor ( ) . GetStackParameterCount ( ) , CallDescriptor : : kNoFlags , <nl> Operator : : kEliminatable ) ; <nl> - / / The stub expects the following arguments : the receiver array , its elements , <nl> - / / the search_element , the array length , and the index to start searching <nl> - / / from . <nl> + / / The stub expects the following arguments : the receiver array , its <nl> + / / elements , the search_element , the array length , and the index to start <nl> + / / searching from . <nl> Node * elements = effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSObjectElements ( ) ) , receiver , <nl> effect , control ) ; <nl> Reduction JSCallReducer : : ReduceArrayIndexOfIncludes ( <nl> Node * from_index = NodeProperties : : GetValueInput ( node , 3 ) ; <nl> from_index = effect = graph ( ) - > NewNode ( simplified ( ) - > CheckSmi ( p . feedback ( ) ) , <nl> from_index , effect , control ) ; <nl> - / / If the index is negative , it means the offset from the end and therefore <nl> - / / needs to be added to the length . If the result is still negative , it <nl> - / / needs to be clamped to 0 . <nl> + / / If the index is negative , it means the offset from the end and <nl> + / / therefore needs to be added to the length . If the result is still <nl> + / / negative , it needs to be clamped to 0 . <nl> new_from_index = graph ( ) - > NewNode ( <nl> common ( ) - > Select ( MachineRepresentation : : kTagged , BranchHint : : kFalse ) , <nl> graph ( ) - > NewNode ( simplified ( ) - > NumberLessThan ( ) , from_index , <nl> Reduction JSCallReducer : : ReduceArraySome ( Node * node , <nl> <nl> Node * k = jsgraph ( ) - > ZeroConstant ( ) ; <nl> <nl> - / / If we have unreliable maps , we need a map check . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> - <nl> - / / Make sure the map hasn ' t changed before we construct the output array . <nl> - effect = graph ( ) - > NewNode ( <nl> - simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , receiver_maps ) , receiver , <nl> - effect , control ) ; <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> Node * original_length = effect = graph ( ) - > NewNode ( <nl> simplified ( ) - > LoadField ( AccessBuilder : : ForJSArrayLength ( kind ) ) , receiver , <nl> Reduction JSCallReducer : : ReduceArraySome ( Node * node , <nl> <nl> / / Wire up the branch for the case when IsCallable fails for the callback . <nl> / / Since { check_throw } is an unconditional throw , it ' s impossible to <nl> - / / return a successful completion . Therefore , we simply connect the successful <nl> - / / completion to the graph end . <nl> + / / return a successful completion . Therefore , we simply connect the <nl> + / / successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceCallApiFunction ( <nl> namespace { <nl> <nl> / / Check whether elements aren ' t mutated ; we play it extremely safe here by <nl> - / / explicitly checking that { node } is only used by { LoadField } or { LoadElement } . <nl> + / / explicitly checking that { node } is only used by { LoadField } or <nl> + / / { LoadElement } . <nl> bool IsSafeArgumentsElements ( Node * node ) { <nl> for ( Edge const edge : node - > use_edges ( ) ) { <nl> if ( ! NodeProperties : : IsValueEdge ( edge ) ) continue ; <nl> Reduction JSCallReducer : : ReduceCallOrConstructWithArrayLikeOrSpread ( <nl> phi - > ReplaceInput ( 1 , on_exception ) ; <nl> } <nl> <nl> - / / The above % ThrowTypeError runtime call is an unconditional throw , making <nl> - / / it impossible to return a successful completion in this case . We simply <nl> - / / connect the successful completion to the graph end . <nl> + / / The above % ThrowTypeError runtime call is an unconditional throw , <nl> + / / making it impossible to return a successful completion in this case . We <nl> + / / simply connect the successful completion to the graph end . <nl> Node * throw_node = <nl> graph ( ) - > NewNode ( common ( ) - > Throw ( ) , check_throw , check_fail ) ; <nl> NodeProperties : : MergeControlToEnd ( graph ( ) , common ( ) , throw_node ) ; <nl> Reduction JSCallReducer : : ReduceArrayPrototypePush ( Node * node ) { <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If the { receiver_maps } information is not reliable , we need <nl> - / / to check that the { receiver } still has one of these maps . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Collect the value inputs to push . <nl> std : : vector < Node * > values ( num_values ) ; <nl> Reduction JSCallReducer : : ReduceArrayPrototypePop ( Node * node ) { <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If the { receiver_maps } information is not reliable , we need <nl> - / / to check that the { receiver } still has one of these maps . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Load the " length " property of the { receiver } . <nl> Node * length = effect = graph ( ) - > NewNode ( <nl> Reduction JSCallReducer : : ReduceArrayPrototypeShift ( Node * node ) { <nl> <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> <nl> - / / If the { receiver_maps } information is not reliable , we need <nl> - / / to check that the { receiver } still has one of these maps . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Load length of the { receiver } . <nl> Node * length = effect = graph ( ) - > NewNode ( <nl> Reduction JSCallReducer : : ReduceArrayPrototypeSlice ( Node * node ) { <nl> if ( ! dependencies ( ) - > DependOnNoElementsProtector ( ) ) UNREACHABLE ( ) ; <nl> } <nl> <nl> - / / If we have unreliable maps , we need a map check , as there might be <nl> - / / side - effects caused by the evaluation of the { node } s parameters . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / TODO ( turbofan ) : We can do even better here , either adding a CloneArray <nl> / / simplified operator , whose output type indicates that it ' s an Array , <nl> Reduction JSCallReducer : : ReducePromisePrototypeCatch ( Node * node ) { <nl> / / when looking up " then " . <nl> if ( ! dependencies ( ) - > DependOnPromiseThenProtector ( ) ) return NoChange ( ) ; <nl> <nl> - / / If the { receiver_maps } aren ' t reliable , we need to repeat the <nl> - / / map check here , guarded by the CALL_IC . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Massage the { node } to call " then " instead by first removing all inputs <nl> / / following the onRejected parameter , and then filling up the parameters <nl> Reduction JSCallReducer : : ReducePromisePrototypeFinally ( Node * node ) { <nl> / / % PromisePrototype % . <nl> if ( ! dependencies ( ) - > DependOnPromiseSpeciesProtector ( ) ) return NoChange ( ) ; <nl> <nl> - / / If the { receiver_maps } aren ' t reliable , we need to repeat the <nl> - / / map check here , guarded by the CALL_IC . <nl> - if ( result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Check if { on_finally } is callable , and if so wrap it into appropriate <nl> / / closures that perform the finalization . <nl> Reduction JSCallReducer : : ReducePromisePrototypeThen ( Node * node ) { <nl> <nl> / / Check if we know something about { receiver } already . <nl> ZoneHandleSet < Map > receiver_maps ; <nl> - NodeProperties : : InferReceiverMapsResult infer_receiver_maps_result = <nl> + NodeProperties : : InferReceiverMapsResult result = <nl> NodeProperties : : InferReceiverMaps ( broker ( ) , receiver , effect , <nl> & receiver_maps ) ; <nl> - if ( infer_receiver_maps_result = = NodeProperties : : kNoReceiverMaps ) { <nl> - return NoChange ( ) ; <nl> - } <nl> + if ( result = = NodeProperties : : kNoReceiverMaps ) return NoChange ( ) ; <nl> DCHECK_NE ( 0 , receiver_maps . size ( ) ) ; <nl> <nl> / / Check whether all { receiver_maps } are JSPromise maps and <nl> Reduction JSCallReducer : : ReducePromisePrototypeThen ( Node * node ) { <nl> / / the Promise constructor . <nl> if ( ! dependencies ( ) - > DependOnPromiseSpeciesProtector ( ) ) return NoChange ( ) ; <nl> <nl> - / / If the { receiver_maps } aren ' t reliable , we need to repeat the <nl> - / / map check here , guarded by the CALL_IC . <nl> - if ( infer_receiver_maps_result = = NodeProperties : : kUnreliableReceiverMaps ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - receiver_maps , p . feedback ( ) ) , <nl> - receiver , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , receiver_maps , p . feedback ( ) , receiver , effect , control ) ; <nl> <nl> / / Check that { on_fulfilled } is callable . <nl> on_fulfilled = graph ( ) - > NewNode ( <nl> Reduction JSCallReducer : : ReducePromisePrototypeThen ( Node * node ) { <nl> on_rejected , jsgraph ( ) - > UndefinedConstant ( ) ) ; <nl> <nl> / / Create the resulting JSPromise . <nl> - Node * result = effect = <nl> + Node * promise = effect = <nl> graph ( ) - > NewNode ( javascript ( ) - > CreatePromise ( ) , context , effect ) ; <nl> <nl> / / Chain { result } onto { receiver } . <nl> - result = effect = graph ( ) - > NewNode ( <nl> + promise = effect = graph ( ) - > NewNode ( <nl> javascript ( ) - > PerformPromiseThen ( ) , receiver , on_fulfilled , on_rejected , <nl> - result , context , frame_state , effect , control ) ; <nl> + promise , context , frame_state , effect , control ) ; <nl> <nl> - / / At this point we know that { result } is going to have the <nl> + / / At this point we know that { promise } is going to have the <nl> / / initial Promise map , since even if { PerformPromiseThen } <nl> - / / above called into the host rejection tracker , the { result } <nl> + / / above called into the host rejection tracker , the { promise } <nl> / / doesn ' t escape to user JavaScript . So bake this information <nl> / / into the graph such that subsequent passes can use the <nl> / / information for further optimizations . <nl> - MapRef result_map = native_context ( ) . promise_function ( ) . initial_map ( ) ; <nl> + MapRef promise_map = native_context ( ) . promise_function ( ) . initial_map ( ) ; <nl> effect = graph ( ) - > NewNode ( <nl> - simplified ( ) - > MapGuard ( ZoneHandleSet < Map > ( result_map . object ( ) ) ) , result , <nl> + simplified ( ) - > MapGuard ( ZoneHandleSet < Map > ( promise_map . object ( ) ) ) , promise , <nl> effect , control ) ; <nl> <nl> - ReplaceWithValue ( node , result , effect , control ) ; <nl> - return Replace ( result ) ; <nl> + ReplaceWithValue ( node , promise , effect , control ) ; <nl> + return Replace ( promise ) ; <nl> } <nl> <nl> / / ES section # sec - promise . resolve <nl> Reduction JSCallReducer : : ReduceRegExpPrototypeTest ( Node * node ) { <nl> ZoneHandleSet < Map > regexp_maps ; <nl> NodeProperties : : InferReceiverMapsResult result = <nl> NodeProperties : : InferReceiverMaps ( broker ( ) , regexp , effect , & regexp_maps ) ; <nl> - <nl> - bool need_map_check = false ; <nl> - switch ( result ) { <nl> - case NodeProperties : : kNoReceiverMaps : <nl> - return NoChange ( ) ; <nl> - case NodeProperties : : kUnreliableReceiverMaps : <nl> - need_map_check = true ; <nl> - break ; <nl> - case NodeProperties : : kReliableReceiverMaps : <nl> - break ; <nl> - } <nl> + if ( result = = NodeProperties : : kNoReceiverMaps ) return NoChange ( ) ; <nl> <nl> for ( auto map : regexp_maps ) { <nl> MapRef receiver_map ( broker ( ) , map ) ; <nl> Reduction JSCallReducer : : ReduceRegExpPrototypeTest ( Node * node ) { <nl> ai_exec . receiver_maps ( ) , JSObjectRef ( broker ( ) , holder ) ) ; <nl> } <nl> <nl> - if ( need_map_check ) { <nl> - effect = <nl> - graph ( ) - > NewNode ( simplified ( ) - > CheckMaps ( CheckMapsFlag : : kNone , <nl> - regexp_maps , p . feedback ( ) ) , <nl> - regexp , effect , control ) ; <nl> - } <nl> + effect = InsertMapChecksIfUnreliableReceiverMaps ( <nl> + result , regexp_maps , p . feedback ( ) , regexp , effect , control ) ; <nl> <nl> Node * context = NodeProperties : : GetContextInput ( node ) ; <nl> Node * frame_state = NodeProperties : : GetFrameStateInput ( node ) ; <nl> mmm a / src / compiler / js - call - reducer . h <nl> ppp b / src / compiler / js - call - reducer . h <nl> <nl> # include " src / base / flags . h " <nl> # include " src / compiler / frame - states . h " <nl> # include " src / compiler / graph - reducer . h " <nl> + # include " src / compiler / node - properties . h " <nl> # include " src / deoptimize - reason . h " <nl> <nl> namespace v8 { <nl> struct FieldAccess ; <nl> class JSGraph ; <nl> class JSHeapBroker ; <nl> class JSOperatorBuilder ; <nl> + class NodeProperties ; <nl> class SimplifiedOperatorBuilder ; <nl> <nl> / / Performs strength reduction on { JSConstruct } and { JSCall } nodes , <nl> class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { <nl> <nl> Reduction ReduceNumberConstructor ( Node * node ) ; <nl> <nl> + Node * InsertMapChecksIfUnreliableReceiverMaps ( <nl> + NodeProperties : : InferReceiverMapsResult result , <nl> + ZoneHandleSet < Map > const & receiver_maps , VectorSlotPair const & feedback , <nl> + Node * receiver , Node * effect , Node * control ) ; <nl> + <nl> / / Returns the updated { to } node , and updates control and effect along the <nl> / / way . <nl> Node * DoFilterPostCallbackWork ( ElementsKind kind , Node * * control , <nl>
|
[ turbofan ] Create helper for inserting map checks
|
v8/v8
|
2bd4bc6f041d1b6389575ea28ce68a3916f84237
|
2019-03-26T09:46:45Z
|
mmm a / xbmc / PlayListPlayer . cpp <nl> ppp b / xbmc / PlayListPlayer . cpp <nl> bool CPlayListPlayer : : PlayNext ( int offset , bool bAutoPlay ) <nl> if ( ( iSong < 0 ) | | ( iSong > = playlist . size ( ) ) | | ( playlist . GetPlayable ( ) < = 0 ) ) <nl> return false ; <nl> <nl> - if ( bAutoPlay ) <nl> - CFileItemPtr item = playlist [ iSong ] ; <nl> - <nl> return Play ( iSong , bAutoPlay ) ; <nl> } <nl> <nl>
|
changed : remove dead code
|
xbmc/xbmc
|
d2e615950f147bdff683564777e03f862aa98ae3
|
2011-06-26T22:58:19Z
|
mmm a / dbms / src / Compression / CompressedReadBufferFromFile . cpp <nl> ppp b / dbms / src / Compression / CompressedReadBufferFromFile . cpp <nl> <nl> # include " CompressedReadBufferFromFile . h " <nl> <nl> - # include < IO / createReadBufferFromFileBase . h > <nl> - # include < IO / WriteHelpers . h > <nl> # include < Compression / CompressionInfo . h > <nl> # include < Compression / LZ4_decompress_faster . h > <nl> + # include < IO / WriteHelpers . h > <nl> + # include < IO / createReadBufferFromFileBase . h > <nl> <nl> <nl> namespace DB <nl> { <nl> - <nl> namespace ErrorCodes <nl> { <nl> extern const int SEEK_POSITION_OUT_OF_BOUND ; <nl> bool CompressedReadBufferFromFile : : nextImpl ( ) <nl> return true ; <nl> } <nl> <nl> + CompressedReadBufferFromFile : : CompressedReadBufferFromFile ( std : : unique_ptr < ReadBufferFromFileBase > buf ) <nl> + : BufferWithOwnMemory < ReadBuffer > ( 0 ) , p_file_in ( std : : move ( buf ) ) , file_in ( * p_file_in ) <nl> + { <nl> + compressed_in = & file_in ; <nl> + } <nl> + <nl> <nl> CompressedReadBufferFromFile : : CompressedReadBufferFromFile ( <nl> const std : : string & path , size_t estimated_size , size_t aio_threshold , size_t mmap_threshold , size_t buf_size ) <nl> - : BufferWithOwnMemory < ReadBuffer > ( 0 ) , <nl> - p_file_in ( createReadBufferFromFileBase ( path , estimated_size , aio_threshold , mmap_threshold , buf_size ) ) , <nl> - file_in ( * p_file_in ) <nl> + : BufferWithOwnMemory < ReadBuffer > ( 0 ) <nl> + , p_file_in ( createReadBufferFromFileBase ( path , estimated_size , aio_threshold , mmap_threshold , buf_size ) ) <nl> + , file_in ( * p_file_in ) <nl> { <nl> compressed_in = & file_in ; <nl> } <nl> CompressedReadBufferFromFile : : CompressedReadBufferFromFile ( <nl> void CompressedReadBufferFromFile : : seek ( size_t offset_in_compressed_file , size_t offset_in_decompressed_block ) <nl> { <nl> if ( size_compressed & & <nl> - offset_in_compressed_file = = file_in . getPositionInFile ( ) - size_compressed & & <nl> + offset_in_compressed_file = = file_in . getPosition ( ) - size_compressed & & <nl> offset_in_decompressed_block < = working_buffer . size ( ) ) <nl> { <nl> bytes + = offset ( ) ; <nl> mmm a / dbms / src / Compression / CompressedReadBufferFromFile . h <nl> ppp b / dbms / src / Compression / CompressedReadBufferFromFile . h <nl> class CompressedReadBufferFromFile : public CompressedReadBufferBase , public Buf <nl> bool nextImpl ( ) override ; <nl> <nl> public : <nl> + CompressedReadBufferFromFile ( std : : unique_ptr < ReadBufferFromFileBase > buf ) ; <nl> + <nl> CompressedReadBufferFromFile ( <nl> const std : : string & path , size_t estimated_size , size_t aio_threshold , size_t mmap_threshold , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) ; <nl> <nl> mmm a / dbms / src / Disks / DiskLocal . cpp <nl> ppp b / dbms / src / Disks / DiskLocal . cpp <nl> void DiskLocal : : copyFile ( const String & from_path , const String & to_path ) <nl> Poco : : File ( disk_path + from_path ) . copyTo ( disk_path + to_path ) ; <nl> } <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > DiskLocal : : readFile ( const String & path , size_t buf_size ) const <nl> + std : : unique_ptr < ReadBufferFromFileBase > DiskLocal : : readFile ( const String & path , size_t buf_size ) const <nl> { <nl> return std : : make_unique < ReadBufferFromFile > ( disk_path + path , buf_size ) ; <nl> } <nl> mmm a / dbms / src / Disks / DiskLocal . h <nl> ppp b / dbms / src / Disks / DiskLocal . h <nl> <nl> # pragma once <nl> <nl> # include < Disks / IDisk . h > <nl> + # include < IO / ReadBufferFromFileBase . h > <nl> # include < IO / ReadBufferFromFile . h > <nl> # include < IO / WriteBufferFromFile . h > <nl> <nl> class DiskLocal : public IDisk <nl> <nl> void copyFile ( const String & from_path , const String & to_path ) override ; <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const override ; <nl> + std : : unique_ptr < ReadBufferFromFileBase > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const override ; <nl> <nl> std : : unique_ptr < WriteBuffer > writeFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE , WriteMode mode = WriteMode : : Rewrite ) override ; <nl> <nl> mmm a / dbms / src / Disks / DiskMemory . cpp <nl> ppp b / dbms / src / Disks / DiskMemory . cpp <nl> namespace ErrorCodes <nl> extern const int FILE_ALREADY_EXISTS ; <nl> extern const int DIRECTORY_DOESNT_EXIST ; <nl> extern const int CANNOT_DELETE_DIRECTORY ; <nl> + extern const int CANNOT_SEEK_THROUGH_FILE ; <nl> + extern const int SEEK_POSITION_OUT_OF_BOUND ; <nl> } <nl> <nl> <nl> class DiskMemoryDirectoryIterator : public IDiskDirectoryIterator <nl> std : : vector < String > : : iterator iter ; <nl> } ; <nl> <nl> + ReadIndirectBuffer : : ReadIndirectBuffer ( String path_ , const String & data_ ) <nl> + : ReadBufferFromFileBase ( ) , buf ( ReadBufferFromString ( data_ ) ) , path ( std : : move ( path_ ) ) <nl> + { <nl> + internal_buffer = buf . buffer ( ) ; <nl> + working_buffer = internal_buffer ; <nl> + pos = working_buffer . begin ( ) ; <nl> + } <nl> + <nl> + off_t ReadIndirectBuffer : : seek ( off_t offset , int whence ) <nl> + { <nl> + if ( whence = = SEEK_SET ) <nl> + { <nl> + if ( offset > = 0 & & working_buffer . begin ( ) + offset < working_buffer . end ( ) ) <nl> + { <nl> + pos = working_buffer . begin ( ) + offset ; <nl> + return size_t ( pos - working_buffer . begin ( ) ) ; <nl> + } <nl> + else <nl> + throw Exception ( <nl> + " Seek position is out of bounds . " <nl> + " Offset : " <nl> + + std : : to_string ( offset ) + " , Max : " + std : : to_string ( size_t ( working_buffer . end ( ) - working_buffer . begin ( ) ) ) , <nl> + ErrorCodes : : SEEK_POSITION_OUT_OF_BOUND ) ; <nl> + } <nl> + else if ( whence = = SEEK_CUR ) <nl> + { <nl> + Position new_pos = pos + offset ; <nl> + if ( new_pos > = working_buffer . begin ( ) & & new_pos < working_buffer . end ( ) ) <nl> + { <nl> + pos = new_pos ; <nl> + return size_t ( pos - working_buffer . begin ( ) ) ; <nl> + } <nl> + else <nl> + throw Exception ( <nl> + " Seek position is out of bounds . " <nl> + " Offset : " <nl> + + std : : to_string ( offset ) + " , Max : " + std : : to_string ( size_t ( working_buffer . end ( ) - working_buffer . begin ( ) ) ) , <nl> + ErrorCodes : : SEEK_POSITION_OUT_OF_BOUND ) ; <nl> + } <nl> + else <nl> + throw Exception ( " Only SEEK_SET and SEEK_CUR seek modes allowed . " , ErrorCodes : : CANNOT_SEEK_THROUGH_FILE ) ; <nl> + } <nl> + <nl> + off_t ReadIndirectBuffer : : getPosition ( ) <nl> + { <nl> + return pos - working_buffer . begin ( ) ; <nl> + } <nl> + <nl> void WriteIndirectBuffer : : finalize ( ) <nl> { <nl> + if ( isFinished ( ) ) <nl> + return ; <nl> + <nl> next ( ) ; <nl> WriteBufferFromVector : : finalize ( ) ; <nl> <nl> void DiskMemory : : copyFile ( const String & / * from_path * / , const String & / * to_path <nl> throw Exception ( " Method copyFile is not implemented for memory disks " , ErrorCodes : : NOT_IMPLEMENTED ) ; <nl> } <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > DiskMemory : : readFile ( const String & path , size_t / * buf_size * / ) const <nl> + std : : unique_ptr < ReadBufferFromFileBase > DiskMemory : : readFile ( const String & path , size_t / * buf_size * / ) const <nl> { <nl> std : : lock_guard lock ( mutex ) ; <nl> <nl> std : : unique_ptr < SeekableReadBuffer > DiskMemory : : readFile ( const String & path , si <nl> if ( iter = = files . end ( ) ) <nl> throw Exception ( " File ' " + path + " ' does not exist " , ErrorCodes : : FILE_DOESNT_EXIST ) ; <nl> <nl> - return std : : make_unique < ReadBufferFromString > ( iter - > second . data ) ; <nl> + return std : : make_unique < ReadIndirectBuffer > ( path , iter - > second . data ) ; <nl> } <nl> <nl> std : : unique_ptr < WriteBuffer > DiskMemory : : writeFile ( const String & path , size_t / * buf_size * / , WriteMode mode ) <nl> mmm a / dbms / src / Disks / DiskMemory . h <nl> ppp b / dbms / src / Disks / DiskMemory . h <nl> <nl> # include < unordered_map > <nl> # include < utility > <nl> # include < Disks / IDisk . h > <nl> + # include < IO / ReadBufferFromFileBase . h > <nl> + # include < IO / ReadBufferFromString . h > <nl> # include < IO / WriteBufferFromString . h > <nl> <nl> namespace DB <nl> class DiskMemory ; <nl> class ReadBuffer ; <nl> class WriteBuffer ; <nl> <nl> - / / This class is responsible to update files metadata after buffer is finalized . <nl> + / / / Adapter with actual behaviour as ReadBufferFromString . <nl> + class ReadIndirectBuffer : public ReadBufferFromFileBase <nl> + { <nl> + public : <nl> + ReadIndirectBuffer ( String path_ , const String & data_ ) ; <nl> + <nl> + std : : string getFileName ( ) const override { return path ; } <nl> + off_t seek ( off_t off , int whence ) override ; <nl> + off_t getPosition ( ) override ; <nl> + <nl> + private : <nl> + ReadBufferFromString buf ; <nl> + String path ; <nl> + } ; <nl> + <nl> + / / / This class is responsible to update files metadata after buffer is finalized . <nl> class WriteIndirectBuffer : public WriteBufferFromOwnString <nl> { <nl> public : <nl> class DiskMemory : public IDisk <nl> <nl> void copyFile ( const String & from_path , const String & to_path ) override ; <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const override ; <nl> + std : : unique_ptr < ReadBufferFromFileBase > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const override ; <nl> <nl> std : : unique_ptr < WriteBuffer > <nl> writeFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE , WriteMode mode = WriteMode : : Rewrite ) override ; <nl> mmm a / dbms / src / Disks / DiskS3 . cpp <nl> ppp b / dbms / src / Disks / DiskS3 . cpp <nl> namespace <nl> <nl> / / Reads data from S3 . <nl> / / It supports reading from multiple S3 paths that resides in Metadata . <nl> - class ReadIndirectBufferFromS3 : public BufferWithOwnMemory < SeekableReadBuffer > <nl> + class ReadIndirectBufferFromS3 : public ReadBufferFromFileBase <nl> { <nl> public : <nl> ReadIndirectBufferFromS3 ( <nl> std : : shared_ptr < Aws : : S3 : : S3Client > client_ptr_ , const String & bucket_ , Metadata metadata_ , size_t buf_size_ ) <nl> - : BufferWithOwnMemory ( buf_size_ ) <nl> + : ReadBufferFromFileBase ( ) <nl> , client_ptr ( std : : move ( client_ptr_ ) ) <nl> , bucket ( bucket_ ) <nl> , metadata ( std : : move ( metadata_ ) ) <nl> , buf_size ( buf_size_ ) <nl> - , offset ( 0 ) <nl> + , absolute_position ( 0 ) <nl> , initialized ( false ) <nl> , current_buf_idx ( 0 ) <nl> , current_buf ( nullptr ) <nl> namespace <nl> <nl> off_t seek ( off_t offset_ , int whence ) override <nl> { <nl> - if ( initialized ) <nl> - throw Exception ( " Seek is allowed only before first read attempt from the buffer . " , ErrorCodes : : CANNOT_SEEK_THROUGH_FILE ) ; <nl> - <nl> if ( whence ! = SEEK_SET ) <nl> throw Exception ( " Only SEEK_SET mode is allowed . " , ErrorCodes : : CANNOT_SEEK_THROUGH_FILE ) ; <nl> <nl> namespace <nl> + std : : to_string ( offset_ ) + " , Max : " + std : : to_string ( metadata . total_size ) , <nl> ErrorCodes : : SEEK_POSITION_OUT_OF_BOUND ) ; <nl> <nl> - offset = offset_ ; <nl> + absolute_position = offset_ ; <nl> + <nl> + / / / TODO : Do not re - initialize buffer if current position within working buffer . <nl> + current_buf = initialize ( ) ; <nl> + pos = working_buffer . end ( ) ; <nl> <nl> - return offset ; <nl> + return absolute_position ; <nl> } <nl> <nl> + off_t getPosition ( ) override { return absolute_position - available ( ) ; } <nl> + <nl> + std : : string getFileName ( ) const override { return metadata . metadata_file_path ; } <nl> + <nl> private : <nl> std : : unique_ptr < ReadBufferFromS3 > initialize ( ) <nl> { <nl> + size_t offset = absolute_position ; <nl> for ( UInt32 i = 0 ; i < metadata . s3_objects_count ; + + i ) <nl> { <nl> current_buf_idx = i ; <nl> namespace <nl> } <nl> offset - = size ; <nl> } <nl> + initialized = true ; <nl> return nullptr ; <nl> } <nl> <nl> namespace <nl> if ( ! initialized ) <nl> { <nl> current_buf = initialize ( ) ; <nl> - <nl> - initialized = true ; <nl> } <nl> <nl> / / If current buffer has remaining data - use it . <nl> if ( current_buf & & current_buf - > next ( ) ) <nl> { <nl> working_buffer = current_buf - > buffer ( ) ; <nl> + absolute_position + = working_buffer . size ( ) ; <nl> return true ; <nl> } <nl> <nl> namespace <nl> current_buf = std : : make_unique < ReadBufferFromS3 > ( client_ptr , bucket , path , buf_size ) ; <nl> current_buf - > next ( ) ; <nl> working_buffer = current_buf - > buffer ( ) ; <nl> + absolute_position + = working_buffer . size ( ) ; <nl> <nl> return true ; <nl> } <nl> namespace <nl> Metadata metadata ; <nl> size_t buf_size ; <nl> <nl> - size_t offset ; <nl> + size_t absolute_position = 0 ; <nl> bool initialized ; <nl> UInt32 current_buf_idx ; <nl> std : : unique_ptr < ReadBufferFromS3 > current_buf ; <nl> class DiskS3Reservation : public IReservation <nl> } ; <nl> <nl> <nl> - DiskS3 : : DiskS3 ( String name_ , std : : shared_ptr < Aws : : S3 : : S3Client > client_ , String bucket_ , String s3_root_path_ , <nl> - String metadata_path_ , size_t min_upload_part_size_ ) <nl> + DiskS3 : : DiskS3 ( <nl> + String name_ , <nl> + std : : shared_ptr < Aws : : S3 : : S3Client > client_ , <nl> + String bucket_ , <nl> + String s3_root_path_ , <nl> + String metadata_path_ , <nl> + size_t min_upload_part_size_ ) <nl> : name ( std : : move ( name_ ) ) <nl> , client ( std : : move ( client_ ) ) <nl> , bucket ( std : : move ( bucket_ ) ) <nl> void DiskS3 : : copyFile ( const String & from_path , const String & to_path ) <nl> to . save ( ) ; <nl> } <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > DiskS3 : : readFile ( const String & path , size_t buf_size ) const <nl> + std : : unique_ptr < ReadBufferFromFileBase > DiskS3 : : readFile ( const String & path , size_t buf_size ) const <nl> { <nl> Metadata metadata ( metadata_path + path ) ; <nl> <nl> void registerDiskS3 ( DiskFactory & factory ) <nl> <nl> String metadata_path = context . getPath ( ) + " disks / " + name + " / " ; <nl> <nl> - auto s3disk = std : : make_shared < DiskS3 > ( name , client , uri . bucket , uri . key , metadata_path , <nl> - context . getSettingsRef ( ) . s3_min_upload_part_size ) ; <nl> + auto s3disk <nl> + = std : : make_shared < DiskS3 > ( name , client , uri . bucket , uri . key , metadata_path , context . getSettingsRef ( ) . s3_min_upload_part_size ) ; <nl> <nl> / / / This code is used only to check access to the corresponding disk . <nl> checkWriteAccess ( s3disk ) ; <nl> mmm a / dbms / src / Disks / DiskS3 . h <nl> ppp b / dbms / src / Disks / DiskS3 . h <nl> class DiskS3 : public IDisk <nl> <nl> void copyFile ( const String & from_path , const String & to_path ) override ; <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > readFile ( const String & path , size_t buf_size ) const override ; <nl> + std : : unique_ptr < ReadBufferFromFileBase > readFile ( const String & path , size_t buf_size ) const override ; <nl> <nl> std : : unique_ptr < WriteBuffer > writeFile ( const String & path , size_t buf_size , WriteMode mode ) override ; <nl> <nl> mmm a / dbms / src / Disks / IDisk . h <nl> ppp b / dbms / src / Disks / IDisk . h <nl> using DiskDirectoryIteratorPtr = std : : unique_ptr < IDiskDirectoryIterator > ; <nl> class IReservation ; <nl> using ReservationPtr = std : : unique_ptr < IReservation > ; <nl> <nl> - class SeekableReadBuffer ; <nl> + class ReadBufferFromFileBase ; <nl> class WriteBuffer ; <nl> <nl> / * * <nl> class IDisk : public Space <nl> virtual void copyFile ( const String & from_path , const String & to_path ) = 0 ; <nl> <nl> / / / Open the file for read and return SeekableReadBuffer object . <nl> - virtual std : : unique_ptr < SeekableReadBuffer > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const = 0 ; <nl> + virtual std : : unique_ptr < ReadBufferFromFileBase > readFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE ) const = 0 ; <nl> <nl> / / / Open the file for write and return WriteBuffer object . <nl> virtual std : : unique_ptr < WriteBuffer > writeFile ( const String & path , size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE , WriteMode mode = WriteMode : : Rewrite ) = 0 ; <nl> mmm a / dbms / src / Disks / tests / gtest_disk . cpp <nl> ppp b / dbms / src / Disks / tests / gtest_disk . cpp <nl> TYPED_TEST ( DiskTest , readFile ) <nl> <nl> / / Test SEEK_SET <nl> { <nl> - DB : : String data ; <nl> + String buf ( 4 , ' 0 ' ) ; <nl> std : : unique_ptr < DB : : SeekableReadBuffer > in = disk - > readFile ( " test_file " ) ; <nl> + <nl> in - > seek ( 5 , SEEK_SET ) ; <nl> - readString ( data , * in ) ; <nl> - EXPECT_EQ ( " data " , data ) ; <nl> + <nl> + in - > readStrict ( buf . data ( ) , 4 ) ; <nl> + EXPECT_EQ ( " data " , buf ) ; <nl> } <nl> <nl> / / Test SEEK_CUR <nl> mmm a / dbms / src / IO / MMapReadBufferFromFileDescriptor . cpp <nl> ppp b / dbms / src / IO / MMapReadBufferFromFileDescriptor . cpp <nl> int MMapReadBufferFromFileDescriptor : : getFD ( ) const <nl> return fd ; <nl> } <nl> <nl> - off_t MMapReadBufferFromFileDescriptor : : getPositionInFile ( ) <nl> + off_t MMapReadBufferFromFileDescriptor : : getPosition ( ) <nl> { <nl> return count ( ) ; <nl> } <nl> mmm a / dbms / src / IO / MMapReadBufferFromFileDescriptor . h <nl> ppp b / dbms / src / IO / MMapReadBufferFromFileDescriptor . h <nl> class MMapReadBufferFromFileDescriptor : public ReadBufferFromFileBase <nl> / / / unmap memory before call to destructor <nl> void finish ( ) ; <nl> <nl> - off_t getPositionInFile ( ) override ; <nl> + off_t getPosition ( ) override ; <nl> std : : string getFileName ( ) const override ; <nl> - int getFD ( ) const override ; <nl> + int getFD ( ) const ; <nl> <nl> private : <nl> size_t length = 0 ; <nl> mmm a / dbms / src / IO / ReadBufferAIO . cpp <nl> ppp b / dbms / src / IO / ReadBufferAIO . cpp <nl> off_t ReadBufferAIO : : seek ( off_t off , int whence ) <nl> { <nl> if ( off > = 0 ) <nl> { <nl> - if ( off > ( std : : numeric_limits < off_t > : : max ( ) - getPositionInFile ( ) ) ) <nl> + if ( off > ( std : : numeric_limits < off_t > : : max ( ) - getPosition ( ) ) ) <nl> throw Exception ( " SEEK_CUR overflow " , ErrorCodes : : ARGUMENT_OUT_OF_BOUND ) ; <nl> } <nl> - else if ( off < - getPositionInFile ( ) ) <nl> + else if ( off < - getPosition ( ) ) <nl> throw Exception ( " SEEK_CUR underflow " , ErrorCodes : : ARGUMENT_OUT_OF_BOUND ) ; <nl> - new_pos_in_file = getPositionInFile ( ) + off ; <nl> + new_pos_in_file = getPosition ( ) + off ; <nl> } <nl> else <nl> throw Exception ( " ReadBufferAIO : : seek expects SEEK_SET or SEEK_CUR as whence " , ErrorCodes : : ARGUMENT_OUT_OF_BOUND ) ; <nl> <nl> - if ( new_pos_in_file ! = getPositionInFile ( ) ) <nl> + if ( new_pos_in_file ! = getPosition ( ) ) <nl> { <nl> off_t first_read_pos_in_file = first_unread_pos_in_file - static_cast < off_t > ( working_buffer . size ( ) ) ; <nl> if ( hasPendingData ( ) & & ( new_pos_in_file > = first_read_pos_in_file ) & & ( new_pos_in_file < = first_unread_pos_in_file ) ) <nl> mmm a / dbms / src / IO / ReadBufferAIO . h <nl> ppp b / dbms / src / IO / ReadBufferAIO . h <nl> class ReadBufferAIO : public ReadBufferFromFileBase <nl> ReadBufferAIO & operator = ( const ReadBufferAIO & ) = delete ; <nl> <nl> void setMaxBytes ( size_t max_bytes_read_ ) ; <nl> - off_t getPositionInFile ( ) override { return first_unread_pos_in_file - ( working_buffer . end ( ) - pos ) ; } <nl> + off_t getPosition ( ) override { return first_unread_pos_in_file - ( working_buffer . end ( ) - pos ) ; } <nl> std : : string getFileName ( ) const override { return filename ; } <nl> - int getFD ( ) const override { return fd ; } <nl> + int getFD ( ) const { return fd ; } <nl> <nl> off_t seek ( off_t off , int whence ) override ; <nl> <nl> mmm a / dbms / src / IO / ReadBufferFromFileBase . h <nl> ppp b / dbms / src / IO / ReadBufferFromFileBase . h <nl> <nl> <nl> namespace DB <nl> { <nl> - <nl> class ReadBufferFromFileBase : public BufferWithOwnMemory < SeekableReadBuffer > <nl> { <nl> public : <nl> class ReadBufferFromFileBase : public BufferWithOwnMemory < SeekableReadBuffer > <nl> ReadBufferFromFileBase ( size_t buf_size , char * existing_memory , size_t alignment ) ; <nl> ReadBufferFromFileBase ( ReadBufferFromFileBase & & ) = default ; <nl> ~ ReadBufferFromFileBase ( ) override ; <nl> - virtual off_t getPositionInFile ( ) = 0 ; <nl> virtual std : : string getFileName ( ) const = 0 ; <nl> - virtual int getFD ( ) const = 0 ; <nl> <nl> / / / It is possible to get information about the time of each reading . <nl> struct ProfileInfo <nl> class ReadBufferFromFileBase : public BufferWithOwnMemory < SeekableReadBuffer > <nl> protected : <nl> ProfileCallback profile_callback ; <nl> clockid_t clock_type { } ; <nl> - <nl> } ; <nl> <nl> } <nl> mmm a / dbms / src / IO / ReadBufferFromFileDescriptor . h <nl> ppp b / dbms / src / IO / ReadBufferFromFileDescriptor . h <nl> class ReadBufferFromFileDescriptor : public ReadBufferFromFileBase <nl> <nl> ReadBufferFromFileDescriptor ( ReadBufferFromFileDescriptor & & ) = default ; <nl> <nl> - int getFD ( ) const override <nl> + int getFD ( ) const <nl> { <nl> return fd ; <nl> } <nl> <nl> - off_t getPositionInFile ( ) override <nl> + off_t getPosition ( ) override <nl> { <nl> return pos_in_file - ( working_buffer . end ( ) - pos ) ; <nl> } <nl> mmm a / dbms / src / IO / ReadBufferFromMemory . cpp <nl> ppp b / dbms / src / IO / ReadBufferFromMemory . cpp <nl> off_t ReadBufferFromMemory : : seek ( off_t offset , int whence ) <nl> throw Exception ( " Only SEEK_SET and SEEK_CUR seek modes allowed . " , ErrorCodes : : CANNOT_SEEK_THROUGH_FILE ) ; <nl> } <nl> <nl> + off_t ReadBufferFromMemory : : getPosition ( ) <nl> + { <nl> + return pos - working_buffer . begin ( ) ; <nl> + } <nl> + <nl> } <nl> mmm a / dbms / src / IO / ReadBufferFromMemory . h <nl> ppp b / dbms / src / IO / ReadBufferFromMemory . h <nl> class ReadBufferFromMemory : public SeekableReadBuffer <nl> } <nl> <nl> off_t seek ( off_t off , int whence ) override ; <nl> + <nl> + off_t getPosition ( ) override ; <nl> } ; <nl> <nl> } <nl> mmm a / dbms / src / IO / ReadBufferFromS3 . cpp <nl> ppp b / dbms / src / IO / ReadBufferFromS3 . cpp <nl> off_t ReadBufferFromS3 : : seek ( off_t offset_ , int whence ) <nl> return offset ; <nl> } <nl> <nl> + <nl> + off_t ReadBufferFromS3 : : getPosition ( ) <nl> + { <nl> + return offset + count ( ) ; <nl> + } <nl> + <nl> std : : unique_ptr < ReadBuffer > ReadBufferFromS3 : : initialize ( ) <nl> { <nl> LOG_TRACE ( log , " Read S3 object . Bucket : " + bucket + " , Key : " + key + " , Offset : " + std : : to_string ( offset ) ) ; <nl> mmm a / dbms / src / IO / ReadBufferFromS3 . h <nl> ppp b / dbms / src / IO / ReadBufferFromS3 . h <nl> class ReadBufferFromS3 : public SeekableReadBuffer <nl> bool nextImpl ( ) override ; <nl> <nl> off_t seek ( off_t off , int whence ) override ; <nl> + off_t getPosition ( ) override ; <nl> <nl> private : <nl> std : : unique_ptr < ReadBuffer > initialize ( ) ; <nl> mmm a / dbms / src / IO / SeekableReadBuffer . h <nl> ppp b / dbms / src / IO / SeekableReadBuffer . h <nl> class SeekableReadBuffer : public ReadBuffer <nl> * @ return New position from the begging of underlying buffer / file . <nl> * / <nl> virtual off_t seek ( off_t off , int whence ) = 0 ; <nl> + <nl> + / * * <nl> + * @ return Offset from the begin of the underlying buffer / file corresponds to the buffer current position . <nl> + * / <nl> + virtual off_t getPosition ( ) = 0 ; <nl> } ; <nl> <nl> } <nl> mmm a / dbms / src / IO / tests / read_buffer_aio . cpp <nl> ppp b / dbms / src / IO / tests / read_buffer_aio . cpp <nl> bool test6 ( const std : : string & filename , const std : : string & buf ) <nl> <nl> DB : : ReadBufferAIO in ( filename , 3 * DEFAULT_AIO_FILE_BLOCK_SIZE ) ; <nl> <nl> - if ( in . getPositionInFile ( ) ! = 0 ) <nl> + if ( in . getPosition ( ) ! = 0 ) <nl> return false ; <nl> <nl> size_t count = in . read ( newbuf . data ( ) , newbuf . length ( ) ) ; <nl> if ( count ! = newbuf . length ( ) ) <nl> return false ; <nl> <nl> - if ( static_cast < size_t > ( in . getPositionInFile ( ) ) ! = buf . length ( ) ) <nl> + if ( static_cast < size_t > ( in . getPosition ( ) ) ! = buf . length ( ) ) <nl> return false ; <nl> <nl> return true ; <nl> bool test20 ( const std : : string & filename , const std : : string & buf ) <nl> return false ; <nl> } <nl> <nl> - ( void ) in . getPositionInFile ( ) ; <nl> + ( void ) in . getPosition ( ) ; <nl> <nl> { <nl> std : : string newbuf ; <nl> mmm a / dbms / src / Storages / StorageLog . cpp <nl> ppp b / dbms / src / Storages / StorageLog . cpp <nl> <nl> # include < Common / StringUtils / StringUtils . h > <nl> # include < Common / typeid_cast . h > <nl> <nl> + # include < Interpreters / evaluateConstantExpression . h > <nl> + <nl> + # include < IO / ReadBufferFromFileBase . h > <nl> # include < Compression / CompressedReadBuffer . h > <nl> # include < Compression / CompressedWriteBuffer . h > <nl> # include < IO / ReadHelpers . h > <nl> <nl> # include < Columns / ColumnArray . h > <nl> <nl> # include < Interpreters / Context . h > <nl> - <nl> + # include < Parsers / ASTLiteral . h > <nl> + # include " StorageLogSettings . h " <nl> <nl> # define DBMS_STORAGE_LOG_DATA_FILE_EXTENSION " . bin " <nl> # define DBMS_STORAGE_LOG_MARKS_FILE_NAME " __marks . mrk " <nl> class LogBlockInputStream final : public IBlockInputStream <nl> plain - > seek ( offset , SEEK_SET ) ; <nl> } <nl> <nl> - std : : unique_ptr < SeekableReadBuffer > plain ; <nl> + std : : unique_ptr < ReadBufferFromFileBase > plain ; <nl> CompressedReadBuffer compressed ; <nl> } ; <nl> <nl> CheckResults StorageLog : : checkData ( const ASTPtr & / * query * / , const Context & / <nl> <nl> void registerStorageLog ( StorageFactory & factory ) <nl> { <nl> + StorageFactory : : StorageFeatures features { <nl> + . supports_settings = true <nl> + } ; <nl> + <nl> factory . registerStorage ( " Log " , [ ] ( const StorageFactory : : Arguments & args ) <nl> { <nl> if ( ! args . engine_args . empty ( ) ) <nl> void registerStorageLog ( StorageFactory & factory ) <nl> " Engine " + args . engine_name + " doesn ' t support any arguments ( " + toString ( args . engine_args . size ( ) ) + " given ) " , <nl> ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> + String disk_name = getDiskName ( * args . storage_def ) ; <nl> + DiskPtr disk = args . context . getDisk ( disk_name ) ; <nl> + <nl> return StorageLog : : create ( <nl> - args . context . getDefaultDisk ( ) , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> + disk , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> args . context . getSettings ( ) . max_compress_block_size ) ; <nl> - } ) ; <nl> + } , features ) ; <nl> } <nl> <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 19cd0dd34e3 <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / StorageLogSettings . cpp <nl> <nl> + # include " StorageLogSettings . h " <nl> + # include < Parsers / ASTCreateQuery . h > <nl> + # include < Parsers / ASTSetQuery . h > <nl> + <nl> + namespace DB <nl> + { <nl> + String getDiskName ( ASTStorage & storage_def ) <nl> + { <nl> + if ( storage_def . settings ) <nl> + { <nl> + SettingsChanges changes = storage_def . settings - > changes ; <nl> + for ( auto it = changes . begin ( ) ; it ! = changes . end ( ) ; + + it ) <nl> + { <nl> + if ( it - > name = = " disk " ) <nl> + return it - > value . safeGet < String > ( ) ; <nl> + } <nl> + } <nl> + return " default " ; <nl> + } <nl> + <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c970cd6be37 <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / StorageLogSettings . h <nl> <nl> + # pragma once <nl> + <nl> + # include < Core / Types . h > <nl> + <nl> + namespace DB <nl> + { <nl> + class ASTStorage ; <nl> + <nl> + String getDiskName ( ASTStorage & storage_def ) ; <nl> + } <nl> mmm a / dbms / src / Storages / StorageStripeLog . cpp <nl> ppp b / dbms / src / Storages / StorageStripeLog . cpp <nl> <nl> # include < Common / escapeForFileName . h > <nl> # include < Common / Exception . h > <nl> <nl> - # include < Compression / CompressedReadBuffer . h > <nl> # include < Compression / CompressedReadBufferFromFile . h > <nl> # include < Compression / CompressedWriteBuffer . h > <nl> # include < IO / ReadHelpers . h > <nl> <nl> <nl> # include < Interpreters / Context . h > <nl> <nl> - # include < Storages / StorageStripeLog . h > <nl> + # include < Interpreters / evaluateConstantExpression . h > <nl> + # include < Parsers / ASTLiteral . h > <nl> # include < Storages / StorageFactory . h > <nl> + # include < Storages / StorageStripeLog . h > <nl> + # include " StorageLogSettings . h " <nl> <nl> <nl> namespace DB <nl> class StripeLogBlockInputStream final : public IBlockInputStream <nl> String data_file_path = storage . table_path + " data . bin " ; <nl> size_t buffer_size = std : : min ( max_read_buffer_size , storage . disk - > getFileSize ( data_file_path ) ) ; <nl> <nl> - data_in . emplace ( fullPath ( storage . disk , data_file_path ) , 0 , 0 , buffer_size ) ; <nl> + data_in . emplace ( storage . disk - > readFile ( data_file_path , buffer_size ) ) ; <nl> block_in . emplace ( * data_in , 0 , index_begin , index_end ) ; <nl> } <nl> } <nl> BlockInputStreams StorageStripeLog : : read ( <nl> if ( ! disk - > exists ( index_file ) ) <nl> return { std : : make_shared < NullBlockInputStream > ( getSampleBlockForColumns ( column_names ) ) } ; <nl> <nl> - CompressedReadBufferFromFile index_in ( fullPath ( disk , index_file ) , 0 , 0 , 0 , INDEX_BUFFER_SIZE ) ; <nl> + CompressedReadBufferFromFile index_in ( disk - > readFile ( index_file , INDEX_BUFFER_SIZE ) ) ; <nl> std : : shared_ptr < const IndexForNativeFormat > index { std : : make_shared < IndexForNativeFormat > ( index_in , column_names_set ) } ; <nl> <nl> BlockInputStreams res ; <nl> void StorageStripeLog : : truncate ( const ASTPtr & , const Context & , TableStructureW <nl> <nl> void registerStorageStripeLog ( StorageFactory & factory ) <nl> { <nl> + StorageFactory : : StorageFeatures features { <nl> + . supports_settings = true <nl> + } ; <nl> + <nl> factory . registerStorage ( " StripeLog " , [ ] ( const StorageFactory : : Arguments & args ) <nl> { <nl> if ( ! args . engine_args . empty ( ) ) <nl> void registerStorageStripeLog ( StorageFactory & factory ) <nl> " Engine " + args . engine_name + " doesn ' t support any arguments ( " + toString ( args . engine_args . size ( ) ) + " given ) " , <nl> ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> + String disk_name = getDiskName ( * args . storage_def ) ; <nl> + DiskPtr disk = args . context . getDisk ( disk_name ) ; <nl> + <nl> return StorageStripeLog : : create ( <nl> - args . context . getDefaultDisk ( ) , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> + disk , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> args . attach , args . context . getSettings ( ) . max_compress_block_size ) ; <nl> - } ) ; <nl> + } , features ) ; <nl> } <nl> <nl> } <nl> mmm a / dbms / src / Storages / StorageTinyLog . cpp <nl> ppp b / dbms / src / Storages / StorageTinyLog . cpp <nl> <nl> # include < Common / Exception . h > <nl> # include < Common / typeid_cast . h > <nl> <nl> + # include < IO / ReadBufferFromFileBase . h > <nl> # include < Compression / CompressionFactory . h > <nl> # include < Compression / CompressedReadBuffer . h > <nl> # include < Compression / CompressedWriteBuffer . h > <nl> <nl> <nl> # include < Interpreters / Context . h > <nl> <nl> - # include < Storages / StorageTinyLog . h > <nl> - # include < Storages / StorageFactory . h > <nl> + # include < Interpreters / evaluateConstantExpression . h > <nl> + # include < Parsers / ASTLiteral . h > <nl> # include < Storages / CheckResults . h > <nl> + # include < Storages / StorageFactory . h > <nl> + # include < Storages / StorageTinyLog . h > <nl> + # include " StorageLogSettings . h " <nl> <nl> # define DBMS_STORAGE_LOG_DATA_FILE_EXTENSION " . bin " <nl> <nl> void StorageTinyLog : : drop ( TableStructureWriteLockHolder & ) <nl> <nl> void registerStorageTinyLog ( StorageFactory & factory ) <nl> { <nl> + StorageFactory : : StorageFeatures features { <nl> + . supports_settings = true <nl> + } ; <nl> + <nl> factory . registerStorage ( " TinyLog " , [ ] ( const StorageFactory : : Arguments & args ) <nl> { <nl> if ( ! args . engine_args . empty ( ) ) <nl> void registerStorageTinyLog ( StorageFactory & factory ) <nl> " Engine " + args . engine_name + " doesn ' t support any arguments ( " + toString ( args . engine_args . size ( ) ) + " given ) " , <nl> ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> + String disk_name = getDiskName ( * args . storage_def ) ; <nl> + DiskPtr disk = args . context . getDisk ( disk_name ) ; <nl> + <nl> return StorageTinyLog : : create ( <nl> - args . context . getDefaultDisk ( ) , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> + disk , args . relative_data_path , args . table_id , args . columns , args . constraints , <nl> args . attach , args . context . getSettings ( ) . max_compress_block_size ) ; <nl> - } ) ; <nl> + } , features ) ; <nl> } <nl> <nl> } <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 4573ddf9cfd . . 00000000000 <nl> mmm a / dbms / tests / integration / test_disk_memory / configs / config . xml <nl> ppp / dev / null <nl> <nl> - < yandex > <nl> - < logger > <nl> - < level > trace < / level > <nl> - < log > / var / log / clickhouse - server / clickhouse - server . log < / log > <nl> - < errorlog > / var / log / clickhouse - server / clickhouse - server . err . log < / errorlog > <nl> - < size > 1000M < / size > <nl> - < count > 10 < / count > <nl> - < stderr > / var / log / clickhouse - server / stderr . log < / stderr > <nl> - < stdout > / var / log / clickhouse - server / stdout . log < / stdout > <nl> - < / logger > <nl> - <nl> - < storage_configuration > <nl> - < disks > <nl> - < default > <nl> - < type > memory < / type > <nl> - < / default > <nl> - < / disks > <nl> - < / storage_configuration > <nl> - < / yandex > <nl> deleted file mode 100644 <nl> index ea9309fcbe1 . . 00000000000 <nl> mmm a / dbms / tests / integration / test_disk_memory / test . py <nl> ppp / dev / null <nl> <nl> - import pytest <nl> - <nl> - from helpers . cluster import ClickHouseCluster <nl> - from helpers . test_tools import TSV <nl> - <nl> - cluster = ClickHouseCluster ( __file__ ) <nl> - node = cluster . add_instance ( " node " , main_configs = [ ' configs / config . xml ' ] ) <nl> - <nl> - <nl> - @ pytest . fixture ( scope = " module " ) <nl> - def started_cluster ( ) : <nl> - try : <nl> - cluster . start ( ) <nl> - yield cluster <nl> - finally : <nl> - cluster . shutdown ( ) <nl> - <nl> - <nl> - def test_tinylog ( started_cluster ) : <nl> - node . query ( ' ' ' CREATE DATABASE IF NOT EXISTS test ' ' ' ) <nl> - <nl> - node . query ( ' ' ' CREATE TABLE test . tinylog ( s String , n UInt8 ) ENGINE = TinyLog ' ' ' ) <nl> - <nl> - node . query ( ' ' ' INSERT INTO test . tinylog SELECT toString ( number ) , number * 2 FROM system . numbers LIMIT 5 ' ' ' ) <nl> - assert TSV ( node . query ( ' ' ' SELECT * FROM test . tinylog ' ' ' ) ) = = TSV ( ' 0 \ t0 \ n1 \ t2 \ n2 \ t4 \ n3 \ t6 \ n4 \ t8 ' ) <nl> - <nl> - node . query ( ' ' ' TRUNCATE TABLE test . tinylog ' ' ' ) <nl> - assert TSV ( node . query ( ' ' ' SELECT * FROM test . tinylog ' ' ' ) ) = = TSV ( ' ' ) <nl> - <nl> - node . query ( ' ' ' DROP TABLE test . tinylog ' ' ' ) <nl> mmm a / dbms / tests / integration / test_log_family_s3 / test . py <nl> ppp b / dbms / tests / integration / test_log_family_s3 / test . py <nl> def cluster ( ) : <nl> cluster . shutdown ( ) <nl> <nl> <nl> - @ pytest . mark . parametrize ( " log_engine , files_overhead " , [ ( " TinyLog " , 1 ) , ( " Log " , 2 ) ] ) <nl> - def test_log_family_s3 ( cluster , log_engine , files_overhead ) : <nl> + @ pytest . mark . parametrize ( <nl> + " log_engine , files_overhead , files_overhead_per_insert " , <nl> + [ ( " TinyLog " , 1 , 1 ) , ( " Log " , 2 , 1 ) , ( " StripeLog " , 1 , 2 ) ] ) <nl> + def test_log_family_s3 ( cluster , log_engine , files_overhead , files_overhead_per_insert ) : <nl> node = cluster . instances [ " node " ] <nl> minio = cluster . minio_client <nl> <nl> def test_log_family_s3 ( cluster , log_engine , files_overhead ) : <nl> <nl> node . query ( " INSERT INTO s3_test SELECT number FROM numbers ( 5 ) " ) <nl> assert node . query ( " SELECT * FROM s3_test " ) = = " 0 \ n1 \ n2 \ n3 \ n4 \ n " <nl> - assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = 1 + files_overhead <nl> + assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = files_overhead_per_insert + files_overhead <nl> <nl> node . query ( " INSERT INTO s3_test SELECT number + 5 FROM numbers ( 3 ) " ) <nl> assert node . query ( " SELECT * FROM s3_test order by id " ) = = " 0 \ n1 \ n2 \ n3 \ n4 \ n5 \ n6 \ n7 \ n " <nl> - assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = 2 + files_overhead <nl> + assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = files_overhead_per_insert * 2 + files_overhead <nl> <nl> node . query ( " INSERT INTO s3_test SELECT number + 8 FROM numbers ( 1 ) " ) <nl> assert node . query ( " SELECT * FROM s3_test order by id " ) = = " 0 \ n1 \ n2 \ n3 \ n4 \ n5 \ n6 \ n7 \ n8 \ n " <nl> - assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = 3 + files_overhead <nl> + assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = files_overhead_per_insert * 3 + files_overhead <nl> <nl> node . query ( " TRUNCATE TABLE s3_test " ) <nl> assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = 0 <nl> new file mode 100644 <nl> index 00000000000 . . 9d8e6d18e1d <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 01083_log_family_disk_memory . reference <nl> <nl> + 0 <nl> + 0 <nl> + 1 <nl> + 0 <nl> + 1 <nl> + 2 <nl> + 0 <nl> + 0 <nl> + 1 <nl> + 0 <nl> + 1 <nl> + 2 <nl> + 0 <nl> + 0 <nl> + 1 <nl> + 0 <nl> + 1 <nl> + 2 <nl> new file mode 100644 <nl> index 00000000000 . . 8fcd03522ed <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 01083_log_family_disk_memory . sql <nl> <nl> + DROP TABLE IF EXISTS log ; <nl> + <nl> + CREATE TABLE log ( x UInt8 ) ENGINE = StripeLog ( ) SETTINGS disk = ' disk_memory ' ; <nl> + <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 0 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 1 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 2 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + <nl> + TRUNCATE TABLE log ; <nl> + DROP TABLE log ; <nl> + <nl> + CREATE TABLE log ( x UInt8 ) ENGINE = TinyLog ( ) SETTINGS disk = ' disk_memory ' ; <nl> + <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 0 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 1 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 2 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + <nl> + TRUNCATE TABLE log ; <nl> + DROP TABLE log ; <nl> + <nl> + CREATE TABLE log ( x UInt8 ) ENGINE = Log ( ) SETTINGS disk = ' disk_memory ' ; <nl> + <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 0 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 1 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + INSERT INTO log VALUES ( 2 ) ; <nl> + SELECT * FROM log ORDER BY x ; <nl> + <nl> + TRUNCATE TABLE log ; <nl> + DROP TABLE log ; <nl>
|
Merge pull request from Jokser / storage - stripe - log - s3
|
ClickHouse/ClickHouse
|
a1193cbbf8ba82bfb48011c80eebd1109b71dff9
|
2020-02-20T16:01:36Z
|
mmm a / . gitignore <nl> ppp b / . gitignore <nl> config . log <nl> / build <nl> / . dummy . in <nl> / . dummy <nl> + / build - aux / config . guess <nl> + / build - aux / config . sub <nl> + / build - aux / install - sh <nl> + / build - aux / missing <nl> <nl> # / guilib / <nl> / guilib / Makefile <nl> new file mode 100644 <nl> index 000000000000 . . 22708ab9f78a <nl> mmm / dev / null <nl> ppp b / build - aux / . dummy <nl> @ @ - 0 , 0 + 1 @ @ <nl> + Dummy file used so that this directory shows up in git . <nl> deleted file mode 100755 <nl> index c2246a4f7f4c . . 000000000000 <nl> mmm a / config . guess <nl> ppp / dev / null <nl> <nl> - # ! / bin / sh <nl> - # Attempt to guess a canonical system name . <nl> - # Copyright ( C ) 1992 , 1993 , 1994 , 1995 , 1996 , 1997 , 1998 , 1999 , <nl> - # 2000 , 2001 , 2002 , 2003 , 2004 , 2005 , 2006 , 2007 , 2008 , 2009 , 2010 <nl> - # Free Software Foundation , Inc . <nl> - <nl> - timestamp = ' 2009 - 12 - 30 ' <nl> - <nl> - # This file is free software ; you can redistribute it and / or modify it <nl> - # under the terms of the GNU General Public License as published by <nl> - # the Free Software Foundation ; either version 2 of the License , or <nl> - # ( at your option ) any later version . <nl> - # <nl> - # This program is distributed in the hope that it will be useful , but <nl> - # WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU <nl> - # General Public License for more details . <nl> - # <nl> - # You should have received a copy of the GNU General Public License <nl> - # along with this program ; if not , write to the Free Software <nl> - # Foundation , Inc . , 51 Franklin Street - Fifth Floor , Boston , MA <nl> - # 02110 - 1301 , USA . <nl> - # <nl> - # As a special exception to the GNU General Public License , if you <nl> - # distribute this file as part of a program that contains a <nl> - # configuration script generated by Autoconf , you may include it under <nl> - # the same distribution terms that you use for the rest of that program . <nl> - <nl> - <nl> - # Originally written by Per Bothner . Please send patches ( context <nl> - # diff format ) to < config - patches @ gnu . org > and include a ChangeLog <nl> - # entry . <nl> - # <nl> - # This script attempts to guess a canonical system name similar to <nl> - # config . sub . If it succeeds , it prints the system name on stdout , and <nl> - # exits with 0 . Otherwise , it exits with 1 . <nl> - # <nl> - # You can get the latest version of this script from : <nl> - # http : / / git . savannah . gnu . org / gitweb / ? p = config . git ; a = blob_plain ; f = config . guess ; hb = HEAD <nl> - <nl> - me = ` echo " $ 0 " | sed - e ' s , . * / , , ' ` <nl> - <nl> - usage = " \ <nl> - Usage : $ 0 [ OPTION ] <nl> - <nl> - Output the configuration name of the system \ ` $ me ' is run on . <nl> - <nl> - Operation modes : <nl> - - h , - - help print this help , then exit <nl> - - t , - - time - stamp print date of last modification , then exit <nl> - - v , - - version print version number , then exit <nl> - <nl> - Report bugs and patches to < config - patches @ gnu . org > . " <nl> - <nl> - version = " \ <nl> - GNU config . guess ( $ timestamp ) <nl> - <nl> - Originally written by Per Bothner . <nl> - Copyright ( C ) 1992 , 1993 , 1994 , 1995 , 1996 , 1997 , 1998 , 1999 , 2000 , <nl> - 2001 , 2002 , 2003 , 2004 , 2005 , 2006 , 2007 , 2008 , 2009 , 2010 Free <nl> - Software Foundation , Inc . <nl> - <nl> - This is free software ; see the source for copying conditions . There is NO <nl> - warranty ; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . " <nl> - <nl> - help = " <nl> - Try \ ` $ me - - help ' for more information . " <nl> - <nl> - # Parse command line <nl> - while test $ # - gt 0 ; do <nl> - case $ 1 in <nl> - - - time - stamp | - - time * | - t ) <nl> - echo " $ timestamp " ; exit ; ; <nl> - - - version | - v ) <nl> - echo " $ version " ; exit ; ; <nl> - - - help | - - h * | - h ) <nl> - echo " $ usage " ; exit ; ; <nl> - - - ) # Stop option processing <nl> - shift ; break ; ; <nl> - - ) # Use stdin as input . <nl> - break ; ; <nl> - - * ) <nl> - echo " $ me : invalid option $ 1 $ help " > & 2 <nl> - exit 1 ; ; <nl> - * ) <nl> - break ; ; <nl> - esac <nl> - done <nl> - <nl> - if test $ # ! = 0 ; then <nl> - echo " $ me : too many arguments $ help " > & 2 <nl> - exit 1 <nl> - fi <nl> - <nl> - trap ' exit 1 ' 1 2 15 <nl> - <nl> - # CC_FOR_BUILD - - compiler used by this script . Note that the use of a <nl> - # compiler to aid in system detection is discouraged as it requires <nl> - # temporary files to be created and , as you can see below , it is a <nl> - # headache to deal with in a portable fashion . <nl> - <nl> - # Historically , ` CC_FOR_BUILD ' used to be named ` HOST_CC ' . We still <nl> - # use ` HOST_CC ' if defined , but it is deprecated . <nl> - <nl> - # Portable tmp directory creation inspired by the Autoconf team . <nl> - <nl> - set_cc_for_build = ' <nl> - trap " exitcode = \ $ ? ; ( rm - f \ $ tmpfiles 2 > / dev / null ; rmdir \ $ tmp 2 > / dev / null ) & & exit \ $ exitcode " 0 ; <nl> - trap " rm - f \ $ tmpfiles 2 > / dev / null ; rmdir \ $ tmp 2 > / dev / null ; exit 1 " 1 2 13 15 ; <nl> - : $ { TMPDIR = / tmp } ; <nl> - { tmp = ` ( umask 077 & & mktemp - d " $ TMPDIR / cgXXXXXX " ) 2 > / dev / null ` & & test - n " $ tmp " & & test - d " $ tmp " ; } | | <nl> - { test - n " $ RANDOM " & & tmp = $ TMPDIR / cg $ $ - $ RANDOM & & ( umask 077 & & mkdir $ tmp ) ; } | | <nl> - { tmp = $ TMPDIR / cg - $ $ & & ( umask 077 & & mkdir $ tmp ) & & echo " Warning : creating insecure temp directory " > & 2 ; } | | <nl> - { echo " $ me : cannot create a temporary directory in $ TMPDIR " > & 2 ; exit 1 ; } ; <nl> - dummy = $ tmp / dummy ; <nl> - tmpfiles = " $ dummy . c $ dummy . o $ dummy . rel $ dummy " ; <nl> - case $ CC_FOR_BUILD , $ HOST_CC , $ CC in <nl> - , , ) echo " int x ; " > $ dummy . c ; <nl> - for c in cc gcc c89 c99 ; do <nl> - if ( $ c - c - o $ dummy . o $ dummy . c ) > / dev / null 2 > & 1 ; then <nl> - CC_FOR_BUILD = " $ c " ; break ; <nl> - fi ; <nl> - done ; <nl> - if test x " $ CC_FOR_BUILD " = x ; then <nl> - CC_FOR_BUILD = no_compiler_found ; <nl> - fi <nl> - ; ; <nl> - , , * ) CC_FOR_BUILD = $ CC ; ; <nl> - , * , * ) CC_FOR_BUILD = $ HOST_CC ; ; <nl> - esac ; set_cc_for_build = ; ' <nl> - <nl> - # This is needed to find uname on a Pyramid OSx when run in the BSD universe . <nl> - # ( ghazi @ noc . rutgers . edu 1994 - 08 - 24 ) <nl> - if ( test - f / . attbin / uname ) > / dev / null 2 > & 1 ; then <nl> - PATH = $ PATH : / . attbin ; export PATH <nl> - fi <nl> - <nl> - UNAME_MACHINE = ` ( uname - m ) 2 > / dev / null ` | | UNAME_MACHINE = unknown <nl> - UNAME_RELEASE = ` ( uname - r ) 2 > / dev / null ` | | UNAME_RELEASE = unknown <nl> - UNAME_SYSTEM = ` ( uname - s ) 2 > / dev / null ` | | UNAME_SYSTEM = unknown <nl> - UNAME_VERSION = ` ( uname - v ) 2 > / dev / null ` | | UNAME_VERSION = unknown <nl> - <nl> - # Note : order is significant - the case branches are not exclusive . <nl> - <nl> - case " $ { UNAME_MACHINE } : $ { UNAME_SYSTEM } : $ { UNAME_RELEASE } : $ { UNAME_VERSION } " in <nl> - * : NetBSD : * : * ) <nl> - # NetBSD ( nbsd ) targets should ( where applicable ) match one or <nl> - # more of the tupples : * - * - netbsdelf * , * - * - netbsdaout * , <nl> - # * - * - netbsdecoff * and * - * - netbsd * . For targets that recently <nl> - # switched to ELF , * - * - netbsd * would select the old <nl> - # object file format . This provides both forward <nl> - # compatibility and a consistent mechanism for selecting the <nl> - # object file format . <nl> - # <nl> - # Note : NetBSD doesn ' t particularly care about the vendor <nl> - # portion of the name . We always set it to " unknown " . <nl> - sysctl = " sysctl - n hw . machine_arch " <nl> - UNAME_MACHINE_ARCH = ` ( / sbin / $ sysctl 2 > / dev / null | | \ <nl> - / usr / sbin / $ sysctl 2 > / dev / null | | echo unknown ) ` <nl> - case " $ { UNAME_MACHINE_ARCH } " in <nl> - armeb ) machine = armeb - unknown ; ; <nl> - arm * ) machine = arm - unknown ; ; <nl> - sh3el ) machine = shl - unknown ; ; <nl> - sh3eb ) machine = sh - unknown ; ; <nl> - sh5el ) machine = sh5le - unknown ; ; <nl> - * ) machine = $ { UNAME_MACHINE_ARCH } - unknown ; ; <nl> - esac <nl> - # The Operating System including object format , if it has switched <nl> - # to ELF recently , or will in the future . <nl> - case " $ { UNAME_MACHINE_ARCH } " in <nl> - arm * | i386 | m68k | ns32k | sh3 * | sparc | vax ) <nl> - eval $ set_cc_for_build <nl> - if echo __ELF__ | $ CC_FOR_BUILD - E - 2 > / dev / null \ <nl> - | grep - q __ELF__ <nl> - then <nl> - # Once all utilities can be ECOFF ( netbsdecoff ) or a . out ( netbsdaout ) . <nl> - # Return netbsd for either . FIX ? <nl> - os = netbsd <nl> - else <nl> - os = netbsdelf <nl> - fi <nl> - ; ; <nl> - * ) <nl> - os = netbsd <nl> - ; ; <nl> - esac <nl> - # The OS release <nl> - # Debian GNU / NetBSD machines have a different userland , and <nl> - # thus , need a distinct triplet . However , they do not need <nl> - # kernel version information , so it can be replaced with a <nl> - # suitable tag , in the style of linux - gnu . <nl> - case " $ { UNAME_VERSION } " in <nl> - Debian * ) <nl> - release = ' - gnu ' <nl> - ; ; <nl> - * ) <nl> - release = ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - _ ] . * / \ . / ' ` <nl> - ; ; <nl> - esac <nl> - # Since CPU_TYPE - MANUFACTURER - KERNEL - OPERATING_SYSTEM : <nl> - # contains redundant information , the shorter form : <nl> - # CPU_TYPE - MANUFACTURER - OPERATING_SYSTEM is used . <nl> - echo " $ { machine } - $ { os } $ { release } " <nl> - exit ; ; <nl> - * : OpenBSD : * : * ) <nl> - UNAME_MACHINE_ARCH = ` arch | sed ' s / OpenBSD . / / ' ` <nl> - echo $ { UNAME_MACHINE_ARCH } - unknown - openbsd $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : ekkoBSD : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - ekkobsd $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : SolidBSD : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - solidbsd $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - macppc : MirBSD : * : * ) <nl> - echo powerpc - unknown - mirbsd $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : MirBSD : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - mirbsd $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - alpha : OSF1 : * : * ) <nl> - case $ UNAME_RELEASE in <nl> - * 4 . 0 ) <nl> - UNAME_RELEASE = ` / usr / sbin / sizer - v | awk ' { print $ 3 } ' ` <nl> - ; ; <nl> - * 5 . * ) <nl> - UNAME_RELEASE = ` / usr / sbin / sizer - v | awk ' { print $ 4 } ' ` <nl> - ; ; <nl> - esac <nl> - # According to Compaq , / usr / sbin / psrinfo has been available on <nl> - # OSF / 1 and Tru64 systems produced since 1995 . I hope that <nl> - # covers most systems running today . This code pipes the CPU <nl> - # types through head - n 1 , so we only detect the type of CPU 0 . <nl> - ALPHA_CPU_TYPE = ` / usr / sbin / psrinfo - v | sed - n - e ' s / ^ The alpha \ ( . * \ ) processor . * $ / \ 1 / p ' | head - n 1 ` <nl> - case " $ ALPHA_CPU_TYPE " in <nl> - " EV4 ( 21064 ) " ) <nl> - UNAME_MACHINE = " alpha " ; ; <nl> - " EV4 . 5 ( 21064 ) " ) <nl> - UNAME_MACHINE = " alpha " ; ; <nl> - " LCA4 ( 21066 / 21068 ) " ) <nl> - UNAME_MACHINE = " alpha " ; ; <nl> - " EV5 ( 21164 ) " ) <nl> - UNAME_MACHINE = " alphaev5 " ; ; <nl> - " EV5 . 6 ( 21164A ) " ) <nl> - UNAME_MACHINE = " alphaev56 " ; ; <nl> - " EV5 . 6 ( 21164PC ) " ) <nl> - UNAME_MACHINE = " alphapca56 " ; ; <nl> - " EV5 . 7 ( 21164PC ) " ) <nl> - UNAME_MACHINE = " alphapca57 " ; ; <nl> - " EV6 ( 21264 ) " ) <nl> - UNAME_MACHINE = " alphaev6 " ; ; <nl> - " EV6 . 7 ( 21264A ) " ) <nl> - UNAME_MACHINE = " alphaev67 " ; ; <nl> - " EV6 . 8CB ( 21264C ) " ) <nl> - UNAME_MACHINE = " alphaev68 " ; ; <nl> - " EV6 . 8AL ( 21264B ) " ) <nl> - UNAME_MACHINE = " alphaev68 " ; ; <nl> - " EV6 . 8CX ( 21264D ) " ) <nl> - UNAME_MACHINE = " alphaev68 " ; ; <nl> - " EV6 . 9A ( 21264 / EV69A ) " ) <nl> - UNAME_MACHINE = " alphaev69 " ; ; <nl> - " EV7 ( 21364 ) " ) <nl> - UNAME_MACHINE = " alphaev7 " ; ; <nl> - " EV7 . 9 ( 21364A ) " ) <nl> - UNAME_MACHINE = " alphaev79 " ; ; <nl> - esac <nl> - # A Pn . n version is a patched version . <nl> - # A Vn . n version is a released version . <nl> - # A Tn . n version is a released field test version . <nl> - # A Xn . n version is an unreleased experimental baselevel . <nl> - # 1 . 2 uses " 1 . 2 " for uname - r . <nl> - echo $ { UNAME_MACHINE } - dec - osf ` echo $ { UNAME_RELEASE } | sed - e ' s / ^ [ PVTX ] / / ' | tr ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' ` <nl> - exit ; ; <nl> - Alpha \ * : Windows_NT * : * ) <nl> - # How do we know it ' s Interix rather than the generic POSIX subsystem ? <nl> - # Should we change UNAME_MACHINE based on the output of uname instead <nl> - # of the specific Alpha model ? <nl> - echo alpha - pc - interix <nl> - exit ; ; <nl> - 21064 : Windows_NT : 50 : 3 ) <nl> - echo alpha - dec - winnt3 . 5 <nl> - exit ; ; <nl> - Amiga * : UNIX_System_V : 4 . 0 : * ) <nl> - echo m68k - unknown - sysv4 <nl> - exit ; ; <nl> - * : [ Aa ] miga [ Oo ] [ Ss ] : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - amigaos <nl> - exit ; ; <nl> - * : [ Mm ] orph [ Oo ] [ Ss ] : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - morphos <nl> - exit ; ; <nl> - * : OS / 390 : * : * ) <nl> - echo i370 - ibm - openedition <nl> - exit ; ; <nl> - * : z / VM : * : * ) <nl> - echo s390 - ibm - zvmoe <nl> - exit ; ; <nl> - * : OS400 : * : * ) <nl> - echo powerpc - ibm - os400 <nl> - exit ; ; <nl> - arm : RISC * : 1 . [ 012 ] * : * | arm : riscix : 1 . [ 012 ] * : * ) <nl> - echo arm - acorn - riscix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - arm : riscos : * : * | arm : RISCOS : * : * ) <nl> - echo arm - unknown - riscos <nl> - exit ; ; <nl> - SR2 ? 01 : HI - UX / MPP : * : * | SR8000 : HI - UX / MPP : * : * ) <nl> - echo hppa1 . 1 - hitachi - hiuxmpp <nl> - exit ; ; <nl> - Pyramid * : OSx * : * : * | MIS * : OSx * : * : * | MIS * : SMP_DC - OSx * : * : * ) <nl> - # akee @ wpdis03 . wpafb . af . mil ( Earle F . Ake ) contributed MIS and NILE . <nl> - if test " ` ( / bin / universe ) 2 > / dev / null ` " = att ; then <nl> - echo pyramid - pyramid - sysv3 <nl> - else <nl> - echo pyramid - pyramid - bsd <nl> - fi <nl> - exit ; ; <nl> - NILE * : * : * : dcosx ) <nl> - echo pyramid - pyramid - svr4 <nl> - exit ; ; <nl> - DRS ? 6000 : unix : 4 . 0 : 6 * ) <nl> - echo sparc - icl - nx6 <nl> - exit ; ; <nl> - DRS ? 6000 : UNIX_SV : 4 . 2 * : 7 * | DRS ? 6000 : isis : 4 . 2 * : 7 * ) <nl> - case ` / usr / bin / uname - p ` in <nl> - sparc ) echo sparc - icl - nx7 ; exit ; ; <nl> - esac ; ; <nl> - s390x : SunOS : * : * ) <nl> - echo $ { UNAME_MACHINE } - ibm - solaris2 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - sun4H : SunOS : 5 . * : * ) <nl> - echo sparc - hal - solaris2 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - sun4 * : SunOS : 5 . * : * | tadpole * : SunOS : 5 . * : * ) <nl> - echo sparc - sun - solaris2 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - i86pc : AuroraUX : 5 . * : * | i86xen : AuroraUX : 5 . * : * ) <nl> - echo i386 - pc - auroraux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - i86pc : SunOS : 5 . * : * | i86xen : SunOS : 5 . * : * ) <nl> - eval $ set_cc_for_build <nl> - SUN_ARCH = " i386 " <nl> - # If there is a compiler , see if it is configured for 64 - bit objects . <nl> - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does . <nl> - # This test works for both compilers . <nl> - if [ " $ CC_FOR_BUILD " ! = ' no_compiler_found ' ] ; then <nl> - if ( echo ' # ifdef __amd64 ' ; echo IS_64BIT_ARCH ; echo ' # endif ' ) | \ <nl> - ( CCOPTS = $ CC_FOR_BUILD - E - 2 > / dev / null ) | \ <nl> - grep IS_64BIT_ARCH > / dev / null <nl> - then <nl> - SUN_ARCH = " x86_64 " <nl> - fi <nl> - fi <nl> - echo $ { SUN_ARCH } - pc - solaris2 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - sun4 * : SunOS : 6 * : * ) <nl> - # According to config . sub , this is the proper way to canonicalize <nl> - # SunOS6 . Hard to guess exactly what SunOS6 will be like , but <nl> - # it ' s likely to be more like Solaris than SunOS4 . <nl> - echo sparc - sun - solaris3 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - sun4 * : SunOS : * : * ) <nl> - case " ` / usr / bin / arch - k ` " in <nl> - Series * | S4 * ) <nl> - UNAME_RELEASE = ` uname - v ` <nl> - ; ; <nl> - esac <nl> - # Japanese Language versions have a version number like ` 4 . 1 . 3 - JL ' . <nl> - echo sparc - sun - sunos ` echo $ { UNAME_RELEASE } | sed - e ' s / - / _ / ' ` <nl> - exit ; ; <nl> - sun3 * : SunOS : * : * ) <nl> - echo m68k - sun - sunos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - sun * : * : 4 . 2BSD : * ) <nl> - UNAME_RELEASE = ` ( sed 1q / etc / motd | awk ' { print substr ( $ 5 , 1 , 3 ) } ' ) 2 > / dev / null ` <nl> - test " x $ { UNAME_RELEASE } " = " x " & & UNAME_RELEASE = 3 <nl> - case " ` / bin / arch ` " in <nl> - sun3 ) <nl> - echo m68k - sun - sunos $ { UNAME_RELEASE } <nl> - ; ; <nl> - sun4 ) <nl> - echo sparc - sun - sunos $ { UNAME_RELEASE } <nl> - ; ; <nl> - esac <nl> - exit ; ; <nl> - aushp : SunOS : * : * ) <nl> - echo sparc - auspex - sunos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - # The situation for MiNT is a little confusing . The machine name <nl> - # can be virtually everything ( everything which is not <nl> - # " atarist " or " atariste " at least should have a processor <nl> - # > m68000 ) . The system name ranges from " MiNT " over " FreeMiNT " <nl> - # to the lowercase version " mint " ( or " freemint " ) . Finally <nl> - # the system name " TOS " denotes a system which is actually not <nl> - # MiNT . But MiNT is downward compatible to TOS , so this should <nl> - # be no problem . <nl> - atarist [ e ] : * MiNT : * : * | atarist [ e ] : * mint : * : * | atarist [ e ] : * TOS : * : * ) <nl> - echo m68k - atari - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - atari * : * MiNT : * : * | atari * : * mint : * : * | atarist [ e ] : * TOS : * : * ) <nl> - echo m68k - atari - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * falcon * : * MiNT : * : * | * falcon * : * mint : * : * | * falcon * : * TOS : * : * ) <nl> - echo m68k - atari - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - milan * : * MiNT : * : * | milan * : * mint : * : * | * milan * : * TOS : * : * ) <nl> - echo m68k - milan - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - hades * : * MiNT : * : * | hades * : * mint : * : * | * hades * : * TOS : * : * ) <nl> - echo m68k - hades - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : * MiNT : * : * | * : * mint : * : * | * : * TOS : * : * ) <nl> - echo m68k - unknown - mint $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - m68k : machten : * : * ) <nl> - echo m68k - apple - machten $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - powerpc : machten : * : * ) <nl> - echo powerpc - apple - machten $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - RISC * : Mach : * : * ) <nl> - echo mips - dec - mach_bsd4 . 3 <nl> - exit ; ; <nl> - RISC * : ULTRIX : * : * ) <nl> - echo mips - dec - ultrix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - VAX * : ULTRIX * : * : * ) <nl> - echo vax - dec - ultrix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - 2020 : CLIX : * : * | 2430 : CLIX : * : * ) <nl> - echo clipper - intergraph - clix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - mips : * : * : UMIPS | mips : * : * : RISCos ) <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - # ifdef __cplusplus <nl> - # include < stdio . h > / * for printf ( ) prototype * / <nl> - int main ( int argc , char * argv [ ] ) { <nl> - # else <nl> - int main ( argc , argv ) int argc ; char * argv [ ] ; { <nl> - # endif <nl> - # if defined ( host_mips ) & & defined ( MIPSEB ) <nl> - # if defined ( SYSTYPE_SYSV ) <nl> - printf ( " mips - mips - riscos % ssysv \ n " , argv [ 1 ] ) ; exit ( 0 ) ; <nl> - # endif <nl> - # if defined ( SYSTYPE_SVR4 ) <nl> - printf ( " mips - mips - riscos % ssvr4 \ n " , argv [ 1 ] ) ; exit ( 0 ) ; <nl> - # endif <nl> - # if defined ( SYSTYPE_BSD43 ) | | defined ( SYSTYPE_BSD ) <nl> - printf ( " mips - mips - riscos % sbsd \ n " , argv [ 1 ] ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - exit ( - 1 ) ; <nl> - } <nl> - EOF <nl> - $ CC_FOR_BUILD - o $ dummy $ dummy . c & & <nl> - dummyarg = ` echo " $ { UNAME_RELEASE } " | sed - n ' s / \ ( [ 0 - 9 ] * \ ) . * / \ 1 / p ' ` & & <nl> - SYSTEM_NAME = ` $ dummy $ dummyarg ` & & <nl> - { echo " $ SYSTEM_NAME " ; exit ; } <nl> - echo mips - mips - riscos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - Motorola : PowerMAX_OS : * : * ) <nl> - echo powerpc - motorola - powermax <nl> - exit ; ; <nl> - Motorola : * : 4 . 3 : PL8 - * ) <nl> - echo powerpc - harris - powermax <nl> - exit ; ; <nl> - Night_Hawk : * : * : PowerMAX_OS | Synergy : PowerMAX_OS : * : * ) <nl> - echo powerpc - harris - powermax <nl> - exit ; ; <nl> - Night_Hawk : Power_UNIX : * : * ) <nl> - echo powerpc - harris - powerunix <nl> - exit ; ; <nl> - m88k : CX / UX : 7 * : * ) <nl> - echo m88k - harris - cxux7 <nl> - exit ; ; <nl> - m88k : * : 4 * : R4 * ) <nl> - echo m88k - motorola - sysv4 <nl> - exit ; ; <nl> - m88k : * : 3 * : R3 * ) <nl> - echo m88k - motorola - sysv3 <nl> - exit ; ; <nl> - AViiON : dgux : * : * ) <nl> - # DG / UX returns AViiON for all architectures <nl> - UNAME_PROCESSOR = ` / usr / bin / uname - p ` <nl> - if [ $ UNAME_PROCESSOR = mc88100 ] | | [ $ UNAME_PROCESSOR = mc88110 ] <nl> - then <nl> - if [ $ { TARGET_BINARY_INTERFACE } x = m88kdguxelfx ] | | \ <nl> - [ $ { TARGET_BINARY_INTERFACE } x = x ] <nl> - then <nl> - echo m88k - dg - dgux $ { UNAME_RELEASE } <nl> - else <nl> - echo m88k - dg - dguxbcs $ { UNAME_RELEASE } <nl> - fi <nl> - else <nl> - echo i586 - dg - dgux $ { UNAME_RELEASE } <nl> - fi <nl> - exit ; ; <nl> - M88 * : DolphinOS : * : * ) # DolphinOS ( SVR3 ) <nl> - echo m88k - dolphin - sysv3 <nl> - exit ; ; <nl> - M88 * : * : R3 * : * ) <nl> - # Delta 88k system running SVR3 <nl> - echo m88k - motorola - sysv3 <nl> - exit ; ; <nl> - XD88 * : * : * : * ) # Tektronix XD88 system running UTekV ( SVR3 ) <nl> - echo m88k - tektronix - sysv3 <nl> - exit ; ; <nl> - Tek43 [ 0 - 9 ] [ 0 - 9 ] : UTek : * : * ) # Tektronix 4300 system running UTek ( BSD ) <nl> - echo m68k - tektronix - bsd <nl> - exit ; ; <nl> - * : IRIX * : * : * ) <nl> - echo mips - sgi - irix ` echo $ { UNAME_RELEASE } | sed - e ' s / - / _ / g ' ` <nl> - exit ; ; <nl> - ? ? ? ? ? ? ? ? : AIX ? : [ 12 ] . 1 : 2 ) # AIX 2 . 2 . 1 or AIX 2 . 1 . 1 is RT / PC AIX . <nl> - echo romp - ibm - aix # uname - m gives an 8 hex - code CPU id <nl> - exit ; ; # Note that : echo " ' ` uname - s ` ' " gives ' AIX ' <nl> - i * 86 : AIX : * : * ) <nl> - echo i386 - ibm - aix <nl> - exit ; ; <nl> - ia64 : AIX : * : * ) <nl> - if [ - x / usr / bin / oslevel ] ; then <nl> - IBM_REV = ` / usr / bin / oslevel ` <nl> - else <nl> - IBM_REV = $ { UNAME_VERSION } . $ { UNAME_RELEASE } <nl> - fi <nl> - echo $ { UNAME_MACHINE } - ibm - aix $ { IBM_REV } <nl> - exit ; ; <nl> - * : AIX : 2 : 3 ) <nl> - if grep bos325 / usr / include / stdio . h > / dev / null 2 > & 1 ; then <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - # include < sys / systemcfg . h > <nl> - <nl> - main ( ) <nl> - { <nl> - if ( ! __power_pc ( ) ) <nl> - exit ( 1 ) ; <nl> - puts ( " powerpc - ibm - aix3 . 2 . 5 " ) ; <nl> - exit ( 0 ) ; <nl> - } <nl> - EOF <nl> - if $ CC_FOR_BUILD - o $ dummy $ dummy . c & & SYSTEM_NAME = ` $ dummy ` <nl> - then <nl> - echo " $ SYSTEM_NAME " <nl> - else <nl> - echo rs6000 - ibm - aix3 . 2 . 5 <nl> - fi <nl> - elif grep bos324 / usr / include / stdio . h > / dev / null 2 > & 1 ; then <nl> - echo rs6000 - ibm - aix3 . 2 . 4 <nl> - else <nl> - echo rs6000 - ibm - aix3 . 2 <nl> - fi <nl> - exit ; ; <nl> - * : AIX : * : [ 456 ] ) <nl> - IBM_CPU_ID = ` / usr / sbin / lsdev - C - c processor - S available | sed 1q | awk ' { print $ 1 } ' ` <nl> - if / usr / sbin / lsattr - El $ { IBM_CPU_ID } | grep ' POWER ' > / dev / null 2 > & 1 ; then <nl> - IBM_ARCH = rs6000 <nl> - else <nl> - IBM_ARCH = powerpc <nl> - fi <nl> - if [ - x / usr / bin / oslevel ] ; then <nl> - IBM_REV = ` / usr / bin / oslevel ` <nl> - else <nl> - IBM_REV = $ { UNAME_VERSION } . $ { UNAME_RELEASE } <nl> - fi <nl> - echo $ { IBM_ARCH } - ibm - aix $ { IBM_REV } <nl> - exit ; ; <nl> - * : AIX : * : * ) <nl> - echo rs6000 - ibm - aix <nl> - exit ; ; <nl> - ibmrt : 4 . 4BSD : * | romp - ibm : BSD : * ) <nl> - echo romp - ibm - bsd4 . 4 <nl> - exit ; ; <nl> - ibmrt : * BSD : * | romp - ibm : BSD : * ) # covers RT / PC BSD and <nl> - echo romp - ibm - bsd $ { UNAME_RELEASE } # 4 . 3 with uname added to <nl> - exit ; ; # report : romp - ibm BSD 4 . 3 <nl> - * : BOSX : * : * ) <nl> - echo rs6000 - bull - bosx <nl> - exit ; ; <nl> - DPX / 2 ? 00 : B . O . S . : * : * ) <nl> - echo m68k - bull - sysv3 <nl> - exit ; ; <nl> - 9000 / [ 34 ] ? ? : 4 . 3bsd : 1 . * : * ) <nl> - echo m68k - hp - bsd <nl> - exit ; ; <nl> - hp300 : 4 . 4BSD : * : * | 9000 / [ 34 ] ? ? : 4 . 3bsd : 2 . * : * ) <nl> - echo m68k - hp - bsd4 . 4 <nl> - exit ; ; <nl> - 9000 / [ 34678 ] ? ? : HP - UX : * : * ) <nl> - HPUX_REV = ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * . [ 0B ] * / / ' ` <nl> - case " $ { UNAME_MACHINE } " in <nl> - 9000 / 31 ? ) HP_ARCH = m68000 ; ; <nl> - 9000 / [ 34 ] ? ? ) HP_ARCH = m68k ; ; <nl> - 9000 / [ 678 ] [ 0 - 9 ] [ 0 - 9 ] ) <nl> - if [ - x / usr / bin / getconf ] ; then <nl> - sc_cpu_version = ` / usr / bin / getconf SC_CPU_VERSION 2 > / dev / null ` <nl> - sc_kernel_bits = ` / usr / bin / getconf SC_KERNEL_BITS 2 > / dev / null ` <nl> - case " $ { sc_cpu_version } " in <nl> - 523 ) HP_ARCH = " hppa1 . 0 " ; ; # CPU_PA_RISC1_0 <nl> - 528 ) HP_ARCH = " hppa1 . 1 " ; ; # CPU_PA_RISC1_1 <nl> - 532 ) # CPU_PA_RISC2_0 <nl> - case " $ { sc_kernel_bits } " in <nl> - 32 ) HP_ARCH = " hppa2 . 0n " ; ; <nl> - 64 ) HP_ARCH = " hppa2 . 0w " ; ; <nl> - ' ' ) HP_ARCH = " hppa2 . 0 " ; ; # HP - UX 10 . 20 <nl> - esac ; ; <nl> - esac <nl> - fi <nl> - if [ " $ { HP_ARCH } " = " " ] ; then <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - <nl> - # define _HPUX_SOURCE <nl> - # include < stdlib . h > <nl> - # include < unistd . h > <nl> - <nl> - int main ( ) <nl> - { <nl> - # if defined ( _SC_KERNEL_BITS ) <nl> - long bits = sysconf ( _SC_KERNEL_BITS ) ; <nl> - # endif <nl> - long cpu = sysconf ( _SC_CPU_VERSION ) ; <nl> - <nl> - switch ( cpu ) <nl> - { <nl> - case CPU_PA_RISC1_0 : puts ( " hppa1 . 0 " ) ; break ; <nl> - case CPU_PA_RISC1_1 : puts ( " hppa1 . 1 " ) ; break ; <nl> - case CPU_PA_RISC2_0 : <nl> - # if defined ( _SC_KERNEL_BITS ) <nl> - switch ( bits ) <nl> - { <nl> - case 64 : puts ( " hppa2 . 0w " ) ; break ; <nl> - case 32 : puts ( " hppa2 . 0n " ) ; break ; <nl> - default : puts ( " hppa2 . 0 " ) ; break ; <nl> - } break ; <nl> - # else / * ! defined ( _SC_KERNEL_BITS ) * / <nl> - puts ( " hppa2 . 0 " ) ; break ; <nl> - # endif <nl> - default : puts ( " hppa1 . 0 " ) ; break ; <nl> - } <nl> - exit ( 0 ) ; <nl> - } <nl> - EOF <nl> - ( CCOPTS = $ CC_FOR_BUILD - o $ dummy $ dummy . c 2 > / dev / null ) & & HP_ARCH = ` $ dummy ` <nl> - test - z " $ HP_ARCH " & & HP_ARCH = hppa <nl> - fi ; ; <nl> - esac <nl> - if [ $ { HP_ARCH } = " hppa2 . 0w " ] <nl> - then <nl> - eval $ set_cc_for_build <nl> - <nl> - # hppa2 . 0w - hp - hpux * has a 64 - bit kernel and a compiler generating <nl> - # 32 - bit code . hppa64 - hp - hpux * has the same kernel and a compiler <nl> - # generating 64 - bit code . GNU and HP use different nomenclature : <nl> - # <nl> - # $ CC_FOR_BUILD = cc . / config . guess <nl> - # = > hppa2 . 0w - hp - hpux11 . 23 <nl> - # $ CC_FOR_BUILD = " cc + DA2 . 0w " . / config . guess <nl> - # = > hppa64 - hp - hpux11 . 23 <nl> - <nl> - if echo __LP64__ | ( CCOPTS = $ CC_FOR_BUILD - E - 2 > / dev / null ) | <nl> - grep - q __LP64__ <nl> - then <nl> - HP_ARCH = " hppa2 . 0w " <nl> - else <nl> - HP_ARCH = " hppa64 " <nl> - fi <nl> - fi <nl> - echo $ { HP_ARCH } - hp - hpux $ { HPUX_REV } <nl> - exit ; ; <nl> - ia64 : HP - UX : * : * ) <nl> - HPUX_REV = ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * . [ 0B ] * / / ' ` <nl> - echo ia64 - hp - hpux $ { HPUX_REV } <nl> - exit ; ; <nl> - 3050 * : HI - UX : * : * ) <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - # include < unistd . h > <nl> - int <nl> - main ( ) <nl> - { <nl> - long cpu = sysconf ( _SC_CPU_VERSION ) ; <nl> - / * The order matters , because CPU_IS_HP_MC68K erroneously returns <nl> - true for CPU_PA_RISC1_0 . CPU_IS_PA_RISC returns correct <nl> - results , however . * / <nl> - if ( CPU_IS_PA_RISC ( cpu ) ) <nl> - { <nl> - switch ( cpu ) <nl> - { <nl> - case CPU_PA_RISC1_0 : puts ( " hppa1 . 0 - hitachi - hiuxwe2 " ) ; break ; <nl> - case CPU_PA_RISC1_1 : puts ( " hppa1 . 1 - hitachi - hiuxwe2 " ) ; break ; <nl> - case CPU_PA_RISC2_0 : puts ( " hppa2 . 0 - hitachi - hiuxwe2 " ) ; break ; <nl> - default : puts ( " hppa - hitachi - hiuxwe2 " ) ; break ; <nl> - } <nl> - } <nl> - else if ( CPU_IS_HP_MC68K ( cpu ) ) <nl> - puts ( " m68k - hitachi - hiuxwe2 " ) ; <nl> - else puts ( " unknown - hitachi - hiuxwe2 " ) ; <nl> - exit ( 0 ) ; <nl> - } <nl> - EOF <nl> - $ CC_FOR_BUILD - o $ dummy $ dummy . c & & SYSTEM_NAME = ` $ dummy ` & & <nl> - { echo " $ SYSTEM_NAME " ; exit ; } <nl> - echo unknown - hitachi - hiuxwe2 <nl> - exit ; ; <nl> - 9000 / 7 ? ? : 4 . 3bsd : * : * | 9000 / 8 ? [ 79 ] : 4 . 3bsd : * : * ) <nl> - echo hppa1 . 1 - hp - bsd <nl> - exit ; ; <nl> - 9000 / 8 ? ? : 4 . 3bsd : * : * ) <nl> - echo hppa1 . 0 - hp - bsd <nl> - exit ; ; <nl> - * 9 ? ? * : MPE / iX : * : * | * 3000 * : MPE / iX : * : * ) <nl> - echo hppa1 . 0 - hp - mpeix <nl> - exit ; ; <nl> - hp7 ? ? : OSF1 : * : * | hp8 ? [ 79 ] : OSF1 : * : * ) <nl> - echo hppa1 . 1 - hp - osf <nl> - exit ; ; <nl> - hp8 ? ? : OSF1 : * : * ) <nl> - echo hppa1 . 0 - hp - osf <nl> - exit ; ; <nl> - i * 86 : OSF1 : * : * ) <nl> - if [ - x / usr / sbin / sysversion ] ; then <nl> - echo $ { UNAME_MACHINE } - unknown - osf1mk <nl> - else <nl> - echo $ { UNAME_MACHINE } - unknown - osf1 <nl> - fi <nl> - exit ; ; <nl> - parisc * : Lites * : * : * ) <nl> - echo hppa1 . 1 - hp - lites <nl> - exit ; ; <nl> - C1 * : ConvexOS : * : * | convex : ConvexOS : C1 * : * ) <nl> - echo c1 - convex - bsd <nl> - exit ; ; <nl> - C2 * : ConvexOS : * : * | convex : ConvexOS : C2 * : * ) <nl> - if getsysinfo - f scalar_acc <nl> - then echo c32 - convex - bsd <nl> - else echo c2 - convex - bsd <nl> - fi <nl> - exit ; ; <nl> - C34 * : ConvexOS : * : * | convex : ConvexOS : C34 * : * ) <nl> - echo c34 - convex - bsd <nl> - exit ; ; <nl> - C38 * : ConvexOS : * : * | convex : ConvexOS : C38 * : * ) <nl> - echo c38 - convex - bsd <nl> - exit ; ; <nl> - C4 * : ConvexOS : * : * | convex : ConvexOS : C4 * : * ) <nl> - echo c4 - convex - bsd <nl> - exit ; ; <nl> - CRAY * Y - MP : * : * : * ) <nl> - echo ymp - cray - unicos $ { UNAME_RELEASE } | sed - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - CRAY * [ A - Z ] 90 : * : * : * ) <nl> - echo $ { UNAME_MACHINE } - cray - unicos $ { UNAME_RELEASE } \ <nl> - | sed - e ' s / CRAY . * \ ( [ A - Z ] 90 \ ) / \ 1 / ' \ <nl> - - e y / ABCDEFGHIJKLMNOPQRSTUVWXYZ / abcdefghijklmnopqrstuvwxyz / \ <nl> - - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - CRAY * TS : * : * : * ) <nl> - echo t90 - cray - unicos $ { UNAME_RELEASE } | sed - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - CRAY * T3E : * : * : * ) <nl> - echo alphaev5 - cray - unicosmk $ { UNAME_RELEASE } | sed - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - CRAY * SV1 : * : * : * ) <nl> - echo sv1 - cray - unicos $ { UNAME_RELEASE } | sed - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - * : UNICOS / mp : * : * ) <nl> - echo craynv - cray - unicosmp $ { UNAME_RELEASE } | sed - e ' s / \ . [ ^ . ] * $ / . X / ' <nl> - exit ; ; <nl> - F30 [ 01 ] : UNIX_System_V : * : * | F700 : UNIX_System_V : * : * ) <nl> - FUJITSU_PROC = ` uname - m | tr ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' ` <nl> - FUJITSU_SYS = ` uname - p | tr ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' | sed - e ' s / \ / / / ' ` <nl> - FUJITSU_REL = ` echo $ { UNAME_RELEASE } | sed - e ' s / / _ / ' ` <nl> - echo " $ { FUJITSU_PROC } - fujitsu - $ { FUJITSU_SYS } $ { FUJITSU_REL } " <nl> - exit ; ; <nl> - 5000 : UNIX_System_V : 4 . * : * ) <nl> - FUJITSU_SYS = ` uname - p | tr ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' | sed - e ' s / \ / / / ' ` <nl> - FUJITSU_REL = ` echo $ { UNAME_RELEASE } | tr ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ' abcdefghijklmnopqrstuvwxyz ' | sed - e ' s / / _ / ' ` <nl> - echo " sparc - fujitsu - $ { FUJITSU_SYS } $ { FUJITSU_REL } " <nl> - exit ; ; <nl> - i * 86 : BSD / 386 : * : * | i * 86 : BSD / OS : * : * | * : Ascend \ Embedded / OS : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - bsdi $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - sparc * : BSD / OS : * : * ) <nl> - echo sparc - unknown - bsdi $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : BSD / OS : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - bsdi $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : FreeBSD : * : * ) <nl> - case $ { UNAME_MACHINE } in <nl> - pc98 ) <nl> - echo i386 - unknown - freebsd ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - ( ] . * / / ' ` ; ; <nl> - amd64 ) <nl> - echo x86_64 - unknown - freebsd ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - ( ] . * / / ' ` ; ; <nl> - * ) <nl> - echo $ { UNAME_MACHINE } - unknown - freebsd ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - ( ] . * / / ' ` ; ; <nl> - esac <nl> - exit ; ; <nl> - i * : CYGWIN * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - cygwin <nl> - exit ; ; <nl> - * : MINGW * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - mingw32 <nl> - exit ; ; <nl> - i * : windows32 * : * ) <nl> - # uname - m includes " - pc " on this system . <nl> - echo $ { UNAME_MACHINE } - mingw32 <nl> - exit ; ; <nl> - i * : PW * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - pw32 <nl> - exit ; ; <nl> - * : Interix * : * ) <nl> - case $ { UNAME_MACHINE } in <nl> - x86 ) <nl> - echo i586 - pc - interix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - authenticamd | genuineintel | EM64T ) <nl> - echo x86_64 - unknown - interix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - IA64 ) <nl> - echo ia64 - unknown - interix $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - esac ; ; <nl> - [ 345 ] 86 : Windows_95 : * | [ 345 ] 86 : Windows_98 : * | [ 345 ] 86 : Windows_NT : * ) <nl> - echo i $ { UNAME_MACHINE } - pc - mks <nl> - exit ; ; <nl> - 8664 : Windows_NT : * ) <nl> - echo x86_64 - pc - mks <nl> - exit ; ; <nl> - i * : Windows_NT * : * | Pentium * : Windows_NT * : * ) <nl> - # How do we know it ' s Interix rather than the generic POSIX subsystem ? <nl> - # It also conflicts with pre - 2 . 0 versions of AT & T UWIN . Should we <nl> - # UNAME_MACHINE based on the output of uname instead of i386 ? <nl> - echo i586 - pc - interix <nl> - exit ; ; <nl> - i * : UWIN * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - uwin <nl> - exit ; ; <nl> - amd64 : CYGWIN * : * : * | x86_64 : CYGWIN * : * : * ) <nl> - echo x86_64 - unknown - cygwin <nl> - exit ; ; <nl> - p * : CYGWIN * : * ) <nl> - echo powerpcle - unknown - cygwin <nl> - exit ; ; <nl> - prep * : SunOS : 5 . * : * ) <nl> - echo powerpcle - unknown - solaris2 ` echo $ { UNAME_RELEASE } | sed - e ' s / [ ^ . ] * / / ' ` <nl> - exit ; ; <nl> - * : GNU : * : * ) <nl> - # the GNU system <nl> - echo ` echo $ { UNAME_MACHINE } | sed - e ' s , [ - / ] . * $ , , ' ` - unknown - gnu ` echo $ { UNAME_RELEASE } | sed - e ' s , / . * $ , , ' ` <nl> - exit ; ; <nl> - * : GNU / * : * : * ) <nl> - # other systems with GNU libc and userland <nl> - echo $ { UNAME_MACHINE } - unknown - ` echo $ { UNAME_SYSTEM } | sed ' s , ^ [ ^ / ] * / , , ' | tr ' [ A - Z ] ' ' [ a - z ] ' ` ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - ( ] . * / / ' ` - gnu <nl> - exit ; ; <nl> - i * 86 : Minix : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - minix <nl> - exit ; ; <nl> - alpha : Linux : * : * ) <nl> - case ` sed - n ' / ^ cpu model / s / ^ . * : \ ( . * \ ) / \ 1 / p ' < / proc / cpuinfo ` in <nl> - EV5 ) UNAME_MACHINE = alphaev5 ; ; <nl> - EV56 ) UNAME_MACHINE = alphaev56 ; ; <nl> - PCA56 ) UNAME_MACHINE = alphapca56 ; ; <nl> - PCA57 ) UNAME_MACHINE = alphapca56 ; ; <nl> - EV6 ) UNAME_MACHINE = alphaev6 ; ; <nl> - EV67 ) UNAME_MACHINE = alphaev67 ; ; <nl> - EV68 * ) UNAME_MACHINE = alphaev68 ; ; <nl> - esac <nl> - objdump - - private - headers / bin / sh | grep - q ld . so . 1 <nl> - if test " $ ? " = 0 ; then LIBC = " libc1 " ; else LIBC = " " ; fi <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu $ { LIBC } <nl> - exit ; ; <nl> - arm * : Linux : * : * ) <nl> - eval $ set_cc_for_build <nl> - if echo __ARM_EABI__ | $ CC_FOR_BUILD - E - 2 > / dev / null \ <nl> - | grep - q __ARM_EABI__ <nl> - then <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - else <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnueabi <nl> - fi <nl> - exit ; ; <nl> - avr32 * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - cris : Linux : * : * ) <nl> - echo cris - axis - linux - gnu <nl> - exit ; ; <nl> - crisv32 : Linux : * : * ) <nl> - echo crisv32 - axis - linux - gnu <nl> - exit ; ; <nl> - frv : Linux : * : * ) <nl> - echo frv - unknown - linux - gnu <nl> - exit ; ; <nl> - i * 86 : Linux : * : * ) <nl> - LIBC = gnu <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - # ifdef __dietlibc__ <nl> - LIBC = dietlibc <nl> - # endif <nl> - EOF <nl> - eval ` $ CC_FOR_BUILD - E $ dummy . c 2 > / dev / null | grep ' ^ LIBC ' ` <nl> - echo " $ { UNAME_MACHINE } - pc - linux - $ { LIBC } " <nl> - exit ; ; <nl> - ia64 : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - m32r * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - m68 * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - mips : Linux : * : * | mips64 : Linux : * : * ) <nl> - eval $ set_cc_for_build <nl> - sed ' s / ^ / / ' < < EOF > $ dummy . c <nl> - # undef CPU <nl> - # undef $ { UNAME_MACHINE } <nl> - # undef $ { UNAME_MACHINE } el <nl> - # if defined ( __MIPSEL__ ) | | defined ( __MIPSEL ) | | defined ( _MIPSEL ) | | defined ( MIPSEL ) <nl> - CPU = $ { UNAME_MACHINE } el <nl> - # else <nl> - # if defined ( __MIPSEB__ ) | | defined ( __MIPSEB ) | | defined ( _MIPSEB ) | | defined ( MIPSEB ) <nl> - CPU = $ { UNAME_MACHINE } <nl> - # else <nl> - CPU = <nl> - # endif <nl> - # endif <nl> - EOF <nl> - eval ` $ CC_FOR_BUILD - E $ dummy . c 2 > / dev / null | grep ' ^ CPU ' ` <nl> - test x " $ { CPU } " ! = x & & { echo " $ { CPU } - unknown - linux - gnu " ; exit ; } <nl> - ; ; <nl> - or32 : Linux : * : * ) <nl> - echo or32 - unknown - linux - gnu <nl> - exit ; ; <nl> - padre : Linux : * : * ) <nl> - echo sparc - unknown - linux - gnu <nl> - exit ; ; <nl> - parisc64 : Linux : * : * | hppa64 : Linux : * : * ) <nl> - echo hppa64 - unknown - linux - gnu <nl> - exit ; ; <nl> - parisc : Linux : * : * | hppa : Linux : * : * ) <nl> - # Look for CPU level <nl> - case ` grep ' ^ cpu [ ^ a - z ] * : ' / proc / cpuinfo 2 > / dev / null | cut - d ' ' - f2 ` in <nl> - PA7 * ) echo hppa1 . 1 - unknown - linux - gnu ; ; <nl> - PA8 * ) echo hppa2 . 0 - unknown - linux - gnu ; ; <nl> - * ) echo hppa - unknown - linux - gnu ; ; <nl> - esac <nl> - exit ; ; <nl> - ppc64 : Linux : * : * ) <nl> - echo powerpc64 - unknown - linux - gnu <nl> - exit ; ; <nl> - ppc : Linux : * : * ) <nl> - echo powerpc - unknown - linux - gnu <nl> - exit ; ; <nl> - s390 : Linux : * : * | s390x : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - ibm - linux <nl> - exit ; ; <nl> - sh64 * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - sh * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - sparc : Linux : * : * | sparc64 : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - vax : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - dec - linux - gnu <nl> - exit ; ; <nl> - x86_64 : Linux : * : * ) <nl> - echo x86_64 - unknown - linux - gnu <nl> - exit ; ; <nl> - xtensa * : Linux : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - linux - gnu <nl> - exit ; ; <nl> - i * 86 : DYNIX / ptx : 4 * : * ) <nl> - # ptx 4 . 0 does uname - s correctly , with DYNIX / ptx in there . <nl> - # earlier versions are messed up and put the nodename in both <nl> - # sysname and nodename . <nl> - echo i386 - sequent - sysv4 <nl> - exit ; ; <nl> - i * 86 : UNIX_SV : 4 . 2MP : 2 . * ) <nl> - # Unixware is an offshoot of SVR4 , but it has its own version <nl> - # number series starting with 2 . . . <nl> - # I am not positive that other SVR4 systems won ' t match this , <nl> - # I just have to hope . - - rms . <nl> - # Use sysv4 . 2uw . . . so that sysv4 * matches it . <nl> - echo $ { UNAME_MACHINE } - pc - sysv4 . 2uw $ { UNAME_VERSION } <nl> - exit ; ; <nl> - i * 86 : OS / 2 : * : * ) <nl> - # If we were able to find ` uname ' , then EMX Unix compatibility <nl> - # is probably installed . <nl> - echo $ { UNAME_MACHINE } - pc - os2 - emx <nl> - exit ; ; <nl> - i * 86 : XTS - 300 : * : STOP ) <nl> - echo $ { UNAME_MACHINE } - unknown - stop <nl> - exit ; ; <nl> - i * 86 : atheos : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - atheos <nl> - exit ; ; <nl> - i * 86 : syllable : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - syllable <nl> - exit ; ; <nl> - i * 86 : LynxOS : 2 . * : * | i * 86 : LynxOS : 3 . [ 01 ] * : * | i * 86 : LynxOS : 4 . [ 02 ] * : * ) <nl> - echo i386 - unknown - lynxos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - i * 86 : * DOS : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - msdosdjgpp <nl> - exit ; ; <nl> - i * 86 : * : 4 . * : * | i * 86 : SYSTEM_V : 4 . * : * ) <nl> - UNAME_REL = ` echo $ { UNAME_RELEASE } | sed ' s / \ / MP $ / / ' ` <nl> - if grep Novell / usr / include / link . h > / dev / null 2 > / dev / null ; then <nl> - echo $ { UNAME_MACHINE } - univel - sysv $ { UNAME_REL } <nl> - else <nl> - echo $ { UNAME_MACHINE } - pc - sysv $ { UNAME_REL } <nl> - fi <nl> - exit ; ; <nl> - i * 86 : * : 5 : [ 678 ] * ) <nl> - # UnixWare 7 . x , OpenUNIX and OpenServer 6 . <nl> - case ` / bin / uname - X | grep " ^ Machine " ` in <nl> - * 486 * ) UNAME_MACHINE = i486 ; ; <nl> - * Pentium ) UNAME_MACHINE = i586 ; ; <nl> - * Pent * | * Celeron ) UNAME_MACHINE = i686 ; ; <nl> - esac <nl> - echo $ { UNAME_MACHINE } - unknown - sysv $ { UNAME_RELEASE } $ { UNAME_SYSTEM } $ { UNAME_VERSION } <nl> - exit ; ; <nl> - i * 86 : * : 3 . 2 : * ) <nl> - if test - f / usr / options / cb . name ; then <nl> - UNAME_REL = ` sed - n ' s / . * Version / / p ' < / usr / options / cb . name ` <nl> - echo $ { UNAME_MACHINE } - pc - isc $ UNAME_REL <nl> - elif / bin / uname - X 2 > / dev / null > / dev / null ; then <nl> - UNAME_REL = ` ( / bin / uname - X | grep Release | sed - e ' s / . * = / / ' ) ` <nl> - ( / bin / uname - X | grep i80486 > / dev / null ) & & UNAME_MACHINE = i486 <nl> - ( / bin / uname - X | grep ' ^ Machine . * Pentium ' > / dev / null ) \ <nl> - & & UNAME_MACHINE = i586 <nl> - ( / bin / uname - X | grep ' ^ Machine . * Pent * II ' > / dev / null ) \ <nl> - & & UNAME_MACHINE = i686 <nl> - ( / bin / uname - X | grep ' ^ Machine . * Pentium Pro ' > / dev / null ) \ <nl> - & & UNAME_MACHINE = i686 <nl> - echo $ { UNAME_MACHINE } - pc - sco $ UNAME_REL <nl> - else <nl> - echo $ { UNAME_MACHINE } - pc - sysv32 <nl> - fi <nl> - exit ; ; <nl> - pc : * : * : * ) <nl> - # Left here for compatibility : <nl> - # uname - m prints for DJGPP always ' pc ' , but it prints nothing about <nl> - # the processor , so we play safe by assuming i586 . <nl> - # Note : whatever this is , it MUST be the same as what config . sub <nl> - # prints for the " djgpp " host , or else GDB configury will decide that <nl> - # this is a cross - build . <nl> - echo i586 - pc - msdosdjgpp <nl> - exit ; ; <nl> - Intel : Mach : 3 * : * ) <nl> - echo i386 - pc - mach3 <nl> - exit ; ; <nl> - paragon : * : * : * ) <nl> - echo i860 - intel - osf1 <nl> - exit ; ; <nl> - i860 : * : 4 . * : * ) # i860 - SVR4 <nl> - if grep Stardent / usr / include / sys / uadmin . h > / dev / null 2 > & 1 ; then <nl> - echo i860 - stardent - sysv $ { UNAME_RELEASE } # Stardent Vistra i860 - SVR4 <nl> - else # Add other i860 - SVR4 vendors below as they are discovered . <nl> - echo i860 - unknown - sysv $ { UNAME_RELEASE } # Unknown i860 - SVR4 <nl> - fi <nl> - exit ; ; <nl> - mini * : CTIX : SYS * 5 : * ) <nl> - # " miniframe " <nl> - echo m68010 - convergent - sysv <nl> - exit ; ; <nl> - mc68k : UNIX : SYSTEM5 : 3 . 51m ) <nl> - echo m68k - convergent - sysv <nl> - exit ; ; <nl> - M680 ? 0 : D - NIX : 5 . 3 : * ) <nl> - echo m68k - diab - dnix <nl> - exit ; ; <nl> - M68 * : * : R3V [ 5678 ] * : * ) <nl> - test - r / sysV68 & & { echo ' m68k - motorola - sysv ' ; exit ; } ; ; <nl> - 3 [ 345 ] ? ? : * : 4 . 0 : 3 . 0 | 3 [ 34 ] ? ? A : * : 4 . 0 : 3 . 0 | 3 [ 34 ] ? ? , * : * : 4 . 0 : 3 . 0 | 3 [ 34 ] ? ? / * : * : 4 . 0 : 3 . 0 | 4400 : * : 4 . 0 : 3 . 0 | 4850 : * : 4 . 0 : 3 . 0 | SKA40 : * : 4 . 0 : 3 . 0 | SDS2 : * : 4 . 0 : 3 . 0 | SHG2 : * : 4 . 0 : 3 . 0 | S7501 * : * : 4 . 0 : 3 . 0 ) <nl> - OS_REL = ' ' <nl> - test - r / etc / . relid \ <nl> - & & OS_REL = . ` sed - n ' s / [ ^ ] * [ ^ ] * \ ( [ 0 - 9 ] [ 0 - 9 ] \ ) . * / \ 1 / p ' < / etc / . relid ` <nl> - / bin / uname - p 2 > / dev / null | grep 86 > / dev / null \ <nl> - & & { echo i486 - ncr - sysv4 . 3 $ { OS_REL } ; exit ; } <nl> - / bin / uname - p 2 > / dev / null | / bin / grep entium > / dev / null \ <nl> - & & { echo i586 - ncr - sysv4 . 3 $ { OS_REL } ; exit ; } ; ; <nl> - 3 [ 34 ] ? ? : * : 4 . 0 : * | 3 [ 34 ] ? ? , * : * : 4 . 0 : * ) <nl> - / bin / uname - p 2 > / dev / null | grep 86 > / dev / null \ <nl> - & & { echo i486 - ncr - sysv4 ; exit ; } ; ; <nl> - NCR * : * : 4 . 2 : * | MPRAS * : * : 4 . 2 : * ) <nl> - OS_REL = ' . 3 ' <nl> - test - r / etc / . relid \ <nl> - & & OS_REL = . ` sed - n ' s / [ ^ ] * [ ^ ] * \ ( [ 0 - 9 ] [ 0 - 9 ] \ ) . * / \ 1 / p ' < / etc / . relid ` <nl> - / bin / uname - p 2 > / dev / null | grep 86 > / dev / null \ <nl> - & & { echo i486 - ncr - sysv4 . 3 $ { OS_REL } ; exit ; } <nl> - / bin / uname - p 2 > / dev / null | / bin / grep entium > / dev / null \ <nl> - & & { echo i586 - ncr - sysv4 . 3 $ { OS_REL } ; exit ; } <nl> - / bin / uname - p 2 > / dev / null | / bin / grep pteron > / dev / null \ <nl> - & & { echo i586 - ncr - sysv4 . 3 $ { OS_REL } ; exit ; } ; ; <nl> - m68 * : LynxOS : 2 . * : * | m68 * : LynxOS : 3 . 0 * : * ) <nl> - echo m68k - unknown - lynxos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - mc68030 : UNIX_System_V : 4 . * : * ) <nl> - echo m68k - atari - sysv4 <nl> - exit ; ; <nl> - TSUNAMI : LynxOS : 2 . * : * ) <nl> - echo sparc - unknown - lynxos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - rs6000 : LynxOS : 2 . * : * ) <nl> - echo rs6000 - unknown - lynxos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - PowerPC : LynxOS : 2 . * : * | PowerPC : LynxOS : 3 . [ 01 ] * : * | PowerPC : LynxOS : 4 . [ 02 ] * : * ) <nl> - echo powerpc - unknown - lynxos $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SM [ BE ] S : UNIX_SV : * : * ) <nl> - echo mips - dde - sysv $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - RM * : ReliantUNIX - * : * : * ) <nl> - echo mips - sni - sysv4 <nl> - exit ; ; <nl> - RM * : SINIX - * : * : * ) <nl> - echo mips - sni - sysv4 <nl> - exit ; ; <nl> - * : SINIX - * : * : * ) <nl> - if uname - p 2 > / dev / null > / dev / null ; then <nl> - UNAME_MACHINE = ` ( uname - p ) 2 > / dev / null ` <nl> - echo $ { UNAME_MACHINE } - sni - sysv4 <nl> - else <nl> - echo ns32k - sni - sysv <nl> - fi <nl> - exit ; ; <nl> - PENTIUM : * : 4 . 0 * : * ) # Unisys ` ClearPath HMP IX 4000 ' SVR4 / MP effort <nl> - # says < Richard . M . Bartel @ ccMail . Census . GOV > <nl> - echo i586 - unisys - sysv4 <nl> - exit ; ; <nl> - * : UNIX_System_V : 4 * : FTX * ) <nl> - # From Gerald Hewes < hewes @ openmarket . com > . <nl> - # How about differentiating between stratus architectures ? - djm <nl> - echo hppa1 . 1 - stratus - sysv4 <nl> - exit ; ; <nl> - * : * : * : FTX * ) <nl> - # From seanf @ swdc . stratus . com . <nl> - echo i860 - stratus - sysv4 <nl> - exit ; ; <nl> - i * 86 : VOS : * : * ) <nl> - # From Paul . Green @ stratus . com . <nl> - echo $ { UNAME_MACHINE } - stratus - vos <nl> - exit ; ; <nl> - * : VOS : * : * ) <nl> - # From Paul . Green @ stratus . com . <nl> - echo hppa1 . 1 - stratus - vos <nl> - exit ; ; <nl> - mc68 * : A / UX : * : * ) <nl> - echo m68k - apple - aux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - news * : NEWS - OS : 6 * : * ) <nl> - echo mips - sony - newsos6 <nl> - exit ; ; <nl> - R [ 34 ] 000 : * System_V * : * : * | R4000 : UNIX_SYSV : * : * | R * 000 : UNIX_SV : * : * ) <nl> - if [ - d / usr / nec ] ; then <nl> - echo mips - nec - sysv $ { UNAME_RELEASE } <nl> - else <nl> - echo mips - unknown - sysv $ { UNAME_RELEASE } <nl> - fi <nl> - exit ; ; <nl> - BeBox : BeOS : * : * ) # BeOS running on hardware made by Be , PPC only . <nl> - echo powerpc - be - beos <nl> - exit ; ; <nl> - BeMac : BeOS : * : * ) # BeOS running on Mac or Mac clone , PPC only . <nl> - echo powerpc - apple - beos <nl> - exit ; ; <nl> - BePC : BeOS : * : * ) # BeOS running on Intel PC compatible . <nl> - echo i586 - pc - beos <nl> - exit ; ; <nl> - BePC : Haiku : * : * ) # Haiku running on Intel PC compatible . <nl> - echo i586 - pc - haiku <nl> - exit ; ; <nl> - SX - 4 : SUPER - UX : * : * ) <nl> - echo sx4 - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SX - 5 : SUPER - UX : * : * ) <nl> - echo sx5 - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SX - 6 : SUPER - UX : * : * ) <nl> - echo sx6 - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SX - 7 : SUPER - UX : * : * ) <nl> - echo sx7 - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SX - 8 : SUPER - UX : * : * ) <nl> - echo sx8 - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - SX - 8R : SUPER - UX : * : * ) <nl> - echo sx8r - nec - superux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - Power * : Rhapsody : * : * ) <nl> - echo powerpc - apple - rhapsody $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : Rhapsody : * : * ) <nl> - echo $ { UNAME_MACHINE } - apple - rhapsody $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : Darwin : * : * ) <nl> - UNAME_PROCESSOR = ` uname - p ` | | UNAME_PROCESSOR = unknown <nl> - case $ UNAME_PROCESSOR in <nl> - i386 ) <nl> - eval $ set_cc_for_build <nl> - if [ " $ CC_FOR_BUILD " ! = ' no_compiler_found ' ] ; then <nl> - if ( echo ' # ifdef __LP64__ ' ; echo IS_64BIT_ARCH ; echo ' # endif ' ) | \ <nl> - ( CCOPTS = $ CC_FOR_BUILD - E - 2 > / dev / null ) | \ <nl> - grep IS_64BIT_ARCH > / dev / null <nl> - then <nl> - UNAME_PROCESSOR = " x86_64 " <nl> - fi <nl> - fi ; ; <nl> - unknown ) UNAME_PROCESSOR = powerpc ; ; <nl> - esac <nl> - echo $ { UNAME_PROCESSOR } - apple - darwin $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : procnto * : * : * | * : QNX : [ 0123456789 ] * : * ) <nl> - UNAME_PROCESSOR = ` uname - p ` <nl> - if test " $ UNAME_PROCESSOR " = " x86 " ; then <nl> - UNAME_PROCESSOR = i386 <nl> - UNAME_MACHINE = pc <nl> - fi <nl> - echo $ { UNAME_PROCESSOR } - $ { UNAME_MACHINE } - nto - qnx $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : QNX : * : 4 * ) <nl> - echo i386 - pc - qnx <nl> - exit ; ; <nl> - NSE - ? : NONSTOP_KERNEL : * : * ) <nl> - echo nse - tandem - nsk $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - NSR - ? : NONSTOP_KERNEL : * : * ) <nl> - echo nsr - tandem - nsk $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : NonStop - UX : * : * ) <nl> - echo mips - compaq - nonstopux <nl> - exit ; ; <nl> - BS2000 : POSIX * : * : * ) <nl> - echo bs2000 - siemens - sysv <nl> - exit ; ; <nl> - DS / * : UNIX_System_V : * : * ) <nl> - echo $ { UNAME_MACHINE } - $ { UNAME_SYSTEM } - $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : Plan9 : * : * ) <nl> - # " uname - m " is not consistent , so use $ cputype instead . 386 <nl> - # is converted to i386 for consistency with other x86 <nl> - # operating systems . <nl> - if test " $ cputype " = " 386 " ; then <nl> - UNAME_MACHINE = i386 <nl> - else <nl> - UNAME_MACHINE = " $ cputype " <nl> - fi <nl> - echo $ { UNAME_MACHINE } - unknown - plan9 <nl> - exit ; ; <nl> - * : TOPS - 10 : * : * ) <nl> - echo pdp10 - unknown - tops10 <nl> - exit ; ; <nl> - * : TENEX : * : * ) <nl> - echo pdp10 - unknown - tenex <nl> - exit ; ; <nl> - KS10 : TOPS - 20 : * : * | KL10 : TOPS - 20 : * : * | TYPE4 : TOPS - 20 : * : * ) <nl> - echo pdp10 - dec - tops20 <nl> - exit ; ; <nl> - XKL - 1 : TOPS - 20 : * : * | TYPE5 : TOPS - 20 : * : * ) <nl> - echo pdp10 - xkl - tops20 <nl> - exit ; ; <nl> - * : TOPS - 20 : * : * ) <nl> - echo pdp10 - unknown - tops20 <nl> - exit ; ; <nl> - * : ITS : * : * ) <nl> - echo pdp10 - unknown - its <nl> - exit ; ; <nl> - SEI : * : * : SEIUX ) <nl> - echo mips - sei - seiux $ { UNAME_RELEASE } <nl> - exit ; ; <nl> - * : DragonFly : * : * ) <nl> - echo $ { UNAME_MACHINE } - unknown - dragonfly ` echo $ { UNAME_RELEASE } | sed - e ' s / [ - ( ] . * / / ' ` <nl> - exit ; ; <nl> - * : * VMS : * : * ) <nl> - UNAME_MACHINE = ` ( uname - p ) 2 > / dev / null ` <nl> - case " $ { UNAME_MACHINE } " in <nl> - A * ) echo alpha - dec - vms ; exit ; ; <nl> - I * ) echo ia64 - dec - vms ; exit ; ; <nl> - V * ) echo vax - dec - vms ; exit ; ; <nl> - esac ; ; <nl> - * : XENIX : * : SysV ) <nl> - echo i386 - pc - xenix <nl> - exit ; ; <nl> - i * 86 : skyos : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - skyos ` echo $ { UNAME_RELEASE } ` | sed - e ' s / . * $ / / ' <nl> - exit ; ; <nl> - i * 86 : rdos : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - rdos <nl> - exit ; ; <nl> - i * 86 : AROS : * : * ) <nl> - echo $ { UNAME_MACHINE } - pc - aros <nl> - exit ; ; <nl> - esac <nl> - <nl> - # echo ' ( No uname command or uname output not recognized . ) ' 1 > & 2 <nl> - # echo " $ { UNAME_MACHINE } : $ { UNAME_SYSTEM } : $ { UNAME_RELEASE } : $ { UNAME_VERSION } " 1 > & 2 <nl> - <nl> - eval $ set_cc_for_build <nl> - cat > $ dummy . c < < EOF <nl> - # ifdef _SEQUENT_ <nl> - # include < sys / types . h > <nl> - # include < sys / utsname . h > <nl> - # endif <nl> - main ( ) <nl> - { <nl> - # if defined ( sony ) <nl> - # if defined ( MIPSEB ) <nl> - / * BFD wants " bsd " instead of " newsos " . Perhaps BFD should be changed , <nl> - I don ' t know . . . . * / <nl> - printf ( " mips - sony - bsd \ n " ) ; exit ( 0 ) ; <nl> - # else <nl> - # include < sys / param . h > <nl> - printf ( " m68k - sony - newsos % s \ n " , <nl> - # ifdef NEWSOS4 <nl> - " 4 " <nl> - # else <nl> - " " <nl> - # endif <nl> - ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( __arm ) & & defined ( __acorn ) & & defined ( __unix ) <nl> - printf ( " arm - acorn - riscix \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - <nl> - # if defined ( hp300 ) & & ! defined ( hpux ) <nl> - printf ( " m68k - hp - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - <nl> - # if defined ( NeXT ) <nl> - # if ! defined ( __ARCHITECTURE__ ) <nl> - # define __ARCHITECTURE__ " m68k " <nl> - # endif <nl> - int version ; <nl> - version = ` ( hostinfo | sed - n ' s / . * NeXT Mach \ ( [ 0 - 9 ] * \ ) . * / \ 1 / p ' ) 2 > / dev / null ` ; <nl> - if ( version < 4 ) <nl> - printf ( " % s - next - nextstep % d \ n " , __ARCHITECTURE__ , version ) ; <nl> - else <nl> - printf ( " % s - next - openstep % d \ n " , __ARCHITECTURE__ , version ) ; <nl> - exit ( 0 ) ; <nl> - # endif <nl> - <nl> - # if defined ( MULTIMAX ) | | defined ( n16 ) <nl> - # if defined ( UMAXV ) <nl> - printf ( " ns32k - encore - sysv \ n " ) ; exit ( 0 ) ; <nl> - # else <nl> - # if defined ( CMU ) <nl> - printf ( " ns32k - encore - mach \ n " ) ; exit ( 0 ) ; <nl> - # else <nl> - printf ( " ns32k - encore - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( __386BSD__ ) <nl> - printf ( " i386 - pc - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - <nl> - # if defined ( sequent ) <nl> - # if defined ( i386 ) <nl> - printf ( " i386 - sequent - dynix \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # if defined ( ns32000 ) <nl> - printf ( " ns32k - sequent - dynix \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( _SEQUENT_ ) <nl> - struct utsname un ; <nl> - <nl> - uname ( & un ) ; <nl> - <nl> - if ( strncmp ( un . version , " V2 " , 2 ) = = 0 ) { <nl> - printf ( " i386 - sequent - ptx2 \ n " ) ; exit ( 0 ) ; <nl> - } <nl> - if ( strncmp ( un . version , " V1 " , 2 ) = = 0 ) { / * XXX is V1 correct ? * / <nl> - printf ( " i386 - sequent - ptx1 \ n " ) ; exit ( 0 ) ; <nl> - } <nl> - printf ( " i386 - sequent - ptx \ n " ) ; exit ( 0 ) ; <nl> - <nl> - # endif <nl> - <nl> - # if defined ( vax ) <nl> - # if ! defined ( ultrix ) <nl> - # include < sys / param . h > <nl> - # if defined ( BSD ) <nl> - # if BSD = = 43 <nl> - printf ( " vax - dec - bsd4 . 3 \ n " ) ; exit ( 0 ) ; <nl> - # else <nl> - # if BSD = = 199006 <nl> - printf ( " vax - dec - bsd4 . 3reno \ n " ) ; exit ( 0 ) ; <nl> - # else <nl> - printf ( " vax - dec - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - # else <nl> - printf ( " vax - dec - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # else <nl> - printf ( " vax - dec - ultrix \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( alliant ) & & defined ( i860 ) <nl> - printf ( " i860 - alliant - bsd \ n " ) ; exit ( 0 ) ; <nl> - # endif <nl> - <nl> - exit ( 1 ) ; <nl> - } <nl> - EOF <nl> - <nl> - $ CC_FOR_BUILD - o $ dummy $ dummy . c 2 > / dev / null & & SYSTEM_NAME = ` $ dummy ` & & <nl> - { echo " $ SYSTEM_NAME " ; exit ; } <nl> - <nl> - # Apollos put the system type in the environment . <nl> - <nl> - test - d / usr / apollo & & { echo $ { ISP } - apollo - $ { SYSTYPE } ; exit ; } <nl> - <nl> - # Convex versions that predate uname can use getsysinfo ( 1 ) <nl> - <nl> - if [ - x / usr / convex / getsysinfo ] <nl> - then <nl> - case ` getsysinfo - f cpu_type ` in <nl> - c1 * ) <nl> - echo c1 - convex - bsd <nl> - exit ; ; <nl> - c2 * ) <nl> - if getsysinfo - f scalar_acc <nl> - then echo c32 - convex - bsd <nl> - else echo c2 - convex - bsd <nl> - fi <nl> - exit ; ; <nl> - c34 * ) <nl> - echo c34 - convex - bsd <nl> - exit ; ; <nl> - c38 * ) <nl> - echo c38 - convex - bsd <nl> - exit ; ; <nl> - c4 * ) <nl> - echo c4 - convex - bsd <nl> - exit ; ; <nl> - esac <nl> - fi <nl> - <nl> - cat > & 2 < < EOF <nl> - $ 0 : unable to guess system type <nl> - <nl> - This script , last modified $ timestamp , has failed to recognize <nl> - the operating system you are using . It is advised that you <nl> - download the most up to date version of the config scripts from <nl> - <nl> - http : / / git . savannah . gnu . org / gitweb / ? p = config . git ; a = blob_plain ; f = config . guess ; hb = HEAD <nl> - and <nl> - http : / / git . savannah . gnu . org / gitweb / ? p = config . git ; a = blob_plain ; f = config . sub ; hb = HEAD <nl> - <nl> - If the version you run ( $ 0 ) is already up to date , please <nl> - send the following data and any information you think might be <nl> - pertinent to < config - patches @ gnu . org > in order to provide the needed <nl> - information to handle your system . <nl> - <nl> - config . guess timestamp = $ timestamp <nl> - <nl> - uname - m = ` ( uname - m ) 2 > / dev / null | | echo unknown ` <nl> - uname - r = ` ( uname - r ) 2 > / dev / null | | echo unknown ` <nl> - uname - s = ` ( uname - s ) 2 > / dev / null | | echo unknown ` <nl> - uname - v = ` ( uname - v ) 2 > / dev / null | | echo unknown ` <nl> - <nl> - / usr / bin / uname - p = ` ( / usr / bin / uname - p ) 2 > / dev / null ` <nl> - / bin / uname - X = ` ( / bin / uname - X ) 2 > / dev / null ` <nl> - <nl> - hostinfo = ` ( hostinfo ) 2 > / dev / null ` <nl> - / bin / universe = ` ( / bin / universe ) 2 > / dev / null ` <nl> - / usr / bin / arch - k = ` ( / usr / bin / arch - k ) 2 > / dev / null ` <nl> - / bin / arch = ` ( / bin / arch ) 2 > / dev / null ` <nl> - / usr / bin / oslevel = ` ( / usr / bin / oslevel ) 2 > / dev / null ` <nl> - / usr / convex / getsysinfo = ` ( / usr / convex / getsysinfo ) 2 > / dev / null ` <nl> - <nl> - UNAME_MACHINE = $ { UNAME_MACHINE } <nl> - UNAME_RELEASE = $ { UNAME_RELEASE } <nl> - UNAME_SYSTEM = $ { UNAME_SYSTEM } <nl> - UNAME_VERSION = $ { UNAME_VERSION } <nl> - EOF <nl> - <nl> - exit 1 <nl> - <nl> - # Local variables : <nl> - # eval : ( add - hook ' write - file - hooks ' time - stamp ) <nl> - # time - stamp - start : " timestamp = ' " <nl> - # time - stamp - format : " % : y - % 02m - % 02d " <nl> - # time - stamp - end : " ' " <nl> - # End : <nl> deleted file mode 100755 <nl> index c2d125724c0e . . 000000000000 <nl> mmm a / config . sub <nl> ppp / dev / null <nl> <nl> - # ! / bin / sh <nl> - # Configuration validation subroutine script . <nl> - # Copyright ( C ) 1992 , 1993 , 1994 , 1995 , 1996 , 1997 , 1998 , 1999 , <nl> - # 2000 , 2001 , 2002 , 2003 , 2004 , 2005 , 2006 , 2007 , 2008 , 2009 , 2010 <nl> - # Free Software Foundation , Inc . <nl> - <nl> - timestamp = ' 2010 - 01 - 22 ' <nl> - <nl> - # This file is ( in principle ) common to ALL GNU software . <nl> - # The presence of a machine in this file suggests that SOME GNU software <nl> - # can handle that machine . It does not imply ALL GNU software can . <nl> - # <nl> - # This file is free software ; you can redistribute it and / or modify <nl> - # it under the terms of the GNU General Public License as published by <nl> - # the Free Software Foundation ; either version 2 of the License , or <nl> - # ( at your option ) any later version . <nl> - # <nl> - # This program is distributed in the hope that it will be useful , <nl> - # but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - # GNU General Public License for more details . <nl> - # <nl> - # You should have received a copy of the GNU General Public License <nl> - # along with this program ; if not , write to the Free Software <nl> - # Foundation , Inc . , 51 Franklin Street - Fifth Floor , Boston , MA <nl> - # 02110 - 1301 , USA . <nl> - # <nl> - # As a special exception to the GNU General Public License , if you <nl> - # distribute this file as part of a program that contains a <nl> - # configuration script generated by Autoconf , you may include it under <nl> - # the same distribution terms that you use for the rest of that program . <nl> - <nl> - <nl> - # Please send patches to < config - patches @ gnu . org > . Submit a context <nl> - # diff and a properly formatted GNU ChangeLog entry . <nl> - # <nl> - # Configuration subroutine to validate and canonicalize a configuration type . <nl> - # Supply the specified configuration type as an argument . <nl> - # If it is invalid , we print an error message on stderr and exit with code 1 . <nl> - # Otherwise , we print the canonical config type on stdout and succeed . <nl> - <nl> - # You can get the latest version of this script from : <nl> - # http : / / git . savannah . gnu . org / gitweb / ? p = config . git ; a = blob_plain ; f = config . sub ; hb = HEAD <nl> - <nl> - # This file is supposed to be the same for all GNU packages <nl> - # and recognize all the CPU types , system types and aliases <nl> - # that are meaningful with * any * GNU software . <nl> - # Each package is responsible for reporting which valid configurations <nl> - # it does not support . The user should be able to distinguish <nl> - # a failure to support a valid configuration from a meaningless <nl> - # configuration . <nl> - <nl> - # The goal of this file is to map all the various variations of a given <nl> - # machine specification into a single specification in the form : <nl> - # CPU_TYPE - MANUFACTURER - OPERATING_SYSTEM <nl> - # or in some cases , the newer four - part form : <nl> - # CPU_TYPE - MANUFACTURER - KERNEL - OPERATING_SYSTEM <nl> - # It is wrong to echo any other type of specification . <nl> - <nl> - me = ` echo " $ 0 " | sed - e ' s , . * / , , ' ` <nl> - <nl> - usage = " \ <nl> - Usage : $ 0 [ OPTION ] CPU - MFR - OPSYS <nl> - $ 0 [ OPTION ] ALIAS <nl> - <nl> - Canonicalize a configuration name . <nl> - <nl> - Operation modes : <nl> - - h , - - help print this help , then exit <nl> - - t , - - time - stamp print date of last modification , then exit <nl> - - v , - - version print version number , then exit <nl> - <nl> - Report bugs and patches to < config - patches @ gnu . org > . " <nl> - <nl> - version = " \ <nl> - GNU config . sub ( $ timestamp ) <nl> - <nl> - Copyright ( C ) 1992 , 1993 , 1994 , 1995 , 1996 , 1997 , 1998 , 1999 , 2000 , <nl> - 2001 , 2002 , 2003 , 2004 , 2005 , 2006 , 2007 , 2008 , 2009 , 2010 Free <nl> - Software Foundation , Inc . <nl> - <nl> - This is free software ; see the source for copying conditions . There is NO <nl> - warranty ; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . " <nl> - <nl> - help = " <nl> - Try \ ` $ me - - help ' for more information . " <nl> - <nl> - # Parse command line <nl> - while test $ # - gt 0 ; do <nl> - case $ 1 in <nl> - - - time - stamp | - - time * | - t ) <nl> - echo " $ timestamp " ; exit ; ; <nl> - - - version | - v ) <nl> - echo " $ version " ; exit ; ; <nl> - - - help | - - h * | - h ) <nl> - echo " $ usage " ; exit ; ; <nl> - - - ) # Stop option processing <nl> - shift ; break ; ; <nl> - - ) # Use stdin as input . <nl> - break ; ; <nl> - - * ) <nl> - echo " $ me : invalid option $ 1 $ help " <nl> - exit 1 ; ; <nl> - <nl> - * local * ) <nl> - # First pass through any local machine types . <nl> - echo $ 1 <nl> - exit ; ; <nl> - <nl> - * ) <nl> - break ; ; <nl> - esac <nl> - done <nl> - <nl> - case $ # in <nl> - 0 ) echo " $ me : missing argument $ help " > & 2 <nl> - exit 1 ; ; <nl> - 1 ) ; ; <nl> - * ) echo " $ me : too many arguments $ help " > & 2 <nl> - exit 1 ; ; <nl> - esac <nl> - <nl> - # Separate what the user gave into CPU - COMPANY and OS or KERNEL - OS ( if any ) . <nl> - # Here we must recognize all the valid KERNEL - OS combinations . <nl> - maybe_os = ` echo $ 1 | sed ' s / ^ \ ( . * \ ) - \ ( [ ^ - ] * - [ ^ - ] * \ ) $ / \ 2 / ' ` <nl> - case $ maybe_os in <nl> - nto - qnx * | linux - gnu * | linux - dietlibc | linux - newlib * | linux - uclibc * | \ <nl> - uclinux - uclibc * | uclinux - gnu * | kfreebsd * - gnu * | knetbsd * - gnu * | netbsd * - gnu * | \ <nl> - kopensolaris * - gnu * | \ <nl> - storm - chaos * | os2 - emx * | rtmk - nova * ) <nl> - os = - $ maybe_os <nl> - basic_machine = ` echo $ 1 | sed ' s / ^ \ ( . * \ ) - \ ( [ ^ - ] * - [ ^ - ] * \ ) $ / \ 1 / ' ` <nl> - ; ; <nl> - * ) <nl> - basic_machine = ` echo $ 1 | sed ' s / - [ ^ - ] * $ / / ' ` <nl> - if [ $ basic_machine ! = $ 1 ] <nl> - then os = ` echo $ 1 | sed ' s / . * - / - / ' ` <nl> - else os = ; fi <nl> - ; ; <nl> - esac <nl> - <nl> - # # # Let ' s recognize common machines as not being operating systems so <nl> - # # # that things like config . sub decstation - 3100 work . We also <nl> - # # # recognize some manufacturers as not being operating systems , so we <nl> - # # # can provide default operating systems below . <nl> - case $ os in <nl> - - sun * os * ) <nl> - # Prevent following clause from handling this invalid input . <nl> - ; ; <nl> - - dec * | - mips * | - sequent * | - encore * | - pc532 * | - sgi * | - sony * | \ <nl> - - att * | - 7300 * | - 3300 * | - delta * | - motorola * | - sun [ 234 ] * | \ <nl> - - unicom * | - ibm * | - next | - hp | - isi * | - apollo | - altos * | \ <nl> - - convergent * | - ncr * | - news | - 32 * | - 3600 * | - 3100 * | - hitachi * | \ <nl> - - c [ 123 ] * | - convex * | - sun | - crds | - omron * | - dg | - ultra | - tti * | \ <nl> - - harris | - dolphin | - highlevel | - gould | - cbm | - ns | - masscomp | \ <nl> - - apple | - axis | - knuth | - cray | - microblaze ) <nl> - os = <nl> - basic_machine = $ 1 <nl> - ; ; <nl> - - bluegene * ) <nl> - os = - cnk <nl> - ; ; <nl> - - sim | - cisco | - oki | - wec | - winbond ) <nl> - os = <nl> - basic_machine = $ 1 <nl> - ; ; <nl> - - scout ) <nl> - ; ; <nl> - - wrs ) <nl> - os = - vxworks <nl> - basic_machine = $ 1 <nl> - ; ; <nl> - - chorusos * ) <nl> - os = - chorusos <nl> - basic_machine = $ 1 <nl> - ; ; <nl> - - chorusrdb ) <nl> - os = - chorusrdb <nl> - basic_machine = $ 1 <nl> - ; ; <nl> - - hiux * ) <nl> - os = - hiuxwe2 <nl> - ; ; <nl> - - sco6 ) <nl> - os = - sco5v6 <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco5 ) <nl> - os = - sco3 . 2v5 <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco4 ) <nl> - os = - sco3 . 2v4 <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco3 . 2 . [ 4 - 9 ] * ) <nl> - os = ` echo $ os | sed - e ' s / sco3 . 2 . / sco3 . 2v / ' ` <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco3 . 2v [ 4 - 9 ] * ) <nl> - # Don ' t forget version if it is 3 . 2v4 or newer . <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco5v6 * ) <nl> - # Don ' t forget version if it is 3 . 2v4 or newer . <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - sco * ) <nl> - os = - sco3 . 2v2 <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - udk * ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - isc ) <nl> - os = - isc2 . 2 <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - clix * ) <nl> - basic_machine = clipper - intergraph <nl> - ; ; <nl> - - isc * ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - pc / ' ` <nl> - ; ; <nl> - - lynx * ) <nl> - os = - lynxos <nl> - ; ; <nl> - - ptx * ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 - . * / 86 - sequent / ' ` <nl> - ; ; <nl> - - windowsnt * ) <nl> - os = ` echo $ os | sed - e ' s / windowsnt / winnt / ' ` <nl> - ; ; <nl> - - psos * ) <nl> - os = - psos <nl> - ; ; <nl> - - mint | - mint [ 0 - 9 ] * ) <nl> - basic_machine = m68k - atari <nl> - os = - mint <nl> - ; ; <nl> - esac <nl> - <nl> - # Decode aliases for certain CPU - COMPANY combinations . <nl> - case $ basic_machine in <nl> - # Recognize the basic CPU types without company name . <nl> - # Some are omitted here because they have special meanings below . <nl> - 1750a | 580 \ <nl> - | a29k \ <nl> - | alpha | alphaev [ 4 - 8 ] | alphaev56 | alphaev6 [ 78 ] | alphapca5 [ 67 ] \ <nl> - | alpha64 | alpha64ev [ 4 - 8 ] | alpha64ev56 | alpha64ev6 [ 78 ] | alpha64pca5 [ 67 ] \ <nl> - | am33_2 . 0 \ <nl> - | arc | arm | arm [ bl ] e | arme [ lb ] | armv [ 2345 ] | armv [ 345 ] [ lb ] | avr | avr32 \ <nl> - | bfin \ <nl> - | c4x | clipper \ <nl> - | d10v | d30v | dlx | dsp16xx \ <nl> - | fido | fr30 | frv \ <nl> - | h8300 | h8500 | hppa | hppa1 . [ 01 ] | hppa2 . 0 | hppa2 . 0 [ nw ] | hppa64 \ <nl> - | i370 | i860 | i960 | ia64 \ <nl> - | ip2k | iq2000 \ <nl> - | lm32 \ <nl> - | m32c | m32r | m32rle | m68000 | m68k | m88k \ <nl> - | maxq | mb | microblaze | mcore | mep | metag \ <nl> - | mips | mipsbe | mipseb | mipsel | mipsle \ <nl> - | mips16 \ <nl> - | mips64 | mips64el \ <nl> - | mips64octeon | mips64octeonel \ <nl> - | mips64orion | mips64orionel \ <nl> - | mips64r5900 | mips64r5900el \ <nl> - | mips64vr | mips64vrel \ <nl> - | mips64vr4100 | mips64vr4100el \ <nl> - | mips64vr4300 | mips64vr4300el \ <nl> - | mips64vr5000 | mips64vr5000el \ <nl> - | mips64vr5900 | mips64vr5900el \ <nl> - | mipsisa32 | mipsisa32el \ <nl> - | mipsisa32r2 | mipsisa32r2el \ <nl> - | mipsisa64 | mipsisa64el \ <nl> - | mipsisa64r2 | mipsisa64r2el \ <nl> - | mipsisa64sb1 | mipsisa64sb1el \ <nl> - | mipsisa64sr71k | mipsisa64sr71kel \ <nl> - | mipstx39 | mipstx39el \ <nl> - | mn10200 | mn10300 \ <nl> - | moxie \ <nl> - | mt \ <nl> - | msp430 \ <nl> - | nios | nios2 \ <nl> - | ns16k | ns32k \ <nl> - | or32 \ <nl> - | pdp10 | pdp11 | pj | pjl \ <nl> - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ <nl> - | pyramid \ <nl> - | rx \ <nl> - | score \ <nl> - | sh | sh [ 1234 ] | sh [ 24 ] a | sh [ 24 ] aeb | sh [ 23 ] e | sh [ 34 ] eb | sheb | shbe | shle | sh [ 1234 ] le | sh3ele \ <nl> - | sh64 | sh64le \ <nl> - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ <nl> - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ <nl> - | spu | strongarm \ <nl> - | tahoe | thumb | tic4x | tic80 | tron \ <nl> - | ubicom32 \ <nl> - | v850 | v850e \ <nl> - | we32k \ <nl> - | x86 | xc16x | xscale | xscalee [ bl ] | xstormy16 | xtensa \ <nl> - | z8k | z80 ) <nl> - basic_machine = $ basic_machine - unknown <nl> - ; ; <nl> - m6811 | m68hc11 | m6812 | m68hc12 | picochip ) <nl> - # Motorola 68HC11 / 12 . <nl> - basic_machine = $ basic_machine - unknown <nl> - os = - none <nl> - ; ; <nl> - m88110 | m680 [ 12346 ] 0 | m683 ? 2 | m68360 | m5200 | v70 | w65 | z8k ) <nl> - ; ; <nl> - ms1 ) <nl> - basic_machine = mt - unknown <nl> - ; ; <nl> - <nl> - # We use ` pc ' rather than ` unknown ' <nl> - # because ( 1 ) that ' s what they normally are , and <nl> - # ( 2 ) the word " unknown " tends to confuse beginning users . <nl> - i * 86 | x86_64 ) <nl> - basic_machine = $ basic_machine - pc <nl> - ; ; <nl> - # Object if more than one company name word . <nl> - * - * - * ) <nl> - echo Invalid configuration \ ` $ 1 \ ' : machine \ ` $ basic_machine \ ' not recognized 1 > & 2 <nl> - exit 1 <nl> - ; ; <nl> - # Recognize the basic CPU types with company name . <nl> - 580 - * \ <nl> - | a29k - * \ <nl> - | alpha - * | alphaev [ 4 - 8 ] - * | alphaev56 - * | alphaev6 [ 78 ] - * \ <nl> - | alpha64 - * | alpha64ev [ 4 - 8 ] - * | alpha64ev56 - * | alpha64ev6 [ 78 ] - * \ <nl> - | alphapca5 [ 67 ] - * | alpha64pca5 [ 67 ] - * | arc - * \ <nl> - | arm - * | armbe - * | armle - * | armeb - * | armv * - * \ <nl> - | avr - * | avr32 - * \ <nl> - | bfin - * | bs2000 - * \ <nl> - | c [ 123 ] * | c30 - * | [ cjt ] 90 - * | c4x - * | c54x - * | c55x - * | c6x - * \ <nl> - | clipper - * | craynv - * | cydra - * \ <nl> - | d10v - * | d30v - * | dlx - * \ <nl> - | elxsi - * \ <nl> - | f30 [ 01 ] - * | f700 - * | fido - * | fr30 - * | frv - * | fx80 - * \ <nl> - | h8300 - * | h8500 - * \ <nl> - | hppa - * | hppa1 . [ 01 ] - * | hppa2 . 0 - * | hppa2 . 0 [ nw ] - * | hppa64 - * \ <nl> - | i * 86 - * | i860 - * | i960 - * | ia64 - * \ <nl> - | ip2k - * | iq2000 - * \ <nl> - | lm32 - * \ <nl> - | m32c - * | m32r - * | m32rle - * \ <nl> - | m68000 - * | m680 [ 012346 ] 0 - * | m68360 - * | m683 ? 2 - * | m68k - * \ <nl> - | m88110 - * | m88k - * | maxq - * | mcore - * | metag - * | microblaze - * \ <nl> - | mips - * | mipsbe - * | mipseb - * | mipsel - * | mipsle - * \ <nl> - | mips16 - * \ <nl> - | mips64 - * | mips64el - * \ <nl> - | mips64octeon - * | mips64octeonel - * \ <nl> - | mips64orion - * | mips64orionel - * \ <nl> - | mips64r5900 - * | mips64r5900el - * \ <nl> - | mips64vr - * | mips64vrel - * \ <nl> - | mips64vr4100 - * | mips64vr4100el - * \ <nl> - | mips64vr4300 - * | mips64vr4300el - * \ <nl> - | mips64vr5000 - * | mips64vr5000el - * \ <nl> - | mips64vr5900 - * | mips64vr5900el - * \ <nl> - | mipsisa32 - * | mipsisa32el - * \ <nl> - | mipsisa32r2 - * | mipsisa32r2el - * \ <nl> - | mipsisa64 - * | mipsisa64el - * \ <nl> - | mipsisa64r2 - * | mipsisa64r2el - * \ <nl> - | mipsisa64sb1 - * | mipsisa64sb1el - * \ <nl> - | mipsisa64sr71k - * | mipsisa64sr71kel - * \ <nl> - | mipstx39 - * | mipstx39el - * \ <nl> - | mmix - * \ <nl> - | mt - * \ <nl> - | msp430 - * \ <nl> - | nios - * | nios2 - * \ <nl> - | none - * | np1 - * | ns16k - * | ns32k - * \ <nl> - | orion - * \ <nl> - | pdp10 - * | pdp11 - * | pj - * | pjl - * | pn - * | power - * \ <nl> - | powerpc - * | powerpc64 - * | powerpc64le - * | powerpcle - * | ppcbe - * \ <nl> - | pyramid - * \ <nl> - | romp - * | rs6000 - * | rx - * \ <nl> - | sh - * | sh [ 1234 ] - * | sh [ 24 ] a - * | sh [ 24 ] aeb - * | sh [ 23 ] e - * | sh [ 34 ] eb - * | sheb - * | shbe - * \ <nl> - | shle - * | sh [ 1234 ] le - * | sh3ele - * | sh64 - * | sh64le - * \ <nl> - | sparc - * | sparc64 - * | sparc64b - * | sparc64v - * | sparc86x - * | sparclet - * \ <nl> - | sparclite - * \ <nl> - | sparcv8 - * | sparcv9 - * | sparcv9b - * | sparcv9v - * | strongarm - * | sv1 - * | sx ? - * \ <nl> - | tahoe - * | thumb - * \ <nl> - | tic30 - * | tic4x - * | tic54x - * | tic55x - * | tic6x - * | tic80 - * \ <nl> - | tile - * | tilegx - * \ <nl> - | tron - * \ <nl> - | ubicom32 - * \ <nl> - | v850 - * | v850e - * | vax - * \ <nl> - | we32k - * \ <nl> - | x86 - * | x86_64 - * | xc16x - * | xps100 - * | xscale - * | xscalee [ bl ] - * \ <nl> - | xstormy16 - * | xtensa * - * \ <nl> - | ymp - * \ <nl> - | z8k - * | z80 - * ) <nl> - ; ; <nl> - # Recognize the basic CPU types without company name , with glob match . <nl> - xtensa * ) <nl> - basic_machine = $ basic_machine - unknown <nl> - ; ; <nl> - # Recognize the various machine names and aliases which stand <nl> - # for a CPU type and a company and sometimes even an OS . <nl> - 386bsd ) <nl> - basic_machine = i386 - unknown <nl> - os = - bsd <nl> - ; ; <nl> - 3b1 | 7300 | 7300 - att | att - 7300 | pc7300 | safari | unixpc ) <nl> - basic_machine = m68000 - att <nl> - ; ; <nl> - 3b * ) <nl> - basic_machine = we32k - att <nl> - ; ; <nl> - a29khif ) <nl> - basic_machine = a29k - amd <nl> - os = - udi <nl> - ; ; <nl> - abacus ) <nl> - basic_machine = abacus - unknown <nl> - ; ; <nl> - adobe68k ) <nl> - basic_machine = m68010 - adobe <nl> - os = - scout <nl> - ; ; <nl> - alliant | fx80 ) <nl> - basic_machine = fx80 - alliant <nl> - ; ; <nl> - altos | altos3068 ) <nl> - basic_machine = m68k - altos <nl> - ; ; <nl> - am29k ) <nl> - basic_machine = a29k - none <nl> - os = - bsd <nl> - ; ; <nl> - amd64 ) <nl> - basic_machine = x86_64 - pc <nl> - ; ; <nl> - amd64 - * ) <nl> - basic_machine = x86_64 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - amdahl ) <nl> - basic_machine = 580 - amdahl <nl> - os = - sysv <nl> - ; ; <nl> - amiga | amiga - * ) <nl> - basic_machine = m68k - unknown <nl> - ; ; <nl> - amigaos | amigados ) <nl> - basic_machine = m68k - unknown <nl> - os = - amigaos <nl> - ; ; <nl> - amigaunix | amix ) <nl> - basic_machine = m68k - unknown <nl> - os = - sysv4 <nl> - ; ; <nl> - apollo68 ) <nl> - basic_machine = m68k - apollo <nl> - os = - sysv <nl> - ; ; <nl> - apollo68bsd ) <nl> - basic_machine = m68k - apollo <nl> - os = - bsd <nl> - ; ; <nl> - aros ) <nl> - basic_machine = i386 - pc <nl> - os = - aros <nl> - ; ; <nl> - aux ) <nl> - basic_machine = m68k - apple <nl> - os = - aux <nl> - ; ; <nl> - balance ) <nl> - basic_machine = ns32k - sequent <nl> - os = - dynix <nl> - ; ; <nl> - blackfin ) <nl> - basic_machine = bfin - unknown <nl> - os = - linux <nl> - ; ; <nl> - blackfin - * ) <nl> - basic_machine = bfin - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - os = - linux <nl> - ; ; <nl> - bluegene * ) <nl> - basic_machine = powerpc - ibm <nl> - os = - cnk <nl> - ; ; <nl> - c90 ) <nl> - basic_machine = c90 - cray <nl> - os = - unicos <nl> - ; ; <nl> - cegcc ) <nl> - basic_machine = arm - unknown <nl> - os = - cegcc <nl> - ; ; <nl> - convex - c1 ) <nl> - basic_machine = c1 - convex <nl> - os = - bsd <nl> - ; ; <nl> - convex - c2 ) <nl> - basic_machine = c2 - convex <nl> - os = - bsd <nl> - ; ; <nl> - convex - c32 ) <nl> - basic_machine = c32 - convex <nl> - os = - bsd <nl> - ; ; <nl> - convex - c34 ) <nl> - basic_machine = c34 - convex <nl> - os = - bsd <nl> - ; ; <nl> - convex - c38 ) <nl> - basic_machine = c38 - convex <nl> - os = - bsd <nl> - ; ; <nl> - cray | j90 ) <nl> - basic_machine = j90 - cray <nl> - os = - unicos <nl> - ; ; <nl> - craynv ) <nl> - basic_machine = craynv - cray <nl> - os = - unicosmp <nl> - ; ; <nl> - cr16 ) <nl> - basic_machine = cr16 - unknown <nl> - os = - elf <nl> - ; ; <nl> - crds | unos ) <nl> - basic_machine = m68k - crds <nl> - ; ; <nl> - crisv32 | crisv32 - * | etraxfs * ) <nl> - basic_machine = crisv32 - axis <nl> - ; ; <nl> - cris | cris - * | etrax * ) <nl> - basic_machine = cris - axis <nl> - ; ; <nl> - crx ) <nl> - basic_machine = crx - unknown <nl> - os = - elf <nl> - ; ; <nl> - da30 | da30 - * ) <nl> - basic_machine = m68k - da30 <nl> - ; ; <nl> - decstation | decstation - 3100 | pmax | pmax - * | pmin | dec3100 | decstatn ) <nl> - basic_machine = mips - dec <nl> - ; ; <nl> - decsystem10 * | dec10 * ) <nl> - basic_machine = pdp10 - dec <nl> - os = - tops10 <nl> - ; ; <nl> - decsystem20 * | dec20 * ) <nl> - basic_machine = pdp10 - dec <nl> - os = - tops20 <nl> - ; ; <nl> - delta | 3300 | motorola - 3300 | motorola - delta \ <nl> - | 3300 - motorola | delta - motorola ) <nl> - basic_machine = m68k - motorola <nl> - ; ; <nl> - delta88 ) <nl> - basic_machine = m88k - motorola <nl> - os = - sysv3 <nl> - ; ; <nl> - dicos ) <nl> - basic_machine = i686 - pc <nl> - os = - dicos <nl> - ; ; <nl> - djgpp ) <nl> - basic_machine = i586 - pc <nl> - os = - msdosdjgpp <nl> - ; ; <nl> - dpx20 | dpx20 - * ) <nl> - basic_machine = rs6000 - bull <nl> - os = - bosx <nl> - ; ; <nl> - dpx2 * | dpx2 * - bull ) <nl> - basic_machine = m68k - bull <nl> - os = - sysv3 <nl> - ; ; <nl> - ebmon29k ) <nl> - basic_machine = a29k - amd <nl> - os = - ebmon <nl> - ; ; <nl> - elxsi ) <nl> - basic_machine = elxsi - elxsi <nl> - os = - bsd <nl> - ; ; <nl> - encore | umax | mmax ) <nl> - basic_machine = ns32k - encore <nl> - ; ; <nl> - es1800 | OSE68k | ose68k | ose | OSE ) <nl> - basic_machine = m68k - ericsson <nl> - os = - ose <nl> - ; ; <nl> - fx2800 ) <nl> - basic_machine = i860 - alliant <nl> - ; ; <nl> - genix ) <nl> - basic_machine = ns32k - ns <nl> - ; ; <nl> - gmicro ) <nl> - basic_machine = tron - gmicro <nl> - os = - sysv <nl> - ; ; <nl> - go32 ) <nl> - basic_machine = i386 - pc <nl> - os = - go32 <nl> - ; ; <nl> - h3050r * | hiux * ) <nl> - basic_machine = hppa1 . 1 - hitachi <nl> - os = - hiuxwe2 <nl> - ; ; <nl> - h8300hms ) <nl> - basic_machine = h8300 - hitachi <nl> - os = - hms <nl> - ; ; <nl> - h8300xray ) <nl> - basic_machine = h8300 - hitachi <nl> - os = - xray <nl> - ; ; <nl> - h8500hms ) <nl> - basic_machine = h8500 - hitachi <nl> - os = - hms <nl> - ; ; <nl> - harris ) <nl> - basic_machine = m88k - harris <nl> - os = - sysv3 <nl> - ; ; <nl> - hp300 - * ) <nl> - basic_machine = m68k - hp <nl> - ; ; <nl> - hp300bsd ) <nl> - basic_machine = m68k - hp <nl> - os = - bsd <nl> - ; ; <nl> - hp300hpux ) <nl> - basic_machine = m68k - hp <nl> - os = - hpux <nl> - ; ; <nl> - hp3k9 [ 0 - 9 ] [ 0 - 9 ] | hp9 [ 0 - 9 ] [ 0 - 9 ] ) <nl> - basic_machine = hppa1 . 0 - hp <nl> - ; ; <nl> - hp9k2 [ 0 - 9 ] [ 0 - 9 ] | hp9k31 [ 0 - 9 ] ) <nl> - basic_machine = m68000 - hp <nl> - ; ; <nl> - hp9k3 [ 2 - 9 ] [ 0 - 9 ] ) <nl> - basic_machine = m68k - hp <nl> - ; ; <nl> - hp9k6 [ 0 - 9 ] [ 0 - 9 ] | hp6 [ 0 - 9 ] [ 0 - 9 ] ) <nl> - basic_machine = hppa1 . 0 - hp <nl> - ; ; <nl> - hp9k7 [ 0 - 79 ] [ 0 - 9 ] | hp7 [ 0 - 79 ] [ 0 - 9 ] ) <nl> - basic_machine = hppa1 . 1 - hp <nl> - ; ; <nl> - hp9k78 [ 0 - 9 ] | hp78 [ 0 - 9 ] ) <nl> - # FIXME : really hppa2 . 0 - hp <nl> - basic_machine = hppa1 . 1 - hp <nl> - ; ; <nl> - hp9k8 [ 67 ] 1 | hp8 [ 67 ] 1 | hp9k80 [ 24 ] | hp80 [ 24 ] | hp9k8 [ 78 ] 9 | hp8 [ 78 ] 9 | hp9k893 | hp893 ) <nl> - # FIXME : really hppa2 . 0 - hp <nl> - basic_machine = hppa1 . 1 - hp <nl> - ; ; <nl> - hp9k8 [ 0 - 9 ] [ 13679 ] | hp8 [ 0 - 9 ] [ 13679 ] ) <nl> - basic_machine = hppa1 . 1 - hp <nl> - ; ; <nl> - hp9k8 [ 0 - 9 ] [ 0 - 9 ] | hp8 [ 0 - 9 ] [ 0 - 9 ] ) <nl> - basic_machine = hppa1 . 0 - hp <nl> - ; ; <nl> - hppa - next ) <nl> - os = - nextstep3 <nl> - ; ; <nl> - hppaosf ) <nl> - basic_machine = hppa1 . 1 - hp <nl> - os = - osf <nl> - ; ; <nl> - hppro ) <nl> - basic_machine = hppa1 . 1 - hp <nl> - os = - proelf <nl> - ; ; <nl> - i370 - ibm * | ibm * ) <nl> - basic_machine = i370 - ibm <nl> - ; ; <nl> - # I ' m not sure what " Sysv32 " means . Should this be sysv3 . 2 ? <nl> - i * 86v32 ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 . * / 86 - pc / ' ` <nl> - os = - sysv32 <nl> - ; ; <nl> - i * 86v4 * ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 . * / 86 - pc / ' ` <nl> - os = - sysv4 <nl> - ; ; <nl> - i * 86v ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 . * / 86 - pc / ' ` <nl> - os = - sysv <nl> - ; ; <nl> - i * 86sol2 ) <nl> - basic_machine = ` echo $ 1 | sed - e ' s / 86 . * / 86 - pc / ' ` <nl> - os = - solaris2 <nl> - ; ; <nl> - i386mach ) <nl> - basic_machine = i386 - mach <nl> - os = - mach <nl> - ; ; <nl> - i386 - vsta | vsta ) <nl> - basic_machine = i386 - unknown <nl> - os = - vsta <nl> - ; ; <nl> - iris | iris4d ) <nl> - basic_machine = mips - sgi <nl> - case $ os in <nl> - - irix * ) <nl> - ; ; <nl> - * ) <nl> - os = - irix4 <nl> - ; ; <nl> - esac <nl> - ; ; <nl> - isi68 | isi ) <nl> - basic_machine = m68k - isi <nl> - os = - sysv <nl> - ; ; <nl> - m68knommu ) <nl> - basic_machine = m68k - unknown <nl> - os = - linux <nl> - ; ; <nl> - m68knommu - * ) <nl> - basic_machine = m68k - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - os = - linux <nl> - ; ; <nl> - m88k - omron * ) <nl> - basic_machine = m88k - omron <nl> - ; ; <nl> - magnum | m3230 ) <nl> - basic_machine = mips - mips <nl> - os = - sysv <nl> - ; ; <nl> - merlin ) <nl> - basic_machine = ns32k - utek <nl> - os = - sysv <nl> - ; ; <nl> - microblaze ) <nl> - basic_machine = microblaze - xilinx <nl> - ; ; <nl> - mingw32 ) <nl> - basic_machine = i386 - pc <nl> - os = - mingw32 <nl> - ; ; <nl> - mingw32ce ) <nl> - basic_machine = arm - unknown <nl> - os = - mingw32ce <nl> - ; ; <nl> - miniframe ) <nl> - basic_machine = m68000 - convergent <nl> - ; ; <nl> - * mint | - mint [ 0 - 9 ] * | * MiNT | * MiNT [ 0 - 9 ] * ) <nl> - basic_machine = m68k - atari <nl> - os = - mint <nl> - ; ; <nl> - mips3 * - * ) <nl> - basic_machine = ` echo $ basic_machine | sed - e ' s / mips3 / mips64 / ' ` <nl> - ; ; <nl> - mips3 * ) <nl> - basic_machine = ` echo $ basic_machine | sed - e ' s / mips3 / mips64 / ' ` - unknown <nl> - ; ; <nl> - monitor ) <nl> - basic_machine = m68k - rom68k <nl> - os = - coff <nl> - ; ; <nl> - morphos ) <nl> - basic_machine = powerpc - unknown <nl> - os = - morphos <nl> - ; ; <nl> - msdos ) <nl> - basic_machine = i386 - pc <nl> - os = - msdos <nl> - ; ; <nl> - ms1 - * ) <nl> - basic_machine = ` echo $ basic_machine | sed - e ' s / ms1 - / mt - / ' ` <nl> - ; ; <nl> - mvs ) <nl> - basic_machine = i370 - ibm <nl> - os = - mvs <nl> - ; ; <nl> - ncr3000 ) <nl> - basic_machine = i486 - ncr <nl> - os = - sysv4 <nl> - ; ; <nl> - netbsd386 ) <nl> - basic_machine = i386 - unknown <nl> - os = - netbsd <nl> - ; ; <nl> - netwinder ) <nl> - basic_machine = armv4l - rebel <nl> - os = - linux <nl> - ; ; <nl> - news | news700 | news800 | news900 ) <nl> - basic_machine = m68k - sony <nl> - os = - newsos <nl> - ; ; <nl> - news1000 ) <nl> - basic_machine = m68030 - sony <nl> - os = - newsos <nl> - ; ; <nl> - news - 3600 | risc - news ) <nl> - basic_machine = mips - sony <nl> - os = - newsos <nl> - ; ; <nl> - necv70 ) <nl> - basic_machine = v70 - nec <nl> - os = - sysv <nl> - ; ; <nl> - next | m * - next ) <nl> - basic_machine = m68k - next <nl> - case $ os in <nl> - - nextstep * ) <nl> - ; ; <nl> - - ns2 * ) <nl> - os = - nextstep2 <nl> - ; ; <nl> - * ) <nl> - os = - nextstep3 <nl> - ; ; <nl> - esac <nl> - ; ; <nl> - nh3000 ) <nl> - basic_machine = m68k - harris <nl> - os = - cxux <nl> - ; ; <nl> - nh [ 45 ] 000 ) <nl> - basic_machine = m88k - harris <nl> - os = - cxux <nl> - ; ; <nl> - nindy960 ) <nl> - basic_machine = i960 - intel <nl> - os = - nindy <nl> - ; ; <nl> - mon960 ) <nl> - basic_machine = i960 - intel <nl> - os = - mon960 <nl> - ; ; <nl> - nonstopux ) <nl> - basic_machine = mips - compaq <nl> - os = - nonstopux <nl> - ; ; <nl> - np1 ) <nl> - basic_machine = np1 - gould <nl> - ; ; <nl> - nsr - tandem ) <nl> - basic_machine = nsr - tandem <nl> - ; ; <nl> - op50n - * | op60c - * ) <nl> - basic_machine = hppa1 . 1 - oki <nl> - os = - proelf <nl> - ; ; <nl> - openrisc | openrisc - * ) <nl> - basic_machine = or32 - unknown <nl> - ; ; <nl> - os400 ) <nl> - basic_machine = powerpc - ibm <nl> - os = - os400 <nl> - ; ; <nl> - OSE68000 | ose68000 ) <nl> - basic_machine = m68000 - ericsson <nl> - os = - ose <nl> - ; ; <nl> - os68k ) <nl> - basic_machine = m68k - none <nl> - os = - os68k <nl> - ; ; <nl> - pa - hitachi ) <nl> - basic_machine = hppa1 . 1 - hitachi <nl> - os = - hiuxwe2 <nl> - ; ; <nl> - paragon ) <nl> - basic_machine = i860 - intel <nl> - os = - osf <nl> - ; ; <nl> - parisc ) <nl> - basic_machine = hppa - unknown <nl> - os = - linux <nl> - ; ; <nl> - parisc - * ) <nl> - basic_machine = hppa - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - os = - linux <nl> - ; ; <nl> - pbd ) <nl> - basic_machine = sparc - tti <nl> - ; ; <nl> - pbb ) <nl> - basic_machine = m68k - tti <nl> - ; ; <nl> - pc532 | pc532 - * ) <nl> - basic_machine = ns32k - pc532 <nl> - ; ; <nl> - pc98 ) <nl> - basic_machine = i386 - pc <nl> - ; ; <nl> - pc98 - * ) <nl> - basic_machine = i386 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - pentium | p5 | k5 | k6 | nexgen | viac3 ) <nl> - basic_machine = i586 - pc <nl> - ; ; <nl> - pentiumpro | p6 | 6x86 | athlon | athlon_ * ) <nl> - basic_machine = i686 - pc <nl> - ; ; <nl> - pentiumii | pentium2 | pentiumiii | pentium3 ) <nl> - basic_machine = i686 - pc <nl> - ; ; <nl> - pentium4 ) <nl> - basic_machine = i786 - pc <nl> - ; ; <nl> - pentium - * | p5 - * | k5 - * | k6 - * | nexgen - * | viac3 - * ) <nl> - basic_machine = i586 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - pentiumpro - * | p6 - * | 6x86 - * | athlon - * ) <nl> - basic_machine = i686 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - pentiumii - * | pentium2 - * | pentiumiii - * | pentium3 - * ) <nl> - basic_machine = i686 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - pentium4 - * ) <nl> - basic_machine = i786 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - pn ) <nl> - basic_machine = pn - gould <nl> - ; ; <nl> - power ) basic_machine = power - ibm <nl> - ; ; <nl> - ppc ) basic_machine = powerpc - unknown <nl> - ; ; <nl> - ppc - * ) basic_machine = powerpc - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - ppcle | powerpclittle | ppc - le | powerpc - little ) <nl> - basic_machine = powerpcle - unknown <nl> - ; ; <nl> - ppcle - * | powerpclittle - * ) <nl> - basic_machine = powerpcle - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - ppc64 ) basic_machine = powerpc64 - unknown <nl> - ; ; <nl> - ppc64 - * ) basic_machine = powerpc64 - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - ppc64le | powerpc64little | ppc64 - le | powerpc64 - little ) <nl> - basic_machine = powerpc64le - unknown <nl> - ; ; <nl> - ppc64le - * | powerpc64little - * ) <nl> - basic_machine = powerpc64le - ` echo $ basic_machine | sed ' s / ^ [ ^ - ] * - / / ' ` <nl> - ; ; <nl> - ps2 ) <nl> - basic_machine = i386 - ibm <nl> - ; ; <nl> - pw32 ) <nl> - basic_machine = i586 - unknown <nl> - os = - pw32 <nl> - ; ; <nl> - rdos ) <nl> - basic_machine = i386 - pc <nl> - os = - rdos <nl> - ; ; <nl> - rom68k ) <nl> - basic_machine = m68k - rom68k <nl> - os = - coff <nl> - ; ; <nl> - rm [ 46 ] 00 ) <nl> - basic_machine = mips - siemens <nl> - ; ; <nl> - rtpc | rtpc - * ) <nl> - basic_machine = romp - ibm <nl> - ; ; <nl> - s390 | s390 - * ) <nl> - basic_machine = s390 - ibm <nl> - ; ; <nl> - s390x | s390x - * ) <nl> - basic_machine = s390x - ibm <nl> - ; ; <nl> - sa29200 ) <nl> - basic_machine = a29k - amd <nl> - os = - udi <nl> - ; ; <nl> - sb1 ) <nl> - basic_machine = mipsisa64sb1 - unknown <nl> - ; ; <nl> - sb1el ) <nl> - basic_machine = mipsisa64sb1el - unknown <nl> - ; ; <nl> - sde ) <nl> - basic_machine = mipsisa32 - sde <nl> - os = - elf <nl> - ; ; <nl> - sei ) <nl> - basic_machine = mips - sei <nl> - os = - seiux <nl> - ; ; <nl> - sequent ) <nl> - basic_machine = i386 - sequent <nl> - ; ; <nl> - sh ) <nl> - basic_machine = sh - hitachi <nl> - os = - hms <nl> - ; ; <nl> - sh5el ) <nl> - basic_machine = sh5le - unknown <nl> - ; ; <nl> - sh64 ) <nl> - basic_machine = sh64 - unknown <nl> - ; ; <nl> - sparclite - wrs | simso - wrs ) <nl> - basic_machine = sparclite - wrs <nl> - os = - vxworks <nl> - ; ; <nl> - sps7 ) <nl> - basic_machine = m68k - bull <nl> - os = - sysv2 <nl> - ; ; <nl> - spur ) <nl> - basic_machine = spur - unknown <nl> - ; ; <nl> - st2000 ) <nl> - basic_machine = m68k - tandem <nl> - ; ; <nl> - stratus ) <nl> - basic_machine = i860 - stratus <nl> - os = - sysv4 <nl> - ; ; <nl> - sun2 ) <nl> - basic_machine = m68000 - sun <nl> - ; ; <nl> - sun2os3 ) <nl> - basic_machine = m68000 - sun <nl> - os = - sunos3 <nl> - ; ; <nl> - sun2os4 ) <nl> - basic_machine = m68000 - sun <nl> - os = - sunos4 <nl> - ; ; <nl> - sun3os3 ) <nl> - basic_machine = m68k - sun <nl> - os = - sunos3 <nl> - ; ; <nl> - sun3os4 ) <nl> - basic_machine = m68k - sun <nl> - os = - sunos4 <nl> - ; ; <nl> - sun4os3 ) <nl> - basic_machine = sparc - sun <nl> - os = - sunos3 <nl> - ; ; <nl> - sun4os4 ) <nl> - basic_machine = sparc - sun <nl> - os = - sunos4 <nl> - ; ; <nl> - sun4sol2 ) <nl> - basic_machine = sparc - sun <nl> - os = - solaris2 <nl> - ; ; <nl> - sun3 | sun3 - * ) <nl> - basic_machine = m68k - sun <nl> - ; ; <nl> - sun4 ) <nl> - basic_machine = sparc - sun <nl> - ; ; <nl> - sun386 | sun386i | roadrunner ) <nl> - basic_machine = i386 - sun <nl> - ; ; <nl> - sv1 ) <nl> - basic_machine = sv1 - cray <nl> - os = - unicos <nl> - ; ; <nl> - symmetry ) <nl> - basic_machine = i386 - sequent <nl> - os = - dynix <nl> - ; ; <nl> - t3e ) <nl> - basic_machine = alphaev5 - cray <nl> - os = - unicos <nl> - ; ; <nl> - t90 ) <nl> - basic_machine = t90 - cray <nl> - os = - unicos <nl> - ; ; <nl> - tic54x | c54x * ) <nl> - basic_machine = tic54x - unknown <nl> - os = - coff <nl> - ; ; <nl> - tic55x | c55x * ) <nl> - basic_machine = tic55x - unknown <nl> - os = - coff <nl> - ; ; <nl> - tic6x | c6x * ) <nl> - basic_machine = tic6x - unknown <nl> - os = - coff <nl> - ; ; <nl> - # This must be matched before tile * . <nl> - tilegx * ) <nl> - basic_machine = tilegx - unknown <nl> - os = - linux - gnu <nl> - ; ; <nl> - tile * ) <nl> - basic_machine = tile - unknown <nl> - os = - linux - gnu <nl> - ; ; <nl> - tx39 ) <nl> - basic_machine = mipstx39 - unknown <nl> - ; ; <nl> - tx39el ) <nl> - basic_machine = mipstx39el - unknown <nl> - ; ; <nl> - toad1 ) <nl> - basic_machine = pdp10 - xkl <nl> - os = - tops20 <nl> - ; ; <nl> - tower | tower - 32 ) <nl> - basic_machine = m68k - ncr <nl> - ; ; <nl> - tpf ) <nl> - basic_machine = s390x - ibm <nl> - os = - tpf <nl> - ; ; <nl> - udi29k ) <nl> - basic_machine = a29k - amd <nl> - os = - udi <nl> - ; ; <nl> - ultra3 ) <nl> - basic_machine = a29k - nyu <nl> - os = - sym1 <nl> - ; ; <nl> - v810 | necv810 ) <nl> - basic_machine = v810 - nec <nl> - os = - none <nl> - ; ; <nl> - vaxv ) <nl> - basic_machine = vax - dec <nl> - os = - sysv <nl> - ; ; <nl> - vms ) <nl> - basic_machine = vax - dec <nl> - os = - vms <nl> - ; ; <nl> - vpp * | vx | vx - * ) <nl> - basic_machine = f301 - fujitsu <nl> - ; ; <nl> - vxworks960 ) <nl> - basic_machine = i960 - wrs <nl> - os = - vxworks <nl> - ; ; <nl> - vxworks68 ) <nl> - basic_machine = m68k - wrs <nl> - os = - vxworks <nl> - ; ; <nl> - vxworks29k ) <nl> - basic_machine = a29k - wrs <nl> - os = - vxworks <nl> - ; ; <nl> - w65 * ) <nl> - basic_machine = w65 - wdc <nl> - os = - none <nl> - ; ; <nl> - w89k - * ) <nl> - basic_machine = hppa1 . 1 - winbond <nl> - os = - proelf <nl> - ; ; <nl> - xbox ) <nl> - basic_machine = i686 - pc <nl> - os = - mingw32 <nl> - ; ; <nl> - xps | xps100 ) <nl> - basic_machine = xps100 - honeywell <nl> - ; ; <nl> - ymp ) <nl> - basic_machine = ymp - cray <nl> - os = - unicos <nl> - ; ; <nl> - z8k - * - coff ) <nl> - basic_machine = z8k - unknown <nl> - os = - sim <nl> - ; ; <nl> - z80 - * - coff ) <nl> - basic_machine = z80 - unknown <nl> - os = - sim <nl> - ; ; <nl> - none ) <nl> - basic_machine = none - none <nl> - os = - none <nl> - ; ; <nl> - <nl> - # Here we handle the default manufacturer of certain CPU types . It is in <nl> - # some cases the only manufacturer , in others , it is the most popular . <nl> - w89k ) <nl> - basic_machine = hppa1 . 1 - winbond <nl> - ; ; <nl> - op50n ) <nl> - basic_machine = hppa1 . 1 - oki <nl> - ; ; <nl> - op60c ) <nl> - basic_machine = hppa1 . 1 - oki <nl> - ; ; <nl> - romp ) <nl> - basic_machine = romp - ibm <nl> - ; ; <nl> - mmix ) <nl> - basic_machine = mmix - knuth <nl> - ; ; <nl> - rs6000 ) <nl> - basic_machine = rs6000 - ibm <nl> - ; ; <nl> - vax ) <nl> - basic_machine = vax - dec <nl> - ; ; <nl> - pdp10 ) <nl> - # there are many clones , so DEC is not a safe bet <nl> - basic_machine = pdp10 - unknown <nl> - ; ; <nl> - pdp11 ) <nl> - basic_machine = pdp11 - dec <nl> - ; ; <nl> - we32k ) <nl> - basic_machine = we32k - att <nl> - ; ; <nl> - sh [ 1234 ] | sh [ 24 ] a | sh [ 24 ] aeb | sh [ 34 ] eb | sh [ 1234 ] le | sh [ 23 ] ele ) <nl> - basic_machine = sh - unknown <nl> - ; ; <nl> - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v ) <nl> - basic_machine = sparc - sun <nl> - ; ; <nl> - cydra ) <nl> - basic_machine = cydra - cydrome <nl> - ; ; <nl> - orion ) <nl> - basic_machine = orion - highlevel <nl> - ; ; <nl> - orion105 ) <nl> - basic_machine = clipper - highlevel <nl> - ; ; <nl> - mac | mpw | mac - mpw ) <nl> - basic_machine = m68k - apple <nl> - ; ; <nl> - pmac | pmac - mpw ) <nl> - basic_machine = powerpc - apple <nl> - ; ; <nl> - * - unknown ) <nl> - # Make sure to match an already - canonicalized machine name . <nl> - ; ; <nl> - * ) <nl> - echo Invalid configuration \ ` $ 1 \ ' : machine \ ` $ basic_machine \ ' not recognized 1 > & 2 <nl> - exit 1 <nl> - ; ; <nl> - esac <nl> - <nl> - # Here we canonicalize certain aliases for manufacturers . <nl> - case $ basic_machine in <nl> - * - digital * ) <nl> - basic_machine = ` echo $ basic_machine | sed ' s / digital . * / dec / ' ` <nl> - ; ; <nl> - * - commodore * ) <nl> - basic_machine = ` echo $ basic_machine | sed ' s / commodore . * / cbm / ' ` <nl> - ; ; <nl> - * ) <nl> - ; ; <nl> - esac <nl> - <nl> - # Decode manufacturer - specific aliases for certain operating systems . <nl> - <nl> - if [ x " $ os " ! = x " " ] <nl> - then <nl> - case $ os in <nl> - # First match some system type aliases <nl> - # that might get confused with valid system types . <nl> - # - solaris * is a basic system type , with this one exception . <nl> - - auroraux ) <nl> - os = - auroraux <nl> - ; ; <nl> - - solaris1 | - solaris1 . * ) <nl> - os = ` echo $ os | sed - e ' s | solaris1 | sunos4 | ' ` <nl> - ; ; <nl> - - solaris ) <nl> - os = - solaris2 <nl> - ; ; <nl> - - svr4 * ) <nl> - os = - sysv4 <nl> - ; ; <nl> - - unixware * ) <nl> - os = - sysv4 . 2uw <nl> - ; ; <nl> - - gnu / linux * ) <nl> - os = ` echo $ os | sed - e ' s | gnu / linux | linux - gnu | ' ` <nl> - ; ; <nl> - # First accept the basic system types . <nl> - # The portable systems comes first . <nl> - # Each alternative MUST END IN A * , to match a version number . <nl> - # - sysv * is not here because it comes later , after sysvr4 . <nl> - - gnu * | - bsd * | - mach * | - minix * | - genix * | - ultrix * | - irix * \ <nl> - | - * vms * | - sco * | - esix * | - isc * | - aix * | - cnk * | - sunos | - sunos [ 34 ] * \ <nl> - | - hpux * | - unos * | - osf * | - luna * | - dgux * | - auroraux * | - solaris * \ <nl> - | - sym * | - kopensolaris * \ <nl> - | - amigaos * | - amigados * | - msdos * | - newsos * | - unicos * | - aof * \ <nl> - | - aos * | - aros * \ <nl> - | - nindy * | - vxsim * | - vxworks * | - ebmon * | - hms * | - mvs * \ <nl> - | - clix * | - riscos * | - uniplus * | - iris * | - rtu * | - xenix * \ <nl> - | - hiux * | - 386bsd * | - knetbsd * | - mirbsd * | - netbsd * \ <nl> - | - openbsd * | - solidbsd * \ <nl> - | - ekkobsd * | - kfreebsd * | - freebsd * | - riscix * | - lynxos * \ <nl> - | - bosx * | - nextstep * | - cxux * | - aout * | - elf * | - oabi * \ <nl> - | - ptx * | - coff * | - ecoff * | - winnt * | - domain * | - vsta * \ <nl> - | - udi * | - eabi * | - lites * | - ieee * | - go32 * | - aux * \ <nl> - | - chorusos * | - chorusrdb * | - cegcc * \ <nl> - | - cygwin * | - pe * | - psos * | - moss * | - proelf * | - rtems * \ <nl> - | - mingw32 * | - linux - gnu * | - linux - newlib * | - linux - uclibc * \ <nl> - | - uxpv * | - beos * | - mpeix * | - udk * \ <nl> - | - interix * | - uwin * | - mks * | - rhapsody * | - darwin * | - opened * \ <nl> - | - openstep * | - oskit * | - conix * | - pw32 * | - nonstopux * \ <nl> - | - storm - chaos * | - tops10 * | - tenex * | - tops20 * | - its * \ <nl> - | - os2 * | - vos * | - palmos * | - uclinux * | - nucleus * \ <nl> - | - morphos * | - superux * | - rtmk * | - rtmk - nova * | - windiss * \ <nl> - | - powermax * | - dnix * | - nx6 | - nx7 | - sei * | - dragonfly * \ <nl> - | - skyos * | - haiku * | - rdos * | - toppers * | - drops * | - es * ) <nl> - # Remember , each alternative MUST END IN * , to match a version number . <nl> - ; ; <nl> - - qnx * ) <nl> - case $ basic_machine in <nl> - x86 - * | i * 86 - * ) <nl> - ; ; <nl> - * ) <nl> - os = - nto $ os <nl> - ; ; <nl> - esac <nl> - ; ; <nl> - - nto - qnx * ) <nl> - ; ; <nl> - - nto * ) <nl> - os = ` echo $ os | sed - e ' s | nto | nto - qnx | ' ` <nl> - ; ; <nl> - - sim | - es1800 * | - hms * | - xray | - os68k * | - none * | - v88r * \ <nl> - | - windows * | - osx | - abug | - netware * | - os9 * | - beos * | - haiku * \ <nl> - | - macos * | - mpw * | - magic * | - mmixware * | - mon960 * | - lnews * ) <nl> - ; ; <nl> - - mac * ) <nl> - os = ` echo $ os | sed - e ' s | mac | macos | ' ` <nl> - ; ; <nl> - - linux - dietlibc ) <nl> - os = - linux - dietlibc <nl> - ; ; <nl> - - linux * ) <nl> - os = ` echo $ os | sed - e ' s | linux | linux - gnu | ' ` <nl> - ; ; <nl> - - sunos5 * ) <nl> - os = ` echo $ os | sed - e ' s | sunos5 | solaris2 | ' ` <nl> - ; ; <nl> - - sunos6 * ) <nl> - os = ` echo $ os | sed - e ' s | sunos6 | solaris3 | ' ` <nl> - ; ; <nl> - - opened * ) <nl> - os = - openedition <nl> - ; ; <nl> - - os400 * ) <nl> - os = - os400 <nl> - ; ; <nl> - - wince * ) <nl> - os = - wince <nl> - ; ; <nl> - - osfrose * ) <nl> - os = - osfrose <nl> - ; ; <nl> - - osf * ) <nl> - os = - osf <nl> - ; ; <nl> - - utek * ) <nl> - os = - bsd <nl> - ; ; <nl> - - dynix * ) <nl> - os = - bsd <nl> - ; ; <nl> - - acis * ) <nl> - os = - aos <nl> - ; ; <nl> - - atheos * ) <nl> - os = - atheos <nl> - ; ; <nl> - - syllable * ) <nl> - os = - syllable <nl> - ; ; <nl> - - 386bsd ) <nl> - os = - bsd <nl> - ; ; <nl> - - ctix * | - uts * ) <nl> - os = - sysv <nl> - ; ; <nl> - - nova * ) <nl> - os = - rtmk - nova <nl> - ; ; <nl> - - ns2 ) <nl> - os = - nextstep2 <nl> - ; ; <nl> - - nsk * ) <nl> - os = - nsk <nl> - ; ; <nl> - # Preserve the version number of sinix5 . <nl> - - sinix5 . * ) <nl> - os = ` echo $ os | sed - e ' s | sinix | sysv | ' ` <nl> - ; ; <nl> - - sinix * ) <nl> - os = - sysv4 <nl> - ; ; <nl> - - tpf * ) <nl> - os = - tpf <nl> - ; ; <nl> - - triton * ) <nl> - os = - sysv3 <nl> - ; ; <nl> - - oss * ) <nl> - os = - sysv3 <nl> - ; ; <nl> - - svr4 ) <nl> - os = - sysv4 <nl> - ; ; <nl> - - svr3 ) <nl> - os = - sysv3 <nl> - ; ; <nl> - - sysvr4 ) <nl> - os = - sysv4 <nl> - ; ; <nl> - # This must come after - sysvr4 . <nl> - - sysv * ) <nl> - ; ; <nl> - - ose * ) <nl> - os = - ose <nl> - ; ; <nl> - - es1800 * ) <nl> - os = - ose <nl> - ; ; <nl> - - xenix ) <nl> - os = - xenix <nl> - ; ; <nl> - - * mint | - mint [ 0 - 9 ] * | - * MiNT | - MiNT [ 0 - 9 ] * ) <nl> - os = - mint <nl> - ; ; <nl> - - aros * ) <nl> - os = - aros <nl> - ; ; <nl> - - kaos * ) <nl> - os = - kaos <nl> - ; ; <nl> - - zvmoe ) <nl> - os = - zvmoe <nl> - ; ; <nl> - - dicos * ) <nl> - os = - dicos <nl> - ; ; <nl> - - nacl * ) <nl> - ; ; <nl> - - none ) <nl> - ; ; <nl> - * ) <nl> - # Get rid of the ` - ' at the beginning of $ os . <nl> - os = ` echo $ os | sed ' s / [ ^ - ] * - / / ' ` <nl> - echo Invalid configuration \ ` $ 1 \ ' : system \ ` $ os \ ' not recognized 1 > & 2 <nl> - exit 1 <nl> - ; ; <nl> - esac <nl> - else <nl> - <nl> - # Here we handle the default operating systems that come with various machines . <nl> - # The value should be what the vendor currently ships out the door with their <nl> - # machine or put another way , the most popular os provided with the machine . <nl> - <nl> - # Note that if you ' re going to try to match " - MANUFACTURER " here ( say , <nl> - # " - sun " ) , then you have to tell the case statement up towards the top <nl> - # that MANUFACTURER isn ' t an operating system . Otherwise , code above <nl> - # will signal an error saying that MANUFACTURER isn ' t an operating <nl> - # system , and we ' ll never get to this point . <nl> - <nl> - case $ basic_machine in <nl> - score - * ) <nl> - os = - elf <nl> - ; ; <nl> - spu - * ) <nl> - os = - elf <nl> - ; ; <nl> - * - acorn ) <nl> - os = - riscix1 . 2 <nl> - ; ; <nl> - arm * - rebel ) <nl> - os = - linux <nl> - ; ; <nl> - arm * - semi ) <nl> - os = - aout <nl> - ; ; <nl> - c4x - * | tic4x - * ) <nl> - os = - coff <nl> - ; ; <nl> - # This must come before the * - dec entry . <nl> - pdp10 - * ) <nl> - os = - tops20 <nl> - ; ; <nl> - pdp11 - * ) <nl> - os = - none <nl> - ; ; <nl> - * - dec | vax - * ) <nl> - os = - ultrix4 . 2 <nl> - ; ; <nl> - m68 * - apollo ) <nl> - os = - domain <nl> - ; ; <nl> - i386 - sun ) <nl> - os = - sunos4 . 0 . 2 <nl> - ; ; <nl> - m68000 - sun ) <nl> - os = - sunos3 <nl> - # This also exists in the configure program , but was not the <nl> - # default . <nl> - # os = - sunos4 <nl> - ; ; <nl> - m68 * - cisco ) <nl> - os = - aout <nl> - ; ; <nl> - mep - * ) <nl> - os = - elf <nl> - ; ; <nl> - mips * - cisco ) <nl> - os = - elf <nl> - ; ; <nl> - mips * - * ) <nl> - os = - elf <nl> - ; ; <nl> - or32 - * ) <nl> - os = - coff <nl> - ; ; <nl> - * - tti ) # must be before sparc entry or we get the wrong os . <nl> - os = - sysv3 <nl> - ; ; <nl> - sparc - * | * - sun ) <nl> - os = - sunos4 . 1 . 1 <nl> - ; ; <nl> - * - be ) <nl> - os = - beos <nl> - ; ; <nl> - * - haiku ) <nl> - os = - haiku <nl> - ; ; <nl> - * - ibm ) <nl> - os = - aix <nl> - ; ; <nl> - * - knuth ) <nl> - os = - mmixware <nl> - ; ; <nl> - * - wec ) <nl> - os = - proelf <nl> - ; ; <nl> - * - winbond ) <nl> - os = - proelf <nl> - ; ; <nl> - * - oki ) <nl> - os = - proelf <nl> - ; ; <nl> - * - hp ) <nl> - os = - hpux <nl> - ; ; <nl> - * - hitachi ) <nl> - os = - hiux <nl> - ; ; <nl> - i860 - * | * - att | * - ncr | * - altos | * - motorola | * - convergent ) <nl> - os = - sysv <nl> - ; ; <nl> - * - cbm ) <nl> - os = - amigaos <nl> - ; ; <nl> - * - dg ) <nl> - os = - dgux <nl> - ; ; <nl> - * - dolphin ) <nl> - os = - sysv3 <nl> - ; ; <nl> - m68k - ccur ) <nl> - os = - rtu <nl> - ; ; <nl> - m88k - omron * ) <nl> - os = - luna <nl> - ; ; <nl> - * - next ) <nl> - os = - nextstep <nl> - ; ; <nl> - * - sequent ) <nl> - os = - ptx <nl> - ; ; <nl> - * - crds ) <nl> - os = - unos <nl> - ; ; <nl> - * - ns ) <nl> - os = - genix <nl> - ; ; <nl> - i370 - * ) <nl> - os = - mvs <nl> - ; ; <nl> - * - next ) <nl> - os = - nextstep3 <nl> - ; ; <nl> - * - gould ) <nl> - os = - sysv <nl> - ; ; <nl> - * - highlevel ) <nl> - os = - bsd <nl> - ; ; <nl> - * - encore ) <nl> - os = - bsd <nl> - ; ; <nl> - * - sgi ) <nl> - os = - irix <nl> - ; ; <nl> - * - siemens ) <nl> - os = - sysv4 <nl> - ; ; <nl> - * - masscomp ) <nl> - os = - rtu <nl> - ; ; <nl> - f30 [ 01 ] - fujitsu | f700 - fujitsu ) <nl> - os = - uxpv <nl> - ; ; <nl> - * - rom68k ) <nl> - os = - coff <nl> - ; ; <nl> - * - * bug ) <nl> - os = - coff <nl> - ; ; <nl> - * - apple ) <nl> - os = - macos <nl> - ; ; <nl> - * - atari * ) <nl> - os = - mint <nl> - ; ; <nl> - * ) <nl> - os = - none <nl> - ; ; <nl> - esac <nl> - fi <nl> - <nl> - # Here we handle the case where we know the os , and the CPU type , but not the <nl> - # manufacturer . We pick the logical manufacturer . <nl> - vendor = unknown <nl> - case $ basic_machine in <nl> - * - unknown ) <nl> - case $ os in <nl> - - riscix * ) <nl> - vendor = acorn <nl> - ; ; <nl> - - sunos * ) <nl> - vendor = sun <nl> - ; ; <nl> - - cnk * | - aix * ) <nl> - vendor = ibm <nl> - ; ; <nl> - - beos * ) <nl> - vendor = be <nl> - ; ; <nl> - - hpux * ) <nl> - vendor = hp <nl> - ; ; <nl> - - mpeix * ) <nl> - vendor = hp <nl> - ; ; <nl> - - hiux * ) <nl> - vendor = hitachi <nl> - ; ; <nl> - - unos * ) <nl> - vendor = crds <nl> - ; ; <nl> - - dgux * ) <nl> - vendor = dg <nl> - ; ; <nl> - - luna * ) <nl> - vendor = omron <nl> - ; ; <nl> - - genix * ) <nl> - vendor = ns <nl> - ; ; <nl> - - mvs * | - opened * ) <nl> - vendor = ibm <nl> - ; ; <nl> - - os400 * ) <nl> - vendor = ibm <nl> - ; ; <nl> - - ptx * ) <nl> - vendor = sequent <nl> - ; ; <nl> - - tpf * ) <nl> - vendor = ibm <nl> - ; ; <nl> - - vxsim * | - vxworks * | - windiss * ) <nl> - vendor = wrs <nl> - ; ; <nl> - - aux * ) <nl> - vendor = apple <nl> - ; ; <nl> - - hms * ) <nl> - vendor = hitachi <nl> - ; ; <nl> - - mpw * | - macos * ) <nl> - vendor = apple <nl> - ; ; <nl> - - * mint | - mint [ 0 - 9 ] * | - * MiNT | - MiNT [ 0 - 9 ] * ) <nl> - vendor = atari <nl> - ; ; <nl> - - vos * ) <nl> - vendor = stratus <nl> - ; ; <nl> - esac <nl> - basic_machine = ` echo $ basic_machine | sed " s / unknown / $ vendor / " ` <nl> - ; ; <nl> - esac <nl> - <nl> - echo $ basic_machine $ os <nl> - exit <nl> - <nl> - # Local variables : <nl> - # eval : ( add - hook ' write - file - hooks ' time - stamp ) <nl> - # time - stamp - start : " timestamp = ' " <nl> - # time - stamp - format : " % : y - % 02m - % 02d " <nl> - # time - stamp - end : " ' " <nl> - # End : <nl> mmm a / configure . in <nl> ppp b / configure . in <nl> AC_INIT ( " xbmc " , 9 . 11 , http : / / trac . xbmc . org ) <nl> AC_CONFIG_HEADERS ( [ config . h ] ) <nl> AH_TOP ( [ # pragma once ] ) <nl> <nl> + AC_CONFIG_AUX_DIR ( [ build - aux ] ) <nl> AM_INIT_AUTOMAKE ( [ foreign ] ) <nl> AC_CANONICAL_HOST <nl> <nl> deleted file mode 100755 <nl> index 6781b987bdbc . . 000000000000 <nl> mmm a / install - sh <nl> ppp / dev / null <nl> <nl> - # ! / bin / sh <nl> - # install - install a program , script , or datafile <nl> - <nl> - scriptversion = 2009 - 04 - 28 . 21 ; # UTC <nl> - <nl> - # This originates from X11R5 ( mit / util / scripts / install . sh ) , which was <nl> - # later released in X11R6 ( xc / config / util / install . sh ) with the <nl> - # following copyright and license . <nl> - # <nl> - # Copyright ( C ) 1994 X Consortium <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 <nl> - # deal in the Software without restriction , including without limitation the <nl> - # rights to use , copy , modify , merge , publish , distribute , sublicense , and / or <nl> - # sell copies of the Software , and to permit persons to whom the Software is <nl> - # furnished to do so , subject to the following conditions : <nl> - # <nl> - # The above copyright notice and this permission notice shall be included in <nl> - # all copies or substantial portions of the Software . <nl> - # <nl> - # THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - # IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - # X CONSORTIUM BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN <nl> - # AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNEC - <nl> - # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> - # <nl> - # Except as contained in this notice , the name of the X Consortium shall not <nl> - # be used in advertising or otherwise to promote the sale , use or other deal - <nl> - # ings in this Software without prior written authorization from the X Consor - <nl> - # tium . <nl> - # <nl> - # <nl> - # FSF changes to this file are in the public domain . <nl> - # <nl> - # Calling this script install - sh is preferred over install . sh , to prevent <nl> - # ` make ' implicit rules from creating a file called install from it <nl> - # when there is no Makefile . <nl> - # <nl> - # This script is compatible with the BSD install script , but was written <nl> - # from scratch . <nl> - <nl> - nl = ' <nl> - ' <nl> - IFS = " " " $ nl " <nl> - <nl> - # set DOITPROG to echo to test this script <nl> - <nl> - # Don ' t use : - since 4 . 3BSD and earlier shells don ' t like it . <nl> - doit = $ { DOITPROG - } <nl> - if test - z " $ doit " ; then <nl> - doit_exec = exec <nl> - else <nl> - doit_exec = $ doit <nl> - fi <nl> - <nl> - # Put in absolute file names if you don ' t have them in your path ; <nl> - # or use environment vars . <nl> - <nl> - chgrpprog = $ { CHGRPPROG - chgrp } <nl> - chmodprog = $ { CHMODPROG - chmod } <nl> - chownprog = $ { CHOWNPROG - chown } <nl> - cmpprog = $ { CMPPROG - cmp } <nl> - cpprog = $ { CPPROG - cp } <nl> - mkdirprog = $ { MKDIRPROG - mkdir } <nl> - mvprog = $ { MVPROG - mv } <nl> - rmprog = $ { RMPROG - rm } <nl> - stripprog = $ { STRIPPROG - strip } <nl> - <nl> - posix_glob = ' ? ' <nl> - initialize_posix_glob = ' <nl> - test " $ posix_glob " ! = " ? " | | { <nl> - if ( set - f ) 2 > / dev / null ; then <nl> - posix_glob = <nl> - else <nl> - posix_glob = : <nl> - fi <nl> - } <nl> - ' <nl> - <nl> - posix_mkdir = <nl> - <nl> - # Desired mode of installed file . <nl> - mode = 0755 <nl> - <nl> - chgrpcmd = <nl> - chmodcmd = $ chmodprog <nl> - chowncmd = <nl> - mvcmd = $ mvprog <nl> - rmcmd = " $ rmprog - f " <nl> - stripcmd = <nl> - <nl> - src = <nl> - dst = <nl> - dir_arg = <nl> - dst_arg = <nl> - <nl> - copy_on_change = false <nl> - no_target_directory = <nl> - <nl> - usage = " \ <nl> - Usage : $ 0 [ OPTION ] . . . [ - T ] SRCFILE DSTFILE <nl> - or : $ 0 [ OPTION ] . . . SRCFILES . . . DIRECTORY <nl> - or : $ 0 [ OPTION ] . . . - t DIRECTORY SRCFILES . . . <nl> - or : $ 0 [ OPTION ] . . . - d DIRECTORIES . . . <nl> - <nl> - In the 1st form , copy SRCFILE to DSTFILE . <nl> - In the 2nd and 3rd , copy all SRCFILES to DIRECTORY . <nl> - In the 4th , create DIRECTORIES . <nl> - <nl> - Options : <nl> - - - help display this help and exit . <nl> - - - version display version info and exit . <nl> - <nl> - - c ( ignored ) <nl> - - C install only if different ( preserve the last data modification time ) <nl> - - d create directories instead of installing files . <nl> - - g GROUP $ chgrpprog installed files to GROUP . <nl> - - m MODE $ chmodprog installed files to MODE . <nl> - - o USER $ chownprog installed files to USER . <nl> - - s $ stripprog installed files . <nl> - - t DIRECTORY install into DIRECTORY . <nl> - - T report an error if DSTFILE is a directory . <nl> - <nl> - Environment variables override the default commands : <nl> - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG <nl> - RMPROG STRIPPROG <nl> - " <nl> - <nl> - while test $ # - ne 0 ; do <nl> - case $ 1 in <nl> - - c ) ; ; <nl> - <nl> - - C ) copy_on_change = true ; ; <nl> - <nl> - - d ) dir_arg = true ; ; <nl> - <nl> - - g ) chgrpcmd = " $ chgrpprog $ 2 " <nl> - shift ; ; <nl> - <nl> - - - help ) echo " $ usage " ; exit $ ? ; ; <nl> - <nl> - - m ) mode = $ 2 <nl> - case $ mode in <nl> - * ' ' * | * ' ' * | * ' <nl> - ' * | * ' * ' * | * ' ? ' * | * ' [ ' * ) <nl> - echo " $ 0 : invalid mode : $ mode " > & 2 <nl> - exit 1 ; ; <nl> - esac <nl> - shift ; ; <nl> - <nl> - - o ) chowncmd = " $ chownprog $ 2 " <nl> - shift ; ; <nl> - <nl> - - s ) stripcmd = $ stripprog ; ; <nl> - <nl> - - t ) dst_arg = $ 2 <nl> - shift ; ; <nl> - <nl> - - T ) no_target_directory = true ; ; <nl> - <nl> - - - version ) echo " $ 0 $ scriptversion " ; exit $ ? ; ; <nl> - <nl> - - - ) shift <nl> - break ; ; <nl> - <nl> - - * ) echo " $ 0 : invalid option : $ 1 " > & 2 <nl> - exit 1 ; ; <nl> - <nl> - * ) break ; ; <nl> - esac <nl> - shift <nl> - done <nl> - <nl> - if test $ # - ne 0 & & test - z " $ dir_arg $ dst_arg " ; then <nl> - # When - d is used , all remaining arguments are directories to create . <nl> - # When - t is used , the destination is already specified . <nl> - # Otherwise , the last argument is the destination . Remove it from $ @ . <nl> - for arg <nl> - do <nl> - if test - n " $ dst_arg " ; then <nl> - # $ @ is not empty : it contains at least $ arg . <nl> - set fnord " $ @ " " $ dst_arg " <nl> - shift # fnord <nl> - fi <nl> - shift # arg <nl> - dst_arg = $ arg <nl> - done <nl> - fi <nl> - <nl> - if test $ # - eq 0 ; then <nl> - if test - z " $ dir_arg " ; then <nl> - echo " $ 0 : no input file specified . " > & 2 <nl> - exit 1 <nl> - fi <nl> - # It ' s OK to call ` install - sh - d ' without argument . <nl> - # This can happen when creating conditional directories . <nl> - exit 0 <nl> - fi <nl> - <nl> - if test - z " $ dir_arg " ; then <nl> - trap ' ( exit $ ? ) ; exit ' 1 2 13 15 <nl> - <nl> - # Set umask so as not to create temps with too - generous modes . <nl> - # However , ' strip ' requires both read and write access to temps . <nl> - case $ mode in <nl> - # Optimize common cases . <nl> - * 644 ) cp_umask = 133 ; ; <nl> - * 755 ) cp_umask = 22 ; ; <nl> - <nl> - * [ 0 - 7 ] ) <nl> - if test - z " $ stripcmd " ; then <nl> - u_plus_rw = <nl> - else <nl> - u_plus_rw = ' % 200 ' <nl> - fi <nl> - cp_umask = ` expr ' ( ' 777 - $ mode % 1000 ' ) ' $ u_plus_rw ` ; ; <nl> - * ) <nl> - if test - z " $ stripcmd " ; then <nl> - u_plus_rw = <nl> - else <nl> - u_plus_rw = , u + rw <nl> - fi <nl> - cp_umask = $ mode $ u_plus_rw ; ; <nl> - esac <nl> - fi <nl> - <nl> - for src <nl> - do <nl> - # Protect names starting with ` - ' . <nl> - case $ src in <nl> - - * ) src = . / $ src ; ; <nl> - esac <nl> - <nl> - if test - n " $ dir_arg " ; then <nl> - dst = $ src <nl> - dstdir = $ dst <nl> - test - d " $ dstdir " <nl> - dstdir_status = $ ? <nl> - else <nl> - <nl> - # Waiting for this to be detected by the " $ cpprog $ src $ dsttmp " command <nl> - # might cause directories to be created , which would be especially bad <nl> - # if $ src ( and thus $ dsttmp ) contains ' * ' . <nl> - if test ! - f " $ src " & & test ! - d " $ src " ; then <nl> - echo " $ 0 : $ src does not exist . " > & 2 <nl> - exit 1 <nl> - fi <nl> - <nl> - if test - z " $ dst_arg " ; then <nl> - echo " $ 0 : no destination specified . " > & 2 <nl> - exit 1 <nl> - fi <nl> - <nl> - dst = $ dst_arg <nl> - # Protect names starting with ` - ' . <nl> - case $ dst in <nl> - - * ) dst = . / $ dst ; ; <nl> - esac <nl> - <nl> - # If destination is a directory , append the input filename ; won ' t work <nl> - # if double slashes aren ' t ignored . <nl> - if test - d " $ dst " ; then <nl> - if test - n " $ no_target_directory " ; then <nl> - echo " $ 0 : $ dst_arg : Is a directory " > & 2 <nl> - exit 1 <nl> - fi <nl> - dstdir = $ dst <nl> - dst = $ dstdir / ` basename " $ src " ` <nl> - dstdir_status = 0 <nl> - else <nl> - # Prefer dirname , but fall back on a substitute if dirname fails . <nl> - dstdir = ` <nl> - ( dirname " $ dst " ) 2 > / dev / null | | <nl> - expr X " $ dst " : ' X \ ( . * [ ^ / ] \ ) / / * [ ^ / ] [ ^ / ] * / * $ ' \ | \ <nl> - X " $ dst " : ' X \ ( / / \ ) [ ^ / ] ' \ | \ <nl> - X " $ dst " : ' X \ ( / / \ ) $ ' \ | \ <nl> - X " $ dst " : ' X \ ( / \ ) ' \ | . 2 > / dev / null | | <nl> - echo X " $ dst " | <nl> - sed ' / ^ X \ ( . * [ ^ / ] \ ) \ / \ / * [ ^ / ] [ ^ / ] * \ / * $ / { <nl> - s / / \ 1 / <nl> - q <nl> - } <nl> - / ^ X \ ( \ / \ / \ ) [ ^ / ] . * / { <nl> - s / / \ 1 / <nl> - q <nl> - } <nl> - / ^ X \ ( \ / \ / \ ) $ / { <nl> - s / / \ 1 / <nl> - q <nl> - } <nl> - / ^ X \ ( \ / \ ) . * / { <nl> - s / / \ 1 / <nl> - q <nl> - } <nl> - s / . * / . / ; q ' <nl> - ` <nl> - <nl> - test - d " $ dstdir " <nl> - dstdir_status = $ ? <nl> - fi <nl> - fi <nl> - <nl> - obsolete_mkdir_used = false <nl> - <nl> - if test $ dstdir_status ! = 0 ; then <nl> - case $ posix_mkdir in <nl> - ' ' ) <nl> - # Create intermediate dirs using mode 755 as modified by the umask . <nl> - # This is like FreeBSD ' install ' as of 1997 - 10 - 28 . <nl> - umask = ` umask ` <nl> - case $ stripcmd . $ umask in <nl> - # Optimize common cases . <nl> - * [ 2367 ] [ 2367 ] ) mkdir_umask = $ umask ; ; <nl> - . * 0 [ 02 ] [ 02 ] | . [ 02 ] [ 02 ] | . [ 02 ] ) mkdir_umask = 22 ; ; <nl> - <nl> - * [ 0 - 7 ] ) <nl> - mkdir_umask = ` expr $ umask + 22 \ <nl> - - $ umask % 100 % 40 + $ umask % 20 \ <nl> - - $ umask % 10 % 4 + $ umask % 2 <nl> - ` ; ; <nl> - * ) mkdir_umask = $ umask , go - w ; ; <nl> - esac <nl> - <nl> - # With - d , create the new directory with the user - specified mode . <nl> - # Otherwise , rely on $ mkdir_umask . <nl> - if test - n " $ dir_arg " ; then <nl> - mkdir_mode = - m $ mode <nl> - else <nl> - mkdir_mode = <nl> - fi <nl> - <nl> - posix_mkdir = false <nl> - case $ umask in <nl> - * [ 123567 ] [ 0 - 7 ] [ 0 - 7 ] ) <nl> - # POSIX mkdir - p sets u + wx bits regardless of umask , which <nl> - # is incompatible with FreeBSD ' install ' when ( umask & 300 ) ! = 0 . <nl> - ; ; <nl> - * ) <nl> - tmpdir = $ { TMPDIR - / tmp } / ins $ RANDOM - $ $ <nl> - trap ' ret = $ ? ; rmdir " $ tmpdir / d " " $ tmpdir " 2 > / dev / null ; exit $ ret ' 0 <nl> - <nl> - if ( umask $ mkdir_umask & & <nl> - exec $ mkdirprog $ mkdir_mode - p - - " $ tmpdir / d " ) > / dev / null 2 > & 1 <nl> - then <nl> - if test - z " $ dir_arg " | | { <nl> - # Check for POSIX incompatibilities with - m . <nl> - # HP - UX 11 . 23 and IRIX 6 . 5 mkdir - m - p sets group - or <nl> - # other - writeable bit of parent directory when it shouldn ' t . <nl> - # FreeBSD 6 . 1 mkdir - m - p sets mode of existing directory . <nl> - ls_ld_tmpdir = ` ls - ld " $ tmpdir " ` <nl> - case $ ls_ld_tmpdir in <nl> - d ? ? ? ? - ? r - * ) different_mode = 700 ; ; <nl> - d ? ? ? ? - ? - - * ) different_mode = 755 ; ; <nl> - * ) false ; ; <nl> - esac & & <nl> - $ mkdirprog - m $ different_mode - p - - " $ tmpdir " & & { <nl> - ls_ld_tmpdir_1 = ` ls - ld " $ tmpdir " ` <nl> - test " $ ls_ld_tmpdir " = " $ ls_ld_tmpdir_1 " <nl> - } <nl> - } <nl> - then posix_mkdir = : <nl> - fi <nl> - rmdir " $ tmpdir / d " " $ tmpdir " <nl> - else <nl> - # Remove any dirs left behind by ancient mkdir implementations . <nl> - rmdir . / $ mkdir_mode . / - p . / - - 2 > / dev / null <nl> - fi <nl> - trap ' ' 0 ; ; <nl> - esac ; ; <nl> - esac <nl> - <nl> - if <nl> - $ posix_mkdir & & ( <nl> - umask $ mkdir_umask & & <nl> - $ doit_exec $ mkdirprog $ mkdir_mode - p - - " $ dstdir " <nl> - ) <nl> - then : <nl> - else <nl> - <nl> - # The umask is ridiculous , or mkdir does not conform to POSIX , <nl> - # or it failed possibly due to a race condition . Create the <nl> - # directory the slow way , step by step , checking for races as we go . <nl> - <nl> - case $ dstdir in <nl> - / * ) prefix = ' / ' ; ; <nl> - - * ) prefix = ' . / ' ; ; <nl> - * ) prefix = ' ' ; ; <nl> - esac <nl> - <nl> - eval " $ initialize_posix_glob " <nl> - <nl> - oIFS = $ IFS <nl> - IFS = / <nl> - $ posix_glob set - f <nl> - set fnord $ dstdir <nl> - shift <nl> - $ posix_glob set + f <nl> - IFS = $ oIFS <nl> - <nl> - prefixes = <nl> - <nl> - for d <nl> - do <nl> - test - z " $ d " & & continue <nl> - <nl> - prefix = $ prefix $ d <nl> - if test - d " $ prefix " ; then <nl> - prefixes = <nl> - else <nl> - if $ posix_mkdir ; then <nl> - ( umask = $ mkdir_umask & & <nl> - $ doit_exec $ mkdirprog $ mkdir_mode - p - - " $ dstdir " ) & & break <nl> - # Don ' t fail if two instances are running concurrently . <nl> - test - d " $ prefix " | | exit 1 <nl> - else <nl> - case $ prefix in <nl> - * \ ' * ) qprefix = ` echo " $ prefix " | sed " s / ' / ' \ \ \ \ \ \ \ \ ' ' / g " ` ; ; <nl> - * ) qprefix = $ prefix ; ; <nl> - esac <nl> - prefixes = " $ prefixes ' $ qprefix ' " <nl> - fi <nl> - fi <nl> - prefix = $ prefix / <nl> - done <nl> - <nl> - if test - n " $ prefixes " ; then <nl> - # Don ' t fail if two instances are running concurrently . <nl> - ( umask $ mkdir_umask & & <nl> - eval " \ $ doit_exec \ $ mkdirprog $ prefixes " ) | | <nl> - test - d " $ dstdir " | | exit 1 <nl> - obsolete_mkdir_used = true <nl> - fi <nl> - fi <nl> - fi <nl> - <nl> - if test - n " $ dir_arg " ; then <nl> - { test - z " $ chowncmd " | | $ doit $ chowncmd " $ dst " ; } & & <nl> - { test - z " $ chgrpcmd " | | $ doit $ chgrpcmd " $ dst " ; } & & <nl> - { test " $ obsolete_mkdir_used $ chowncmd $ chgrpcmd " = false | | <nl> - test - z " $ chmodcmd " | | $ doit $ chmodcmd $ mode " $ dst " ; } | | exit 1 <nl> - else <nl> - <nl> - # Make a couple of temp file names in the proper directory . <nl> - dsttmp = $ dstdir / _inst . $ $ _ <nl> - rmtmp = $ dstdir / _rm . $ $ _ <nl> - <nl> - # Trap to clean up those temp files at exit . <nl> - trap ' ret = $ ? ; rm - f " $ dsttmp " " $ rmtmp " & & exit $ ret ' 0 <nl> - <nl> - # Copy the file name to the temp name . <nl> - ( umask $ cp_umask & & $ doit_exec $ cpprog " $ src " " $ dsttmp " ) & & <nl> - <nl> - # and set any options ; do chmod last to preserve setuid bits . <nl> - # <nl> - # If any of these fail , we abort the whole thing . If we want to <nl> - # ignore errors from any of these , just make sure not to ignore <nl> - # errors from the above " $ doit $ cpprog $ src $ dsttmp " command . <nl> - # <nl> - { test - z " $ chowncmd " | | $ doit $ chowncmd " $ dsttmp " ; } & & <nl> - { test - z " $ chgrpcmd " | | $ doit $ chgrpcmd " $ dsttmp " ; } & & <nl> - { test - z " $ stripcmd " | | $ doit $ stripcmd " $ dsttmp " ; } & & <nl> - { test - z " $ chmodcmd " | | $ doit $ chmodcmd $ mode " $ dsttmp " ; } & & <nl> - <nl> - # If - C , don ' t bother to copy if it wouldn ' t change the file . <nl> - if $ copy_on_change & & <nl> - old = ` LC_ALL = C ls - dlL " $ dst " 2 > / dev / null ` & & <nl> - new = ` LC_ALL = C ls - dlL " $ dsttmp " 2 > / dev / null ` & & <nl> - <nl> - eval " $ initialize_posix_glob " & & <nl> - $ posix_glob set - f & & <nl> - set X $ old & & old = : $ 2 : $ 4 : $ 5 : $ 6 & & <nl> - set X $ new & & new = : $ 2 : $ 4 : $ 5 : $ 6 & & <nl> - $ posix_glob set + f & & <nl> - <nl> - test " $ old " = " $ new " & & <nl> - $ cmpprog " $ dst " " $ dsttmp " > / dev / null 2 > & 1 <nl> - then <nl> - rm - f " $ dsttmp " <nl> - else <nl> - # Rename the file to the real destination . <nl> - $ doit $ mvcmd - f " $ dsttmp " " $ dst " 2 > / dev / null | | <nl> - <nl> - # The rename failed , perhaps because mv can ' t rename something else <nl> - # to itself , or perhaps because mv is so ancient that it does not <nl> - # support - f . <nl> - { <nl> - # Now remove or move aside any old file at destination location . <nl> - # We try this two ways since rm can ' t unlink itself on some <nl> - # systems and the destination file might be busy for other <nl> - # reasons . In this case , the final cleanup might fail but the new <nl> - # file should still install successfully . <nl> - { <nl> - test ! - f " $ dst " | | <nl> - $ doit $ rmcmd - f " $ dst " 2 > / dev / null | | <nl> - { $ doit $ mvcmd - f " $ dst " " $ rmtmp " 2 > / dev / null & & <nl> - { $ doit $ rmcmd - f " $ rmtmp " 2 > / dev / null ; : ; } <nl> - } | | <nl> - { echo " $ 0 : cannot unlink or rename $ dst " > & 2 <nl> - ( exit 1 ) ; exit 1 <nl> - } <nl> - } & & <nl> - <nl> - # Now rename the file to the real destination . <nl> - $ doit $ mvcmd " $ dsttmp " " $ dst " <nl> - } <nl> - fi | | exit 1 <nl> - <nl> - trap ' ' 0 <nl> - fi <nl> - done <nl> - <nl> - # Local variables : <nl> - # eval : ( add - hook ' write - file - hooks ' time - stamp ) <nl> - # time - stamp - start : " scriptversion = " <nl> - # time - stamp - format : " % : y - % 02m - % 02d . % 02H " <nl> - # time - stamp - time - zone : " UTC " <nl> - # time - stamp - end : " ; # UTC " <nl> - # End : <nl> deleted file mode 100755 <nl> index 28055d2ae6f2 . . 000000000000 <nl> mmm a / missing <nl> ppp / dev / null <nl> <nl> - # ! / bin / sh <nl> - # Common stub for a few missing GNU programs while installing . <nl> - <nl> - scriptversion = 2009 - 04 - 28 . 21 ; # UTC <nl> - <nl> - # Copyright ( C ) 1996 , 1997 , 1999 , 2000 , 2002 , 2003 , 2004 , 2005 , 2006 , <nl> - # 2008 , 2009 Free Software Foundation , Inc . <nl> - # Originally by Fran , cois Pinard < pinard @ iro . umontreal . ca > , 1996 . <nl> - <nl> - # This program is free software ; you can redistribute it and / or modify <nl> - # it under the terms of the GNU General Public License as published by <nl> - # the Free Software Foundation ; either version 2 , or ( at your option ) <nl> - # any later version . <nl> - <nl> - # This program is distributed in the hope that it will be useful , <nl> - # but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - # GNU General Public License for more details . <nl> - <nl> - # You should have received a copy of the GNU General Public License <nl> - # along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> - <nl> - # As a special exception to the GNU General Public License , if you <nl> - # distribute this file as part of a program that contains a <nl> - # configuration script generated by Autoconf , you may include it under <nl> - # the same distribution terms that you use for the rest of that program . <nl> - <nl> - if test $ # - eq 0 ; then <nl> - echo 1 > & 2 " Try \ ` $ 0 - - help ' for more information " <nl> - exit 1 <nl> - fi <nl> - <nl> - run = : <nl> - sed_output = ' s / . * - - output [ = ] \ ( [ ^ ] * \ ) . * / \ 1 / p ' <nl> - sed_minuso = ' s / . * - o \ ( [ ^ ] * \ ) . * / \ 1 / p ' <nl> - <nl> - # In the cases where this matters , ` missing ' is being run in the <nl> - # srcdir already . <nl> - if test - f configure . ac ; then <nl> - configure_ac = configure . ac <nl> - else <nl> - configure_ac = configure . in <nl> - fi <nl> - <nl> - msg = " missing on your system " <nl> - <nl> - case $ 1 in <nl> mmmrun ) <nl> - # Try to run requested program , and just exit if it succeeds . <nl> - run = <nl> - shift <nl> - " $ @ " & & exit 0 <nl> - # Exit code 63 means version mismatch . This often happens <nl> - # when the user try to use an ancient version of a tool on <nl> - # a file that requires a minimum version . In this case we <nl> - # we should proceed has if the program had been absent , or <nl> - # if - - run hadn ' t been passed . <nl> - if test $ ? = 63 ; then <nl> - run = : <nl> - msg = " probably too old " <nl> - fi <nl> - ; ; <nl> - <nl> - - h | - - h | - - he | - - hel | - - help ) <nl> - echo " \ <nl> - $ 0 [ OPTION ] . . . PROGRAM [ ARGUMENT ] . . . <nl> - <nl> - Handle \ ` PROGRAM [ ARGUMENT ] . . . ' for when PROGRAM is missing , or return an <nl> - error status if there is no known handling for PROGRAM . <nl> - <nl> - Options : <nl> - - h , - - help display this help and exit <nl> - - v , - - version output version information and exit <nl> - - - run try to run the given command , and emulate it if it fails <nl> - <nl> - Supported PROGRAM values : <nl> - aclocal touch file \ ` aclocal . m4 ' <nl> - autoconf touch file \ ` configure ' <nl> - autoheader touch file \ ` config . h . in ' <nl> - autom4te touch the output file , or create a stub one <nl> - automake touch all \ ` Makefile . in ' files <nl> - bison create \ ` y . tab . [ ch ] ' , if possible , from existing . [ ch ] <nl> - flex create \ ` lex . yy . c ' , if possible , from existing . c <nl> - help2man touch the output file <nl> - lex create \ ` lex . yy . c ' , if possible , from existing . c <nl> - makeinfo touch the output file <nl> - tar try tar , gnutar , gtar , then tar without non - portable flags <nl> - yacc create \ ` y . tab . [ ch ] ' , if possible , from existing . [ ch ] <nl> - <nl> - Version suffixes to PROGRAM as well as the prefixes \ ` gnu - ' , \ ` gnu ' , and <nl> - \ ` g ' are ignored when checking the name . <nl> - <nl> - Send bug reports to < bug - automake @ gnu . org > . " <nl> - exit $ ? <nl> - ; ; <nl> - <nl> - - v | - - v | - - ve | - - ver | - - vers | - - versi | - - versio | - - version ) <nl> - echo " missing $ scriptversion ( GNU Automake ) " <nl> - exit $ ? <nl> - ; ; <nl> - <nl> - - * ) <nl> - echo 1 > & 2 " $ 0 : Unknown \ ` $ 1 ' option " <nl> - echo 1 > & 2 " Try \ ` $ 0 - - help ' for more information " <nl> - exit 1 <nl> - ; ; <nl> - <nl> - esac <nl> - <nl> - # normalize program name to check for . <nl> - program = ` echo " $ 1 " | sed ' <nl> - s / ^ gnu - / / ; t <nl> - s / ^ gnu / / ; t <nl> - s / ^ g / / ; t ' ` <nl> - <nl> - # Now exit if we have it , but it failed . Also exit now if we <nl> - # don ' t have it and - - version was passed ( most likely to detect <nl> - # the program ) . This is about non - GNU programs , so use $ 1 not <nl> - # $ program . <nl> - case $ 1 in <nl> - lex * | yacc * ) <nl> - # Not GNU programs , they don ' t have - - version . <nl> - ; ; <nl> - <nl> - tar * ) <nl> - if test - n " $ run " ; then <nl> - echo 1 > & 2 " ERROR : \ ` tar ' requires - - run " <nl> - exit 1 <nl> - elif test " x $ 2 " = " x - - version " | | test " x $ 2 " = " x - - help " ; then <nl> - exit 1 <nl> - fi <nl> - ; ; <nl> - <nl> - * ) <nl> - if test - z " $ run " & & ( $ 1 - - version ) > / dev / null 2 > & 1 ; then <nl> - # We have it , but it failed . <nl> - exit 1 <nl> - elif test " x $ 2 " = " x - - version " | | test " x $ 2 " = " x - - help " ; then <nl> - # Could not run - - version or - - help . This is probably someone <nl> - # running ` $ TOOL - - version ' or ` $ TOOL - - help ' to check whether <nl> - # $ TOOL exists and not knowing $ TOOL uses missing . <nl> - exit 1 <nl> - fi <nl> - ; ; <nl> - esac <nl> - <nl> - # If it does not exist , or fails to run ( possibly an outdated version ) , <nl> - # try to emulate it . <nl> - case $ program in <nl> - aclocal * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified \ ` acinclude . m4 ' or \ ` $ { configure_ac } ' . You might want <nl> - to install the \ ` Automake ' and \ ` Perl ' packages . Grab them from <nl> - any GNU archive site . " <nl> - touch aclocal . m4 <nl> - ; ; <nl> - <nl> - autoconf * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified \ ` $ { configure_ac } ' . You might want to install the <nl> - \ ` Autoconf ' and \ ` GNU m4 ' packages . Grab them from any GNU <nl> - archive site . " <nl> - touch configure <nl> - ; ; <nl> - <nl> - autoheader * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified \ ` acconfig . h ' or \ ` $ { configure_ac } ' . You might want <nl> - to install the \ ` Autoconf ' and \ ` GNU m4 ' packages . Grab them <nl> - from any GNU archive site . " <nl> - files = ` sed - n ' s / ^ [ ] * A [ CM ] _CONFIG_HEADER ( \ ( [ ^ ) ] * \ ) ) . * / \ 1 / p ' $ { configure_ac } ` <nl> - test - z " $ files " & & files = " config . h " <nl> - touch_files = <nl> - for f in $ files ; do <nl> - case $ f in <nl> - * : * ) touch_files = " $ touch_files " ` echo " $ f " | <nl> - sed - e ' s / ^ [ ^ : ] * : / / ' - e ' s / : . * / / ' ` ; ; <nl> - * ) touch_files = " $ touch_files $ f . in " ; ; <nl> - esac <nl> - done <nl> - touch $ touch_files <nl> - ; ; <nl> - <nl> - automake * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified \ ` Makefile . am ' , \ ` acinclude . m4 ' or \ ` $ { configure_ac } ' . <nl> - You might want to install the \ ` Automake ' and \ ` Perl ' packages . <nl> - Grab them from any GNU archive site . " <nl> - find . - type f - name Makefile . am - print | <nl> - sed ' s / \ . am $ / . in / ' | <nl> - while read f ; do touch " $ f " ; done <nl> - ; ; <nl> - <nl> - autom4te * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is needed , but is $ msg . <nl> - You might have modified some files without having the <nl> - proper tools for further handling them . <nl> - You can get \ ` $ 1 ' as part of \ ` Autoconf ' from any GNU <nl> - archive site . " <nl> - <nl> - file = ` echo " $ * " | sed - n " $ sed_output " ` <nl> - test - z " $ file " & & file = ` echo " $ * " | sed - n " $ sed_minuso " ` <nl> - if test - f " $ file " ; then <nl> - touch $ file <nl> - else <nl> - test - z " $ file " | | exec > $ file <nl> - echo " # ! / bin / sh " <nl> - echo " # Created by GNU Automake missing as a replacement of " <nl> - echo " # $ $ @ " <nl> - echo " exit 0 " <nl> - chmod + x $ file <nl> - exit 1 <nl> - fi <nl> - ; ; <nl> - <nl> - bison * | yacc * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' $ msg . You should only need it if <nl> - you modified a \ ` . y ' file . You may need the \ ` Bison ' package <nl> - in order for those modifications to take effect . You can get <nl> - \ ` Bison ' from any GNU archive site . " <nl> - rm - f y . tab . c y . tab . h <nl> - if test $ # - ne 1 ; then <nl> - eval LASTARG = " \ $ { $ # } " <nl> - case $ LASTARG in <nl> - * . y ) <nl> - SRCFILE = ` echo " $ LASTARG " | sed ' s / y $ / c / ' ` <nl> - if test - f " $ SRCFILE " ; then <nl> - cp " $ SRCFILE " y . tab . c <nl> - fi <nl> - SRCFILE = ` echo " $ LASTARG " | sed ' s / y $ / h / ' ` <nl> - if test - f " $ SRCFILE " ; then <nl> - cp " $ SRCFILE " y . tab . h <nl> - fi <nl> - ; ; <nl> - esac <nl> - fi <nl> - if test ! - f y . tab . h ; then <nl> - echo > y . tab . h <nl> - fi <nl> - if test ! - f y . tab . c ; then <nl> - echo ' main ( ) { return 0 ; } ' > y . tab . c <nl> - fi <nl> - ; ; <nl> - <nl> - lex * | flex * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified a \ ` . l ' file . You may need the \ ` Flex ' package <nl> - in order for those modifications to take effect . You can get <nl> - \ ` Flex ' from any GNU archive site . " <nl> - rm - f lex . yy . c <nl> - if test $ # - ne 1 ; then <nl> - eval LASTARG = " \ $ { $ # } " <nl> - case $ LASTARG in <nl> - * . l ) <nl> - SRCFILE = ` echo " $ LASTARG " | sed ' s / l $ / c / ' ` <nl> - if test - f " $ SRCFILE " ; then <nl> - cp " $ SRCFILE " lex . yy . c <nl> - fi <nl> - ; ; <nl> - esac <nl> - fi <nl> - if test ! - f lex . yy . c ; then <nl> - echo ' main ( ) { return 0 ; } ' > lex . yy . c <nl> - fi <nl> - ; ; <nl> - <nl> - help2man * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified a dependency of a manual page . You may need the <nl> - \ ` Help2man ' package in order for those modifications to take <nl> - effect . You can get \ ` Help2man ' from any GNU archive site . " <nl> - <nl> - file = ` echo " $ * " | sed - n " $ sed_output " ` <nl> - test - z " $ file " & & file = ` echo " $ * " | sed - n " $ sed_minuso " ` <nl> - if test - f " $ file " ; then <nl> - touch $ file <nl> - else <nl> - test - z " $ file " | | exec > $ file <nl> - echo " . ab help2man is required to generate this page " <nl> - exit $ ? <nl> - fi <nl> - ; ; <nl> - <nl> - makeinfo * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is $ msg . You should only need it if <nl> - you modified a \ ` . texi ' or \ ` . texinfo ' file , or any other file <nl> - indirectly affecting the aspect of the manual . The spurious <nl> - call might also be the consequence of using a buggy \ ` make ' ( AIX , <nl> - DU , IRIX ) . You might want to install the \ ` Texinfo ' package or <nl> - the \ ` GNU make ' package . Grab either from any GNU archive site . " <nl> - # The file to touch is that specified with - o . . . <nl> - file = ` echo " $ * " | sed - n " $ sed_output " ` <nl> - test - z " $ file " & & file = ` echo " $ * " | sed - n " $ sed_minuso " ` <nl> - if test - z " $ file " ; then <nl> - # . . . or it is the one specified with @ setfilename . . . <nl> - infile = ` echo " $ * " | sed ' s / . * \ ( [ ^ ] * \ ) * $ / \ 1 / ' ` <nl> - file = ` sed - n ' <nl> - / ^ @ setfilename / { <nl> - s / . * \ ( [ ^ ] * \ ) * $ / \ 1 / <nl> - p <nl> - q <nl> - } ' $ infile ` <nl> - # . . . or it is derived from the source name ( dir / f . texi becomes f . info ) <nl> - test - z " $ file " & & file = ` echo " $ infile " | sed ' s , . * / , , ; s , . [ ^ . ] * $ , , ' ` . info <nl> - fi <nl> - # If the file does not exist , the user really needs makeinfo ; <nl> - # let ' s fail without touching anything . <nl> - test - f $ file | | exit 1 <nl> - touch $ file <nl> - ; ; <nl> - <nl> - tar * ) <nl> - shift <nl> - <nl> - # We have already tried tar in the generic part . <nl> - # Look for gnutar / gtar before invocation to avoid ugly error <nl> - # messages . <nl> - if ( gnutar - - version > / dev / null 2 > & 1 ) ; then <nl> - gnutar " $ @ " & & exit 0 <nl> - fi <nl> - if ( gtar - - version > / dev / null 2 > & 1 ) ; then <nl> - gtar " $ @ " & & exit 0 <nl> - fi <nl> - firstarg = " $ 1 " <nl> - if shift ; then <nl> - case $ firstarg in <nl> - * o * ) <nl> - firstarg = ` echo " $ firstarg " | sed s / o / / ` <nl> - tar " $ firstarg " " $ @ " & & exit 0 <nl> - ; ; <nl> - esac <nl> - case $ firstarg in <nl> - * h * ) <nl> - firstarg = ` echo " $ firstarg " | sed s / h / / ` <nl> - tar " $ firstarg " " $ @ " & & exit 0 <nl> - ; ; <nl> - esac <nl> - fi <nl> - <nl> - echo 1 > & 2 " \ <nl> - WARNING : I can ' t seem to be able to run \ ` tar ' with the given arguments . <nl> - You may want to install GNU tar or Free paxutils , or check the <nl> - command line arguments . " <nl> - exit 1 <nl> - ; ; <nl> - <nl> - * ) <nl> - echo 1 > & 2 " \ <nl> - WARNING : \ ` $ 1 ' is needed , and is $ msg . <nl> - You might have modified some files without having the <nl> - proper tools for further handling them . Check the \ ` README ' file , <nl> - it often tells you about the needed prerequisites for installing <nl> - this package . You may also peek at any GNU archive site , in case <nl> - some other package would contain this missing \ ` $ 1 ' program . " <nl> - exit 1 <nl> - ; ; <nl> - esac <nl> - <nl> - exit 0 <nl> - <nl> - # Local variables : <nl> - # eval : ( add - hook ' write - file - hooks ' time - stamp ) <nl> - # time - stamp - start : " scriptversion = " <nl> - # time - stamp - format : " % : y - % 02m - % 02d . % 02H " <nl> - # time - stamp - time - zone : " UTC " <nl> - # time - stamp - end : " ; # UTC " <nl> - # End : <nl>
|
Use an auxilary directory for build tools and ensure they ' re not placed in revision control .
|
xbmc/xbmc
|
0776bcd7960bc9d2af08399b3c8f4b5c46625a95
|
2010-03-26T21:14:09Z
|
mmm a / configure . in <nl> ppp b / configure . in <nl> XB_CONFIG_MODULE ( [ lib / ffmpeg ] , [ <nl> sed - i " " - e " s # YASM = yasm # YASM = $ { prefix } / bin / yasm # " config . mak & & <nl> sed - i " " - e " s # YASMDEP = yasm # YASMDEP = $ { prefix } / bin / yasm # " config . mak & & <nl> sed - i " " - e " s # - D_ISOC99_SOURCE - D_POSIX_C_SOURCE = 200112 # # " config . mak <nl> + if test " $ use_arch " = " ppc " ; then <nl> + sed - i " " - e " s / HAVE_GNU_AS 1 / HAVE_GNU_AS 0 / " config . h <nl> + sed - i " " - e " s / ^ HAVE_GNU_AS = yes / ! HAVE_GNU_AS = yes / " config . mak <nl> + fi <nl> else <nl> CFLAGS = " " \ <nl> LDFLAGS = " $ ( echo " $ LDFLAGS " | sed " s / - Wl , - Bsymbolic - functions / / g " ) " \ <nl>
|
[ osx ] disable GNU_AS when building ffmpeg for ppc
|
xbmc/xbmc
|
65eea14dd955caad15c22edac51e5b6769238511
|
2011-05-03T21:10:07Z
|
mmm a / xbmc / interfaces / Builtins . cpp <nl> ppp b / xbmc / interfaces / Builtins . cpp <nl> int CBuiltins : : Execute ( const CStdString & execString ) <nl> else if ( execute . Equals ( " weather . locationset " ) ) <nl> { <nl> int loc = atoi ( params [ 0 ] ) ; <nl> - CGUIMessage msg ( GUI_MSG_ITEM_SELECT , 0 , 0 , loc - 1 ) ; <nl> + CGUIMessage msg ( GUI_MSG_ITEM_SELECT , 0 , 0 , loc ) ; <nl> g_windowManager . SendMessage ( msg , WINDOW_WEATHER ) ; <nl> } <nl> else if ( execute . Equals ( " weather . locationnext " ) ) <nl> mmm a / xbmc / settings / GUISettings . cpp <nl> ppp b / xbmc / settings / GUISettings . cpp <nl> void CGUISettings : : Initialize ( ) <nl> / / My Weather settings <nl> AddGroup ( 2 , 8 ) ; <nl> CSettingsCategory * wea = AddCategory ( 2 , " weather " , 16000 ) ; <nl> + AddInt ( NULL , " weather . currentlocation " , 0 , 1 , 1 , 1 , 3 , SPIN_CONTROL_INT_PLUS , NULL , - 1 ) ; <nl> AddString ( wea , " weather . areacode1 " , 14019 , " USNY0996 - New York , NY " , BUTTON_CONTROL_STANDARD ) ; <nl> AddString ( wea , " weather . areacode2 " , 14020 , " UKXX0085 - London , United Kingdom " , BUTTON_CONTROL_STANDARD ) ; <nl> AddString ( wea , " weather . areacode3 " , 14021 , " JAXX0085 - Tokyo , Japan " , BUTTON_CONTROL_STANDARD ) ; <nl> mmm a / xbmc / utils / Weather . cpp <nl> ppp b / xbmc / utils / Weather . cpp <nl> <nl> # include " Util . h " <nl> # include " Application . h " <nl> # include " settings / GUISettings . h " <nl> + # include " settings / Settings . h " <nl> # include " guilib / GUIWindowManager . h " <nl> # include " GUIUserMessages . h " <nl> # include " dialogs / GUIDialogProgress . h " <nl> using namespace XFILE ; <nl> # define PARTNER_ID " 1004124588 " / / weather . com partner id <nl> # define PARTNER_KEY " 079f24145f208494 " / / weather . com partner key <nl> <nl> - # define MAX_LOCATION 3 <nl> # define LOCALIZED_TOKEN_FIRSTID 370 <nl> # define LOCALIZED_TOKEN_LASTID 395 <nl> # define LOCALIZED_TOKEN_FIRSTID2 1396 <nl> CStdString CWeather : : GetAreaCode ( const CStdString & codeAndCity ) <nl> return areaCode ; <nl> } <nl> <nl> + / * ! <nl> + \ brief Retrieve the city name for the specified location from the settings <nl> + \ param iLocation the location index ( can be in the range [ 1 . . MAXLOCATION ] ) <nl> + \ return the city name ( without the accompanying region area code ) <nl> + * / <nl> CStdString CWeather : : GetLocation ( int iLocation ) <nl> { <nl> - if ( m_location [ iLocation ] . IsEmpty ( ) ) <nl> + if ( m_location [ iLocation - 1 ] . IsEmpty ( ) ) <nl> { <nl> CStdString setting ; <nl> - setting . Format ( " weather . areacode % i " , iLocation + 1 ) ; <nl> - m_location [ iLocation ] = GetAreaCity ( g_guiSettings . GetString ( setting ) ) ; <nl> + setting . Format ( " weather . areacode % i " , iLocation ) ; <nl> + m_location [ iLocation - 1 ] = GetAreaCity ( g_guiSettings . GetString ( setting ) ) ; <nl> } <nl> - return m_location [ iLocation ] ; <nl> + return m_location [ iLocation - 1 ] ; <nl> } <nl> <nl> void CWeather : : Reset ( ) <nl> const day_forecast & CWeather : : GetForecast ( int day ) const <nl> return m_info . forecast [ day ] ; <nl> } <nl> <nl> + / * ! <nl> + \ brief Saves the specified location index to the settings . Call Refresh ( ) <nl> + afterwards to update weather info for the new location . <nl> + \ param iLocation the new location index ( can be in the range [ 1 . . MAXLOCATION ] ) <nl> + * / <nl> + void CWeather : : SetArea ( int iLocation ) <nl> + { <nl> + g_guiSettings . SetInt ( " weather . currentlocation " , iLocation ) ; <nl> + g_settings . Save ( ) ; <nl> + } <nl> + <nl> + / * ! <nl> + \ brief Retrieves the current location index from the settings <nl> + \ return the active location index ( will be in the range [ 1 . . MAXLOCATION ] ) <nl> + * / <nl> + int CWeather : : GetArea ( ) const <nl> + { <nl> + return g_guiSettings . GetInt ( " weather . currentlocation " ) ; <nl> + } <nl> + <nl> CJob * CWeather : : GetJob ( ) const <nl> { <nl> CStdString strSetting ; <nl> - strSetting . Format ( " weather . areacode % i " , m_iCurWeather + 1 ) ; <nl> + strSetting . Format ( " weather . areacode % i " , GetArea ( ) ) ; <nl> return new CWeatherJob ( GetAreaCode ( g_guiSettings . GetString ( strSetting ) ) ) ; <nl> } <nl> <nl> mmm a / xbmc / utils / Weather . h <nl> ppp b / xbmc / utils / Weather . h <nl> class TiXmlElement ; <nl> # define WEATHER_LABEL_CURRENT_DEWP 27 <nl> # define WEATHER_LABEL_CURRENT_HUMI 28 <nl> <nl> + # define MAX_LOCATION 3 <nl> + <nl> struct day_forecast <nl> { <nl> CStdString m_icon ; <nl> class CWeather : public CInfoLoader <nl> bool IsFetched ( ) ; <nl> void Reset ( ) ; <nl> <nl> - void SetArea ( int iArea ) { m_iCurWeather = iArea ; } ; <nl> - int GetArea ( ) const { return m_iCurWeather ; } ; <nl> + void SetArea ( int iLocation ) ; <nl> + int GetArea ( ) const ; <nl> <nl> static CStdString GetAreaCode ( const CStdString & codeAndCity ) ; <nl> static CStdString GetAreaCity ( const CStdString & codeAndCity ) ; <nl> class CWeather : public CInfoLoader <nl> <nl> private : <nl> <nl> - CStdString m_location [ 3 ] ; <nl> - unsigned int m_iCurWeather ; <nl> + CStdString m_location [ MAX_LOCATION ] ; <nl> <nl> CWeatherInfo m_info ; <nl> } ; <nl> mmm a / xbmc / windows / GUIWindowWeather . cpp <nl> ppp b / xbmc / windows / GUIWindowWeather . cpp <nl> using namespace ADDON ; <nl> # define CONTROL_LABELD0GEN 34 <nl> # define CONTROL_IMAGED0IMG 35 <nl> <nl> - # define PARTNER_ID " 1004124588 " / / weather . com partner id <nl> - # define PARTNER_KEY " 079f24145f208494 " / / weather . com partner key <nl> - <nl> - # define MAX_LOCATION 3 <nl> # define LOCALIZED_TOKEN_FIRSTID 370 <nl> # define LOCALIZED_TOKEN_LASTID 395 <nl> <nl> FIXME ' S <nl> CGUIWindowWeather : : CGUIWindowWeather ( void ) <nl> : CGUIWindow ( WINDOW_WEATHER , " MyWeather . xml " ) <nl> { <nl> - m_iCurWeather = 0 ; <nl> } <nl> <nl> CGUIWindowWeather : : ~ CGUIWindowWeather ( void ) <nl> bool CGUIWindowWeather : : OnMessage ( CGUIMessage & message ) <nl> int iControl = message . GetSenderId ( ) ; <nl> if ( iControl = = CONTROL_BTNREFRESH ) <nl> { <nl> - Refresh ( ) ; / / Refresh clicked so do a complete update <nl> + g_weatherManager . Refresh ( ) ; / / Refresh clicked so do a complete update <nl> } <nl> else if ( iControl = = CONTROL_SELECTLOCATION ) <nl> { <nl> bool CGUIWindowWeather : : OnMessage ( CGUIMessage & message ) <nl> { <nl> if ( message . GetSenderId ( ) = = 0 ) / / handle only message from builtin <nl> { <nl> - int v = ( message . GetParam1 ( ) + ( int ) m_iCurWeather ) % MAX_LOCATION ; <nl> - if ( v < 0 ) v + = MAX_LOCATION ; <nl> + / / Clamp location between 1 and MAX_LOCATION <nl> + int v = ( g_weatherManager . GetArea ( ) + message . GetParam1 ( ) - 1 ) % MAX_LOCATION + 1 ; <nl> + if ( v < 1 ) v + = MAX_LOCATION ; <nl> SetLocation ( v ) ; <nl> return true ; <nl> } <nl> void CGUIWindowWeather : : UpdateLocations ( ) <nl> g_windowManager . SendMessage ( msg ) ; <nl> CGUIMessage msg2 ( GUI_MSG_LABEL_ADD , GetID ( ) , CONTROL_SELECTLOCATION ) ; <nl> <nl> - for ( unsigned int i = 0 ; i < MAX_LOCATION ; i + + ) <nl> + int iCurWeather = g_weatherManager . GetArea ( ) ; <nl> + <nl> + for ( unsigned int i = 1 ; i < = MAX_LOCATION ; i + + ) <nl> { <nl> CStdString strLabel = g_weatherManager . GetLocation ( i ) ; <nl> if ( strLabel . size ( ) > 1 ) / / got the location string yet ? <nl> void CGUIWindowWeather : : UpdateLocations ( ) <nl> } <nl> else <nl> { <nl> - strLabel . Format ( " AreaCode % i " , i + 1 ) ; <nl> + strLabel . Format ( " AreaCode % i " , i ) ; <nl> <nl> msg2 . SetLabel ( strLabel ) ; <nl> msg2 . SetParam1 ( i ) ; <nl> g_windowManager . SendMessage ( msg2 ) ; <nl> } <nl> - if ( i = = m_iCurWeather ) <nl> + if ( i = = iCurWeather ) <nl> SET_CONTROL_LABEL ( CONTROL_SELECTLOCATION , strLabel ) ; <nl> } <nl> <nl> - CONTROL_SELECT_ITEM ( CONTROL_SELECTLOCATION , m_iCurWeather ) ; <nl> + CONTROL_SELECT_ITEM ( CONTROL_SELECTLOCATION , iCurWeather ) ; <nl> } <nl> <nl> void CGUIWindowWeather : : UpdateButtons ( ) <nl> void CGUIWindowWeather : : UpdateButtons ( ) <nl> <nl> SET_CONTROL_LABEL ( CONTROL_BTNREFRESH , 184 ) ; / / Refresh <nl> <nl> - SET_CONTROL_LABEL ( WEATHER_LABEL_LOCATION , g_weatherManager . GetLocation ( m_iCurWeather ) ) ; <nl> + SET_CONTROL_LABEL ( WEATHER_LABEL_LOCATION , g_weatherManager . GetLocation ( g_weatherManager . GetArea ( ) ) ) ; <nl> SET_CONTROL_LABEL ( CONTROL_LABELUPDATED , g_weatherManager . GetLastUpdateTime ( ) ) ; <nl> <nl> SET_CONTROL_LABEL ( WEATHER_LABEL_CURRENT_COND , g_weatherManager . GetInfo ( WEATHER_LABEL_CURRENT_COND ) ) ; <nl> void CGUIWindowWeather : : FrameMove ( ) <nl> CGUIWindow : : FrameMove ( ) ; <nl> } <nl> <nl> + / * ! <nl> + \ brief Sets the location to the specified index and refreshes the weather <nl> + \ param loc the location index ( in the range [ 1 . . MAXLOCATION ] ) <nl> + * / <nl> void CGUIWindowWeather : : SetLocation ( int loc ) <nl> { <nl> - if ( loc < 0 | | loc > = MAX_LOCATION ) <nl> + if ( loc < 1 | | loc > MAX_LOCATION ) <nl> return ; <nl> - <nl> - m_iCurWeather = loc ; <nl> - CStdString strLabel = g_weatherManager . GetLocation ( m_iCurWeather ) ; <nl> - int iPos = strLabel . ReverseFind ( " , " ) ; <nl> - if ( iPos ) <nl> - strLabel = strLabel . substr ( 0 , iPos ) ; <nl> - <nl> - SET_CONTROL_LABEL ( CONTROL_SELECTLOCATION , strLabel ) ; <nl> - Refresh ( ) ; <nl> - } <nl> - <nl> - / / Do a complete download , parse and update <nl> - void CGUIWindowWeather : : Refresh ( ) <nl> - { <nl> - g_weatherManager . SetArea ( m_iCurWeather ) ; <nl> + / / Avoid a settings write if old location = = new location <nl> + if ( g_weatherManager . GetArea ( ) ! = loc ) <nl> + { <nl> + g_weatherManager . SetArea ( loc ) ; <nl> + CStdString strLabel = g_weatherManager . GetLocation ( loc ) ; <nl> + int iPos = strLabel . ReverseFind ( " , " ) ; <nl> + if ( iPos ) <nl> + strLabel = strLabel . substr ( 0 , iPos ) ; <nl> + SET_CONTROL_LABEL ( CONTROL_SELECTLOCATION , strLabel ) ; <nl> + } <nl> g_weatherManager . Refresh ( ) ; <nl> } <nl> <nl> void CGUIWindowWeather : : SetProperties ( ) <nl> { <nl> / / Current weather <nl> - SetProperty ( " Location " , g_weatherManager . GetLocation ( m_iCurWeather ) ) ; <nl> - SetProperty ( " LocationIndex " , int ( m_iCurWeather + 1 ) ) ; <nl> + int iCurWeather = g_weatherManager . GetArea ( ) ; <nl> + SetProperty ( " Location " , g_weatherManager . GetLocation ( iCurWeather ) ) ; <nl> + SetProperty ( " LocationIndex " , iCurWeather ) ; <nl> CStdString strSetting ; <nl> - strSetting . Format ( " weather . areacode % i " , m_iCurWeather + 1 ) ; <nl> + strSetting . Format ( " weather . areacode % i " , iCurWeather ) ; <nl> SetProperty ( " AreaCode " , CWeather : : GetAreaCode ( g_guiSettings . GetString ( strSetting ) ) ) ; <nl> SetProperty ( " Updated " , g_weatherManager . GetLastUpdateTime ( ) ) ; <nl> SetProperty ( " Current . ConditionIcon " , g_weatherManager . GetInfo ( WEATHER_IMAGE_CURRENT_ICON ) ) ; <nl> void CGUIWindowWeather : : CallScript ( ) <nl> <nl> / / get the current locations area code <nl> CStdString strSetting ; <nl> - strSetting . Format ( " weather . areacode % i " , m_iCurWeather + 1 ) ; <nl> + strSetting . Format ( " weather . areacode % i " , g_weatherManager . GetArea ( ) ) ; <nl> argv . push_back ( CWeather : : GetAreaCode ( g_guiSettings . GetString ( strSetting ) ) ) ; <nl> <nl> / / call our script , passing the areacode <nl> mmm a / xbmc / windows / GUIWindowWeather . h <nl> ppp b / xbmc / windows / GUIWindowWeather . h <nl> class CGUIWindowWeather : public CGUIWindow <nl> void CallScript ( ) ; <nl> void SetLocation ( int loc ) ; <nl> <nl> - void Refresh ( ) ; <nl> - <nl> - unsigned int m_iCurWeather ; <nl> CStopWatch m_scriptTimer ; <nl> } ; <nl>
|
Added : XBMC remembers the weather location
|
xbmc/xbmc
|
22c1861b0512feecd087a3cff47d35664db32789
|
2011-07-25T08:00:22Z
|
new file mode 100644 <nl> index 0000000000000 . . 0ef5f111b2a46 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / training / python / training / sgdr_learning_rate_decay . py <nl> <nl> + # Copyright 2015 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + " " " SGDR learning rate decay function . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import math <nl> + <nl> + from tensorflow . python . framework import constant_op <nl> + from tensorflow . python . framework import ops <nl> + from tensorflow . python . ops import math_ops , control_flow_ops <nl> + <nl> + <nl> + def sgdr_decay ( learning_rate , global_step , initial_period_steps , <nl> + t_mul = 2 . 0 , m_mul = 1 . 0 , name = None ) : <nl> + " " " Implements Stochastic Gradient Descent with Warm Restarts ( SGDR ) . <nl> + <nl> + As described in " SGDR : Stochastic Gradient Descent <nl> + with Warm Restarts " by Ilya Loshchilov & Frank Hutter , Proceedings of <nl> + ICLR ' 2017 , available at https : / / arxiv . org / pdf / 1608 . 03983 . pdf <nl> + <nl> + The learning rate decreases according to cosine annealing : <nl> + <nl> + ` ` ` python <nl> + learning_rate * 0 . 5 * ( 1 + cos ( x_val * pi ) ) # for x_val defined in [ 0 , 1 ] <nl> + ` ` ` <nl> + <nl> + Thus , at the beginning ( when the restart index i = 0 ) , <nl> + the learning rate decreases for ` initial_period_steps ` steps from the initial <nl> + learning rate ` learning_rate ` ( when ` x_val = 0 ` , we get ` cos ( 0 ) = 1 ` ) to <nl> + 0 ( when ` x_val = 1 ` , we get ` cos ( pi ) = - 1 ` ) . <nl> + <nl> + The decrease within the i - th period takes ` t_i ` steps , <nl> + where ` t_0 ` = ` initial_period_steps ` is the user - defined number of batch <nl> + iterations ( not epochs as in the paper ) to be performed before the first <nl> + restart is launched . <nl> + <nl> + Then , we perform the first restart ( i = 1 ) by setting the learning rate to <nl> + ` learning_rate * ( m_mul ^ i ) ` , where ` m_mul in [ 0 , 1 ] ` ( set to 1 by default ) . <nl> + The i - th restart runs for ` t_i = t_0 * ( t_mul ^ i ) ` steps , i . e . , every new <nl> + restart runs ` t_mul ` times longer than the previous one . <nl> + <nl> + Importantly , when one has no access to a validation set , SGDR suggests <nl> + to report the best expected / recommended solution in the following way : <nl> + When we are within our initial run ( i = 0 ) , every new solution represents <nl> + SGDR ' s recommended solution . Instead , when i > 0 , the recommended solution is <nl> + the one obtained at the end of each restart . <nl> + <nl> + Note that the minimum learning rate is set to 0 for simplicity , <nl> + you can adjust the code to deal with any positive minimum learning rate <nl> + as defined in the paper . <nl> + <nl> + ` initial_period_steps ` is the duration of the first period measured in terms <nl> + of number of minibatch updates . If one wants to use epochs , one should compute <nl> + the number of updates required for an epoch . <nl> + <nl> + For example , assume the following parameters and intention : <nl> + Minibatch size : 100 <nl> + Training dataset size : 10000 <nl> + If the user wants the first decay period to span across 5 epochs , then <nl> + ` initial_period_steps ` = 5 * 10000 / 100 = 500 <nl> + <nl> + Train for 10000 batch iterations with the initial learning rate set to <nl> + 0 . 1 , then restart to run 2 times longer , i . e , for 20000 batch iterations <nl> + and with the initial learning rate 0 . 05 , then restart again and again , <nl> + doubling the runtime of each new period and with two times smaller <nl> + initial learning rate . <nl> + <nl> + To accomplish the above , one would write : <nl> + <nl> + ` ` ` python <nl> + . . . <nl> + global_step = tf . Variable ( 0 , trainable = False ) <nl> + starter_learning_rate = 0 . 1 <nl> + learning_rate = sgdr_decay ( starter_learning_rate , global_step , <nl> + initial_period_steps = 10000 , t_mul = 2 , m_mul = 0 . 5 ) <nl> + # Passing global_step to minimize ( ) will increment it at each step . <nl> + learning_step = ( <nl> + tf . train . GradientDescentOptimizer ( learning_rate ) <nl> + . minimize ( . . . my loss . . . , global_step = global_step ) <nl> + ) <nl> + <nl> + # Step | 0 | 1000 | 5000 | 9000 | 9999 | 10000 | 11000 | <nl> + # LR | 0 . 1 | 0 . 097 | 0 . 05 | 0 . 002 | 0 . 00 | 0 . 05 | 0 . 0496 | <nl> + <nl> + # Step | 20000 | 29000 | 29999 | 30000 | <nl> + # LR | 0 . 025 | 0 . 0003 | 0 . 00 | 0 . 025 | <nl> + ` ` ` <nl> + <nl> + Args : <nl> + learning_rate : A scalar ` float32 ` or ` float64 ` ` Tensor ` or a <nl> + Python number . The initial learning rate . <nl> + global_step : A scalar ` int32 ` or ` int64 ` ` Tensor ` or a Python number . <nl> + Global step to use for the decay computation . Must not be negative . <nl> + initial_period_steps : Duration of the first period measured as the number <nl> + of minibatch updates , if one wants to use epochs , one should compute <nl> + the number of updates required for an epoch . <nl> + t_mul : A scalar ` float32 ` or ` float64 ` ` Tensor ` or a Python number . <nl> + Must be positive . <nl> + Used to derive the number of iterations in the i - th period : <nl> + ` initial_period_steps * ( t_mul ^ i ) ` . Defaults to 2 . 0 . <nl> + m_mul : A scalar ` float32 ` or ` float64 ` ` Tensor ` or a Python number . <nl> + Must be positive . <nl> + Used to derive the initial learning rate of the i - th period : <nl> + ` learning_rate * ( m_mul ^ i ) ` . Defaults to 1 . 0 <nl> + <nl> + Returns : <nl> + A scalar ` Tensor ` of the same type as ` learning_rate ` . <nl> + The learning rate for a provided global_step . <nl> + Raises : <nl> + ValueError : if ` global_step ` is not supplied . <nl> + " " " <nl> + <nl> + if global_step is None : <nl> + raise ValueError ( " global_step is required for sgdr_decay . " ) <nl> + with ops . name_scope ( name , " SGDRDecay " , <nl> + [ learning_rate , global_step , <nl> + initial_period_steps , t_mul , m_mul ] ) as name : <nl> + learning_rate = ops . convert_to_tensor ( learning_rate , <nl> + name = " initial_learning_rate " ) <nl> + dtype = learning_rate . dtype <nl> + global_step = math_ops . cast ( global_step , dtype ) <nl> + t_0 = math_ops . cast ( initial_period_steps , dtype ) <nl> + t_mul = math_ops . cast ( t_mul , dtype ) <nl> + m_mul = math_ops . cast ( m_mul , dtype ) <nl> + <nl> + c_one = math_ops . cast ( constant_op . constant ( 1 . 0 ) , dtype ) <nl> + c_half = math_ops . cast ( constant_op . constant ( 0 . 5 ) , dtype ) <nl> + c_pi = math_ops . cast ( constant_op . constant ( math . pi ) , dtype ) <nl> + <nl> + # Find normalized value of the current step <nl> + x_val = math_ops . div ( global_step , t_0 ) <nl> + <nl> + def compute_step ( x_val , geometric = False ) : <nl> + if geometric : <nl> + # Consider geometric series where t_mul ! = 1 <nl> + # 1 + t_mul + t_mul ^ 2 . . . = ( 1 - t_mul ^ i_restart ) / ( 1 - t_mul ) <nl> + <nl> + # First find how many restarts were performed for a given x_val <nl> + # Find maximal integer i_restart value for which this equation holds <nl> + # x_val > = ( 1 - t_mul ^ i_restart ) / ( 1 - t_mul ) <nl> + # x_val * ( 1 - t_mul ) < = ( 1 - t_mul ^ i_restart ) <nl> + # t_mul ^ i_restart < = ( 1 - x_val * ( 1 - t_mul ) ) <nl> + <nl> + # tensorflow allows only log with base e <nl> + # i_restart < = log ( 1 - x_val * ( 1 - t_mul ) / log ( t_mul ) <nl> + # Find how many restarts were performed <nl> + <nl> + i_restart = math_ops . floor ( <nl> + math_ops . log ( c_one - x_val * ( c_one - t_mul ) ) / math_ops . log ( t_mul ) ) <nl> + # Compute the sum of all restarts before the current one <nl> + sum_r = ( c_one - t_mul * * i_restart ) / ( c_one - t_mul ) <nl> + # Compute our position within the current restart <nl> + x_val = ( x_val - sum_r ) / t_mul * * i_restart <nl> + <nl> + else : <nl> + # Find how many restarts were performed <nl> + i_restart = math_ops . floor ( x_val ) <nl> + # Compute our position within the current restart <nl> + x_val = x_val - i_restart <nl> + return i_restart , x_val <nl> + <nl> + i_restart , x_val = control_flow_ops . cond ( <nl> + math_ops . equal ( t_mul , c_one ) , <nl> + lambda : compute_step ( x_val , geometric = False ) , <nl> + lambda : compute_step ( x_val , geometric = True ) ) <nl> + <nl> + # If m_mul < 1 , then the initial learning rate of every new restart will be <nl> + # smaller , i . e . , by a factor of m_mul * * i_restart at i_restart - th restart <nl> + m_fac = learning_rate * ( m_mul * * i_restart ) <nl> + <nl> + return math_ops . multiply ( c_half * m_fac , <nl> + ( math_ops . cos ( x_val * c_pi ) + c_one ) , name = name ) <nl> new file mode 100644 <nl> index 0000000000000 . . 4a46e9a49ef20 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / training / python / training / sgdr_learning_rate_decay_test . py <nl> <nl> + # Copyright 2015 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + " " " Functional test for sgdr learning rate decay . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import math <nl> + <nl> + from sgdr_learning_rate_decay import sgdr_decay <nl> + from tensorflow . python . platform import googletest <nl> + from tensorflow . python . framework import test_util <nl> + from tensorflow . python . framework import dtypes <nl> + from tensorflow import placeholder <nl> + <nl> + <nl> + class SGDRDecayTest ( test_util . TensorFlowTestCase ) : <nl> + " " " Unit tests for SGDR learning rate decay . " " " <nl> + <nl> + def get_original_values ( self , lr , t_e , mult_factor , iter_per_epoch , epochs ) : <nl> + " " " Get an array with learning rate values from the consecutive steps using <nl> + the original implementation <nl> + ( https : / / github . com / loshchil / SGDR / blob / master / SGDR_WRNs . py ) . " " " <nl> + t0 = math . pi / 2 . 0 <nl> + tt = 0 <nl> + te_next = t_e <nl> + <nl> + lr_values = [ ] <nl> + sh_lr = lr <nl> + for epoch in range ( epochs ) : <nl> + for _ in range ( iter_per_epoch ) : <nl> + # In the original approach training function is executed here <nl> + lr_values . append ( sh_lr ) <nl> + dt = 2 . 0 * math . pi / float ( 2 . 0 * t_e ) <nl> + tt = tt + float ( dt ) / iter_per_epoch <nl> + if tt > = math . pi : <nl> + tt = tt - math . pi <nl> + cur_t = t0 + tt <nl> + new_lr = lr * ( 1 . 0 + math . sin ( cur_t ) ) / 2 . 0 # lr_min = 0 , lr_max = lr <nl> + sh_lr = new_lr <nl> + if ( epoch + 1 ) = = te_next : # time to restart <nl> + sh_lr = lr <nl> + tt = 0 # by setting to 0 we set lr to lr_max , see above <nl> + t_e = t_e * mult_factor # change the period of restarts <nl> + te_next = te_next + t_e # note the next restart ' s epoch <nl> + <nl> + return lr_values <nl> + <nl> + def get_sgdr_values ( self , lr , initial_period_steps , t_mul , iters ) : <nl> + " " " Get an array with learning rate values from the consecutive steps <nl> + using current tensorflow implementation . " " " <nl> + with self . test_session ( ) : <nl> + step = placeholder ( dtypes . int32 ) <nl> + <nl> + decay = sgdr_decay ( lr , step , initial_period_steps , t_mul ) <nl> + lr_values = [ ] <nl> + for i in range ( iters ) : <nl> + lr_values . append ( decay . eval ( feed_dict = { step : i } ) ) <nl> + <nl> + return lr_values <nl> + <nl> + def testCompareToOriginal ( self ) : <nl> + " " " Compare values generated by tensorflow implementation to the values <nl> + generated by the original implementation <nl> + ( https : / / github . com / loshchil / SGDR / blob / master / SGDR_WRNs . py ) . " " " <nl> + with self . test_session ( ) : <nl> + lr = 10 . 0 <nl> + init_steps = 2 <nl> + t_mul = 3 <nl> + iters = 10 <nl> + epochs = 50 <nl> + <nl> + org_lr = self . get_original_values ( lr , init_steps , t_mul , iters , epochs ) <nl> + sgdr_lr = self . get_sgdr_values ( lr , init_steps * iters , t_mul , iters * epochs ) <nl> + <nl> + for org , sgdr in zip ( org_lr , sgdr_lr ) : <nl> + self . assertAllClose ( org , sgdr ) <nl> + <nl> + def testMDecay ( self ) : <nl> + " " " Test m_mul argument . Check values for learning rate at the beginning <nl> + of the first , second , third and fourth period . " " " <nl> + with self . test_session ( ) : <nl> + step = placeholder ( dtypes . int32 ) <nl> + <nl> + lr = 0 . 1 <nl> + t_e = 10 <nl> + t_mul = 3 <nl> + m_mul = 0 . 9 <nl> + <nl> + decay = sgdr_decay ( lr , step , t_e , t_mul , m_mul ) <nl> + <nl> + test_step = 0 <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , <nl> + lr ) <nl> + <nl> + test_step = t_e <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , <nl> + lr * m_mul ) <nl> + <nl> + test_step = t_e + t_e * t_mul <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , <nl> + lr * m_mul * * 2 ) <nl> + <nl> + test_step = t_e + t_e * t_mul + t_e * ( t_mul * * 2 ) <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , <nl> + lr * ( m_mul * * 3 ) ) <nl> + <nl> + def testCos ( self ) : <nl> + " " " Check learning rate values at the beginning , in the middle <nl> + and at the end of the period . " " " <nl> + with self . test_session ( ) : <nl> + step = placeholder ( dtypes . int32 ) <nl> + lr = 0 . 2 <nl> + t_e = 1000 <nl> + t_mul = 1 <nl> + <nl> + decay = sgdr_decay ( lr , step , t_e , t_mul ) <nl> + <nl> + test_step = 0 <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , lr ) <nl> + <nl> + test_step = t_e / / 2 <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , lr / 2 ) <nl> + <nl> + test_step = t_e <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , lr ) <nl> + <nl> + test_step = t_e * 3 / / 2 <nl> + self . assertAllClose ( decay . eval ( feed_dict = { step : test_step } ) , lr / 2 ) <nl> + <nl> + if __name__ = = " __main__ " : <nl> + googletest . main ( ) <nl>
|
SGDR Learning Rate Decay Algorithm ( )
|
tensorflow/tensorflow
|
ca061bd29f46fc4017123dd81addf49214842b45
|
2017-08-09T15:59:43Z
|
mmm a / tensorflow / contrib / distribute / python / keras_test . py <nl> ppp b / tensorflow / contrib / distribute / python / keras_test . py <nl> def test_batchnorm_correctness ( self , distribution , fused ) : <nl> np . testing . assert_allclose ( out . std ( ) , 1 . 0 , atol = 1e - 1 ) <nl> <nl> <nl> - class TestDistributionStrategyVariableValidation ( test . TestCase , <nl> - parameterized . TestCase ) : <nl> + class TestDistributionStrategyValidation ( test . TestCase , <nl> + parameterized . TestCase ) : <nl> <nl> @ combinations . generate ( all_strategy_combinations_minus_default ( ) ) <nl> def test_layer_outside_scope ( self , distribution ) : <nl> def test_model_outside_scope ( self , distribution ) : <nl> metrics = [ ' mae ' , keras . metrics . CategoricalAccuracy ( ) ] <nl> model . compile ( optimizer , loss , metrics = metrics ) <nl> <nl> + @ combinations . generate ( all_strategy_combinations_minus_default ( ) ) <nl> + def test_loop_in_scope ( self , distribution ) : <nl> + with self . cached_session ( ) : <nl> + with self . assertRaisesRegexp ( <nl> + RuntimeError , ' should not be run inside the distribution strategy ' ) : <nl> + with distribution . scope ( ) : <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> + optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) <nl> + loss = ' mse ' <nl> + model . compile ( optimizer , loss ) <nl> + input_array = np . zeros ( ( 3 , 3 ) , dtype = np . float32 ) <nl> + model . predict ( input_array ) <nl> + <nl> <nl> if __name__ = = ' __main__ ' : <nl> test . main ( ) <nl> mmm a / tensorflow / python / keras / engine / distributed_training_utils . py <nl> ppp b / tensorflow / python / keras / engine / distributed_training_utils . py <nl> <nl> from tensorflow . python . ops import math_ops <nl> from tensorflow . python . ops import variables <nl> from tensorflow . python . platform import tf_logging as logging <nl> + from tensorflow . python . training import distribution_strategy_context <nl> from tensorflow . python . training . mode_keys import ModeKeys <nl> from tensorflow . python . util import nest <nl> <nl> <nl> + def validate_not_in_strategy_scope ( ) : <nl> + " " " Validate fit / eval / predict are not running in DS scope . " " " <nl> + if distribution_strategy_context . has_distribution_strategy ( ) : <nl> + if distribution_strategy_context . in_cross_replica_context ( ) : <nl> + raise RuntimeError ( <nl> + ' Fit / Eval / Predict should not be run inside the distribution strategy ' <nl> + ' scope . Only model creation and compilation should be in ' <nl> + ' distribution strategy scope . ' ) <nl> + <nl> + <nl> def set_weights ( distribution_strategy , dist_model , weights ) : <nl> " " " Sets the weights of the replicated models . <nl> <nl> mmm a / tensorflow / python / keras / engine / training_distributed . py <nl> ppp b / tensorflow / python / keras / engine / training_distributed . py <nl> def fit_distributed ( model , <nl> steps_per_epoch = None , <nl> validation_steps = None ) : <nl> " " " Fit loop for Distribution Strategies . " " " <nl> + # TODO ( b / 122314600 ) : Remove the scope validate . <nl> + distributed_training_utils . validate_not_in_strategy_scope ( ) <nl> distributed_training_utils . validate_callbacks ( callbacks , model . optimizer ) <nl> distributed_training_utils . validate_inputs ( <nl> x , y , model . _distribution_strategy ) <nl> def evaluate_distributed ( model , <nl> steps = None , <nl> callbacks = None ) : <nl> " " " Evaluate loop for Distribution Strategies . " " " <nl> + # TODO ( b / 122314600 ) : Remove the scope validate . <nl> + distributed_training_utils . validate_not_in_strategy_scope ( ) <nl> distributed_training_utils . validate_inputs ( x , y , model . _distribution_strategy ) <nl> first_x_value = nest . flatten ( x ) [ 0 ] <nl> if isinstance ( first_x_value , np . ndarray ) : <nl> def predict_distributed ( model , <nl> steps = None , <nl> callbacks = None ) : <nl> " " " Predict loop for Distribution Strategies . " " " <nl> + # TODO ( b / 122314600 ) : Remove the scope validate . <nl> + distributed_training_utils . validate_not_in_strategy_scope ( ) <nl> distributed_training_utils . validate_inputs ( <nl> x , None , model . _distribution_strategy ) <nl> first_x_value = nest . flatten ( x ) [ 0 ] <nl>
|
Throw an error when running loop inside scope
|
tensorflow/tensorflow
|
2c65e8b01301d3d001952b3fc92d4a06c1f08bf5
|
2019-01-03T23:29:57Z
|
mmm a / src / apps / MultitouchExtension / Resources / Assets . xcassets / ic_refresh_18pt . imageset / Contents . json <nl> ppp b / src / apps / MultitouchExtension / Resources / Assets . xcassets / ic_refresh_18pt . imageset / Contents . json <nl> <nl> " info " : { <nl> " version " : 1 , <nl> " author " : " xcode " <nl> + } , <nl> + " properties " : { <nl> + " template - rendering - intent " : " template " <nl> } <nl> } <nl> \ No newline at end of file <nl>
|
support Dark mode @ MultitouchExtension
|
pqrs-org/Karabiner-Elements
|
ce115f9d01885218d66338d88918198e9327ddeb
|
2019-09-04T03:56:23Z
|
mmm a / admin / static / handlebars / dataexplorer - query_li - template . handlebars <nl> ppp b / admin / static / handlebars / dataexplorer - query_li - template . handlebars <nl> <nl> < img src = " images / warning - icon . png " class = " broken_query " <nl> title = " This query produced an error " / > <nl> { { / if } } <nl> - < button class = " btn load_query " data - id = { { id } } > Load < / button > <nl> < button class = " btn delete_query " data - id = { { id } } > Remove < / button > <nl> + < button class = " btn load_query " data - id = { { id } } > Load < / button > <nl> < / div > <nl> < / div > <nl> < / li > <nl>
|
Swapped load / delete buttons in query history
|
rethinkdb/rethinkdb
|
f8340f53cb99ae2082ab4e0211e285b387f40c87
|
2014-12-10T21:57:19Z
|
mmm a / platform / osx / os_osx . h <nl> ppp b / platform / osx / os_osx . h <nl> <nl> <nl> class OS_OSX : public OS_Unix { <nl> public : <nl> - enum { <nl> - KEY_EVENT_BUFFER_SIZE = 512 <nl> - } ; <nl> - <nl> struct KeyEvent { <nl> unsigned int osx_state ; <nl> bool pressed ; <nl> class OS_OSX : public OS_Unix { <nl> uint32_t unicode ; <nl> } ; <nl> <nl> - KeyEvent key_event_buffer [ KEY_EVENT_BUFFER_SIZE ] ; <nl> + Vector < KeyEvent > key_event_buffer ; <nl> int key_event_pos ; <nl> <nl> bool force_quit ; <nl> mmm a / platform / osx / os_osx . mm <nl> ppp b / platform / osx / os_osx . mm <nl> static void get_key_modifier_state ( unsigned int p_osx_state , Ref < InputEventWithM <nl> state - > set_metakey ( ( p_osx_state & NSEventModifierFlagCommand ) ) ; <nl> } <nl> <nl> + static void push_to_key_event_buffer ( const OS_OSX : : KeyEvent & p_event ) { <nl> + <nl> + Vector < OS_OSX : : KeyEvent > & buffer = OS_OSX : : singleton - > key_event_buffer ; <nl> + if ( OS_OSX : : singleton - > key_event_pos > = buffer . size ( ) ) { <nl> + buffer . resize ( 1 + OS_OSX : : singleton - > key_event_pos ) ; <nl> + } <nl> + buffer [ OS_OSX : : singleton - > key_event_pos + + ] = p_event ; <nl> + } <nl> + <nl> static int mouse_x = 0 ; <nl> static int mouse_y = 0 ; <nl> static int prev_mouse_x = 0 ; <nl> - ( void ) insertText : ( id ) aString replacementRange : ( NSRange ) replacementRange { <nl> ke . scancode = 0 ; <nl> ke . unicode = codepoint ; <nl> <nl> - OS_OSX : : singleton - > key_event_buffer [ OS_OSX : : singleton - > key_event_pos + + ] = ke ; <nl> + push_to_key_event_buffer ( ke ) ; <nl> } <nl> [ self cancelComposition ] ; <nl> } <nl> - ( void ) keyDown : ( NSEvent * ) event { <nl> ke . scancode = latin_keyboard_keycode_convert ( translateKey ( [ event keyCode ] ) ) ; <nl> ke . unicode = 0 ; <nl> <nl> - OS_OSX : : singleton - > key_event_buffer [ OS_OSX : : singleton - > key_event_pos + + ] = ke ; <nl> + push_to_key_event_buffer ( ke ) ; <nl> } <nl> <nl> if ( ( OS_OSX : : singleton - > im_position . x ! = 0 ) & & ( OS_OSX : : singleton - > im_position . y ! = 0 ) ) <nl> - ( void ) flagsChanged : ( NSEvent * ) event { <nl> ke . scancode = latin_keyboard_keycode_convert ( translateKey ( key ) ) ; <nl> ke . unicode = 0 ; <nl> <nl> - OS_OSX : : singleton - > key_event_buffer [ OS_OSX : : singleton - > key_event_pos + + ] = ke ; <nl> + push_to_key_event_buffer ( ke ) ; <nl> } <nl> } <nl> <nl> - ( void ) keyUp : ( NSEvent * ) event { <nl> ke . scancode = latin_keyboard_keycode_convert ( translateKey ( [ event keyCode ] ) ) ; <nl> ke . unicode = 0 ; <nl> <nl> - OS_OSX : : singleton - > key_event_buffer [ OS_OSX : : singleton - > key_event_pos + + ] = ke ; <nl> + push_to_key_event_buffer ( ke ) ; <nl> } <nl> } <nl> <nl>
|
Merge pull request from poke1024 / macos - keybuffer
|
godotengine/godot
|
fe2932a969cdc0483c31c12c1f8bfd5868401da8
|
2018-01-19T08:12:18Z
|
mmm a / build / features . gypi <nl> ppp b / build / features . gypi <nl> <nl> ' Release ' : { <nl> ' variables ' : { <nl> ' v8_enable_extra_checks % ' : 0 , <nl> - ' v8_enable_handle_zapping % ' : 1 , <nl> + ' v8_enable_handle_zapping % ' : 0 , <nl> } , <nl> ' conditions ' : [ <nl> [ ' v8_enable_extra_checks = = 1 ' , { <nl>
|
Revert r17018 - " Turn on handle zapping for release builds "
|
v8/v8
|
06f16a132c1816d1a393f97bb6774664cacabc33
|
2013-10-11T07:42:43Z
|
mmm a / src / buffer_cache / mirrored / page_map . hpp <nl> ppp b / src / buffer_cache / mirrored / page_map . hpp <nl> <nl> # include " containers / two_level_array . hpp " <nl> # include " config / args . hpp " <nl> # include " buffer_cache / types . hpp " <nl> + # include " serializer / types . hpp " <nl> <nl> class mc_inner_buf_t ; <nl> <nl> class array_map_t { <nl> rassert ( array . size ( ) = = 0 ) ; <nl> } <nl> <nl> - inner_buf_t * find ( block_id_t block_id ) { <nl> + inner_buf_t * find ( block_id_t block_id ) { <nl> return array . get ( block_id ) ; <nl> } <nl> <nl> mmm a / src / buffer_cache / types . hpp <nl> ppp b / src / buffer_cache / types . hpp <nl> <nl> # ifndef __BUFFER_CACHE_TYPES_HPP__ <nl> # define __BUFFER_CACHE_TYPES_HPP__ <nl> <nl> - # include " serializer / types . hpp " <nl> + # include < stdint . h > <nl> <nl> typedef uint32_t block_magic_comparison_t ; <nl> <nl>
|
Deincluded serializer / types from buffer_cache / types .
|
rethinkdb/rethinkdb
|
7bfe3e6286a9a672945d92c21e5501370a7fdb2f
|
2011-07-12T12:03:40Z
|
mmm a / tensorflow / core / platform / file_system_helper . cc <nl> ppp b / tensorflow / core / platform / file_system_helper . cc <nl> Status GetMatchingPaths ( FileSystem * fs , Env * env , const string & pattern , <nl> dir_q . pop_front ( ) ; <nl> std : : vector < string > children ; <nl> Status s = fs - > GetChildren ( current_dir , & children ) ; <nl> - / / We will ignore permission denied error , and update status otherwise . <nl> - if ( s . code ( ) ! = tensorflow : : error : : PERMISSION_DENIED ) { <nl> - ret . Update ( s ) ; <nl> + / / In case PERMISSION_DENIED is encountered , we bail here . <nl> + if ( s . code ( ) = = tensorflow : : error : : PERMISSION_DENIED ) { <nl> + continue ; <nl> } <nl> + ret . Update ( s ) ; <nl> if ( children . empty ( ) ) continue ; <nl> / / This IsDirectory call can be expensive for some FS . Parallelizing it . <nl> children_dir_status . resize ( children . size ( ) ) ; <nl>
|
Update matching_files and bail in case PERMISSION_DENIED is encountered ,
|
tensorflow/tensorflow
|
be275e00c9134ef3e7cce1b0806f62aec28b6945
|
2018-08-11T21:54:45Z
|
mmm a / src / layer / arm / neon_mathfun . h <nl> ppp b / src / layer / arm / neon_mathfun . h <nl> static inline float32x4_t pow_ps ( float32x4_t a , float32x4_t b ) <nl> / / pow ( x , m ) = exp ( m * log ( x ) ) <nl> return exp_ps ( vmulq_f32 ( b , log_ps ( a ) ) ) ; <nl> } <nl> + <nl> + # include " neon_mathfun_tanh . h " <nl> new file mode 100644 <nl> index 0000000000 . . 1175bf65c0 <nl> mmm / dev / null <nl> ppp b / src / layer / arm / neon_mathfun_tanh . h <nl> <nl> + / / Tencent is pleased to support the open source community by making ncnn available . <nl> + / / <nl> + / / Copyright ( C ) 2019 THL A29 Limited , a Tencent company . All rights reserved . <nl> + / / <nl> + / / Licensed under the BSD 3 - Clause License ( the " License " ) ; you may not use this file except <nl> + / / in compliance with the License . You may obtain a copy of the License at <nl> + / / <nl> + / / https : / / opensource . org / licenses / BSD - 3 - Clause <nl> + / / <nl> + / / Unless required by applicable law or agreed to in writing , software distributed <nl> + / / under the License is distributed on an " AS IS " BASIS , WITHOUT WARRANTIES OR <nl> + / / CONDITIONS OF ANY KIND , either express or implied . See the License for the <nl> + / / specific language governing permissions and limitations under the License . <nl> + <nl> + # include < arm_neon . h > <nl> + <nl> + / / tanh neon vector version <nl> + / / refer the scalar version from Cephes Math Library <nl> + <nl> + # define c_cephes_HALFMAXLOGF 44 . 014845935754205f <nl> + # define c_cephes_tanh_C1 0 . 625f <nl> + <nl> + # define c_cephes_tanh_p0 - 5 . 70498872745E - 3 <nl> + # define c_cephes_tanh_p1 + 2 . 06390887954E - 2 <nl> + # define c_cephes_tanh_p2 - 5 . 37397155531E - 2 <nl> + # define c_cephes_tanh_p3 + 1 . 33314422036E - 1 <nl> + # define c_cephes_tanh_p4 - 3 . 33332819422E - 1 <nl> + <nl> + / * Single precision hyperbolic tangent computed for 4 simultaneous float * / <nl> + static inline float32x4_t tanh_ps ( float32x4_t x ) <nl> + { <nl> + float32x4_t x2 = vabsq_f32 ( x ) ; <nl> + <nl> + uint32x4_t mask_l = vcgeq_f32 ( x2 , vdupq_n_f32 ( c_cephes_tanh_C1 ) ) ; <nl> + uint32x4_t mask_l2 = vcgtq_f32 ( x2 , vdupq_n_f32 ( c_cephes_HALFMAXLOGF ) ) ; <nl> + <nl> + / / abs ( x ) > = 0 . 625 <nl> + / / tanh ( x ) = ( exp ( 2x ) - 1 ) / ( exp ( 2x ) + 1 ) <nl> + float32x4_t _one = vdupq_n_f32 ( 1 . f ) ; <nl> + float32x4_t exp_x_x = exp_ps ( vaddq_f32 ( x , x ) ) ; <nl> + # if __aarch64__ <nl> + float32x4_t y0 = vdivq_f32 ( vsubq_f32 ( exp_x_x , _one ) , vaddq_f32 ( exp_x_x , _one ) ) ; <nl> + # else <nl> + float32x4_t y0 = div_ps ( vsubq_f32 ( exp_x_x , _one ) , vaddq_f32 ( exp_x_x , _one ) ) ; <nl> + # endif <nl> + <nl> + / / abs ( x ) < 0 . 625 <nl> + / * <nl> + z = x2 * x2 ; <nl> + z = <nl> + ( ( ( ( - 5 . 70498872745E - 3 * z <nl> + + 2 . 06390887954E - 2 ) * z <nl> + - 5 . 37397155531E - 2 ) * z <nl> + + 1 . 33314422036E - 1 ) * z <nl> + - 3 . 33332819422E - 1 ) * z * x <nl> + + x ; <nl> + * / <nl> + static const float cephes_tanh_p [ 5 ] = { c_cephes_tanh_p0 , c_cephes_tanh_p1 , c_cephes_tanh_p2 , c_cephes_tanh_p3 , c_cephes_tanh_p4 } ; <nl> + float32x4_t y = vld1q_dup_f32 ( cephes_tanh_p + 0 ) ; <nl> + float32x4_t c1 = vld1q_dup_f32 ( cephes_tanh_p + 1 ) ; <nl> + float32x4_t c2 = vld1q_dup_f32 ( cephes_tanh_p + 2 ) ; <nl> + float32x4_t c3 = vld1q_dup_f32 ( cephes_tanh_p + 3 ) ; <nl> + float32x4_t c4 = vld1q_dup_f32 ( cephes_tanh_p + 4 ) ; <nl> + <nl> + float32x4_t z = vmulq_f32 ( x , x ) ; <nl> + <nl> + y = vmulq_f32 ( y , z ) ; <nl> + y = vaddq_f32 ( y , c1 ) ; <nl> + y = vmulq_f32 ( y , z ) ; <nl> + y = vaddq_f32 ( y , c2 ) ; <nl> + y = vmulq_f32 ( y , z ) ; <nl> + y = vaddq_f32 ( y , c3 ) ; <nl> + y = vmulq_f32 ( y , z ) ; <nl> + y = vaddq_f32 ( y , c4 ) ; <nl> + <nl> + y = vmulq_f32 ( y , z ) ; <nl> + y = vmulq_f32 ( y , x ) ; <nl> + y = vaddq_f32 ( y , x ) ; <nl> + <nl> + / / abs ( x ) > HALFMAXLOGF <nl> + / / return 1 . 0 or - 1 . 0 <nl> + uint32x4_t mask_pos = vcgtq_f32 ( x2 , vdupq_n_f32 ( 0 . f ) ) ; <nl> + float32x4_t y1 = vreinterpretq_f32_s32 ( vbslq_u32 ( mask_pos , vreinterpretq_u32_f32 ( vdupq_n_f32 ( 1 . f ) ) , vreinterpretq_u32_f32 ( vdupq_n_f32 ( - 1 . f ) ) ) ) ; <nl> + <nl> + y = vreinterpretq_f32_s32 ( vbslq_u32 ( mask_l , vreinterpretq_u32_f32 ( y0 ) , vreinterpretq_u32_f32 ( y ) ) ) ; <nl> + y = vreinterpretq_f32_s32 ( vbslq_u32 ( mask_l2 , vreinterpretq_u32_f32 ( y1 ) , vreinterpretq_u32_f32 ( y ) ) ) ; <nl> + return y ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . abd3c05a7d <nl> mmm / dev / null <nl> ppp b / src / layer / arm / tanh_arm . cpp <nl> <nl> + / / Tencent is pleased to support the open source community by making ncnn available . <nl> + / / <nl> + / / Copyright ( C ) 2019 THL A29 Limited , a Tencent company . All rights reserved . <nl> + / / <nl> + / / Licensed under the BSD 3 - Clause License ( the " License " ) ; you may not use this file except <nl> + / / in compliance with the License . You may obtain a copy of the License at <nl> + / / <nl> + / / https : / / opensource . org / licenses / BSD - 3 - Clause <nl> + / / <nl> + / / Unless required by applicable law or agreed to in writing , software distributed <nl> + / / under the License is distributed on an " AS IS " BASIS , WITHOUT WARRANTIES OR <nl> + / / CONDITIONS OF ANY KIND , either express or implied . See the License for the <nl> + / / specific language governing permissions and limitations under the License . <nl> + <nl> + # include " tanh_arm . h " <nl> + <nl> + # if __ARM_NEON <nl> + # include < arm_neon . h > <nl> + # include " neon_mathfun . h " <nl> + # endif / / __ARM_NEON <nl> + <nl> + # include < math . h > <nl> + <nl> + namespace ncnn { <nl> + <nl> + DEFINE_LAYER_CREATOR ( TanH_arm ) <nl> + <nl> + int TanH_arm : : forward_inplace ( Mat & bottom_top_blob , const Option & opt ) const <nl> + { <nl> + int w = bottom_top_blob . w ; <nl> + int h = bottom_top_blob . h ; <nl> + int channels = bottom_top_blob . c ; <nl> + int size = w * h ; <nl> + int elempack = bottom_top_blob . elempack ; <nl> + <nl> + # if __ARM_NEON <nl> + if ( elempack = = 4 ) <nl> + { <nl> + # pragma omp parallel for num_threads ( opt . num_threads ) <nl> + for ( int q = 0 ; q < channels ; q + + ) <nl> + { <nl> + float * ptr = bottom_top_blob . channel ( q ) ; <nl> + <nl> + for ( int i = 0 ; i < size ; i + + ) <nl> + { <nl> + float32x4_t _p = vld1q_f32 ( ptr ) ; <nl> + _p = tanh_ps ( _p ) ; <nl> + vst1q_f32 ( ptr , _p ) ; <nl> + ptr + = 4 ; <nl> + } <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> + # endif / / __ARM_NEON <nl> + <nl> + # pragma omp parallel for num_threads ( opt . num_threads ) <nl> + for ( int q = 0 ; q < channels ; q + + ) <nl> + { <nl> + float * ptr = bottom_top_blob . channel ( q ) ; <nl> + <nl> + # if __ARM_NEON <nl> + int nn = size > > 2 ; <nl> + int remain = size - ( nn < < 2 ) ; <nl> + # else <nl> + int remain = size ; <nl> + # endif / / __ARM_NEON <nl> + <nl> + # if __ARM_NEON <nl> + for ( ; nn > 0 ; nn - - ) <nl> + { <nl> + float32x4_t _p = vld1q_f32 ( ptr ) ; <nl> + _p = tanh_ps ( _p ) ; <nl> + vst1q_f32 ( ptr , _p ) ; <nl> + ptr + = 4 ; <nl> + } <nl> + # endif / / __ARM_NEON <nl> + for ( ; remain > 0 ; remain - - ) <nl> + { <nl> + * ptr = tanh ( * ptr ) ; <nl> + ptr + + ; <nl> + } <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + } / / namespace ncnn <nl> new file mode 100644 <nl> index 0000000000 . . dba6ac9b83 <nl> mmm / dev / null <nl> ppp b / src / layer / arm / tanh_arm . h <nl> <nl> + / / Tencent is pleased to support the open source community by making ncnn available . <nl> + / / <nl> + / / Copyright ( C ) 2019 THL A29 Limited , a Tencent company . All rights reserved . <nl> + / / <nl> + / / Licensed under the BSD 3 - Clause License ( the " License " ) ; you may not use this file except <nl> + / / in compliance with the License . You may obtain a copy of the License at <nl> + / / <nl> + / / https : / / opensource . org / licenses / BSD - 3 - Clause <nl> + / / <nl> + / / Unless required by applicable law or agreed to in writing , software distributed <nl> + / / under the License is distributed on an " AS IS " BASIS , WITHOUT WARRANTIES OR <nl> + / / CONDITIONS OF ANY KIND , either express or implied . See the License for the <nl> + / / specific language governing permissions and limitations under the License . <nl> + <nl> + # ifndef LAYER_TANH_ARM_H <nl> + # define LAYER_TANH_ARM_H <nl> + <nl> + # include " tanh . h " <nl> + <nl> + namespace ncnn { <nl> + <nl> + class TanH_arm : virtual public TanH <nl> + { <nl> + public : <nl> + virtual int forward_inplace ( Mat & bottom_top_blob , const Option & opt ) const ; <nl> + } ; <nl> + <nl> + } / / namespace ncnn <nl> + <nl> + # endif / / LAYER_TANH_ARM_H <nl> mmm a / src / layer / arm / unaryop_arm . cpp <nl> ppp b / src / layer / arm / unaryop_arm . cpp <nl> struct unary_op_reciprocal : std : : unary_function < T , T > { <nl> } <nl> } ; <nl> <nl> - / / template < typename T > <nl> - / / struct unary_op_tanh : std : : unary_function < T , T > { <nl> - / / T operator ( ) ( const T & x ) const { return tanh ( x ) ; } <nl> - / / } ; <nl> + template < typename T > <nl> + struct unary_op_tanh : std : : unary_function < T , T > { <nl> + T operator ( ) ( const T & x ) const { return tanh_ps ( x ) ; } <nl> + } ; <nl> <nl> int UnaryOp_arm : : forward_inplace ( Mat & bottom_top_blob , const Option & opt ) const <nl> { <nl> int UnaryOp_arm : : forward_inplace ( Mat & bottom_top_blob , const Option & opt ) const <nl> if ( op_type = = Operation_RECIPROCAL ) <nl> return unary_op_inplace < unary_op_reciprocal < float32x4_t > > ( bottom_top_blob , opt ) ; <nl> <nl> - / / TODO <nl> - / / if ( op_type = = Operation_TANH ) <nl> - / / return unary_op_inplace < unary_op_tanh < float32x4_t > > ( bottom_top_blob , opt ) ; <nl> + if ( op_type = = Operation_TANH ) <nl> + return unary_op_inplace < unary_op_tanh < float32x4_t > > ( bottom_top_blob , opt ) ; <nl> <nl> } <nl> <nl>
|
tanh arm neon optimize
|
Tencent/ncnn
|
b322db1845675dc435a227fde2729f3d27242134
|
2019-07-30T13:34:41Z
|
mmm a / folly / portability / OpenSSL . cpp <nl> ppp b / folly / portability / OpenSSL . cpp <nl> <nl> * limitations under the License . <nl> * / <nl> # include < folly / portability / OpenSSL . h > <nl> + <nl> # include < stdexcept > <nl> <nl> namespace folly { <nl> + namespace portability { <nl> namespace ssl { <nl> <nl> - # if FOLLY_OPENSSL_IS_110 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 1 . 0 only <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + # if OPENSSL_IS_BORINGSSL <nl> + int SSL_CTX_set1_sigalgs_list ( SSL_CTX * , const char * ) { <nl> + return 1 ; / / 0 implies error <nl> + } <nl> + <nl> + int TLS1_get_client_version ( SSL * s ) { <nl> + / / Note that this isn ' t the client version , and the API to <nl> + / / get this has been hidden . It may be found by parsing the <nl> + / / ClientHello ( there is a callback via the SSL_HANDSHAKE struct ) <nl> + return s - > version ; <nl> + } <nl> + # endif <nl> + <nl> + # if FOLLY_OPENSSL_IS_100 <nl> + uint32_t SSL_CIPHER_get_id ( const SSL_CIPHER * c ) { <nl> + return c - > id ; <nl> + } <nl> + <nl> + int TLS1_get_client_version ( const SSL * s ) { <nl> + return ( s - > client_version > > 8 ) = = TLS1_VERSION_MAJOR ? s - > client_version : 0 ; <nl> + } <nl> + # endif <nl> + <nl> + # if FOLLY_OPENSSL_IS_100 | | FOLLY_OPENSSL_IS_101 <nl> + int X509_get_signature_nid ( X509 * cert ) { <nl> + return OBJ_obj2nid ( cert - > sig_alg - > algorithm ) ; <nl> + } <nl> + # endif <nl> + <nl> + # if FOLLY_OPENSSL_IS_100 | | FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_102 <nl> + int SSL_CTX_up_ref ( SSL_CTX * ctx ) { <nl> + return CRYPTO_add ( & ctx - > references , 1 , CRYPTO_LOCK_SSL_CTX ) ; <nl> + } <nl> + <nl> + int SSL_SESSION_up_ref ( SSL_SESSION * session ) { <nl> + return CRYPTO_add ( & session - > references , 1 , CRYPTO_LOCK_SSL_SESSION ) ; <nl> + } <nl> + <nl> + int X509_up_ref ( X509 * x ) { <nl> + return CRYPTO_add ( & x - > references , 1 , CRYPTO_LOCK_X509 ) ; <nl> + } <nl> + # endif <nl> <nl> - # else <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in BoringSSL and OpenSSL < 1 . 1 . 0 ( i . e . , 1 . 0 . 2 , 1 . 0 . 1 , 1 . 0 . 0 , etc ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + # if ! FOLLY_OPENSSL_IS_110 <nl> void BIO_meth_free ( BIO_METHOD * biom ) { <nl> OPENSSL_free ( ( void * ) biom ) ; <nl> } <nl> int BIO_meth_set_write ( BIO_METHOD * biom , int ( * write ) ( BIO * , const char * , int ) ) { <nl> return 1 ; <nl> } <nl> <nl> - void EVP_MD_CTX_free ( EVP_MD_CTX * ctx ) { <nl> - EVP_MD_CTX_destroy ( ctx ) ; <nl> - } <nl> - <nl> const char * SSL_SESSION_get0_hostname ( const SSL_SESSION * s ) { <nl> return s - > tlsext_hostname ; <nl> } <nl> <nl> - EVP_MD_CTX * EVP_MD_CTX_new ( void ) { <nl> + EVP_MD_CTX * EVP_MD_CTX_new ( ) { <nl> EVP_MD_CTX * ctx = ( EVP_MD_CTX * ) OPENSSL_malloc ( sizeof ( EVP_MD_CTX ) ) ; <nl> if ( ! ctx ) { <nl> throw std : : runtime_error ( " Cannot allocate EVP_MD_CTX " ) ; <nl> EVP_MD_CTX * EVP_MD_CTX_new ( void ) { <nl> return ctx ; <nl> } <nl> <nl> - HMAC_CTX * HMAC_CTX_new ( void ) { <nl> + void EVP_MD_CTX_free ( EVP_MD_CTX * ctx ) { <nl> + EVP_MD_CTX_destroy ( ctx ) ; <nl> + } <nl> + <nl> + HMAC_CTX * HMAC_CTX_new ( ) { <nl> HMAC_CTX * ctx = ( HMAC_CTX * ) OPENSSL_malloc ( sizeof ( HMAC_CTX ) ) ; <nl> if ( ! ctx ) { <nl> throw std : : runtime_error ( " Cannot allocate HMAC_CTX " ) ; <nl> int DH_set0_pqg ( DH * dh , BIGNUM * p , BIGNUM * q , BIGNUM * g ) { <nl> <nl> return 1 ; <nl> } <nl> - <nl> - # ifdef OPENSSL_IS_BORINGSSL <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in BoringSSL only <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - int SSL_CTX_set1_sigalgs_list ( SSL_CTX * , const char * ) { <nl> - return 1 ; / / 0 implies error <nl> - } <nl> - <nl> - int TLS1_get_client_version ( SSL * s ) { <nl> - / / Note that this isn ' t the client version , and the API to <nl> - / / get this has been hidden . It may be found by parsing the <nl> - / / ClientHello ( there is a callback via the SSL_HANDSHAKE struct ) <nl> - return s - > version ; <nl> - } <nl> - <nl> - # elif FOLLY_OPENSSL_IS_102 | | FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 0 . 2 and 1 . 0 . 1 / 1 . 0 . 0 ( both deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - int SSL_CTX_up_ref ( SSL_CTX * ctx ) { <nl> - return CRYPTO_add ( & ctx - > references , 1 , CRYPTO_LOCK_SSL_CTX ) ; <nl> - } <nl> - <nl> - int SSL_SESSION_up_ref ( SSL_SESSION * session ) { <nl> - return CRYPTO_add ( & session - > references , 1 , CRYPTO_LOCK_SSL_SESSION ) ; <nl> - } <nl> - <nl> - int X509_up_ref ( X509 * x ) { <nl> - return CRYPTO_add ( & x - > references , 1 , CRYPTO_LOCK_X509 ) ; <nl> - } <nl> - <nl> - # if FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 0 . 1 / 1 . 0 . 0 ( both deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - int X509_get_signature_nid ( X509 * cert ) { <nl> - return OBJ_obj2nid ( cert - > sig_alg - > algorithm ) ; <nl> - } <nl> - <nl> # endif <nl> <nl> - # if FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed only in 1 . 0 . 0 only ( deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - uint32_t SSL_CIPHER_get_id ( const SSL_CIPHER * c ) { <nl> - return c - > id ; <nl> - } <nl> - <nl> - int TLS1_get_client_version ( const SSL * s ) { <nl> - return ( s - > client_version > > 8 ) = = TLS1_VERSION_MAJOR ? s - > client_version : 0 ; <nl> } <nl> - <nl> - # endif <nl> - <nl> - # endif / / ! ( OPENSSL_IS_BORINGSSL | | <nl> - / / FOLLY_OPENSSL_IS_101 | | <nl> - / / FOLLY_OPENSSL_IS_102 | | <nl> - / / FOLLY_OPENSSL_IS_100 ) <nl> - <nl> - # endif / / ! FOLLY_OPENSSL_IS_110 <nl> } <nl> } <nl> mmm a / folly / portability / OpenSSL . h <nl> ppp b / folly / portability / OpenSSL . h <nl> <nl> * limitations under the License . <nl> * / <nl> <nl> - / / <nl> - / / This class attempts to " unify " the OpenSSL libcrypto / libssl APIs between <nl> - / / OpenSSL 1 . 0 . 2 , 1 . 1 . 0 ( and some earlier versions ) and BoringSSL . The general <nl> - / / idea is to provide namespaced wrapper methods for versions which do not <nl> - / / which already exist in BoringSSL and 1 . 1 . 0 , but there are few APIs such as <nl> - / / SSL_CTX_set1_sigalgs_list and so on which exist in 1 . 0 . 2 but were removed <nl> - / / in BoringSSL <nl> - / / <nl> - <nl> # pragma once <nl> <nl> / / This must come before the OpenSSL includes . <nl> # include < folly / portability / Windows . h > <nl> <nl> + # include < folly / Portability . h > <nl> + <nl> # include < openssl / dh . h > <nl> # include < openssl / evp . h > <nl> # include < openssl / ssl . h > <nl> # include < openssl / x509 . h > <nl> - # include < cstdint > <nl> - <nl> - namespace folly { <nl> - namespace ssl { <nl> <nl> / / BoringSSL doesn ' t have notion of versioning although it defines <nl> / / OPENSSL_VERSION_NUMBER to maintain compatibility . The following variables are <nl> / / intended to be specific to OpenSSL . <nl> # if ! defined ( OPENSSL_IS_BORINGSSL ) <nl> - # define FOLLY_OPENSSL_IS_100 \ <nl> + # define FOLLY_OPENSSL_IS_100 \ <nl> ( OPENSSL_VERSION_NUMBER > = 0x10000003L & & \ <nl> OPENSSL_VERSION_NUMBER < 0x1000105fL ) <nl> - # define FOLLY_OPENSSL_IS_101 \ <nl> + # define FOLLY_OPENSSL_IS_101 \ <nl> ( OPENSSL_VERSION_NUMBER > = 0x1000105fL & & \ <nl> OPENSSL_VERSION_NUMBER < 0x1000200fL ) <nl> - # define FOLLY_OPENSSL_IS_102 \ <nl> + # define FOLLY_OPENSSL_IS_102 \ <nl> ( OPENSSL_VERSION_NUMBER > = 0x1000200fL & & \ <nl> OPENSSL_VERSION_NUMBER < 0x10100000L ) <nl> - # define FOLLY_OPENSSL_IS_110 ( OPENSSL_VERSION_NUMBER > = 0x10100000L ) <nl> - # endif / / ! defined ( OPENSSL_IS_BORINGSSL ) <nl> + # define FOLLY_OPENSSL_IS_110 ( OPENSSL_VERSION_NUMBER > = 0x10100000L ) <nl> + # endif <nl> <nl> - / / BoringSSL and OpenSSL 1 . 0 . 2 later with TLS extension support ALPN . <nl> - # if defined ( OPENSSL_IS_BORINGSSL ) | | \ <nl> - ( OPENSSL_VERSION_NUMBER > = 0x1000200fL & & \ <nl> - ! defined ( OPENSSL_NO_TLSEXT ) ) <nl> - # define FOLLY_OPENSSL_HAS_ALPN 1 <nl> - # else <nl> - # define FOLLY_OPENSSL_HAS_ALPN 0 <nl> + # if ! OPENSSL_IS_BORINGSSL & & ! FOLLY_OPENSSL_IS_100 & & ! FOLLY_OPENSSL_IS_101 \ <nl> + & & ! FOLLY_OPENSSL_IS_102 & & ! FOLLY_OPENSSL_IS_110 <nl> + # warning Compiling with unsupported OpenSSL version <nl> # endif <nl> <nl> / / BoringSSL and OpenSSL 0 . 9 . 8f later with TLS extension support SNI . <nl> - # if defined ( OPENSSL_IS_BORINGSSL ) | | \ <nl> - ( OPENSSL_VERSION_NUMBER > = 0x00908070L & & \ <nl> - ! defined ( OPENSSL_NO_TLSEXT ) ) <nl> - # define FOLLY_OPENSSL_HAS_SNI 1 <nl> + # if OPENSSL_IS_BORINGSSL | | \ <nl> + ( OPENSSL_VERSION_NUMBER > = 0x00908070L & & ! defined ( OPENSSL_NO_TLSEXT ) ) <nl> + # define FOLLY_OPENSSL_HAS_SNI 1 <nl> # else <nl> - # define FOLLY_OPENSSL_HAS_SNI 0 <nl> + # define FOLLY_OPENSSL_HAS_SNI 0 <nl> # endif <nl> <nl> - # if FOLLY_OPENSSL_IS_110 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 1 . 0 only <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> + / / BoringSSL and OpenSSL 1 . 0 . 2 later with TLS extension support ALPN . <nl> + # if OPENSSL_IS_BORINGSSL | | \ <nl> + ( OPENSSL_VERSION_NUMBER > = 0x1000200fL & & ! defined ( OPENSSL_NO_TLSEXT ) ) <nl> + # define FOLLY_OPENSSL_HAS_ALPN 1 <nl> # else <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in BoringSSL and OpenSSL ! = 1 . 1 . 0 ( 1 . 0 . 2 , 1 . 0 . 1 , 1 . 0 . 0 . . . ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void BIO_meth_free ( BIO_METHOD * biom ) ; <nl> - int BIO_meth_set_read ( BIO_METHOD * biom , int ( * read ) ( BIO * , char * , int ) ) ; <nl> - int BIO_meth_set_write ( BIO_METHOD * biom , int ( * write ) ( BIO * , const char * , int ) ) ; <nl> - void EVP_MD_CTX_free ( EVP_MD_CTX * ctx ) ; <nl> - const char * SSL_SESSION_get0_hostname ( const SSL_SESSION * s ) ; <nl> - <nl> - EVP_MD_CTX * EVP_MD_CTX_new ( void ) ; <nl> - void EVP_MD_CTX_free ( EVP_MD_CTX * ctx ) ; <nl> - <nl> - HMAC_CTX * HMAC_CTX_new ( void ) ; <nl> - void HMAC_CTX_free ( HMAC_CTX * ctx ) ; <nl> - <nl> - unsigned long SSL_SESSION_get_ticket_lifetime_hint ( const SSL_SESSION * s ) ; <nl> - int SSL_SESSION_has_ticket ( const SSL_SESSION * ) ; <nl> - int DH_set0_pqg ( DH * dh , BIGNUM * p , BIGNUM * q , BIGNUM * g ) ; <nl> + # define FOLLY_OPENSSL_HAS_ALPN 0 <nl> + # endif <nl> <nl> - # ifdef OPENSSL_IS_BORINGSSL <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in BoringSSL only <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / This attempts to " unify " the OpenSSL libcrypto / libssl APIs between <nl> + / / OpenSSL 1 . 0 . 2 , 1 . 1 . 0 ( and some earlier versions ) and BoringSSL . The general <nl> + / / idea is to provide namespaced wrapper methods for versions which do not <nl> + / / which already exist in BoringSSL and 1 . 1 . 0 , but there are few APIs such as <nl> + / / SSL_CTX_set1_sigalgs_list and so on which exist in 1 . 0 . 2 but were removed <nl> + / / in BoringSSL <nl> + namespace folly { <nl> + namespace portability { <nl> + namespace ssl { <nl> <nl> + # if OPENSSL_IS_BORINGSSL <nl> int SSL_CTX_set1_sigalgs_list ( SSL_CTX * ctx , const char * sigalgs_list ) ; <nl> int TLS1_get_client_version ( SSL * s ) ; <nl> + # endif <nl> <nl> - # elif FOLLY_OPENSSL_IS_102 | | FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 0 . 2 and 1 . 0 . 1 / 1 . 0 . 0 ( both deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + # if FOLLY_OPENSSL_IS_100 <nl> + uint32_t SSL_CIPHER_get_id ( const SSL_CIPHER * ) ; <nl> + int TLS1_get_client_version ( const SSL * ) ; <nl> + # endif <nl> <nl> + # if FOLLY_OPENSSL_IS_100 | | FOLLY_OPENSSL_IS_101 <nl> + int X509_get_signature_nid ( X509 * cert ) ; <nl> + # endif <nl> + <nl> + # if FOLLY_OPENSSL_IS_100 | | FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_102 <nl> int SSL_CTX_up_ref ( SSL_CTX * session ) ; <nl> int SSL_SESSION_up_ref ( SSL_SESSION * session ) ; <nl> int X509_up_ref ( X509 * x ) ; <nl> + # endif <nl> <nl> - # if FOLLY_OPENSSL_IS_101 | | FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed in 1 . 0 . 1 / 1 . 0 . 0 ( both deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - int X509_get_signature_nid ( X509 * cert ) ; <nl> + # if ! FOLLY_OPENSSL_IS_110 <nl> + void BIO_meth_free ( BIO_METHOD * biom ) ; <nl> + int BIO_meth_set_read ( BIO_METHOD * biom , int ( * read ) ( BIO * , char * , int ) ) ; <nl> + int BIO_meth_set_write ( BIO_METHOD * biom , int ( * write ) ( BIO * , const char * , int ) ) ; <nl> <nl> - # endif <nl> + const char * SSL_SESSION_get0_hostname ( const SSL_SESSION * s ) ; <nl> <nl> - # if FOLLY_OPENSSL_IS_100 <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / APIs needed only in 1 . 0 . 0 only ( deprecated ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + EVP_MD_CTX * EVP_MD_CTX_new ( ) ; <nl> + void EVP_MD_CTX_free ( EVP_MD_CTX * ctx ) ; <nl> <nl> - uint32_t SSL_CIPHER_get_id ( const SSL_CIPHER * ) ; <nl> - int TLS1_get_client_version ( const SSL * ) ; <nl> + HMAC_CTX * HMAC_CTX_new ( ) ; <nl> + void HMAC_CTX_free ( HMAC_CTX * ctx ) ; <nl> <nl> + unsigned long SSL_SESSION_get_ticket_lifetime_hint ( const SSL_SESSION * s ) ; <nl> + int SSL_SESSION_has_ticket ( const SSL_SESSION * s ) ; <nl> + int DH_set0_pqg ( DH * dh , BIGNUM * p , BIGNUM * q , BIGNUM * g ) ; <nl> # endif <nl> - # else <nl> - # warning Compiling with unsupported OpenSSL version <nl> - <nl> - # endif / / ! ( OPENSSL_IS_BORINGSSL | | FOLLY_OPENSSL_IS_101 | | <nl> - / / FOLLY_OPENSSL_IS_102 | | FOLLY_OPENSSL_IS_100 ) <nl> <nl> - # endif / / ! FOLLY_OPENSSL_IS_110 <nl> + } <nl> + } <nl> + } <nl> <nl> - } / / ssl <nl> - } / / folly <nl> + FOLLY_PUSH_WARNING <nl> + # if __CLANG_PREREQ ( 3 , 0 ) <nl> + FOLLY_GCC_DISABLE_WARNING ( header - hygiene ) <nl> + # endif <nl> + / * using override * / using namespace folly : : portability : : ssl ; <nl> + FOLLY_POP_WARNING <nl>
|
Re - work the OpenSSL portability header to be a portability header
|
facebook/folly
|
9783dc4e7cfa938f1c33666ec0a31c204dff60ed
|
2017-04-10T18:20:12Z
|
mmm a / folly / io / async / SSLContext . cpp <nl> ppp b / folly / io / async / SSLContext . cpp <nl> SSLContext : : SSLContext ( SSLVersion version ) { <nl> SSL_CTX_set_tlsext_servername_callback ( ctx_ , baseServerNameOpenSSLCallback ) ; <nl> SSL_CTX_set_tlsext_servername_arg ( ctx_ , this ) ; <nl> # endif <nl> + <nl> + # ifdef OPENSSL_NPN_NEGOTIATED <nl> + Random : : seed ( nextProtocolPicker_ ) ; <nl> + # endif <nl> } <nl> <nl> SSLContext : : ~ SSLContext ( ) { <nl> bool SSLContext : : setRandomizedAdvertisedNextProtocols ( <nl> dst + = protoLength ; <nl> } <nl> total_weight + = item . weight ; <nl> - advertised_item . probability = item . weight ; <nl> advertisedNextProtocols_ . push_back ( advertised_item ) ; <nl> + advertisedNextProtocolWeights_ . push_back ( item . weight ) ; <nl> } <nl> if ( total_weight = = 0 ) { <nl> deleteNextProtocolsStrings ( ) ; <nl> return false ; <nl> } <nl> - for ( auto & advertised_item : advertisedNextProtocols_ ) { <nl> - advertised_item . probability / = total_weight ; <nl> - } <nl> + nextProtocolDistribution_ = <nl> + std : : discrete_distribution < > ( advertisedNextProtocolWeights_ . begin ( ) , <nl> + advertisedNextProtocolWeights_ . end ( ) ) ; <nl> if ( ( uint8_t ) protocolType & ( uint8_t ) NextProtocolType : : NPN ) { <nl> SSL_CTX_set_next_protos_advertised_cb ( <nl> ctx_ , advertisedNextProtocolCallback , this ) ; <nl> void SSLContext : : deleteNextProtocolsStrings ( ) { <nl> delete [ ] protocols . protocols ; <nl> } <nl> advertisedNextProtocols_ . clear ( ) ; <nl> + advertisedNextProtocolWeights_ . clear ( ) ; <nl> } <nl> <nl> void SSLContext : : unsetNextProtocols ( ) { <nl> void SSLContext : : unsetNextProtocols ( ) { <nl> } <nl> <nl> size_t SSLContext : : pickNextProtocols ( ) { <nl> - unsigned char random_byte ; <nl> - RAND_bytes ( & random_byte , 1 ) ; <nl> - double random_value = random_byte / 255 . 0 ; <nl> - double sum = 0 ; <nl> - for ( size_t i = 0 ; i < advertisedNextProtocols_ . size ( ) ; + + i ) { <nl> - sum + = advertisedNextProtocols_ [ i ] . probability ; <nl> - if ( sum < random_value & & i + 1 < advertisedNextProtocols_ . size ( ) ) { <nl> - continue ; <nl> - } <nl> - return i ; <nl> - } <nl> - CHECK ( false ) < < " Failed to pickNextProtocols " ; <nl> + CHECK ( ! advertisedNextProtocols_ . empty ( ) ) < < " Failed to pickNextProtocols " ; <nl> + return nextProtocolDistribution_ ( nextProtocolPicker_ ) ; <nl> } <nl> <nl> int SSLContext : : advertisedNextProtocolCallback ( SSL * ssl , <nl> mmm a / folly / io / async / SSLContext . h <nl> ppp b / folly / io / async / SSLContext . h <nl> <nl> # include < vector > <nl> # include < memory > <nl> # include < string > <nl> + # include < random > <nl> <nl> # include < openssl / ssl . h > <nl> # include < openssl / tls1 . h > <nl> <nl> # include < folly / folly - config . h > <nl> # endif <nl> <nl> + # include < folly / Random . h > <nl> + <nl> namespace folly { <nl> <nl> / * * <nl> class SSLContext { <nl> std : : list < std : : string > protocols ; <nl> } ; <nl> <nl> - struct AdvertisedNextProtocolsItem { <nl> - unsigned char * protocols ; <nl> - unsigned length ; <nl> - double probability ; <nl> - } ; <nl> - <nl> / / Function that selects a client protocol given the server ' s list <nl> using ClientProtocolFilterCallback = bool ( * ) ( unsigned char * * , unsigned int * , <nl> const unsigned char * , unsigned int ) ; <nl> class SSLContext { <nl> static bool initialized_ ; <nl> <nl> # ifdef OPENSSL_NPN_NEGOTIATED <nl> + <nl> + struct AdvertisedNextProtocolsItem { <nl> + unsigned char * protocols ; <nl> + unsigned length ; <nl> + } ; <nl> + <nl> / * * <nl> * Wire - format list of advertised protocols for use in NPN . <nl> * / <nl> std : : vector < AdvertisedNextProtocolsItem > advertisedNextProtocols_ ; <nl> + std : : vector < int > advertisedNextProtocolWeights_ ; <nl> + std : : discrete_distribution < int > nextProtocolDistribution_ ; <nl> + Random : : DefaultGenerator nextProtocolPicker_ ; <nl> + <nl> static int sNextProtocolsExDataIndex_ ; <nl> <nl> static int advertisedNextProtocolCallback ( SSL * ssl , <nl>
|
Update SSLContext to use discrete_distribution
|
facebook/folly
|
92c9ccb6e8958fd706dc259a854e3f721f85ea19
|
2015-12-10T01:20:24Z
|
mmm a / osquery / tables / specs / x / processes . table <nl> ppp b / osquery / tables / specs / x / processes . table <nl> description ( " All running processes on the host system . " ) <nl> schema ( [ <nl> Column ( " pid " , INTEGER , " Process ( or thread ) ID " ) , <nl> Column ( " name " , TEXT , " The process path or shorthand argv [ 0 ] " ) , <nl> - Column ( " path " , TEXT ) , <nl> + Column ( " path " , TEXT , " Path to executed binary " ) , <nl> Column ( " cmdline " , TEXT , " Complete argv " ) , <nl> - Column ( " uid " , BIGINT ) , <nl> - Column ( " gid " , BIGINT ) , <nl> - Column ( " euid " , BIGINT ) , <nl> - Column ( " egid " , BIGINT ) , <nl> + Column ( " cwd " , TEXT , " Process current working directory " ) , <nl> + Column ( " root " , TEXT , " Process virtual root directory " ) , <nl> + Column ( " uid " , BIGINT , " Unsigned user ID " ) , <nl> + Column ( " gid " , BIGINT , " Unsgiend groud ID " ) , <nl> + Column ( " euid " , BIGINT , " Unsigned effective user ID " ) , <nl> + Column ( " egid " , BIGINT , " Unsigned effective group ID " ) , <nl> Column ( " on_disk " , TEXT , " The process path exist yes = 1 , no = - 1 " ) , <nl> - Column ( " wired_size " , TEXT ) , <nl> - Column ( " resident_size " , TEXT ) , <nl> - Column ( " phys_footprint " , TEXT ) , <nl> - Column ( " user_time " , TEXT ) , <nl> - Column ( " system_time " , TEXT ) , <nl> - Column ( " start_time " , TEXT ) , <nl> - Column ( " parent " , INTEGER ) , <nl> + Column ( " wired_size " , TEXT , " Bytes of unpagable memory used by process " ) , <nl> + Column ( " resident_size " , TEXT , " Bytes of private memory used by process " ) , <nl> + Column ( " phys_footprint " , TEXT , " Bytes of total physical memory used " ) , <nl> + Column ( " user_time " , TEXT , " CPU time spent in user space " ) , <nl> + Column ( " system_time " , TEXT , " CPU time spent in kernel space " ) , <nl> + Column ( " start_time " , TEXT , " Unix timestamp of process start " ) , <nl> + Column ( " parent " , INTEGER , " Process parent ' s PID " ) , <nl> ] ) <nl> implementation ( " system / processes @ genProcesses " ) <nl> mmm a / osquery / tables / system / darwin / processes . cpp <nl> ppp b / osquery / tables / system / darwin / processes . cpp <nl> struct proc_cred { <nl> inline bool getProcCred ( int pid , proc_cred & cred ) { <nl> struct proc_bsdshortinfo bsdinfo ; <nl> <nl> - if ( proc_pidinfo ( pid , PROC_PIDT_SHORTBSDINFO , 0 , & bsdinfo , sizeof ( bsdinfo ) ) ! = <nl> - - 1 ) { <nl> + if ( proc_pidinfo ( pid , PROC_PIDT_SHORTBSDINFO , 0 , & bsdinfo , sizeof ( bsdinfo ) ) = = <nl> + sizeof ( bsdinfo ) ) { <nl> cred . real . uid = bsdinfo . pbsi_ruid ; <nl> cred . real . gid = bsdinfo . pbsi_ruid ; <nl> cred . effective . uid = bsdinfo . pbsi_uid ; <nl> static int genMaxArgs ( ) { <nl> return argmax ; <nl> } <nl> <nl> + void genProcRootAndCWD ( int pid , Row & r ) { <nl> + struct proc_vnodepathinfo pathinfo ; <nl> + if ( proc_pidinfo ( <nl> + pid , PROC_PIDVNODEPATHINFO , 0 , & pathinfo , sizeof ( pathinfo ) ) = = <nl> + sizeof ( pathinfo ) ) { <nl> + if ( pathinfo . pvi_cdir . vip_vi . vi_stat . vst_dev ! = 0 ) { <nl> + r [ " cwd " ] = std : : string ( pathinfo . pvi_cdir . vip_path ) ; <nl> + } <nl> + if ( pathinfo . pvi_rdir . vip_vi . vi_stat . vst_dev ! = 0 ) { <nl> + r [ " root " ] = std : : string ( pathinfo . pvi_rdir . vip_path ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> std : : vector < std : : string > getProcRawArgs ( int pid , size_t argmax ) { <nl> std : : vector < std : : string > args ; <nl> uid_t euid = geteuid ( ) ; <nl> QueryData genProcesses ( QueryContext & context ) { <nl> std : : string cmdline = boost : : algorithm : : join ( getProcArgs ( pid , argmax ) , " " ) ; <nl> boost : : algorithm : : trim ( cmdline ) ; <nl> r [ " cmdline " ] = cmdline ; <nl> + genProcRootAndCWD ( pid , r ) ; <nl> <nl> proc_cred cred ; <nl> if ( getProcCred ( pid , cred ) ) { <nl> QueryData genProcesses ( QueryContext & context ) { <nl> r [ " egid " ] = BIGINT ( cred . effective . gid ) ; <nl> } <nl> <nl> + / / Find the parent process . <nl> const auto parent_it = parent_pid . find ( pid ) ; <nl> if ( parent_it ! = parent_pid . end ( ) ) { <nl> r [ " parent " ] = INTEGER ( parent_it - > second ) ; <nl> QueryData genProcesses ( QueryContext & context ) { <nl> r [ " parent " ] = " - 1 " ; <nl> } <nl> <nl> - / / if the path of the executable that started the process is available and <nl> - / / the path exists on disk , set on_disk to 1 . if the path is not <nl> - / / available , set on_disk to - 1 . if , and only if , the path of the <nl> - / / executable is available and the file does not exist on disk , set on_disk <nl> + / / If the path of the executable that started the process is available and <nl> + / / the path exists on disk , set on_disk to 1 . If the path is not <nl> + / / available , set on_disk to - 1 . If , and only if , the path of the <nl> + / / executable is available and the file does NOT exist on disk , set on_disk <nl> / / to 0 . <nl> r [ " on_disk " ] = osquery : : pathExists ( r [ " path " ] ) . toString ( ) ; <nl> <nl> QueryData genProcesses ( QueryContext & context ) { <nl> pid , RUSAGE_INFO_V2 , ( rusage_info_t * ) & rusage_info_data ) ; <nl> / / proc_pid_rusage returns - 1 if it was unable to gather information <nl> if ( rusage_status = = 0 ) { <nl> - / / size information <nl> + / / size / memory information <nl> r [ " wired_size " ] = TEXT ( rusage_info_data . ri_wired_size ) ; <nl> r [ " resident_size " ] = TEXT ( rusage_info_data . ri_resident_size ) ; <nl> r [ " phys_footprint " ] = TEXT ( rusage_info_data . ri_phys_footprint ) ; <nl> QueryData genProcesses ( QueryContext & context ) { <nl> r [ " start_time " ] = TEXT ( rusage_info_data . ri_proc_start_abstime ) ; <nl> } <nl> <nl> - / / save the results <nl> results . push_back ( r ) ; <nl> } <nl> <nl> mmm a / osquery / tables / system / linux / processes . cpp <nl> ppp b / osquery / tables / system / linux / processes . cpp <nl> namespace tables { <nl> PROC_FILLCOM | PROC_FILLMEM | PROC_FILLSTATUS | PROC_FILLSTAT <nl> # endif <nl> <nl> - std : : string getProcName ( const proc_t * proc_info ) { <nl> + inline std : : string getProcName ( const proc_t * proc_info ) { <nl> return std : : string ( proc_info - > cmd ) ; <nl> } <nl> <nl> - std : : string getProcAttr ( const std : : string & attr , const proc_t * proc_info ) { <nl> + inline std : : string getProcAttr ( const std : : string & attr , const proc_t * proc_info ) { <nl> return " / proc / " + std : : to_string ( proc_info - > tid ) + " / " + attr ; <nl> } <nl> <nl> - std : : string readProcCMDLine ( const proc_t * proc_info ) { <nl> + inline std : : string readProcCMDLine ( const proc_t * proc_info ) { <nl> auto attr = getProcAttr ( " cmdline " , proc_info ) ; <nl> <nl> std : : string result ; <nl> std : : string readProcCMDLine ( const proc_t * proc_info ) { <nl> return result ; <nl> } <nl> <nl> - std : : string readProcLink ( const proc_t * proc_info ) { <nl> + inline std : : string readProcLink ( const proc_t * proc_info , <nl> + const std : : string & attr ) { <nl> / / The exe is a symlink to the binary on - disk . <nl> - auto attr = getProcAttr ( " exe " , proc_info ) ; <nl> - long path_max = pathconf ( attr . c_str ( ) , _PC_PATH_MAX ) ; <nl> + auto attr_path = getProcAttr ( attr , proc_info ) ; <nl> + long path_max = pathconf ( attr_path . c_str ( ) , _PC_PATH_MAX ) ; <nl> auto link_path = ( char * ) malloc ( path_max ) ; <nl> memset ( link_path , 0 , path_max ) ; <nl> <nl> std : : string result ; <nl> - int bytes = readlink ( attr . c_str ( ) , link_path , path_max ) ; <nl> + int bytes = readlink ( attr_path . c_str ( ) , link_path , path_max ) ; <nl> if ( bytes > = 0 ) { <nl> result = std : : string ( link_path ) ; <nl> } <nl> QueryData genProcesses ( QueryContext & context ) { <nl> <nl> Row r ; <nl> r [ " pid " ] = INTEGER ( proc_info - > tid ) ; <nl> - r [ " uid " ] = BIGINT ( ( unsigned int ) proc_info - > ruid ) ; <nl> - r [ " gid " ] = BIGINT ( ( unsigned int ) proc_info - > rgid ) ; <nl> - r [ " euid " ] = BIGINT ( ( unsigned int ) proc_info - > euid ) ; <nl> - r [ " egid " ] = BIGINT ( ( unsigned int ) proc_info - > egid ) ; <nl> + r [ " parent " ] = INTEGER ( proc_info - > ppid ) ; <nl> + r [ " path " ] = readProcLink ( proc_info , " exe " ) ; <nl> r [ " name " ] = getProcName ( proc_info ) ; <nl> + <nl> + / / Read / parse cmdline arguments . <nl> std : : string cmdline = readProcCMDLine ( proc_info ) ; <nl> boost : : algorithm : : trim ( cmdline ) ; <nl> r [ " cmdline " ] = cmdline ; <nl> - r [ " path " ] = readProcLink ( proc_info ) ; <nl> + r [ " cwd " ] = readProcLink ( proc_info , " cwd " ) ; <nl> + r [ " root " ] = readProcLink ( proc_info , " root " ) ; <nl> + <nl> + r [ " uid " ] = BIGINT ( ( unsigned int ) proc_info - > ruid ) ; <nl> + r [ " gid " ] = BIGINT ( ( unsigned int ) proc_info - > rgid ) ; <nl> + r [ " euid " ] = BIGINT ( ( unsigned int ) proc_info - > euid ) ; <nl> + r [ " egid " ] = BIGINT ( ( unsigned int ) proc_info - > egid ) ; <nl> + <nl> + / / If the path of the executable that started the process is available and <nl> + / / the path exists on disk , set on_disk to 1 . If the path is not <nl> + / / available , set on_disk to - 1 . If , and only if , the path of the <nl> + / / executable is available and the file does NOT exist on disk , set on_disk <nl> + / / to 0 . <nl> r [ " on_disk " ] = osquery : : pathExists ( r [ " path " ] ) . toString ( ) ; <nl> <nl> + / / size / memory information <nl> + r [ " wired_size " ] = " 0 " ; / / No support for unpagable counters in linux . <nl> r [ " resident_size " ] = INTEGER ( proc_info - > vm_rss ) ; <nl> r [ " phys_footprint " ] = INTEGER ( proc_info - > vm_size ) ; <nl> + <nl> + / / time information <nl> r [ " user_time " ] = INTEGER ( proc_info - > utime ) ; <nl> r [ " system_time " ] = INTEGER ( proc_info - > stime ) ; <nl> r [ " start_time " ] = INTEGER ( proc_info - > start_time ) ; <nl> - r [ " parent " ] = INTEGER ( proc_info - > ppid ) ; <nl> <nl> results . push_back ( r ) ; <nl> standardFreeproc ( proc_info ) ; <nl>
|
Add ' cwd ' , ' root ' to processes
|
osquery/osquery
|
340dcd775a30836b4de4e1aca553daeaca8a20b8
|
2015-02-13T02:05:10Z
|
mmm a / ELECTRON_VERSION <nl> ppp b / ELECTRON_VERSION <nl> @ @ - 1 + 1 @ @ <nl> - 10 . 0 . 0 - nightly . 20200213 <nl> \ No newline at end of file <nl> + 10 . 0 . 0 - nightly . 20200214 <nl> \ No newline at end of file <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> { <nl> " name " : " electron " , <nl> - " version " : " 10 . 0 . 0 - nightly . 20200213 " , <nl> + " version " : " 10 . 0 . 0 - nightly . 20200214 " , <nl> " repository " : " https : / / github . com / electron / electron " , <nl> " description " : " Build cross platform desktop apps with JavaScript , HTML , and CSS " , <nl> " devDependencies " : { <nl> mmm a / shell / browser / resources / win / atom . rc <nl> ppp b / shell / browser / resources / win / atom . rc <nl> END <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 10 , 0 , 0 , 20200213 <nl> - PRODUCTVERSION 10 , 0 , 0 , 20200213 <nl> + FILEVERSION 10 , 0 , 0 , 20200214 <nl> + PRODUCTVERSION 10 , 0 , 0 , 20200214 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl>
|
Bump v10 . 0 . 0 - nightly . 20200214
|
electron/electron
|
b7bb1cc4c31ae737adc8da29b36b2c8e134c273f
|
2020-02-14T15:31:36Z
|
mmm a / lib / SILOptimizer / Mandatory / DefiniteInitialization . cpp <nl> ppp b / lib / SILOptimizer / Mandatory / DefiniteInitialization . cpp <nl> handleConditionalDestroys ( SILValue ControlVariableAddr ) { <nl> auto & Availability = CDElt . Availability ; <nl> <nl> B . setInsertionPoint ( Release ) ; <nl> + B . setCurrentDebugScope ( Release - > getDebugScope ( ) ) ; <nl> <nl> / / Value types and root classes don ' t require any fancy handling . <nl> / / Just conditionally destroy each memory element , and for classes , <nl> handleConditionalDestroys ( SILValue ControlVariableAddr ) { <nl> <nl> / / If true , self . init or super . init was called and self was consumed . <nl> B . setInsertionPoint ( ConsumedBlock - > begin ( ) ) ; <nl> + B . setCurrentDebugScope ( ConsumedBlock - > begin ( ) - > getDebugScope ( ) ) ; <nl> processUninitializedRelease ( Release , true , B . getInsertionPoint ( ) ) ; <nl> <nl> / / If false , self is uninitialized and must be freed . <nl> B . setInsertionPoint ( DeallocBlock - > begin ( ) ) ; <nl> + B . setCurrentDebugScope ( DeallocBlock - > begin ( ) - > getDebugScope ( ) ) ; <nl> destroyMemoryElements ( Loc , Availability ) ; <nl> processUninitializedRelease ( Release , false , B . getInsertionPoint ( ) ) ; <nl> <nl> handleConditionalDestroys ( SILValue ControlVariableAddr ) { <nl> <nl> / / If true , self was consumed or is fully initialized . <nl> B . setInsertionPoint ( LiveBlock - > begin ( ) ) ; <nl> + B . setCurrentDebugScope ( LiveBlock - > begin ( ) - > getDebugScope ( ) ) ; <nl> emitReleaseOfSelfWhenNotConsumed ( Loc , Release ) ; <nl> isDeadRelease = false ; <nl> <nl> / / If false , self is uninitialized and must be freed . <nl> B . setInsertionPoint ( DeallocBlock - > begin ( ) ) ; <nl> + B . setCurrentDebugScope ( DeallocBlock - > begin ( ) - > getDebugScope ( ) ) ; <nl> destroyMemoryElements ( Loc , Availability ) ; <nl> processUninitializedRelease ( Release , false , B . getInsertionPoint ( ) ) ; <nl> <nl> new file mode 100644 <nl> index 000000000000 . . 055d65d181c2 <nl> mmm / dev / null <nl> ppp b / test / SILOptimizer / di - conditional - destroy - scope . swift <nl> <nl> + / / RUN : % target - swift - frontend - emit - sil % s - Onone - Xllvm \ <nl> + / / RUN : - sil - print - after = definite - init - Xllvm \ <nl> + / / RUN : - sil - print - only - functions = $ S2fs36RecursibleDirectoryContentsGeneratorC4path10fileSystemAcA12AbsolutePathV_AA04FileH0_ptKc33_F8B132991B28208F48606E87DC165393Llfc \ <nl> + / / RUN : - Xllvm - sil - print - debuginfo - o / dev / null 2 > & 1 | % FileCheck % s <nl> + <nl> + / / REQUIRES : objc_interop <nl> + <nl> + <nl> + / / CHECK : % 49 = ref_element_addr % 48 : $ RecursibleDirectoryContentsGenerator , # RecursibleDirectoryContentsGenerator . fileSystem , loc { { . * } } : 38 : 5 , scope 2 <nl> + / / CHECK : destroy_addr % 49 : $ * FileSystem , loc { { . * } } : 38 : 5 , scope 2 <nl> + <nl> + <nl> + import Foundation <nl> + <nl> + public struct AbsolutePath { <nl> + public init ( _ absStr : String ) { } <nl> + } <nl> + <nl> + public protocol FileSystem : class { <nl> + func getDirectoryContents ( _ path : AbsolutePath ) throws - > [ String ] <nl> + } <nl> + public extension FileSystem { <nl> + } <nl> + <nl> + public var currentWorkingDirectory : AbsolutePath { <nl> + let cwdStr = FileManager . default . currentDirectoryPath <nl> + return AbsolutePath ( cwdStr ) <nl> + } <nl> + public class RecursibleDirectoryContentsGenerator { <nl> + private var current : ( path : AbsolutePath , iterator : IndexingIterator < [ String ] > ) <nl> + private let fileSystem : FileSystem <nl> + fileprivate init ( <nl> + path : AbsolutePath , <nl> + fileSystem : FileSystem <nl> + ) throws { <nl> + self . fileSystem = fileSystem <nl> + current = ( path , try fileSystem . getDirectoryContents ( path ) . makeIterator ( ) ) <nl> + } <nl> + } <nl>
|
Merge remote - tracking branch ' origin / master ' into master - llvm - swift5 - transition
|
apple/swift
|
ec23886552fb88f2bbe5fc1653e6bf0a74c4a9ad
|
2018-01-23T19:44:28Z
|
mmm a / DIRECTORY . md <nl> ppp b / DIRECTORY . md <nl> <nl> * [ Stack ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / data_structure / stk / stack . h ) <nl> * [ Test Stack ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / data_structure / stk / test_stack . cpp ) <nl> * [ Tree ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / data_structure / Tree . cpp ) <nl> + * [ Trie Modern ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / data_structure / trie_modern . cpp ) <nl> * [ Trie Tree ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / data_structure / trie_tree . cpp ) <nl> <nl> # # Dynamic Programming <nl> <nl> * [ Searching Of Element In Dynamic Array ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / dynamic_programming / searching_of_element_in_dynamic_array . cpp ) <nl> * [ Tree Height ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / dynamic_programming / tree_height . cpp ) <nl> <nl> + # # Geometry <nl> + * [ Line Segment Intersection ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / geometry / line_segment_intersection . cpp ) <nl> + <nl> # # Graph <nl> * [ Bfs ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / graph / BFS . cpp ) <nl> * [ Bridge Finding With Tarjan Algorithm ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / graph / bridge_finding_with_tarjan_algorithm . cpp ) <nl> <nl> * [ Fibonacci ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / fibonacci . cpp ) <nl> * [ Greatest Common Divisor ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / greatest_common_divisor . cpp ) <nl> * [ Greatest Common Divisor Euclidean ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / greatest_common_divisor_euclidean . cpp ) <nl> + * [ Least Common Multiple ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / least_common_multiple . cpp ) <nl> * [ Modular Inverse Fermat Little Theorem ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / modular_inverse_fermat_little_theorem . cpp ) <nl> * [ Number Of Positive Divisors ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / number_of_positive_divisors . cpp ) <nl> * [ Power For Huge Numbers ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / math / power_for_huge_numbers . cpp ) <nl> <nl> * [ Non Recursive Merge Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / non_recursive_merge_sort . cpp ) <nl> * [ Numericstringsort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / NumericStringSort . cpp ) <nl> * [ Oddeven Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / OddEven % 20Sort . cpp ) <nl> - * [ Quick Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / Quick % 20Sort . cpp ) <nl> + * [ Quick Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / quick_sort . cpp ) <nl> * [ Radix Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / Radix % 20Sort . cpp ) <nl> * [ Selection Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / Selection % 20Sort . cpp ) <nl> * [ Shell Sort ] ( https : / / github . com / TheAlgorithms / C - Plus - Plus / blob / master / sorting / Shell % 20Sort . cpp ) <nl> new file mode 100644 <nl> index 0000000000 . . 218c90b68b <nl> mmm / dev / null <nl> ppp b / data_structure / trie_modern . cpp <nl> <nl> + / * * <nl> + * Copyright 2020 @ author Anmol3299 <nl> + * @ file <nl> + * <nl> + * A basic implementation of trie class to store only lower - case strings . <nl> + * / <nl> + # include < iostream > / / for io operations <nl> + # include < memory > / / for std : : shared_ptr < > <nl> + # include < string > / / for std : : string class <nl> + <nl> + / * * <nl> + * A basic implementation of trie class to store only lower - case strings . <nl> + * You can extend the implementation to all the ASCII characters by changing the <nl> + * value of @ ALPHABETS to 128 . <nl> + * / <nl> + class Trie { <nl> + private : <nl> + static constexpr size_t ALPHABETS = 26 ; <nl> + <nl> + / * * <nl> + * Structure of trie node . <nl> + * This struct doesn ' t need a constructor as we are initializing using <nl> + * intializer list which is more efficient than if we had done so with <nl> + * constructor . <nl> + * / <nl> + struct TrieNode { <nl> + / / An array of pointers of size 26 which tells if a character of word is <nl> + / / present or not . <nl> + std : : shared_ptr < TrieNode > character [ ALPHABETS ] { nullptr } ; <nl> + <nl> + bool isEndOfWord { false } ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Function to check if a node has some children which can form words . <nl> + * @ param node whose character array of pointers need to be checked for <nl> + * children . <nl> + * @ return if a child is found , it returns @ true , else it returns @ false . <nl> + * / <nl> + inline static bool hasChildren ( std : : shared_ptr < TrieNode > node ) { <nl> + for ( size_t i = 0 ; i < ALPHABETS ; i + + ) { <nl> + if ( node - > character [ i ] ) { <nl> + return true ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / * * <nl> + * A recursive helper function to remove a word from the trie . First , it <nl> + * recursively traverses to the location of last character of word in the <nl> + * trie . However , if the word is not found , the function returns a runtime <nl> + * error . Upon successfully reaching the last character of word in trie , if <nl> + * sets the isEndOfWord to false and deletes the node if and only if it has <nl> + * no children , else it returns the current node . <nl> + * @ param word is the string which needs to be removed from trie . <nl> + * @ param curr is the current node we are at . <nl> + * @ param index is the index of the @ word we are at . <nl> + * @ return if current node has childern , it returns @ curr , else it returns <nl> + * nullptr . <nl> + * @ throw a runtime error in case @ word is not found in the trie . <nl> + * / <nl> + std : : shared_ptr < TrieNode > removeWordHelper ( const std : : string & word , <nl> + std : : shared_ptr < TrieNode > curr , <nl> + size_t index ) { <nl> + if ( word . size ( ) = = index ) { <nl> + if ( curr - > isEndOfWord ) { <nl> + curr - > isEndOfWord = false ; <nl> + } <nl> + if ( hasChildren ( curr ) ) { <nl> + return curr ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + size_t idx = word [ index ] - ' a ' ; <nl> + <nl> + / / Throw a runtime error in case the user enters a word which is not <nl> + / / present in the trie . <nl> + if ( ! curr - > character [ idx ] ) { <nl> + throw std : : runtime_error ( std : : move ( std : : string ( " Word not found . " ) ) ) ; <nl> + } <nl> + <nl> + curr - > character [ idx ] = <nl> + removeWordHelper ( word , curr - > character [ idx ] , index + 1 ) ; <nl> + <nl> + / / This if condition checks if the node has some childern . <nl> + / / The 1st if check , i . e . ( curr - > character [ idx ] ) is checked specifically <nl> + / / because if the older string is a prefix of some other string , then , <nl> + / / there would be no need to check all 26 characters . Example - str1 = <nl> + / / abbey , str2 = abbex and we want to delete string " abbey " , then in <nl> + / / this case , there would be no need to check all characters for the <nl> + / / chars a , b , b . <nl> + if ( curr - > character [ idx ] | | hasChildren ( curr ) ) { <nl> + return curr ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + public : <nl> + / / constructor to initialise the root of the trie . <nl> + Trie ( ) : m_root ( std : : make_shared < TrieNode > ( ) ) { } <nl> + <nl> + / * * <nl> + * Insert a word into the trie . <nl> + * @ param word which needs to be inserted into the string . <nl> + * / <nl> + void insert ( const std : : string & word ) { <nl> + auto curr = m_root ; <nl> + for ( char ch : word ) { <nl> + size_t index = ch - ' a ' ; <nl> + <nl> + / / if a node for current word is not already present in trie , create <nl> + / / a new node for it . <nl> + if ( ! curr - > character [ index ] ) { <nl> + curr - > character [ index ] = std : : make_shared < TrieNode > ( ) ; <nl> + } <nl> + <nl> + curr = curr - > character [ index ] ; <nl> + } <nl> + curr - > isEndOfWord = true ; <nl> + } <nl> + <nl> + / * * <nl> + * Search if a word is present in trie or not . <nl> + * @ param word which is needed to be searched in the trie . <nl> + * @ return True if the word is found in trie and isEndOfWord is set to true . <nl> + * @ return False if word is not found in trie or isEndOfWord is set to <nl> + * false . <nl> + * / <nl> + bool search ( const std : : string & word ) { <nl> + auto curr = m_root ; <nl> + for ( char ch : word ) { <nl> + size_t index = ch - ' a ' ; <nl> + <nl> + / / if any node for a character is not found , then return that the <nl> + / / word cannot be formed . <nl> + if ( ! curr - > character [ index ] ) { <nl> + return false ; <nl> + } <nl> + curr = curr - > character [ index ] ; <nl> + } <nl> + return curr - > isEndOfWord ; <nl> + } <nl> + <nl> + / / Function to remove the word which calls the helper function . <nl> + void removeWord ( const std : : string & word ) { <nl> + m_root = removeWordHelper ( word , m_root , 0 ) ; <nl> + } <nl> + <nl> + private : <nl> + / / data member to store the root of the trie . <nl> + std : : shared_ptr < TrieNode > m_root ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Main function <nl> + * / <nl> + int main ( ) { <nl> + Trie trie ; <nl> + trie . insert ( " hel " ) ; <nl> + trie . insert ( " hello " ) ; <nl> + trie . removeWord ( " hel " ) ; <nl> + std : : cout < < trie . search ( " hello " ) < < ' \ n ' ; <nl> + <nl> + return 0 ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . 0b5b858d74 <nl> mmm / dev / null <nl> ppp b / geometry / line_segment_intersection . cpp <nl> <nl> + / * * <nl> + * @ file <nl> + * @ brief check whether two line segments intersect each other <nl> + * or not . <nl> + * / <nl> + # include < iostream > <nl> + <nl> + / * * <nl> + * Define a Point . <nl> + * / <nl> + struct Point { <nl> + int x ; / / / Point respect to x coordinate <nl> + int y ; / / / Point respect to y coordinate <nl> + } ; <nl> + <nl> + / * * <nl> + * intersect returns true if segments of two line intersects and <nl> + * false if they do not . It calls the subroutines direction <nl> + * which computes the orientation . <nl> + * / <nl> + struct SegmentIntersection { <nl> + inline bool intersect ( Point first_point , Point second_point , <nl> + Point third_point , Point forth_point ) { <nl> + int direction1 = direction ( third_point , forth_point , first_point ) ; <nl> + int direction2 = direction ( third_point , forth_point , second_point ) ; <nl> + int direction3 = direction ( first_point , second_point , third_point ) ; <nl> + int direction4 = direction ( first_point , second_point , forth_point ) ; <nl> + <nl> + if ( ( direction1 < 0 | | direction2 > 0 ) & & ( direction3 < 0 | | <nl> + direction4 > 0 ) ) <nl> + return true ; <nl> + <nl> + else if ( direction1 = = 0 & & on_segment ( third_point , forth_point , <nl> + first_point ) ) <nl> + return true ; <nl> + <nl> + else if ( direction2 = = 0 & & on_segment ( third_point , forth_point , <nl> + second_point ) ) <nl> + return true ; <nl> + <nl> + else if ( direction3 = = 0 & & on_segment ( first_point , second_point , <nl> + third_point ) ) <nl> + return true ; <nl> + <nl> + else if ( direction3 = = 0 & & on_segment ( first_point , second_point , <nl> + forth_point ) ) <nl> + return true ; <nl> + <nl> + else <nl> + return false ; <nl> + } <nl> + <nl> + / * * <nl> + * We will find direction of line here respect to @ first_point . <nl> + * Here @ second_point and @ third_point is first and second points <nl> + * of the line respectively . we want a method to determine which way a <nl> + * given angle these three points turns . If returned number is negative , <nl> + * then the angle is counter - clockwise . That means the line is going to <nl> + * right to left . We will fount angle as clockwise if the method returns <nl> + * positive number . <nl> + * / <nl> + inline int direction ( Point first_point , Point second_point , <nl> + Point third_point ) { <nl> + return ( ( third_point . x - first_point . x ) * ( second_point . y - first_point . y ) ) - <nl> + ( ( second_point . x - first_point . x ) * ( third_point . y - first_point . y ) ) ; <nl> + } <nl> + <nl> + / * * <nl> + * This method determines whether a point known to be colinear <nl> + * with a segment lies on that segment . <nl> + * / <nl> + inline bool on_segment ( Point first_point , Point second_point , <nl> + Point third_point ) { <nl> + if ( std : : min ( first_point . x , second_point . x ) < = third_point . x & & <nl> + third_point . x < = std : : max ( first_point . x , second_point . x ) & & <nl> + std : : min ( first_point . y , second_point . y ) < = third_point . y & & <nl> + third_point . y < = std : : max ( first_point . y , second_point . y ) ) <nl> + return true ; <nl> + <nl> + else <nl> + return false ; <nl> + } <nl> + } ; <nl> + <nl> + / * * <nl> + * This is the main function to test whether the algorithm is <nl> + * working well . <nl> + * / <nl> + int main ( ) { <nl> + SegmentIntersection segment ; <nl> + Point first_point , second_point , third_point , forth_point ; <nl> + <nl> + std : : cin > > first_point . x > > first_point . y ; <nl> + std : : cin > > second_point . x > > second_point . y ; <nl> + std : : cin > > third_point . x > > third_point . y ; <nl> + std : : cin > > forth_point . x > > forth_point . y ; <nl> + <nl> + printf ( " % d " , segment . intersect ( first_point , second_point , third_point , <nl> + forth_point ) ) ; <nl> + std : : cout < < std : : endl ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . 7419457160 <nl> mmm / dev / null <nl> ppp b / math / least_common_multiple . cpp <nl> <nl> + / * * <nl> + * Copyright 2020 @ author tjgurwara99 <nl> + * @ file <nl> + * <nl> + * A basic implementation of LCM function <nl> + * / <nl> + <nl> + # include < cassert > <nl> + # include < iostream > <nl> + <nl> + / * * <nl> + * Function for finding greatest common divisor of two numbers . <nl> + * @ params two integers x and y whose gcd we want to find . <nl> + * @ return greatest common divisor of x and y . <nl> + * / <nl> + unsigned int gcd ( unsigned int x , unsigned int y ) { <nl> + if ( x = = 0 ) { <nl> + return y ; <nl> + } <nl> + if ( y = = 0 ) { <nl> + return x ; <nl> + } <nl> + if ( x = = y ) { <nl> + return x ; <nl> + } <nl> + if ( x > y ) { <nl> + / / The following is valid because we have checked whether y = = 0 <nl> + <nl> + int temp = x / y ; <nl> + return gcd ( y , x - temp * y ) ; <nl> + } <nl> + / / Again the following is valid because we have checked whether x = = 0 <nl> + <nl> + int temp = y / x ; <nl> + return gcd ( x , y - temp * x ) ; <nl> + } <nl> + <nl> + / * * <nl> + * Function for finding the least common multiple of two numbers . <nl> + * @ params integer x and y whose lcm we want to find . <nl> + * @ return lcm of x and y using the relation x * y = gcd ( x , y ) * lcm ( x , y ) <nl> + * / <nl> + unsigned int lcm ( unsigned int x , unsigned int y ) { return x * y / gcd ( x , y ) ; } <nl> + <nl> + / * * <nl> + * Function for testing the lcm ( ) functions with some assert statements . <nl> + * / <nl> + void tests ( ) { <nl> + / / First test on lcm ( 5 , 10 ) = = 10 <nl> + assert ( ( ( void ) " LCM of 5 and 10 is 10 but lcm function gives a different " <nl> + " result . \ n " , <nl> + lcm ( 5 , 10 ) = = 10 ) ) ; <nl> + std : : cout < < " First assertion passes : LCM of 5 and 10 is " < < lcm ( 5 , 10 ) <nl> + < < std : : endl ; <nl> + <nl> + / / Second test on lcm ( 2 , 3 ) = = 6 as 2 and 3 are coprime ( prime in fact ) <nl> + assert ( ( ( void ) " LCM of 2 and 3 is 6 but lcm function gives a different " <nl> + " result . \ n " , <nl> + lcm ( 2 , 3 ) = = 6 ) ) ; <nl> + std : : cout < < " Second assertion passes : LCM of 2 and 3 is " < < lcm ( 2 , 3 ) <nl> + < < std : : endl ; <nl> + } <nl> + <nl> + / * * <nl> + * Main function <nl> + * / <nl> + int main ( ) { <nl> + tests ( ) ; <nl> + return 0 ; <nl> + } <nl>
|
Merge pull request from TheAlgorithms / master
|
TheAlgorithms/C-Plus-Plus
|
1da2ffb57a3a426ed70b30a446c218d275cccc03
|
2020-06-12T22:49:51Z
|
mmm a / projects / SelfTest / Baselines / console . std . approved . txt <nl> ppp b / projects / SelfTest / Baselines / console . std . approved . txt <nl> MiscTests . cpp : < line number > : FAILED : <nl> with expansion : <nl> false <nl> <nl> - spannermmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + loose text artifact <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> just failure <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> MessageTests . cpp : < line number > <nl> mmm a / projects / SelfTest / Baselines / console . sw . approved . txt <nl> ppp b / projects / SelfTest / Baselines / console . sw . approved . txt <nl> MiscTests . cpp : < line number > <nl> MiscTests . cpp : < line number > : <nl> PASSED : <nl> <nl> - spannermmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + loose text artifact <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> just failure <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> MessageTests . cpp : < line number > <nl> mmm a / projects / SelfTest / Baselines / junit . sw . approved . txt <nl> ppp b / projects / SelfTest / Baselines / junit . sw . approved . txt <nl> <nl> < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> - < testsuitesspanner > <nl> + < testsuitesloose text artifact <nl> + > <nl> < testsuite name = " < exe - name > " errors = " 15 " failures = " 87 " tests = " 902 " hostname = " tbd " time = " { duration } " timestamp = " { iso8601 - timestamp } " > <nl> < testcase classname = " < exe - name > . global " name = " # A test name that starts with a # " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " # 748 - captures with unexpected exceptions / outside assertions " time = " { duration } " > <nl> mmm a / projects / SelfTest / Baselines / xml . sw . approved . txt <nl> ppp b / projects / SelfTest / Baselines / xml . sw . approved . txt <nl> <nl> < TestCase name = " # A test name that starts with a # " filename = " projects / < exe - name > / MiscTests . cpp " > <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> - < TestCase name = " # 748 - captures with unexpected exceptions " tags = " [ ! shouldfail ] [ ! throws ] " filename = " projects / < exe - name > / ExceptionTests . cpp " > <nl> + < TestCase name = " # 748 - captures with unexpected exceptions " tags = " [ ! shouldfail ] [ ! throws ] [ . ] [ failing ] [ hide ] " filename = " projects / < exe - name > / ExceptionTests . cpp " > <nl> < Section name = " outside assertions " filename = " projects / < exe - name > / ExceptionTests . cpp " > <nl> < Info > <nl> answer : = 42 <nl> <nl> < / Expression > <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> - < TestCase name = " # 835 - - errno should not be touched by Catch " tags = " [ ! shouldfail ] " filename = " projects / < exe - name > / MiscTests . cpp " > <nl> + < TestCase name = " # 835 - - errno should not be touched by Catch " tags = " [ ! shouldfail ] [ . ] [ failing ] [ hide ] " filename = " projects / < exe - name > / MiscTests . cpp " > <nl> < Expression success = " false " type = " CHECK " filename = " projects / < exe - name > / MiscTests . cpp " > <nl> < Original > <nl> f ( ) = = 0 <nl> Message from section two <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> < TestCase name = " has printf " filename = " projects / < exe - name > / TrickyTests . cpp " > <nl> - spanner < OverallResult success = " true " / > <nl> + loose text artifact <nl> + < OverallResult success = " true " / > <nl> < / TestCase > <nl> < TestCase name = " just failure " tags = " [ . ] [ fail ] [ hide ] [ isolated info ] [ messages ] " filename = " projects / < exe - name > / MessageTests . cpp " > <nl> < Failure filename = " projects / < exe - name > / MessageTests . cpp " > <nl> mmm a / projects / SelfTest / ExceptionTests . cpp <nl> ppp b / projects / SelfTest / ExceptionTests . cpp <nl> TEST_CASE ( " Mismatching exception messages failing the test " , " [ . ] [ failing ] [ ! thr <nl> REQUIRE_THROWS_WITH ( thisThrows ( ) , " expected exception " ) ; <nl> } <nl> <nl> - TEST_CASE ( " # 748 - captures with unexpected exceptions " , " [ ! shouldfail ] [ ! throws ] " ) { <nl> + TEST_CASE ( " # 748 - captures with unexpected exceptions " , " [ . ] [ failing ] [ ! throws ] [ ! shouldfail ] " ) { <nl> int answer = 42 ; <nl> CAPTURE ( answer ) ; <nl> / / the message should be printed on the first two sections but not on the third <nl> mmm a / projects / SelfTest / MiscTests . cpp <nl> ppp b / projects / SelfTest / MiscTests . cpp <nl> static int f ( ) { <nl> return 1 ; <nl> } <nl> <nl> - TEST_CASE ( " # 835 - - errno should not be touched by Catch " , " [ ! shouldfail ] " ) { <nl> + TEST_CASE ( " # 835 - - errno should not be touched by Catch " , " [ . ] [ failing ] [ ! shouldfail ] " ) { <nl> errno = 1 ; <nl> CHECK ( f ( ) = = 0 ) ; <nl> REQUIRE ( errno = = 1 ) ; / / Check that f ( ) doesn ' t touch errno . <nl> mmm a / projects / SelfTest / TrickyTests . cpp <nl> ppp b / projects / SelfTest / TrickyTests . cpp <nl> TEST_CASE ( " X / level / 1 / b " , " [ Tricky ] " ) { SUCCEED ( " " ) ; } <nl> <nl> TEST_CASE ( " has printf " ) { <nl> <nl> - / / This can cause problems as , currently , stdout itself is not redirect - only the cout ( and cerr ) buffer <nl> - printf ( " spanner " ) ; <nl> + / / This can cause problems as , currently , stdout itself is not redirected - only the cout ( and cerr ) buffer <nl> + printf ( " loose text artifact \ n " ) ; <nl> } <nl> <nl> TEST_CASE ( " assertions with commas are allowed " ) { <nl>
|
Cleaned up the output a bit
|
catchorg/Catch2
|
df5c31bb1938d39d8916365a676e708fdb15d4c9
|
2017-08-11T09:38:29Z
|
mmm a / tensorflow / python / keras / models . py <nl> ppp b / tensorflow / python / keras / models . py <nl> def _clone_functional_model ( model , input_tensors = None , layer_fn = _clone_layer ) : <nl> raise ValueError ( ' Expected ` model ` argument ' <nl> ' to be a functional ` Model ` instance , ' <nl> ' got a ` Sequential ` instance instead : ' , model ) <nl> + if not model . _is_graph_network : <nl> + raise ValueError ( ' Expected ` model ` argument ' <nl> + ' to be a functional ` Model ` instance , ' <nl> + ' but got a subclass model instead . ' ) <nl> <nl> layer_map = { } # Cache for created layers . <nl> tensor_map = { } # Map { reference_tensor : corresponding_tensor } <nl>
|
Raise error if model to clone is a subclass model .
|
tensorflow/tensorflow
|
322ffb8f86961a26f0faa555bc8919982dec9401
|
2019-03-29T16:11:14Z
|
mmm a / tensorflow / tensorboard / backend / application_test . py <nl> ppp b / tensorflow / tensorboard / backend / application_test . py <nl> class UnnamedPlugin ( base_plugin . TBPlugin ) : <nl> def get_plugin_apps ( self ) : <nl> pass <nl> <nl> + def is_active ( self ) : <nl> + return True <nl> + <nl> class MockPlugin ( UnnamedPlugin ) : <nl> plugin_name = ' mock ' <nl> <nl> mmm a / tensorflow / tensorboard / backend / event_processing / event_accumulator . py <nl> ppp b / tensorflow / tensorboard / backend / event_processing / event_accumulator . py <nl> def HealthPills ( self , node_name ) : <nl> " " " <nl> return self . _health_pills . Items ( node_name ) <nl> <nl> + def GetOpsWithHealthPills ( self ) : <nl> + " " " Determines which ops have at least 1 health pill event . <nl> + <nl> + Returns : <nl> + A list of names of ops with at least 1 health pill event . <nl> + " " " <nl> + return self . _health_pills . Keys ( ) <nl> + <nl> def Graph ( self ) : <nl> " " " Return the graph definition , if there is one . <nl> <nl> mmm a / tensorflow / tensorboard / backend / event_processing / event_accumulator_test . py <nl> ppp b / tensorflow / tensorboard / backend / event_processing / event_accumulator_test . py <nl> def testHealthPills ( self ) : <nl> acc = ea . EventAccumulator ( gen ) <nl> gen . AddHealthPill ( 13371337 , 41 , ' Add ' , 0 , range ( 1 , 13 ) ) <nl> gen . AddHealthPill ( 13381338 , 42 , ' Add ' , 1 , range ( 42 , 54 ) ) <nl> - <nl> - acc = ea . EventAccumulator ( gen ) <nl> acc . Reload ( ) <nl> <nl> # Retrieve the health pills for each node name . <nl> def testHealthPills ( self ) : <nl> value = range ( 42 , 54 ) ) , <nl> gotten_events [ 1 ] ) <nl> <nl> + def testGetOpsWithHealthPills ( self ) : <nl> + gen = _EventGenerator ( self ) <nl> + acc = ea . EventAccumulator ( gen ) <nl> + gen . AddHealthPill ( 13371337 , 41 , ' Add ' , 0 , range ( 1 , 13 ) ) <nl> + gen . AddHealthPill ( 13381338 , 42 , ' MatMul ' , 1 , range ( 42 , 54 ) ) <nl> + acc . Reload ( ) <nl> + self . assertItemsEqual ( [ ' Add ' , ' MatMul ' ] , acc . GetOpsWithHealthPills ( ) ) <nl> + <nl> def testHistograms ( self ) : <nl> gen = _EventGenerator ( self ) <nl> acc = ea . EventAccumulator ( gen ) <nl> mmm a / tensorflow / tensorboard / backend / event_processing / event_multiplexer . py <nl> ppp b / tensorflow / tensorboard / backend / event_processing / event_multiplexer . py <nl> def HealthPills ( self , run , node_name ) : <nl> accumulator = self . _GetAccumulator ( run ) <nl> return accumulator . HealthPills ( node_name ) <nl> <nl> + def GetOpsWithHealthPills ( self , run ) : <nl> + " " " Determines which ops have at least 1 health pill event for a given run . <nl> + <nl> + Args : <nl> + run : The name of the run . <nl> + <nl> + Raises : <nl> + KeyError : If the run is not found , or the node name is not available for <nl> + the given run . <nl> + <nl> + Returns : <nl> + The list of names of ops with health pill events . <nl> + " " " <nl> + return self . _GetAccumulator ( run ) . GetOpsWithHealthPills ( ) <nl> + <nl> def Graph ( self , run ) : <nl> " " " Retrieve the graph associated with the provided run . <nl> <nl> mmm a / tensorflow / tensorboard / backend / event_processing / event_multiplexer_test . py <nl> ppp b / tensorflow / tensorboard / backend / event_processing / event_multiplexer_test . py <nl> <nl> from __future__ import division <nl> from __future__ import print_function <nl> <nl> + import functools <nl> import os <nl> import os . path <nl> import shutil <nl> def _CreateCleanDirectory ( path ) : <nl> <nl> class _FakeAccumulator ( object ) : <nl> <nl> - def __init__ ( self , path ) : <nl> + def __init__ ( self , path , health_pill_mapping = None ) : <nl> + " " " Constructs a fake accumulator with some fake events . <nl> + <nl> + Args : <nl> + path : The path for the run that this accumulator is for . <nl> + health_pill_mapping : An optional mapping from Op to health pill strings . <nl> + " " " <nl> self . _path = path <nl> self . reload_called = False <nl> - self . _node_names_to_health_pills = { ' Add ' : [ ' hp1 ' , ' hp2 ' ] } <nl> + self . _node_names_to_health_pills = health_pill_mapping or { } <nl> <nl> def Tags ( self ) : <nl> return { event_accumulator . IMAGES : [ ' im1 ' , ' im2 ' ] , <nl> def HealthPills ( self , node_name ) : <nl> health_pills = self . _node_names_to_health_pills [ node_name ] <nl> return [ self . _path + ' / ' + health_pill for health_pill in health_pills ] <nl> <nl> + def GetOpsWithHealthPills ( self ) : <nl> + return self . _node_names_to_health_pills . keys ( ) <nl> + <nl> def Histograms ( self , tag_name ) : <nl> return self . _TagHelper ( tag_name , event_accumulator . HISTOGRAMS ) <nl> <nl> def Reload ( self ) : <nl> self . reload_called = True <nl> <nl> <nl> - # pylint : disable = unused - argument <nl> - def _GetFakeAccumulator ( <nl> - path , <nl> - size_guidance = None , <nl> - compression_bps = None , <nl> - purge_orphaned_data = None ) : <nl> - return _FakeAccumulator ( path ) <nl> - # pylint : enable = unused - argument <nl> + def _GetFakeAccumulator ( path , <nl> + size_guidance = None , <nl> + compression_bps = None , <nl> + purge_orphaned_data = None , <nl> + health_pill_mapping = None ) : <nl> + del size_guidance , compression_bps , purge_orphaned_data # Unused . <nl> + return _FakeAccumulator ( path , health_pill_mapping = health_pill_mapping ) <nl> <nl> <nl> class EventMultiplexerTest ( test_util . TensorFlowTestCase ) : <nl> def testScalars ( self ) : <nl> self . assertEqual ( run1_expected , run1_actual ) <nl> <nl> def testHealthPills ( self ) : <nl> + self . stubs . Set ( event_accumulator , ' EventAccumulator ' , <nl> + functools . partial ( <nl> + _GetFakeAccumulator , <nl> + health_pill_mapping = { ' Add ' : [ ' hp1 ' , ' hp2 ' ] } ) ) <nl> x = event_multiplexer . EventMultiplexer ( { ' run1 ' : ' path1 ' , ' run2 ' : ' path2 ' } ) <nl> self . assertEqual ( [ ' path1 / hp1 ' , ' path1 / hp2 ' ] , x . HealthPills ( ' run1 ' , ' Add ' ) ) <nl> <nl> + def testGetOpsWithHealthPillsWhenHealthPillsAreNotAvailable ( self ) : <nl> + # The event accumulator lacks health pills for the run . <nl> + x = event_multiplexer . EventMultiplexer ( { ' run1 ' : ' path1 ' , ' run2 ' : ' path2 ' } ) <nl> + self . assertItemsEqual ( [ ] , x . GetOpsWithHealthPills ( ' run1 ' ) ) <nl> + <nl> + def testGetOpsWithHealthPillsWhenHealthPillsAreAvailable ( self ) : <nl> + # The event accumulator has health pills for the run . <nl> + self . stubs . Set ( event_accumulator , ' EventAccumulator ' , <nl> + functools . partial ( <nl> + _GetFakeAccumulator , <nl> + health_pill_mapping = { ' Add ' : [ ' hp1 ' , ' hp2 ' ] } ) ) <nl> + x = event_multiplexer . EventMultiplexer ( { ' run1 ' : ' path1 ' , ' run2 ' : ' path2 ' } ) <nl> + self . assertItemsEqual ( [ ' Add ' ] , x . GetOpsWithHealthPills ( ' run1 ' ) ) <nl> + <nl> def testExceptions ( self ) : <nl> x = event_multiplexer . EventMultiplexer ( { ' run1 ' : ' path1 ' , ' run2 ' : ' path2 ' } ) <nl> with self . assertRaises ( KeyError ) : <nl> mmm a / tensorflow / tensorboard / plugins / base_plugin . py <nl> ppp b / tensorflow / tensorboard / plugins / base_plugin . py <nl> def get_plugin_apps ( self , multiplexer , logdir ) : <nl> A dict mapping route paths to WSGI applications . <nl> " " " <nl> raise NotImplementedError ( ) <nl> + <nl> + @ abstractmethod <nl> + def is_active ( self ) : <nl> + " " " Determines whether this plugin is active . <nl> + <nl> + A plugin may not be active for instance if it lacks relevant data . If a <nl> + plugin is inactive , the frontend may avoid issuing requests to its routes . <nl> + <nl> + Returns : <nl> + A boolean value . Whether this plugin is active . <nl> + " " " <nl> + raise NotImplementedError ( ) <nl> mmm a / tensorflow / tensorboard / plugins / debugger / debugger_plugin . py <nl> ppp b / tensorflow / tensorboard / plugins / debugger / debugger_plugin . py <nl> def get_plugin_apps ( self , multiplexer , logdir ) : <nl> _HEALTH_PILLS_ROUTE : self . _serve_health_pills_handler , <nl> } <nl> <nl> + def is_active ( self ) : <nl> + " " " Determines whether this plugin is active . <nl> + <nl> + This plugin is active if any health pills information is present for any <nl> + run . This method must be called only after get_plugin_apps has been called . <nl> + <nl> + Returns : <nl> + A boolean . Whether this plugin is active . <nl> + " " " <nl> + for run_name in self . _event_multiplexer . Runs ( ) : <nl> + if self . _event_multiplexer . GetOpsWithHealthPills ( run_name ) : <nl> + return True <nl> + <nl> + return False <nl> + <nl> @ wrappers . Request . application <nl> def _serve_health_pills_handler ( self , request ) : <nl> " " " A ( wrapped ) werkzeug handler for serving health pills . <nl> mmm a / tensorflow / tensorboard / plugins / debugger / debugger_plugin_test . py <nl> ppp b / tensorflow / tensorboard / plugins / debugger / debugger_plugin_test . py <nl> def testHealthPillsRouteProvided ( self ) : <nl> self . assertIn ( ' / health_pills ' , apps ) <nl> self . assertIsInstance ( apps [ ' / health_pills ' ] , collections . Callable ) <nl> <nl> + def testHealthPillsPluginIsActive ( self ) : <nl> + self . plugin . get_plugin_apps ( self . multiplexer , self . log_dir ) <nl> + <nl> + # The multiplexer has sampled health pills . <nl> + self . assertTrue ( self . plugin . is_active ( ) ) <nl> + <nl> + def testHealthPillsPluginIsInactive ( self ) : <nl> + self . plugin . get_plugin_apps ( <nl> + event_multiplexer . EventMultiplexer ( { } ) , self . log_dir ) <nl> + <nl> + # The multiplexer lacks sampled health pills . <nl> + self . assertFalse ( self . plugin . is_active ( ) ) <nl> + <nl> def testRequestHealthPillsForRunFoo ( self ) : <nl> " " " Tests that the plugin produces health pills for a specified run . " " " <nl> response = self . server . post ( <nl> mmm a / tensorflow / tensorboard / plugins / projector / projector_plugin . py <nl> ppp b / tensorflow / tensorboard / plugins / projector / projector_plugin . py <nl> def get_plugin_apps ( self , multiplexer , logdir ) : <nl> } <nl> return self . _handlers <nl> <nl> + def is_active ( self ) : <nl> + " " " Determines whether this plugin is active . <nl> + <nl> + This plugin is only active if any run has an embedding . <nl> + <nl> + Returns : <nl> + A boolean . Whether this plugin is active . <nl> + " " " <nl> + return bool ( self . configs ) <nl> + <nl> @ property <nl> def configs ( self ) : <nl> " " " Returns a map of run paths to ` ProjectorConfig ` protos . " " " <nl> mmm a / tensorflow / tensorboard / plugins / projector / projector_plugin_test . py <nl> ppp b / tensorflow / tensorboard / plugins / projector / projector_plugin_test . py <nl> def testTensorWithValidCheckpoint ( self ) : <nl> expected_tensor = np . array ( [ [ 6 , 6 ] ] , dtype = ' float32 ' ) <nl> self . assertTrue ( np . array_equal ( tensor , expected_tensor ) ) <nl> <nl> + def testPluginIsActive ( self ) : <nl> + self . _GenerateProjectorTestData ( ) <nl> + self . _SetupWSGIApp ( ) <nl> + <nl> + # Embedding data is available . <nl> + self . assertTrue ( self . plugin . is_active ( ) ) <nl> + <nl> + def testPluginIsNotActive ( self ) : <nl> + self . _SetupWSGIApp ( ) <nl> + <nl> + # Embedding data is not available . <nl> + self . assertFalse ( self . plugin . is_active ( ) ) <nl> + <nl> def _SetupWSGIApp ( self ) : <nl> multiplexer = event_multiplexer . EventMultiplexer ( <nl> size_guidance = application . DEFAULT_SIZE_GUIDANCE , <nl> purge_orphaned_data = True ) <nl> - plugin = projector_plugin . ProjectorPlugin ( ) <nl> + self . plugin = projector_plugin . ProjectorPlugin ( ) <nl> wsgi_app = application . TensorBoardWSGIApp ( <nl> - self . log_dir , [ plugin ] , multiplexer , reload_interval = 0 ) <nl> + self . log_dir , [ self . plugin ] , multiplexer , reload_interval = 0 ) <nl> self . server = werkzeug_test . Client ( wsgi_app , wrappers . BaseResponse ) <nl> <nl> def _Get ( self , path ) : <nl> mmm a / tensorflow / tensorboard / plugins / text / text_plugin . py <nl> ppp b / tensorflow / tensorboard / plugins / text / text_plugin . py <nl> def get_plugin_apps ( self , multiplexer , unused_logdir ) : <nl> RUNS_ROUTE : self . runs_route , <nl> TEXT_ROUTE : self . text_route , <nl> } <nl> + <nl> + def is_active ( self ) : <nl> + " " " Determines whether this plugin is active . <nl> + <nl> + This plugin is only active if TensorBoard sampled any text summaries . <nl> + <nl> + Returns : <nl> + Whether this plugin is active . <nl> + " " " <nl> + return bool ( self . index_impl ( ) ) <nl> mmm a / tensorflow / tensorboard / plugins / text / text_plugin_test . py <nl> ppp b / tensorflow / tensorboard / plugins / text / text_plugin_test . py <nl> def test_text_array_to_html ( self ) : <nl> < / table > " " " ) <nl> self . assertEqual ( convert ( d3 ) , d3_expected ) <nl> <nl> + def testPluginIsActive ( self ) : <nl> + plugin = text_plugin . TextPlugin ( ) <nl> + multiplexer = event_multiplexer . EventMultiplexer ( ) <nl> + plugin . get_plugin_apps ( event_multiplexer . EventMultiplexer ( ) , None ) <nl> + <nl> + # The plugin is inactive because text summaries are not available . <nl> + self . assertFalse ( plugin . is_active ( ) ) <nl> + <nl> + multiplexer . AddRunsFromDirectory ( self . logdir ) <nl> + multiplexer . Reload ( ) <nl> + <nl> + # The plugin is active because text summaries are available . <nl> + self . assertTrue ( self . plugin . is_active ( ) ) <nl> + <nl> <nl> if __name__ = = ' __main__ ' : <nl> test . main ( ) <nl>
|
Add an is_active method to plugins
|
tensorflow/tensorflow
|
e671e3ddcbe86933f27cc481f276b27e3603af0a
|
2017-04-06T18:52:02Z
|
mmm a / xbmc / cores / omxplayer / OMXPlayerVideo . cpp <nl> ppp b / xbmc / cores / omxplayer / OMXPlayerVideo . cpp <nl> void OMXPlayerVideo : : Output ( int iGroupId , double pts , bool bDropPacket ) <nl> double pts_media = m_av_clock - > OMXMediaTime ( false , false ) ; <nl> ProcessOverlays ( iGroupId , pts_media ) ; <nl> <nl> - while ( ! CThread : : m_bStop & & m_av_clock - > GetAbsoluteClock ( false ) < ( iCurrentClock + iSleepTime + DVD_MSEC_TO_TIME ( 500 ) ) ) <nl> - Sleep ( 1 ) ; <nl> + if ( ! CThread : : m_bStop & & m_av_clock - > GetAbsoluteClock ( false ) < ( iCurrentClock + iSleepTime + DVD_MSEC_TO_TIME ( 500 ) ) ) <nl> + return ; <nl> <nl> g_renderManager . FlipPage ( CThread : : m_bStop , ( iCurrentClock + iSleepTime ) / DVD_TIME_BASE , - 1 , FS_NONE ) ; <nl> <nl>
|
Merge pull request from popcornmix / avoid_video_block
|
xbmc/xbmc
|
997517fa83c20cc7c62492d1015d4c97c3786855
|
2013-02-03T11:03:25Z
|
mmm a / src / mongo / db / compact . cpp <nl> ppp b / src / mongo / db / compact . cpp <nl> namespace mongo { <nl> extern SortPhaseOne * precalced ; <nl> <nl> bool _compact ( const char * ns , NamespaceDetails * d , string & errmsg , bool validate , BSONObjBuilder & result , double pf , int pb ) { <nl> - / / int les = d - > lastExtentSize ; <nl> - <nl> / / this is a big job , so might as well make things tidy before we start just to be nice . <nl> - getDur ( ) . commitNow ( ) ; <nl> + getDur ( ) . commitIfNeeded ( ) ; <nl> <nl> list < DiskLoc > extents ; <nl> for ( DiskLoc L = d - > firstExtent ; ! L . isNull ( ) ; L = L . ext ( ) - > xnext ) <nl> namespace mongo { <nl> return false ; <nl> } <nl> <nl> - getDur ( ) . commitNow ( ) ; <nl> + getDur ( ) . commitIfNeeded ( ) ; <nl> <nl> long long skipped = 0 ; <nl> int n = 0 ; <nl> namespace mongo { <nl> <nl> bool ok ; <nl> { <nl> - writelock lk ; <nl> + Lock : : DBWrite lk ( ns ) ; <nl> BackgroundOperation : : assertNoBgOpInProgForNs ( ns . c_str ( ) ) ; <nl> Client : : Context ctx ( ns ) ; <nl> NamespaceDetails * d = nsdetails ( ns . c_str ( ) ) ; <nl> namespace mongo { <nl> } <nl> <nl> { <nl> - writelock lk ; <nl> + Lock : : DBWrite lk ( ns ) ; <nl> Client : : Context ctx ( ns ) ; <nl> NamespaceDetails * d = nsdetails ( ns . c_str ( ) ) ; <nl> if ( ! d ) { <nl> mmm a / src / mongo / db / dur . h <nl> ppp b / src / mongo / db / dur . h <nl> namespace mongo { <nl> You must be at least read locked when you call this . Ideally , you are not write locked <nl> and then read operations can occur concurrently . <nl> <nl> + Do not use this . Use commitIfNeeded ( ) instead . <nl> + <nl> @ return true if - - dur is on . <nl> @ return false if - - dur is off . ( in which case there is action ) <nl> * / <nl>
|
SERVER - 4328 use a db level lock not a global for compact command
|
mongodb/mongo
|
fda3f259ef8c59918c14a106b9adfc94f8565f17
|
2012-03-16T17:50:30Z
|
mmm a / build / makefile_base . mak <nl> ppp b / build / makefile_base . mak <nl> export <nl> default $ ( MAKECMDGOALS ) : nested_make <nl> <nl> nested_make : <nl> - $ ( MAKE ) $ ( MAKECMDGOALS ) - f $ ( firstword $ ( MAKEFILE_LIST ) ) NO_NESTED_MAKE = 1 <nl> + + $ ( MAKE ) $ ( MAKECMDGOALS ) - f $ ( firstword $ ( MAKEFILE_LIST ) ) NO_NESTED_MAKE = 1 <nl> <nl> else # ( Rest of the file is the else ) <nl> <nl> openal : openal32 openal64 <nl> <nl> openal64 : SHELL = $ ( CONTAINER_SHELL64 ) <nl> openal64 : $ ( OPENAL_CONFIGURE_FILES64 ) <nl> - cd $ ( OPENAL_OBJ64 ) & & \ <nl> - $ ( MAKE ) VERBOSE = 1 & & \ <nl> - $ ( MAKE ) install VERBOSE = 1 & & \ <nl> - mkdir - p . . / $ ( DST_DIR ) / lib64 & & \ <nl> - cp - L . . / $ ( TOOLS_DIR64 ) / lib / libopenal * . . / $ ( DST_DIR ) / lib64 / & & \ <nl> - [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( DST_DIR ) / lib64 / libopenal . so <nl> + + $ ( MAKE ) - C $ ( OPENAL_OBJ64 ) VERBOSE = 1 <nl> + + $ ( MAKE ) - C $ ( OPENAL_OBJ64 ) install VERBOSE = 1 <nl> + mkdir - p $ ( DST_DIR ) / lib64 <nl> + cp - L $ ( TOOLS_DIR64 ) / lib / libopenal * $ ( DST_DIR ) / lib64 / <nl> + [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) $ ( DST_DIR ) / lib64 / libopenal . so <nl> <nl> <nl> openal32 : SHELL = $ ( CONTAINER_SHELL32 ) <nl> openal32 : $ ( OPENAL_CONFIGURE_FILES32 ) <nl> - cd $ ( OPENAL_OBJ32 ) & & \ <nl> - $ ( MAKE ) VERBOSE = 1 & & \ <nl> - $ ( MAKE ) install VERBOSE = 1 & & \ <nl> - mkdir - p . . / $ ( DST_DIR ) / lib & & \ <nl> - cp - L . . / $ ( TOOLS_DIR32 ) / lib / libopenal * . . / $ ( DST_DIR ) / lib / & & \ <nl> - [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( DST_DIR ) / lib / libopenal . so <nl> + + $ ( MAKE ) - C $ ( OPENAL_OBJ32 ) VERBOSE = 1 <nl> + + $ ( MAKE ) - C $ ( OPENAL_OBJ32 ) install VERBOSE = 1 <nl> + mkdir - p $ ( DST_DIR ) / lib <nl> + cp - L $ ( TOOLS_DIR32 ) / lib / libopenal * $ ( DST_DIR ) / lib / <nl> + [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) $ ( DST_DIR ) / lib / libopenal . so <nl> <nl> <nl> # # <nl> ffmpeg : ffmpeg32 ffmpeg64 <nl> <nl> ffmpeg64 : SHELL = $ ( CONTAINER_SHELL64 ) <nl> ffmpeg64 : $ ( FFMPEG_CONFIGURE_FILES64 ) <nl> - cd $ ( FFMPEG_OBJ64 ) & & \ <nl> - $ ( MAKE ) & & \ <nl> - $ ( MAKE ) install & & \ <nl> - cp - L . . / $ ( TOOLS_DIR64 ) / lib / { libavcodec , libavutil } * . . / $ ( DST_DIR ) / lib64 <nl> + + $ ( MAKE ) - C $ ( FFMPEG_OBJ64 ) <nl> + + $ ( MAKE ) - C $ ( FFMPEG_OBJ64 ) install <nl> + cp - L $ ( TOOLS_DIR64 ) / lib / { libavcodec , libavutil } * $ ( DST_DIR ) / lib64 <nl> <nl> ffmpeg32 : SHELL = $ ( CONTAINER_SHELL32 ) <nl> ffmpeg32 : $ ( FFMPEG_CONFIGURE_FILES32 ) <nl> - cd $ ( FFMPEG_OBJ32 ) & & \ <nl> - $ ( MAKE ) & & \ <nl> - $ ( MAKE ) install & & \ <nl> - cp - L . . / $ ( TOOLS_DIR32 ) / lib / { libavcodec , libavutil } * . . / $ ( DST_DIR ) / lib <nl> + + $ ( MAKE ) - C $ ( FFMPEG_OBJ32 ) <nl> + + $ ( MAKE ) - C $ ( FFMPEG_OBJ32 ) install <nl> + cp - L $ ( TOOLS_DIR32 ) / lib / { libavcodec , libavutil } * $ ( DST_DIR ) / lib <nl> <nl> endif # ifeq ( $ ( WITH_FFMPEG ) , 1 ) <nl> <nl> lsteamclient : lsteamclient32 lsteamclient64 <nl> <nl> lsteamclient64 : SHELL = $ ( CONTAINER_SHELL64 ) <nl> lsteamclient64 : $ ( LSTEAMCLIENT_CONFIGURE_FILES64 ) | $ ( WINE_BUILDTOOLS64 ) $ ( filter $ ( MAKECMDGOALS ) , wine64 wine32 wine ) <nl> - cd $ ( LSTEAMCLIENT_OBJ64 ) & & \ <nl> - PATH = " $ ( abspath $ ( TOOLS_DIR64 ) ) / bin : $ ( PATH ) " \ <nl> - CXXFLAGS = " - Wno - attributes - O2 " CFLAGS = " - O2 - g " $ ( MAKE ) & & \ <nl> - [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( LSTEAMCLIENT_OBJ64 ) / lsteamclient . dll . so & & \ <nl> - cp - a . / lsteamclient . dll . so . . / $ ( DST_DIR ) / lib64 / wine / <nl> + + env PATH = " $ ( abspath $ ( TOOLS_DIR64 ) ) / bin : $ ( PATH ) " CXXFLAGS = " - Wno - attributes - O2 " CFLAGS = " - O2 - g " \ <nl> + $ ( MAKE ) - C $ ( LSTEAMCLIENT_OBJ64 ) <nl> + [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) $ ( LSTEAMCLIENT_OBJ64 ) / lsteamclient . dll . so <nl> + cp - a $ ( LSTEAMCLIENT_OBJ64 ) / lsteamclient . dll . so $ ( DST_DIR ) / lib64 / wine / <nl> <nl> lsteamclient32 : SHELL = $ ( CONTAINER_SHELL32 ) <nl> lsteamclient32 : $ ( LSTEAMCLIENT_CONFIGURE_FILES32 ) | $ ( WINE_BUILDTOOLS32 ) $ ( filter $ ( MAKECMDGOALS ) , wine64 wine32 wine ) <nl> - cd $ ( LSTEAMCLIENT_OBJ32 ) & & \ <nl> - PATH = " $ ( abspath $ ( TOOLS_DIR32 ) ) / bin : $ ( PATH ) " \ <nl> - LDFLAGS = " - m32 " CXXFLAGS = " - m32 - Wno - attributes - O2 " CFLAGS = " - m32 - O2 - g " \ <nl> - $ ( MAKE ) & & \ <nl> - [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( LSTEAMCLIENT_OBJ32 ) / lsteamclient . dll . so & & \ <nl> - cp - a . / lsteamclient . dll . so . . / $ ( DST_DIR ) / lib / wine / <nl> + + env PATH = " $ ( abspath $ ( TOOLS_DIR32 ) ) / bin : $ ( PATH ) " LDFLAGS = " - m32 " CXXFLAGS = " - m32 - Wno - attributes - O2 " CFLAGS = " - m32 - O2 - g " \ <nl> + $ ( MAKE ) - C $ ( LSTEAMCLIENT_OBJ32 ) <nl> + [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) $ ( LSTEAMCLIENT_OBJ32 ) / lsteamclient . dll . so <nl> + cp - a $ ( LSTEAMCLIENT_OBJ32 ) / lsteamclient . dll . so $ ( DST_DIR ) / lib / wine / <nl> <nl> # # <nl> # # wine <nl> lsteamclient32 : $ ( LSTEAMCLIENT_CONFIGURE_FILES32 ) | $ ( WINE_BUILDTOOLS32 ) $ ( filte <nl> WINE_CONFIGURE_FILES32 : = $ ( WINE_OBJ32 ) / Makefile <nl> WINE_CONFIGURE_FILES64 : = $ ( WINE_OBJ64 ) / Makefile <nl> <nl> + WINE_COMMON_MAKE_ARGS : = \ <nl> + STRIP = " $ ( STRIP_QUOTED ) " \ <nl> + INSTALL_PROGRAM_FLAGS = " $ ( INSTALL_PROGRAM_FLAGS ) " <nl> + <nl> + WINE64_MAKE_ARGS : = \ <nl> + $ ( WINE_COMMON_MAKE_ARGS ) \ <nl> + prefix = " $ ( abspath $ ( TOOLS_DIR64 ) ) " \ <nl> + libdir = " $ ( abspath $ ( TOOLS_DIR64 ) ) / lib64 " \ <nl> + dlldir = " $ ( abspath $ ( TOOLS_DIR64 ) ) / lib64 / wine " <nl> + <nl> + WINE32_MAKE_ARGS : = \ <nl> + $ ( WINE_COMMON_MAKE_ARGS ) \ <nl> + prefix = " $ ( abspath $ ( TOOLS_DIR32 ) ) " \ <nl> + libdir = " $ ( abspath $ ( TOOLS_DIR32 ) ) / lib " \ <nl> + dlldir = " $ ( abspath $ ( TOOLS_DIR32 ) ) / lib / wine " <nl> + <nl> # 64bit - configure <nl> $ ( WINE_CONFIGURE_FILES64 ) : SHELL = $ ( CONTAINER_SHELL64 ) <nl> $ ( WINE_CONFIGURE_FILES64 ) : $ ( MAKEFILE_DEP ) | $ ( WINE_OBJ64 ) <nl> $ ( WINE_BUILDTOOLS64 ) $ ( WINE_OUT ) wine64 : wine64 - intermediate <nl> <nl> wine64 - intermediate : SHELL = $ ( CONTAINER_SHELL64 ) <nl> wine64 - intermediate : $ ( WINE_CONFIGURE_FILES64 ) <nl> - cd $ ( WINE_OBJ64 ) & & \ <nl> - STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) & & \ <nl> - INSTALL_PROGRAM_FLAGS = $ ( INSTALL_PROGRAM_FLAGS ) STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) install - lib & & \ <nl> - INSTALL_PROGRAM_FLAGS = $ ( INSTALL_PROGRAM_FLAGS ) STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) \ <nl> - prefix = $ ( abspath $ ( TOOLS_DIR64 ) ) libdir = $ ( abspath $ ( TOOLS_DIR64 ) ) / lib64 \ <nl> - dlldir = $ ( abspath $ ( TOOLS_DIR64 ) ) / lib64 / wine \ <nl> - install - dev install - lib & & \ <nl> - rm - f . . / $ ( DST_DIR ) / bin / { msiexec , notepad , regedit , regsvr32 , wineboot , winecfg , wineconsole , winedbg , winefile , winemine , winepath } <nl> - rm - rf . . / $ ( DST_DIR ) / share / man / <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ64 ) $ ( WINE_COMMON_MAKE_ARGS ) <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ64 ) $ ( WINE_COMMON_MAKE_ARGS ) install - lib <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ64 ) $ ( WINE64_MAKE_ARGS ) install - lib install - dev <nl> + rm - f $ ( DST_DIR ) / bin / { msiexec , notepad , regedit , regsvr32 , wineboot , winecfg , wineconsole , winedbg , winefile , winemine , winepath } <nl> + rm - rf $ ( DST_DIR ) / share / man / <nl> <nl> # # This installs 32 - bit stuff manually , see <nl> # # https : / / wiki . winehq . org / Packaging # WoW64_Workarounds <nl> $ ( WINE_BUILDTOOLS32 ) wine32 : wine32 - intermediate <nl> <nl> wine32 - intermediate : SHELL = $ ( CONTAINER_SHELL32 ) <nl> wine32 - intermediate : $ ( WINE_CONFIGURE_FILES32 ) <nl> - cd $ ( WINE_OBJ32 ) & & \ <nl> - STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) & & \ <nl> - INSTALL_PROGRAM_FLAGS = $ ( INSTALL_PROGRAM_FLAGS ) STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) install - lib & & \ <nl> - INSTALL_PROGRAM_FLAGS = $ ( INSTALL_PROGRAM_FLAGS ) STRIP = $ ( STRIP_QUOTED ) \ <nl> - $ ( MAKE ) \ <nl> - prefix = $ ( abspath $ ( TOOLS_DIR32 ) ) libdir = $ ( abspath $ ( TOOLS_DIR32 ) ) / lib \ <nl> - dlldir = $ ( abspath $ ( TOOLS_DIR32 ) ) / lib / wine \ <nl> - install - dev install - lib & & \ <nl> - mkdir - p . . / $ ( DST_DIR ) / { lib , bin } & & \ <nl> - cp - a . . / $ ( WINE_DST32 ) / lib . . / $ ( DST_DIR ) / & & \ <nl> - cp - a . . / $ ( WINE_DST32 ) / bin / wine . . / $ ( DST_DIR ) / bin & & \ <nl> - cp - a . . / $ ( WINE_DST32 ) / bin / wine - preloader . . / $ ( DST_DIR ) / bin / <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ32 ) $ ( WINE_COMMON_MAKE_ARGS ) <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ32 ) $ ( WINE_COMMON_MAKE_ARGS ) install - lib <nl> + + $ ( MAKE ) - C $ ( WINE_OBJ32 ) $ ( WINE32_MAKE_ARGS ) install - lib install - dev <nl> + mkdir - p $ ( DST_DIR ) / { lib , bin } <nl> + cp - a $ ( WINE_DST32 ) / lib $ ( DST_DIR ) / <nl> + cp - a $ ( WINE_DST32 ) / bin / wine $ ( DST_DIR ) / bin / <nl> + cp - a $ ( WINE_DST32 ) / bin / wine - preloader $ ( DST_DIR ) / bin / <nl> <nl> # # <nl> # # vrclient <nl> vrclient : vrclient32 vrclient64 <nl> <nl> vrclient64 : SHELL = $ ( CONTAINER_SHELL64 ) <nl> vrclient64 : $ ( VRCLIENT_CONFIGURE_FILES64 ) | $ ( WINE_BUILDTOOLS64 ) $ ( filter $ ( MAKECMDGOALS ) , wine64 wine32 wine ) <nl> + + env CXXFLAGS = " - Wno - attributes - std = c + + 0x - O2 - g " CFLAGS = " - O2 - g " PATH = " $ ( abspath $ ( TOOLS_DIR64 ) ) / bin : $ ( PATH ) " \ <nl> + $ ( MAKE ) - C $ ( VRCLIENT_OBJ64 ) <nl> cd $ ( VRCLIENT_OBJ64 ) & & \ <nl> - CXXFLAGS = " - Wno - attributes - std = c + + 0x - O2 - g " CFLAGS = " - O2 - g " PATH = " $ ( abspath $ ( TOOLS_DIR64 ) ) / bin : $ ( PATH ) " \ <nl> - $ ( MAKE ) & & \ <nl> PATH = $ ( abspath $ ( TOOLS_DIR64 ) ) / bin : $ ( PATH ) \ <nl> winebuild - - dll - - fake - module - E . . / $ ( VRCLIENT ) / vrclient_x64 / vrclient_x64 . spec - o vrclient_x64 . dll . fake & & \ <nl> [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( VRCLIENT_OBJ64 ) / vrclient_x64 . dll . so & & \ <nl> vrclient64 : $ ( VRCLIENT_CONFIGURE_FILES64 ) | $ ( WINE_BUILDTOOLS64 ) $ ( filter $ ( MAKE <nl> <nl> vrclient32 : SHELL = $ ( CONTAINER_SHELL32 ) <nl> vrclient32 : $ ( VRCLIENT_CONFIGURE_FILES32 ) | $ ( WINE_BUILDTOOLS32 ) $ ( filter $ ( MAKECMDGOALS ) , wine64 wine32 wine ) <nl> + + env LDFLAGS = " - m32 " CXXFLAGS = " - m32 - Wno - attributes - std = c + + 0x - O2 - g " CFLAGS = " - m32 - O2 - g " PATH = " $ ( abspath $ ( TOOLS_DIR32 ) ) / bin : $ ( PATH ) " \ <nl> + $ ( MAKE ) - C $ ( VRCLIENT_OBJ32 ) <nl> cd $ ( VRCLIENT_OBJ32 ) & & \ <nl> - LDFLAGS = " - m32 " CXXFLAGS = " - m32 - Wno - attributes - std = c + + 0x - O2 - g " CFLAGS = " - m32 - O2 - g " PATH = " $ ( abspath $ ( TOOLS_DIR32 ) ) / bin : $ ( PATH ) " \ <nl> - $ ( MAKE ) & & \ <nl> PATH = $ ( abspath $ ( TOOLS_DIR32 ) ) / bin : $ ( PATH ) \ <nl> winebuild - - dll - - fake - module - E . . / $ ( VRCLIENT32 ) / vrclient / vrclient . spec - o vrclient . dll . fake & & \ <nl> [ x " $ ( STRIP ) " = x ] | | $ ( STRIP ) . . / $ ( VRCLIENT_OBJ32 ) / vrclient . dll . so & & \ <nl> $ ( CMAKE_BIN64 ) cmake64 : cmake64 - intermediate <nl> <nl> cmake64 - intermediate : SHELL = $ ( CONTAINER_SHELL64 ) <nl> cmake64 - intermediate : $ ( CMAKE_CONFIGURE_FILES64 ) $ ( filter $ ( MAKECMDGOALS ) , cmake64 ) <nl> - cd $ ( CMAKE_OBJ64 ) & & \ <nl> - $ ( MAKE ) & & $ ( MAKE ) install & & \ <nl> - touch . . / $ ( CMAKE_BIN64 ) <nl> + + $ ( MAKE ) - C $ ( CMAKE_OBJ64 ) <nl> + + $ ( MAKE ) - C $ ( CMAKE_OBJ64 ) install <nl> + touch $ ( CMAKE_BIN64 ) <nl> <nl> $ ( CMAKE_BIN32 ) cmake32 : cmake32 - intermediate <nl> <nl> cmake32 - intermediate : SHELL = $ ( CONTAINER_SHELL32 ) <nl> cmake32 - intermediate : $ ( CMAKE_CONFIGURE_FILES32 ) $ ( filter $ ( MAKECMDGOALS ) , cmake32 ) <nl> - cd $ ( CMAKE_OBJ32 ) & & \ <nl> - $ ( MAKE ) & & $ ( MAKE ) install & & \ <nl> - touch . . / $ ( CMAKE_BIN32 ) <nl> + + $ ( MAKE ) - C $ ( CMAKE_OBJ32 ) <nl> + + $ ( MAKE ) - C $ ( CMAKE_OBJ32 ) install <nl> + touch $ ( CMAKE_BIN32 ) <nl> <nl> # # <nl> # # dxvk <nl> $ ( DXVK_CONFIGURE_FILES64 ) : $ ( MAKEFILE_DEP ) | $ ( DXVK_OBJ64 ) <nl> cd " $ ( DXVK ) " & & \ <nl> PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " \ <nl> meson - - prefix = " $ ( abspath $ ( DXVK_OBJ64 ) ) " - - cross - file build - win64 . txt " $ ( abspath $ ( DXVK_OBJ64 ) ) " <nl> - <nl> cd " $ ( DXVK_OBJ64 ) " & & \ <nl> PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " meson configure - Dbuildtype = release <nl> <nl> $ ( DXVK_CONFIGURE_FILES32 ) : $ ( MAKEFILE_DEP ) | $ ( DXVK_OBJ32 ) <nl> cd " $ ( DXVK ) " & & \ <nl> PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " \ <nl> meson - - prefix = " $ ( abspath $ ( DXVK_OBJ32 ) ) " - - cross - file build - win32 . txt " $ ( abspath $ ( DXVK_OBJ32 ) ) " <nl> - <nl> cd " $ ( DXVK_OBJ32 ) " & & \ <nl> PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " meson configure - Dbuildtype = release <nl> <nl> dxvk_configure32 : $ ( DXVK_CONFIGURE_FILES32 ) <nl> dxvk : dxvk32 dxvk64 <nl> <nl> dxvk64 : $ ( DXVK_CONFIGURE_FILES64 ) <nl> - cd " $ ( DXVK_OBJ64 ) " & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja install <nl> - <nl> + env PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja - C " $ ( DXVK_OBJ64 ) " install <nl> mkdir - p " $ ( DST_DIR ) / lib64 / wine / dxvk " <nl> cp " $ ( DXVK_OBJ64 ) " / bin / dxgi . dll " $ ( DST_DIR ) " / lib64 / wine / dxvk <nl> cp " $ ( DXVK_OBJ64 ) " / bin / d3d11 . dll " $ ( DST_DIR ) " / lib64 / wine / dxvk <nl> dxvk64 : $ ( DXVK_CONFIGURE_FILES64 ) <nl> <nl> <nl> dxvk32 : $ ( DXVK_CONFIGURE_FILES32 ) <nl> - cd " $ ( DXVK_OBJ32 ) " & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja & & \ <nl> - PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja install <nl> - <nl> + env PATH = " $ ( abspath $ ( SRCDIR ) ) / glslang / bin / : $ ( PATH ) " ninja - C " $ ( DXVK_OBJ32 ) " install <nl> mkdir - p " $ ( DST_DIR ) " / lib / wine / dxvk <nl> cp " $ ( DXVK_OBJ32 ) " / bin / dxgi . dll " $ ( DST_DIR ) " / lib / wine / dxvk / <nl> cp " $ ( DXVK_OBJ32 ) " / bin / d3d11 . dll " $ ( DST_DIR ) " / lib / wine / dxvk / <nl>
|
makefile_base : allow using " make - jN "
|
ValveSoftware/Proton
|
dff8cce67b990b81dda0ebe5760f8f85f6216770
|
2018-10-17T18:48:02Z
|
mmm a / caffe2 / operators / conditional_op . cc <nl> ppp b / caffe2 / operators / conditional_op . cc <nl> have the exact same shape and type . <nl> . Input ( 0 , " Condition " , " Boolean tensor to select DataT or DataF " ) <nl> . Input ( 1 , " DataT " , " Data to use when True " ) <nl> . Input ( 2 , " DataF " , " Data to use when False " ) <nl> - . Output ( 0 , " DataO " , " Output data after applying ConditionalOp " ) ; <nl> + . Output ( 0 , " DataO " , " Output data after applying ConditionalOp " ) <nl> + . IdenticalTypeAndShapeOfInput ( 1 ) ; <nl> <nl> NO_GRADIENT ( Conditional ) ; <nl> <nl>
|
Add ShapeTypeInference for Conditional operator ( )
|
pytorch/pytorch
|
8d384600b8d11a4f4833398a592c3dd8045ed55c
|
2018-06-28T19:10:24Z
|
mmm a / tensorflow / core / kernels / data / experimental / parallel_interleave_dataset_op . cc <nl> ppp b / tensorflow / core / kernels / data / experimental / parallel_interleave_dataset_op . cc <nl> constexpr char kInterleaveIndices [ ] = " interleave_indices " ; <nl> constexpr char kStagingSize [ ] = " staging_size " ; <nl> constexpr char kStagingIndices [ ] = " staging_indices " ; <nl> constexpr char kWorkerThreadsRunning [ ] = " worker_threads_running " ; <nl> - constexpr char kTFDataParallelInterleaveWorker [ ] = <nl> - " tf_data_parallel_interleave_worker " ; <nl> + constexpr char kDataParallelInterleaveWorker [ ] = <nl> + " data_parallel_interleave_worker " ; <nl> constexpr char kWorker [ ] = " worker " ; <nl> constexpr char kInputSize [ ] = " input_size " ; <nl> constexpr char kInput [ ] = " input " ; <nl> class ParallelInterleaveDatasetOp : : Dataset : public DatasetBase { <nl> for ( size_t i = 0 ; i < dataset ( ) - > num_threads ( ) ; + + i ) { <nl> std : : shared_ptr < IteratorContext > new_ctx ( new IteratorContext ( * ctx ) ) ; <nl> worker_threads_ . emplace_back ( ctx - > StartThread ( <nl> - strings : : StrCat ( kTFDataParallelInterleaveWorker , " _ " , i ) , <nl> + strings : : StrCat ( kDataParallelInterleaveWorker , " _ " , i ) , <nl> [ this , new_ctx , i ] ( ) { WorkerThread ( new_ctx , i ) ; } ) ) ; <nl> } <nl> } <nl> class ParallelInterleaveDatasetOp : : Dataset : public DatasetBase { <nl> workers_ [ i ] . SetInputs ( s , std : : move ( args ) ) ; <nl> std : : shared_ptr < IteratorContext > new_ctx ( new IteratorContext ( * ctx ) ) ; <nl> worker_threads_ . push_back ( ctx - > StartThread ( <nl> - strings : : StrCat ( kTFDataParallelInterleaveWorker , " _ " , i ) , <nl> + strings : : StrCat ( kDataParallelInterleaveWorker , " _ " , i ) , <nl> [ this , new_ctx , i ] ( ) { WorkerThread ( new_ctx , i ) ; } ) ) ; <nl> if ( i < dataset ( ) - > cycle_length_ ) { <nl> interleave_indices_ . push_back ( i ) ; <nl>
|
[ tf . data ] Remove extra " tf_ " prefix from thread names of parallel interleave threads .
|
tensorflow/tensorflow
|
7a33771b76da4e19640ae149e283fdb43102983c
|
2020-06-12T21:28:35Z
|
mmm a / src / arm64 / macro - assembler - arm64 . cc <nl> ppp b / src / arm64 / macro - assembler - arm64 . cc <nl> void TurboAssembler : : CopySlots ( Register dst , Register src , <nl> CopyDoubleWords ( dst , src , slot_count ) ; <nl> } <nl> <nl> - void TurboAssembler : : CopyDoubleWords ( Register dst , Register src , <nl> - Register count ) { <nl> + void TurboAssembler : : CopyDoubleWords ( Register dst , Register src , Register count , <nl> + CopyDoubleWordsMode mode ) { <nl> DCHECK ( ! AreAliased ( dst , src , count ) ) ; <nl> <nl> if ( emit_debug_code ( ) ) { <nl> - / / Copy requires dst < src | | ( dst - src ) > = count . <nl> - Label dst_below_src ; <nl> - Subs ( dst , dst , src ) ; <nl> - B ( lt , & dst_below_src ) ; <nl> - Cmp ( dst , count ) ; <nl> + Register pointer1 = dst ; <nl> + Register pointer2 = src ; <nl> + if ( mode = = kSrcLessThanDst ) { <nl> + pointer1 = src ; <nl> + pointer2 = dst ; <nl> + } <nl> + / / Copy requires pointer1 < pointer2 | | ( pointer1 - pointer2 ) > = count . <nl> + Label pointer1_below_pointer2 ; <nl> + Subs ( pointer1 , pointer1 , pointer2 ) ; <nl> + B ( lt , & pointer1_below_pointer2 ) ; <nl> + Cmp ( pointer1 , count ) ; <nl> Check ( ge , kOffsetOutOfRange ) ; <nl> - Bind ( & dst_below_src ) ; <nl> - Add ( dst , dst , src ) ; <nl> + Bind ( & pointer1_below_pointer2 ) ; <nl> + Add ( pointer1 , pointer1 , pointer2 ) ; <nl> } <nl> - <nl> static_assert ( kPointerSize = = kDRegSize , <nl> " pointers must be the same size as doubles " ) ; <nl> + <nl> + int direction = ( mode = = kDstLessThanSrc ) ? 1 : - 1 ; <nl> UseScratchRegisterScope scope ( this ) ; <nl> VRegister temp0 = scope . AcquireD ( ) ; <nl> VRegister temp1 = scope . AcquireD ( ) ; <nl> <nl> - Label pairs , done ; <nl> + Label pairs , loop , done ; <nl> <nl> Tbz ( count , 0 , & pairs ) ; <nl> - Ldr ( temp0 , MemOperand ( src , kPointerSize , PostIndex ) ) ; <nl> + Ldr ( temp0 , MemOperand ( src , direction * kPointerSize , PostIndex ) ) ; <nl> Sub ( count , count , 1 ) ; <nl> - Str ( temp0 , MemOperand ( dst , kPointerSize , PostIndex ) ) ; <nl> + Str ( temp0 , MemOperand ( dst , direction * kPointerSize , PostIndex ) ) ; <nl> <nl> Bind ( & pairs ) ; <nl> + if ( mode = = kSrcLessThanDst ) { <nl> + / / Adjust pointers for post - index ldp / stp with negative offset : <nl> + Sub ( dst , dst , kPointerSize ) ; <nl> + Sub ( src , src , kPointerSize ) ; <nl> + } <nl> + Bind ( & loop ) ; <nl> Cbz ( count , & done ) ; <nl> - Ldp ( temp0 , temp1 , MemOperand ( src , 2 * kPointerSize , PostIndex ) ) ; <nl> + Ldp ( temp0 , temp1 , MemOperand ( src , 2 * direction * kPointerSize , PostIndex ) ) ; <nl> Sub ( count , count , 2 ) ; <nl> - Stp ( temp0 , temp1 , MemOperand ( dst , 2 * kPointerSize , PostIndex ) ) ; <nl> - B ( & pairs ) ; <nl> + Stp ( temp0 , temp1 , MemOperand ( dst , 2 * direction * kPointerSize , PostIndex ) ) ; <nl> + B ( & loop ) ; <nl> <nl> / / TODO ( all ) : large copies may benefit from using temporary Q registers <nl> / / to copy four double words per iteration . <nl> mmm a / src / arm64 / macro - assembler - arm64 . h <nl> ppp b / src / arm64 / macro - assembler - arm64 . h <nl> class TurboAssembler : public Assembler { <nl> void CopySlots ( Register dst , Register src , Register slot_count ) ; <nl> <nl> / / Copy count double words from the address in register src to the address <nl> - / / in register dst . Address dst must be less than src , or the gap between <nl> - / / them must be greater than or equal to count double words , otherwise the <nl> - / / result is unpredictable . The function may corrupt its register arguments . <nl> - / / The registers must not alias each other . <nl> - void CopyDoubleWords ( Register dst , Register src , Register count ) ; <nl> + / / in register dst . There are two modes for this function : <nl> + / / 1 ) Address dst must be less than src , or the gap between them must be <nl> + / / greater than or equal to count double words , otherwise the result is <nl> + / / unpredictable . This is the default mode . <nl> + / / 2 ) Address src must be less than dst , or the gap between them must be <nl> + / / greater than or equal to count double words , otherwise the result is <nl> + / / undpredictable . In this mode , src and dst specify the last ( highest ) <nl> + / / address of the regions to copy from and to . <nl> + / / The case where src = = dst is not supported . <nl> + / / The function may corrupt its register arguments . The registers must not <nl> + / / alias each other . <nl> + enum CopyDoubleWordsMode { kDstLessThanSrc , kSrcLessThanDst } ; <nl> + void CopyDoubleWords ( Register dst , Register src , Register count , <nl> + CopyDoubleWordsMode mode = kDstLessThanSrc ) ; <nl> <nl> / / Calculate the address of a double word - sized slot at slot_offset from the <nl> / / stack pointer , and write it to dst . Positive slot_offsets are at addresses <nl> mmm a / test / cctest / test - assembler - arm64 . cc <nl> ppp b / test / cctest / test - assembler - arm64 . cc <nl> TEST ( copy_slots_up ) { <nl> TEARDOWN ( ) ; <nl> } <nl> <nl> + TEST ( copy_double_words_downwards_even ) { <nl> + INIT_V8 ( ) ; <nl> + SETUP ( ) ; <nl> + <nl> + const uint64_t ones = 0x1111111111111111UL ; <nl> + const uint64_t twos = 0x2222222222222222UL ; <nl> + const uint64_t threes = 0x3333333333333333UL ; <nl> + const uint64_t fours = 0x4444444444444444UL ; <nl> + <nl> + START ( ) ; <nl> + <nl> + __ Mov ( jssp , __ StackPointer ( ) ) ; <nl> + __ SetStackPointer ( jssp ) ; <nl> + <nl> + / / Test copying 12 slots up one slot . <nl> + __ Mov ( x1 , ones ) ; <nl> + __ Mov ( x2 , twos ) ; <nl> + __ Mov ( x3 , threes ) ; <nl> + __ Mov ( x4 , fours ) ; <nl> + <nl> + __ Push ( xzr ) ; <nl> + __ Push ( x1 , x2 , x3 , x4 ) ; <nl> + __ Push ( x1 , x2 , x1 , x2 ) ; <nl> + __ Push ( x3 , x4 , x3 , x4 ) ; <nl> + <nl> + __ SlotAddress ( x5 , 12 ) ; <nl> + __ SlotAddress ( x6 , 11 ) ; <nl> + __ Mov ( x7 , 12 ) ; <nl> + __ CopyDoubleWords ( x5 , x6 , x7 , TurboAssembler : : kSrcLessThanDst ) ; <nl> + <nl> + __ Drop ( 1 ) ; <nl> + __ Pop ( x4 , x5 , x6 , x7 ) ; <nl> + __ Pop ( x8 , x9 , x10 , x11 ) ; <nl> + __ Pop ( x12 , x13 , x14 , x15 ) ; <nl> + <nl> + __ Mov ( csp , jssp ) ; <nl> + __ SetStackPointer ( csp ) ; <nl> + <nl> + END ( ) ; <nl> + <nl> + RUN ( ) ; <nl> + <nl> + CHECK_EQUAL_64 ( ones , x15 ) ; <nl> + CHECK_EQUAL_64 ( twos , x14 ) ; <nl> + CHECK_EQUAL_64 ( threes , x13 ) ; <nl> + CHECK_EQUAL_64 ( fours , x12 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( ones , x11 ) ; <nl> + CHECK_EQUAL_64 ( twos , x10 ) ; <nl> + CHECK_EQUAL_64 ( ones , x9 ) ; <nl> + CHECK_EQUAL_64 ( twos , x8 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( threes , x7 ) ; <nl> + CHECK_EQUAL_64 ( fours , x6 ) ; <nl> + CHECK_EQUAL_64 ( threes , x5 ) ; <nl> + CHECK_EQUAL_64 ( fours , x4 ) ; <nl> + <nl> + TEARDOWN ( ) ; <nl> + } <nl> + <nl> + TEST ( copy_double_words_downwards_odd ) { <nl> + INIT_V8 ( ) ; <nl> + SETUP ( ) ; <nl> + <nl> + const uint64_t ones = 0x1111111111111111UL ; <nl> + const uint64_t twos = 0x2222222222222222UL ; <nl> + const uint64_t threes = 0x3333333333333333UL ; <nl> + const uint64_t fours = 0x4444444444444444UL ; <nl> + const uint64_t fives = 0x5555555555555555UL ; <nl> + <nl> + START ( ) ; <nl> + <nl> + __ Mov ( jssp , __ StackPointer ( ) ) ; <nl> + __ SetStackPointer ( jssp ) ; <nl> + <nl> + / / Test copying 13 slots up one slot . <nl> + __ Mov ( x1 , ones ) ; <nl> + __ Mov ( x2 , twos ) ; <nl> + __ Mov ( x3 , threes ) ; <nl> + __ Mov ( x4 , fours ) ; <nl> + __ Mov ( x5 , fives ) ; <nl> + <nl> + __ Push ( xzr , x5 ) ; <nl> + __ Push ( x1 , x2 , x3 , x4 ) ; <nl> + __ Push ( x1 , x2 , x1 , x2 ) ; <nl> + __ Push ( x3 , x4 , x3 , x4 ) ; <nl> + <nl> + __ SlotAddress ( x5 , 13 ) ; <nl> + __ SlotAddress ( x6 , 12 ) ; <nl> + __ Mov ( x7 , 13 ) ; <nl> + __ CopyDoubleWords ( x5 , x6 , x7 , TurboAssembler : : kSrcLessThanDst ) ; <nl> + <nl> + __ Drop ( 1 ) ; <nl> + __ Pop ( x4 ) ; <nl> + __ Pop ( x5 , x6 , x7 , x8 ) ; <nl> + __ Pop ( x9 , x10 , x11 , x12 ) ; <nl> + __ Pop ( x13 , x14 , x15 , x16 ) ; <nl> + <nl> + __ Mov ( csp , jssp ) ; <nl> + __ SetStackPointer ( csp ) ; <nl> + <nl> + END ( ) ; <nl> + <nl> + RUN ( ) ; <nl> + <nl> + CHECK_EQUAL_64 ( fives , x16 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( ones , x15 ) ; <nl> + CHECK_EQUAL_64 ( twos , x14 ) ; <nl> + CHECK_EQUAL_64 ( threes , x13 ) ; <nl> + CHECK_EQUAL_64 ( fours , x12 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( ones , x11 ) ; <nl> + CHECK_EQUAL_64 ( twos , x10 ) ; <nl> + CHECK_EQUAL_64 ( ones , x9 ) ; <nl> + CHECK_EQUAL_64 ( twos , x8 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( threes , x7 ) ; <nl> + CHECK_EQUAL_64 ( fours , x6 ) ; <nl> + CHECK_EQUAL_64 ( threes , x5 ) ; <nl> + CHECK_EQUAL_64 ( fours , x4 ) ; <nl> + <nl> + TEARDOWN ( ) ; <nl> + } <nl> + <nl> + TEST ( copy_noop ) { <nl> + INIT_V8 ( ) ; <nl> + SETUP ( ) ; <nl> + <nl> + const uint64_t ones = 0x1111111111111111UL ; <nl> + const uint64_t twos = 0x2222222222222222UL ; <nl> + const uint64_t threes = 0x3333333333333333UL ; <nl> + const uint64_t fours = 0x4444444444444444UL ; <nl> + const uint64_t fives = 0x5555555555555555UL ; <nl> + <nl> + START ( ) ; <nl> + <nl> + __ Mov ( jssp , __ StackPointer ( ) ) ; <nl> + __ SetStackPointer ( jssp ) ; <nl> + <nl> + __ Mov ( x1 , ones ) ; <nl> + __ Mov ( x2 , twos ) ; <nl> + __ Mov ( x3 , threes ) ; <nl> + __ Mov ( x4 , fours ) ; <nl> + __ Mov ( x5 , fives ) ; <nl> + <nl> + __ Push ( xzr , x5 , x5 , xzr ) ; <nl> + __ Push ( x3 , x4 , x3 , x4 ) ; <nl> + __ Push ( x1 , x2 , x1 , x2 ) ; <nl> + __ Push ( x1 , x2 , x3 , x4 ) ; <nl> + <nl> + / / src < dst , count = = 0 <nl> + __ SlotAddress ( x5 , 3 ) ; <nl> + __ SlotAddress ( x6 , 2 ) ; <nl> + __ Mov ( x7 , 0 ) ; <nl> + __ CopyDoubleWords ( x5 , x6 , x7 , TurboAssembler : : kSrcLessThanDst ) ; <nl> + <nl> + / / dst < src , count = = 0 <nl> + __ SlotAddress ( x5 , 2 ) ; <nl> + __ SlotAddress ( x6 , 3 ) ; <nl> + __ Mov ( x7 , 0 ) ; <nl> + __ CopyDoubleWords ( x5 , x6 , x7 , TurboAssembler : : kDstLessThanSrc ) ; <nl> + <nl> + __ Pop ( x1 , x2 , x3 , x4 ) ; <nl> + __ Pop ( x5 , x6 , x7 , x8 ) ; <nl> + __ Pop ( x9 , x10 , x11 , x12 ) ; <nl> + __ Pop ( x13 , x14 , x15 , x16 ) ; <nl> + <nl> + __ Mov ( csp , jssp ) ; <nl> + __ SetStackPointer ( csp ) ; <nl> + <nl> + END ( ) ; <nl> + <nl> + RUN ( ) ; <nl> + <nl> + CHECK_EQUAL_64 ( fours , x1 ) ; <nl> + CHECK_EQUAL_64 ( threes , x2 ) ; <nl> + CHECK_EQUAL_64 ( twos , x3 ) ; <nl> + CHECK_EQUAL_64 ( ones , x4 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( twos , x5 ) ; <nl> + CHECK_EQUAL_64 ( ones , x6 ) ; <nl> + CHECK_EQUAL_64 ( twos , x7 ) ; <nl> + CHECK_EQUAL_64 ( ones , x8 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( fours , x9 ) ; <nl> + CHECK_EQUAL_64 ( threes , x10 ) ; <nl> + CHECK_EQUAL_64 ( fours , x11 ) ; <nl> + CHECK_EQUAL_64 ( threes , x12 ) ; <nl> + <nl> + CHECK_EQUAL_64 ( 0 , x13 ) ; <nl> + CHECK_EQUAL_64 ( fives , x14 ) ; <nl> + CHECK_EQUAL_64 ( fives , x15 ) ; <nl> + CHECK_EQUAL_64 ( 0 , x16 ) ; <nl> + <nl> + TEARDOWN ( ) ; <nl> + } <nl> + <nl> TEST ( jump_both_smi ) { <nl> INIT_V8 ( ) ; <nl> SETUP ( ) ; <nl>
|
[ arm64 ] Add CopyDoubleWordsMode option to CopyDoubleWords .
|
v8/v8
|
1adce94ab3355ef8fdab66c26c48a30540ac55b7
|
2017-11-15T19:03:47Z
|
mmm a / xbmc / cores / VideoRenderers / RenderManager . h <nl> ppp b / xbmc / cores / VideoRenderers / RenderManager . h <nl> class CXBMCRenderManager <nl> <nl> void AddOverlay ( CDVDOverlay * o , double pts ) <nl> { <nl> + { CSingleLock lock ( m_presentlock ) ; <nl> + if ( m_free . empty ( ) ) <nl> + return ; <nl> + } <nl> CSharedLock lock ( m_sharedSection ) ; <nl> m_overlays . AddOverlay ( o , pts , m_free . front ( ) ) ; <nl> } <nl>
|
renderer : do not add overlays when eating video frames - fixes segfault
|
xbmc/xbmc
|
3b31ff00df247fdeba609e0d747f266338ad7a76
|
2015-03-15T21:51:12Z
|
mmm a / util / net / sock . cpp <nl> ppp b / util / net / sock . cpp <nl> <nl> <nl> namespace mongo { <nl> <nl> - static mongo : : mutex sock_mutex ( " sock_mutex " ) ; <nl> - <nl> static bool ipv6 = false ; <nl> void enableIPv6 ( bool state ) { ipv6 = state ; } <nl> bool IPv6Enabled ( ) { return ipv6 ; } <nl> <nl> + / / mmm SockAddr <nl> + <nl> SockAddr : : SockAddr ( int sourcePort ) { <nl> memset ( as < sockaddr_in > ( ) . sin_zero , 0 , sizeof ( as < sockaddr_in > ( ) . sin_zero ) ) ; <nl> as < sockaddr_in > ( ) . sin_family = AF_INET ; <nl> namespace mongo { <nl> return false ; <nl> } <nl> <nl> + SockAddr unknownAddress ( " 0 . 0 . 0 . 0 " , 0 ) ; <nl> + <nl> + <nl> + / / mmmmmm hostname mmmmmmmmmmmmmmmmmm - <nl> + <nl> string hostbyname ( const char * hostname ) { <nl> string addr = SockAddr ( hostname , 0 ) . getAddr ( ) ; <nl> if ( addr = = " 0 . 0 . 0 . 0 " ) <nl> namespace mongo { <nl> return addr ; <nl> } <nl> <nl> - # if defined ( _WIN32 ) <nl> - namespace { <nl> - struct WinsockInit { <nl> - WinsockInit ( ) { <nl> - WSADATA d ; <nl> - if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & d ) ! = 0 ) { <nl> - out ( ) < < " ERROR : wsastartup failed " < < errnoWithDescription ( ) < < endl ; <nl> - problem ( ) < < " ERROR : wsastartup failed " < < errnoWithDescription ( ) < < endl ; <nl> - dbexit ( EXIT_NTSERVICE_ERROR ) ; <nl> - } <nl> - } <nl> - } winsock_init ; <nl> - } <nl> - # endif <nl> - <nl> - SockAddr unknownAddress ( " 0 . 0 . 0 . 0 " , 0 ) ; <nl> - <nl> - <nl> string _hostNameCached ; <nl> static void _hostNameCachedInit ( ) { <nl> _hostNameCached = getHostName ( ) ; <nl> namespace mongo { <nl> return _hostNameCached ; <nl> } <nl> <nl> + / / mmmmmmmmm SocketException mmmmmmmmm - <nl> + <nl> string SocketException : : toString ( ) const { <nl> stringstream ss ; <nl> ss < < _ei . code < < " socket exception [ " < < _type < < " ] " ; <nl> namespace mongo { <nl> } <nl> <nl> <nl> + / / mmmmmmmmm - global init mmmmmmmmmmmm - <nl> + <nl> + <nl> + # if defined ( _WIN32 ) <nl> + struct WinsockInit { <nl> + WinsockInit ( ) { <nl> + WSADATA d ; <nl> + if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & d ) ! = 0 ) { <nl> + out ( ) < < " ERROR : wsastartup failed " < < errnoWithDescription ( ) < < endl ; <nl> + problem ( ) < < " ERROR : wsastartup failed " < < errnoWithDescription ( ) < < endl ; <nl> + dbexit ( EXIT_NTSERVICE_ERROR ) ; <nl> + } <nl> + } <nl> + } winsock_init ; <nl> + # endif <nl> + <nl> + <nl> + <nl> <nl> <nl> } / / namespace mongo <nl>
|
net cleaning : re - organizing file
|
mongodb/mongo
|
36f0e51d71eb0dd7c5e5f598e0db383c48830382
|
2011-07-06T21:50:09Z
|
mmm a / ports / sciter / CONTROL <nl> ppp b / ports / sciter / CONTROL <nl> <nl> Source : sciter <nl> - Version : 4 . 0 . 1 . 1 <nl> + Version : 4 . 0 . 2 - 1 <nl> Description : Sciter is an embeddable HTML / CSS / scripting engine . <nl> Maintainer : andrew . fedoniouk @ gmail . com , ehysta @ gmail . com <nl> mmm a / ports / sciter / portfile . cmake <nl> ppp b / ports / sciter / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> # header - only library <nl> set ( VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled ) <nl> <nl> - set ( SCITER_VERSION 4 . 0 . 1 . 1 ) <nl> - set ( SCITER_REVISION 5caaf6f5bd408fd45c30deb873ce76ae7af53819 ) <nl> - set ( SCITER_SHA 88d332891a98fd80200ae04a7b5cc72a6edcbc123abe8147a17ac8e4189fbc4b7ed58f7acc06a6683ec3f1ed74e133115c35599751f6a31358b911e07b602ec4 ) <nl> + set ( SCITER_VERSION 4 . 0 . 2 - 1 ) <nl> + set ( SCITER_REVISION 2d1de5b6d9da55b50168cb9069c8b12490f39d60 ) <nl> + set ( SCITER_SHA 3d33bd0f76474b76e2281b96517c26ac1bb4b8009847499c063c0066a8e69280019c133a10967be8aaed97bbd6186023728619233dea6e7bcf1567e45cd57017 ) <nl> <nl> if ( VCPKG_TARGET_ARCHITECTURE STREQUAL x64 ) <nl> set ( SCITER_ARCH 64 ) <nl>
|
[ sciter ] Update to 4 . 0 . 2 . 5262
|
microsoft/vcpkg
|
b7201507ff154afb2471654b9a7707e92f059cb4
|
2017-08-07T07:42:49Z
|
mmm a / utilities / transactions / transaction_lock_mgr . cc <nl> ppp b / utilities / transactions / transaction_lock_mgr . cc <nl> Status TransactionLockMgr : : AcquireWithTimeout ( <nl> do { <nl> / / Decide how long to wait <nl> int64_t cv_end_time = - 1 ; <nl> - <nl> - / / Check if held lock ' s expiration time is sooner than our timeout <nl> - if ( expire_time_hint > 0 & & <nl> - ( timeout < 0 | | ( timeout > 0 & & expire_time_hint < end_time ) ) ) { <nl> - / / expiration time is sooner than our timeout <nl> + if ( expire_time_hint > 0 & & end_time > 0 ) { <nl> + cv_end_time = std : : min ( expire_time_hint , end_time ) ; <nl> + } else if ( expire_time_hint > 0 ) { <nl> cv_end_time = expire_time_hint ; <nl> - } else if ( timeout > = 0 ) { <nl> + } else if ( end_time > 0 ) { <nl> cv_end_time = end_time ; <nl> } <nl> <nl>
|
Compute cv_end_time with simpler logic ( )
|
facebook/rocksdb
|
2e276973e4cb9f943c2ac7f7b15730c8bfc33cb1
|
2020-03-27T23:01:23Z
|
mmm a / xbmc / platform / win32 / input / IRServerSuite . cpp <nl> ppp b / xbmc / platform / win32 / input / IRServerSuite . cpp <nl> void CIRServerSuite : : Process ( ) <nl> m_profileId = CServiceBroker : : GetProfileManager ( ) . GetCurrentProfileId ( ) ; <nl> m_irTranslator . Load ( IRSS_MAP_FILENAME ) ; <nl> <nl> - / / try to connect 60 times @ a 5 second interval ( 5 minutes ) <nl> - / / multiple tries because irss service might be up and running a little later then xbmc on boot . <nl> + bool logging = true ; <nl> + <nl> + / / try to connect continuously with a 5 second interval <nl> + / / multiple tries because : <nl> + / / 1 . irss might be up and running a little later on boot . <nl> + / / 2 . irss might be restarted <nl> while ( ! m_bStop ) <nl> { <nl> - if ( ! Connect ( true ) ) <nl> + if ( ! Connect ( logging ) ) <nl> { <nl> - CLog : : LogF ( LOGINFO , " failed to connect to irss , will keep retrying every 5 seconds " ) ; <nl> + if ( logging ) <nl> + CLog : : LogF ( LOGINFO , " failed to connect to irss , will keep retrying every 5 seconds " ) ; <nl> + <nl> if ( AbortableWait ( m_event , 5000 ) = = WAIT_SIGNALED ) <nl> break ; <nl> + <nl> + logging = false ; <nl> continue ; <nl> } <nl> <nl> void CIRServerSuite : : Process ( ) <nl> { <nl> if ( ! ReadNext ( ) ) <nl> { <nl> + logging = true ; <nl> break ; <nl> } <nl> } <nl>
|
Merge pull request from afedchin / irss
|
xbmc/xbmc
|
2ac986a3da535e10ff5bbdf8fce9130a3f23b259
|
2018-06-06T13:59:33Z
|
mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> void CVideoDatabase : : UpdateFanart ( const CFileItem & item , VIDEODB_CONTENT_TYPE ty <nl> try <nl> { <nl> m_pDS - > exec ( exec . c_str ( ) ) ; <nl> - <nl> - if ( type = = VIDEODB_CONTENT_TVSHOWS ) <nl> - AnnounceUpdate ( " tvshow " , item . GetVideoInfoTag ( ) - > m_iDbId ) ; <nl> - else if ( type = = VIDEODB_CONTENT_MOVIES ) <nl> - AnnounceUpdate ( " movie " , item . GetVideoInfoTag ( ) - > m_iDbId ) ; <nl> } <nl> catch ( . . . ) <nl> { <nl> mmm a / xbmc / video / dialogs / GUIDialogVideoInfo . cpp <nl> ppp b / xbmc / video / dialogs / GUIDialogVideoInfo . cpp <nl> <nl> # include " guilib / LocalizeStrings . h " <nl> # include " GUIUserMessages . h " <nl> # include " TextureCache . h " <nl> + # include " interfaces / AnnouncementManager . h " <nl> <nl> using namespace std ; <nl> using namespace XFILE ; <nl> void CGUIDialogVideoInfo : : OnGetThumb ( ) <nl> VIDEO : : CVideoInfoScanner : : ApplyThumbToFolder ( m_movieItem - > GetProperty ( " set_folder_thumb " ) . asString ( ) , newThumb ) ; <nl> } <nl> m_hasUpdatedThumb = true ; <nl> + AnnounceUpdate ( " thumb " ) ; <nl> <nl> / / Update our screen <nl> Update ( ) ; <nl> void CGUIDialogVideoInfo : : OnGetFanart ( ) <nl> else <nl> m_movieItem - > ClearProperty ( " fanart_image " ) ; <nl> m_hasUpdatedThumb = true ; <nl> + AnnounceUpdate ( " fanart " ) ; <nl> <nl> / / Update our screen <nl> Update ( ) ; <nl> } <nl> <nl> + void CGUIDialogVideoInfo : : AnnounceUpdate ( const std : : string & type ) <nl> + { <nl> + CVariant data ; <nl> + data [ " art " ] = type ; <nl> + ANNOUNCEMENT : : CAnnouncementManager : : Announce ( ANNOUNCEMENT : : VideoLibrary , " xbmc " , " OnUpdate " , CFileItemPtr ( new CFileItem ( * m_movieItem ) ) , data ) ; <nl> + } <nl> + <nl> void CGUIDialogVideoInfo : : PlayTrailer ( ) <nl> { <nl> CFileItem item ; <nl> mmm a / xbmc / video / dialogs / GUIDialogVideoInfo . h <nl> ppp b / xbmc / video / dialogs / GUIDialogVideoInfo . h <nl> class CGUIDialogVideoInfo : <nl> protected : <nl> void Update ( ) ; <nl> void SetLabel ( int iControl , const CStdString & strLabel ) ; <nl> + void AnnounceUpdate ( const std : : string & type ) ; <nl> <nl> / / link cast to movies <nl> void ClearCastList ( ) ; <nl> mmm a / xbmc / windows / GUIWindowHome . cpp <nl> ppp b / xbmc / windows / GUIWindowHome . cpp <nl> void CGUIWindowHome : : Announce ( AnnouncementFlag flag , const char * sender , const c <nl> { <nl> if ( data . isMember ( " playcount " ) ) <nl> ra_flag | = Totals ; <nl> + if ( data . isMember ( " art " ) ) <nl> + ra_flag | = Video ; <nl> } <nl> else if ( strcmp ( message , " OnScanFinished " ) = = 0 ) <nl> { <nl>
|
fire OnUpdate events when the thumb or fanart is updated in the video info dialog , fixes .
|
xbmc/xbmc
|
0e6b47804558e4d19a572838003cdf880ef3588c
|
2012-05-09T21:37:56Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> include_directories ( $ { SDL2_INCLUDE_DIR } ) <nl> include_directories ( $ { OPENGL_INCLUDE_DIR } ) <nl> <nl> # internal includes <nl> - include_directories ( src / common / src ) <nl> - include_directories ( src / core / src ) <nl> - include_directories ( src / citra / src ) <nl> + include_directories ( src ) <nl> <nl> # process subdirectories <nl> if ( QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4 ) <nl> mmm a / src / CMakeLists . txt <nl> ppp b / src / CMakeLists . txt <nl> <nl> add_subdirectory ( common ) <nl> add_subdirectory ( core ) <nl> add_subdirectory ( citra ) <nl> + add_subdirectory ( video_core ) <nl> <nl> if ( QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4 ) <nl> # add_subdirectory ( citra_qt ) <nl> mmm a / src / citra / CMakeLists . txt <nl> ppp b / src / citra / CMakeLists . txt <nl> <nl> - set ( SRCS src / citra . cpp <nl> - src / emuwindow / emuwindow_glfw . cpp ) <nl> + set ( SRCS citra . cpp <nl> + emuwindow / emuwindow_glfw . cpp ) <nl> <nl> # NOTE : This is a workaround for CMake bug 0006976 ( missing X11_xf86vmode_LIB variable ) <nl> if ( NOT X11_xf86vmode_LIB ) <nl> mmm a / src / common / CMakeLists . txt <nl> ppp b / src / common / CMakeLists . txt <nl> <nl> - set ( SRCS src / break_points . cpp <nl> - src / console_listener . cpp <nl> - src / extended_trace . cpp <nl> - src / file_search . cpp <nl> - src / file_util . cpp <nl> - src / hash . cpp <nl> - src / log_manager . cpp <nl> - src / math_util . cpp <nl> - src / mem_arena . cpp <nl> - src / memory_util . cpp <nl> - src / misc . cpp <nl> - src / msg_handler . cpp <nl> - src / string_util . cpp <nl> - src / thread . cpp <nl> - src / timer . cpp <nl> - src / version . cpp ) <nl> + set ( SRCS break_points . cpp <nl> + console_listener . cpp <nl> + extended_trace . cpp <nl> + file_search . cpp <nl> + file_util . cpp <nl> + hash . cpp <nl> + log_manager . cpp <nl> + math_util . cpp <nl> + mem_arena . cpp <nl> + memory_util . cpp <nl> + misc . cpp <nl> + msg_handler . cpp <nl> + string_util . cpp <nl> + thread . cpp <nl> + timer . cpp <nl> + utf8 . cpp <nl> + version . cpp ) <nl> <nl> add_library ( common STATIC $ { SRCS } ) <nl> mmm a / src / core / CMakeLists . txt <nl> ppp b / src / core / CMakeLists . txt <nl> <nl> - set ( SRCS src / core . cpp <nl> - src / memory . cpp <nl> - src / boot / apploader . cpp <nl> - src / boot / bootrom . cpp <nl> - src / boot / loader . cpp <nl> - src / hle / hle . cpp <nl> - src / hw / hw . cpp <nl> - ) <nl> + set ( SRCS core . cpp <nl> + core_timing . cpp <nl> + loader . cpp <nl> + mem_map . cpp <nl> + mem_map_funcs . cpp <nl> + system . cpp <nl> + arm / disassembler / arm_disasm . cpp <nl> + arm / interpreter / arm_interpreter . cpp <nl> + arm / interpreter / armemu . cpp <nl> + arm / interpreter / arminit . cpp <nl> + arm / interpreter / armmmu . cpp <nl> + arm / interpreter / armos . cpp <nl> + arm / interpreter / armsupp . cpp <nl> + arm / interpreter / armvirt . cpp <nl> + arm / interpreter / thumbemu . cpp <nl> + arm / mmu / arm1176jzf_s_mmu . cpp <nl> + elf / elf_reader . cpp <nl> + file_sys / directory_file_system / cpp <nl> + file_sys / meta_file_system . cpp <nl> + hw / hw . cpp <nl> + hw / hw_lcd . cpp ) <nl> <nl> add_library ( core STATIC $ { SRCS } ) <nl> mmm a / src / video_core / CMakeLists . txt <nl> ppp b / src / video_core / CMakeLists . txt <nl> <nl> - set ( SRCS <nl> - src / bp_mem . cpp <nl> - src / cp_mem . cpp <nl> - src / xf_mem . cpp <nl> - src / fifo . cpp <nl> - src / fifo_player . cpp <nl> - src / vertex_loader . cpp <nl> - src / vertex_manager . cpp <nl> - src / video_core . cpp <nl> - src / shader_manager . cpp <nl> - src / texture_decoder . cpp <nl> - src / texture_manager . cpp <nl> + set ( SRCS src / video_core . cpp <nl> src / utils . cpp <nl> - src / renderer_gl3 / renderer_gl3 . cpp <nl> - src / renderer_gl3 / shader_interface . cpp <nl> - src / renderer_gl3 / texture_interface . cpp <nl> - src / renderer_gl3 / uniform_manager . cpp ) <nl> + src / renderer_opengl / renderer_opengl . cpp ) <nl> <nl> add_library ( video_core STATIC $ { SRCS } ) <nl>
|
updated CMakeLists
|
yuzu-emu/yuzu
|
6b83509a7ebe42126068c3500e638cb64b1e32e8
|
2014-04-10T03:09:05Z
|
mmm a / buildscripts / resmokeconfig / suites / core_small_oplog_rs_initsync . yml <nl> ppp b / buildscripts / resmokeconfig / suites / core_small_oplog_rs_initsync . yml <nl> selector : <nl> - jstests / core / opcounters_write_cmd . js <nl> - jstests / core / read_after_optime . js <nl> - jstests / core / capped_update . js <nl> + # These tests use map - reduce which can lead to consistency mismatches ( SERVER - 27147 ) . <nl> + - jstests / core / bypass_doc_validation . js <nl> + - jstests / core / collation . js <nl> + - jstests / core / commands_that_do_not_write_do_not_accept_wc . js <nl> + - jstests / core / constructors . js <nl> + - jstests / core / eval_mr . js <nl> + - jstests / core / geo_big_polygon3 . js <nl> + - jstests / core / geo_mapreduce . js <nl> + - jstests / core / geo_mapreduce2 . js <nl> + - jstests / core / index_stats . js <nl> + - jstests / core / mr1 . js <nl> + - jstests / core / mr2 . js <nl> + - jstests / core / mr3 . js <nl> + - jstests / core / mr4 . js <nl> + - jstests / core / mr5 . js <nl> + - jstests / core / mr_bigobject . js <nl> + - jstests / core / mr_bigobject_replace . js <nl> + - jstests / core / mr_comments . js <nl> + - jstests / core / mr_errorhandling . js <nl> + - jstests / core / mr_index . js <nl> + - jstests / core / mr_index2 . js <nl> + - jstests / core / mr_index3 . js <nl> + - jstests / core / mr_killop . js <nl> + - jstests / core / mr_merge . js <nl> + - jstests / core / mr_merge2 . js <nl> + - jstests / core / mr_mutable_properties . js <nl> + - jstests / core / mr_optim . js <nl> + - jstests / core / mr_outreduce . js <nl> + - jstests / core / mr_outreduce2 . js <nl> + - jstests / core / mr_replaceIntoDB . js <nl> + - jstests / core / mr_sort . js <nl> + - jstests / core / mr_stored . js <nl> + - jstests / core / mr_undef . js <nl> + - jstests / core / opcounters_active . js <nl> + - jstests / core / or4 . js <nl> + - jstests / core / profile_mapreduce . js <nl> + - jstests / core / recursion . js <nl> + - jstests / core / system_profile . js <nl> + - jstests / core / temp_cleanup . js <nl> <nl> run_hook_interval : & run_hook_interval 20 <nl> executor : <nl> mmm a / buildscripts / resmokeconfig / suites / core_small_oplog_rs_resync . yml <nl> ppp b / buildscripts / resmokeconfig / suites / core_small_oplog_rs_resync . yml <nl> selector : <nl> - jstests / core / opcounters_write_cmd . js <nl> - jstests / core / read_after_optime . js <nl> - jstests / core / capped_update . js <nl> + # These tests use map - reduce which can lead to consistency mismatches ( SERVER - 27147 ) . <nl> + - jstests / core / bypass_doc_validation . js <nl> + - jstests / core / collation . js <nl> + - jstests / core / commands_that_do_not_write_do_not_accept_wc . js <nl> + - jstests / core / constructors . js <nl> + - jstests / core / eval_mr . js <nl> + - jstests / core / geo_big_polygon3 . js <nl> + - jstests / core / geo_mapreduce . js <nl> + - jstests / core / geo_mapreduce2 . js <nl> + - jstests / core / index_stats . js <nl> + - jstests / core / mr1 . js <nl> + - jstests / core / mr2 . js <nl> + - jstests / core / mr3 . js <nl> + - jstests / core / mr4 . js <nl> + - jstests / core / mr5 . js <nl> + - jstests / core / mr_bigobject . js <nl> + - jstests / core / mr_bigobject_replace . js <nl> + - jstests / core / mr_comments . js <nl> + - jstests / core / mr_errorhandling . js <nl> + - jstests / core / mr_index . js <nl> + - jstests / core / mr_index2 . js <nl> + - jstests / core / mr_index3 . js <nl> + - jstests / core / mr_killop . js <nl> + - jstests / core / mr_merge . js <nl> + - jstests / core / mr_merge2 . js <nl> + - jstests / core / mr_mutable_properties . js <nl> + - jstests / core / mr_optim . js <nl> + - jstests / core / mr_outreduce . js <nl> + - jstests / core / mr_outreduce2 . js <nl> + - jstests / core / mr_replaceIntoDB . js <nl> + - jstests / core / mr_sort . js <nl> + - jstests / core / mr_stored . js <nl> + - jstests / core / mr_undef . js <nl> + - jstests / core / opcounters_active . js <nl> + - jstests / core / or4 . js <nl> + - jstests / core / profile_mapreduce . js <nl> + - jstests / core / recursion . js <nl> + - jstests / core / system_profile . js <nl> + - jstests / core / temp_cleanup . js <nl> <nl> run_hook_interval : & run_hook_interval 20 <nl> executor : <nl>
|
SERVER - 27206 blacklist tests involving MapReduce from initial sync dynamic passthroughs
|
mongodb/mongo
|
bddb3bee3b9c5e7660dbfd8cede4f0dc8cc44699
|
2016-11-29T22:15:51Z
|
mmm a / tensorflow / python / eager / def_function_test . py <nl> ppp b / tensorflow / python / eager / def_function_test . py <nl> def g ( x ) : <nl> signature_args , _ = conc . structured_input_signature <nl> self . assertEqual ( ' z ' , signature_args [ 0 ] [ 0 ] . name ) <nl> <nl> - with self . assertRaisesRegexp ( <nl> - ValueError , ' either zero or all names have to be specified ' ) : <nl> - conc = g . get_concrete_function ( [ <nl> - tensor_spec . TensorSpec ( None , dtypes . float32 , ' z ' ) , <nl> - tensor_spec . TensorSpec ( None , dtypes . float32 ) , <nl> - ] ) <nl> - <nl> def test_error_inner_capture ( self ) : <nl> <nl> @ def_function . function <nl> mmm a / tensorflow / python / framework / func_graph . py <nl> ppp b / tensorflow / python / framework / func_graph . py <nl> def _get_defun_inputs ( args , names , structure , flat_shapes = None ) : <nl> arg_value = nest . map_structure ( _get_composite_tensor_spec , arg_value ) <nl> <nl> flattened = nest . flatten ( arg_value , expand_composites = True ) <nl> - tensor_specs = [ <nl> - arg for arg in flattened if isinstance ( arg , tensor_spec . DenseSpec ) <nl> - ] <nl> - specified_names = [ arg . name for arg in tensor_specs if arg . name ] <nl> - if specified_names and len ( specified_names ) < len ( tensor_specs ) : <nl> - raise ValueError ( " If specifying TensorSpec names for nested structures , " <nl> - " either zero or all names have to be specified . " <nl> - " TensorSpecs : { } , specified names : { } " . format ( <nl> - tensor_specs , specified_names ) ) <nl> <nl> for arg in flattened : <nl> # We have a shape entry for each arg , regardless of whether it ' s a real <nl>
|
For tf . function inputs with nested values , do not require that either zero or all TensorSpecs in the nested value need to have names .
|
tensorflow/tensorflow
|
d1a6976039c769423814f690661fd2c1b471b08c
|
2020-05-04T19:00:59Z
|
mmm a / src / core / hle / kernel / thread . cpp <nl> ppp b / src / core / hle / kernel / thread . cpp <nl> ResultVal < SharedPtr < Thread > > Thread : : Create ( std : : string name , VAddr entry_point , <nl> thread - > nominal_priority = thread - > current_priority = priority ; <nl> thread - > last_running_ticks = CoreTiming : : GetTicks ( ) ; <nl> thread - > processor_id = processor_id ; <nl> + thread - > ideal_core = processor_id ; <nl> + thread - > mask = 1 < < processor_id ; <nl> thread - > wait_objects . clear ( ) ; <nl> thread - > mutex_wait_address = 0 ; <nl> thread - > condvar_wait_address = 0 ; <nl>
|
thread : Initialize ideal_core and mask members .
|
yuzu-emu/yuzu
|
4822765fefbb81ad55fe4db7561ccf69b9a60bcd
|
2018-05-10T23:34:52Z
|
mmm a / xbmc / windowing / X11 / GLContext . h <nl> ppp b / xbmc / windowing / X11 / GLContext . h <nl> class CGLContext <nl> } <nl> virtual ~ CGLContext ( ) = default ; <nl> virtual bool Refresh ( bool force , int screen , Window glWindow , bool & newContext ) = 0 ; <nl> + virtual bool CreatePB ( ) { return false ; } ; <nl> virtual void Destroy ( ) = 0 ; <nl> virtual void Detach ( ) = 0 ; <nl> virtual void SetVSync ( bool enable ) = 0 ; <nl> mmm a / xbmc / windowing / X11 / GLContextEGL . cpp <nl> ppp b / xbmc / windowing / X11 / GLContextEGL . cpp <nl> CGLContextEGL : : CGLContextEGL ( Display * dpy ) : CGLContext ( dpy ) <nl> m_eglSurface = EGL_NO_SURFACE ; <nl> m_eglContext = EGL_NO_CONTEXT ; <nl> m_eglConfig = EGL_NO_CONFIG ; <nl> + <nl> + eglGetPlatformDisplayEXT = ( PFNEGLGETPLATFORMDISPLAYEXTPROC ) eglGetProcAddress ( " eglGetPlatformDisplayEXT " ) ; <nl> } <nl> <nl> CGLContextEGL : : ~ CGLContextEGL ( ) <nl> bool CGLContextEGL : : Refresh ( bool force , int screen , Window glWindow , bool & newCo <nl> return true ; <nl> } <nl> <nl> - / / create context <nl> - bool retVal = false ; <nl> + Destroy ( ) ; <nl> + newContext = true ; <nl> <nl> - if ( m_eglDisplay = = EGL_NO_DISPLAY ) <nl> + if ( eglGetPlatformDisplayEXT ) <nl> { <nl> - m_eglDisplay = eglGetDisplay ( ( EGLNativeDisplayType ) m_dpy ) ; <nl> - if ( m_eglDisplay = = EGL_NO_DISPLAY ) <nl> + EGLint attribs [ ] = <nl> { <nl> - CLog : : Log ( LOGERROR , " failed to get egl display \ n " ) ; <nl> - return false ; <nl> - } <nl> - if ( ! eglInitialize ( m_eglDisplay , NULL , NULL ) ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to initialize egl display \ n " ) ; <nl> - return false ; <nl> - } <nl> + EGL_PLATFORM_X11_SCREEN_EXT , screen , <nl> + EGL_NONE <nl> + } ; <nl> + m_eglDisplay = eglGetPlatformDisplayEXT ( EGL_PLATFORM_X11_EXT , ( EGLNativeDisplayType ) m_dpy , <nl> + attribs ) ; <nl> + } <nl> + else <nl> + m_eglDisplay = eglGetDisplay ( ( EGLNativeDisplayType ) m_dpy ) ; <nl> + <nl> + if ( m_eglDisplay = = EGL_NO_DISPLAY ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to get egl display " ) ; <nl> + return false ; <nl> } <nl> + if ( ! eglInitialize ( m_eglDisplay , NULL , NULL ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to initialize egl \ n " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + if ( ! eglBindAPI ( EGL_OPENGL_API ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to initialize egl " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / / create context <nl> <nl> XVisualInfo vMask ; <nl> XVisualInfo * vInfo = nullptr ; <nl> bool CGLContextEGL : : Refresh ( bool force , int screen , Window glWindow , bool & newCo <nl> vMask . screen = screen ; <nl> XWindowAttributes winAttr ; <nl> <nl> - if ( XGetWindowAttributes ( m_dpy , glWindow , & winAttr ) ) <nl> + if ( ! XGetWindowAttributes ( m_dpy , glWindow , & winAttr ) ) <nl> { <nl> - vMask . visualid = XVisualIDFromVisual ( winAttr . visual ) ; <nl> - vInfo = XGetVisualInfo ( m_dpy , VisualScreenMask | VisualIDMask , & vMask , & availableVisuals ) ; <nl> - if ( ! vInfo ) <nl> - { <nl> - CLog : : Log ( LOGWARNING , " Failed to get VisualInfo of visual 0x % x " , ( unsigned ) vMask . visualid ) ; <nl> - } <nl> - else if ( ! IsSuitableVisual ( vInfo ) ) <nl> - { <nl> - CLog : : Log ( LOGWARNING , " Visual 0x % x of the window is not suitable , looking for another one . . . " , <nl> - ( unsigned ) vInfo - > visualid ) ; <nl> - XFree ( vInfo ) ; <nl> - vInfo = nullptr ; <nl> - } <nl> - } <nl> - else <nl> CLog : : Log ( LOGWARNING , " Failed to get window attributes " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - if ( vInfo ) <nl> + vMask . visualid = XVisualIDFromVisual ( winAttr . visual ) ; <nl> + vInfo = XGetVisualInfo ( m_dpy , VisualScreenMask | VisualIDMask , & vMask , & availableVisuals ) ; <nl> + if ( ! vInfo ) <nl> { <nl> - CLog : : Log ( LOGNOTICE , " Using visual 0x % x " , ( unsigned ) vInfo - > visualid ) ; <nl> - <nl> - if ( m_eglContext ) <nl> - { <nl> - eglMakeCurrent ( m_eglContext , EGL_NO_SURFACE , EGL_NO_SURFACE , EGL_NO_CONTEXT ) ; <nl> - eglDestroyContext ( m_eglDisplay , m_eglContext ) ; <nl> - m_eglContext = EGL_NO_CONTEXT ; <nl> - <nl> - if ( m_eglSurface ) <nl> - { <nl> - eglDestroySurface ( m_eglDisplay , m_eglSurface ) ; <nl> - m_eglSurface = EGL_NO_SURFACE ; <nl> - } <nl> - eglTerminate ( m_eglDisplay ) ; <nl> - m_eglDisplay = EGL_NO_DISPLAY ; <nl> - XSync ( m_dpy , False ) ; <nl> - newContext = true ; <nl> - } <nl> + CLog : : Log ( LOGERROR , " Failed to get VisualInfo of visual 0x % x " , ( unsigned ) vMask . visualid ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - m_eglDisplay = eglGetDisplay ( ( EGLNativeDisplayType ) m_dpy ) ; <nl> - if ( m_eglDisplay = = EGL_NO_DISPLAY ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to get egl display " ) ; <nl> - return false ; <nl> - } <nl> - if ( ! eglInitialize ( m_eglDisplay , NULL , NULL ) ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to initialize egl \ n " ) ; <nl> - return false ; <nl> - } <nl> + if ( ! IsSuitableVisual ( vInfo ) ) <nl> + { <nl> + CLog : : Log ( LOGWARNING , " Visual 0x % x of the window is not suitable " , ( unsigned ) vInfo - > visualid ) ; <nl> + XFree ( vInfo ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - if ( ! eglBindAPI ( EGL_OPENGL_API ) ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to initialize egl " ) ; <nl> - XFree ( vInfo ) ; <nl> - return false ; <nl> - } <nl> + CLog : : Log ( LOGNOTICE , " Using visual 0x % x " , ( unsigned ) vInfo - > visualid ) ; <nl> <nl> - if ( m_eglConfig = = EGL_NO_CONFIG ) <nl> - { <nl> - m_eglConfig = GetEGLConfig ( m_eglDisplay , vInfo ) ; <nl> - } <nl> + m_eglConfig = GetEGLConfig ( m_eglDisplay , vInfo ) ; <nl> + XFree ( vInfo ) ; <nl> <nl> - if ( m_eglConfig = = EGL_NO_CONFIG ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to get eglconfig for visual id " ) ; <nl> - XFree ( vInfo ) ; <nl> - return false ; <nl> - } <nl> + if ( m_eglConfig = = EGL_NO_CONFIG ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to get eglconfig for visual id " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - if ( m_eglSurface = = EGL_NO_SURFACE ) <nl> - { <nl> - m_eglSurface = eglCreateWindowSurface ( m_eglDisplay , m_eglConfig , glWindow , NULL ) ; <nl> - if ( m_eglSurface = = EGL_NO_SURFACE ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to create EGL window surface % d " , eglGetError ( ) ) ; <nl> - XFree ( vInfo ) ; <nl> - return false ; <nl> - } <nl> - } <nl> + m_eglSurface = eglCreateWindowSurface ( m_eglDisplay , m_eglConfig , glWindow , NULL ) ; <nl> + if ( m_eglSurface = = EGL_NO_SURFACE ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to create EGL window surface % d " , eglGetError ( ) ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - EGLint contextAttributes [ ] = <nl> - { <nl> + EGLint contextAttributes [ ] = <nl> + { <nl> EGL_CONTEXT_MAJOR_VERSION_KHR , 3 , <nl> EGL_CONTEXT_MINOR_VERSION_KHR , 2 , <nl> EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR , EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR , <nl> EGL_NONE <nl> + } ; <nl> + m_eglContext = eglCreateContext ( m_eglDisplay , m_eglConfig , EGL_NO_CONTEXT , contextAttributes ) ; <nl> + if ( m_eglContext = = EGL_NO_CONTEXT ) <nl> + { <nl> + EGLint contextAttributes [ ] = <nl> + { <nl> + EGL_CONTEXT_MAJOR_VERSION_KHR , 2 , <nl> + EGL_NONE <nl> } ; <nl> m_eglContext = eglCreateContext ( m_eglDisplay , m_eglConfig , EGL_NO_CONTEXT , contextAttributes ) ; <nl> + <nl> if ( m_eglContext = = EGL_NO_CONTEXT ) <nl> { <nl> - EGLint contextAttributes [ ] = <nl> - { <nl> - EGL_CONTEXT_MAJOR_VERSION_KHR , 2 , <nl> - EGL_NONE <nl> - } ; <nl> - m_eglContext = eglCreateContext ( m_eglDisplay , m_eglConfig , EGL_NO_CONTEXT , contextAttributes ) ; <nl> - <nl> - if ( m_eglContext = = EGL_NO_CONTEXT ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " failed to create EGL context \ n " ) ; <nl> - return false ; <nl> - } <nl> + CLog : : Log ( LOGERROR , " failed to create EGL context \ n " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - CLog : : Log ( LOGWARNING , " Failed to get an OpenGL context supporting core profile 3 . 2 , \ <nl> + CLog : : Log ( LOGWARNING , " Failed to get an OpenGL context supporting core profile 3 . 2 , \ <nl> using legacy mode with reduced feature set " ) ; <nl> - } <nl> + } <nl> <nl> - if ( ! eglMakeCurrent ( m_eglDisplay , m_eglSurface , m_eglSurface , m_eglContext ) ) <nl> - { <nl> - CLog : : Log ( LOGERROR , " Failed to make context current % p % p % p \ n " , m_eglDisplay , m_eglSurface , m_eglContext ) ; <nl> - return false ; <nl> - } <nl> - XFree ( vInfo ) ; <nl> - retVal = true ; <nl> + if ( ! eglMakeCurrent ( m_eglDisplay , m_eglSurface , m_eglSurface , m_eglContext ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " Failed to make context current % p % p % p \ n " , m_eglDisplay , m_eglSurface , m_eglContext ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + eglGetSyncValuesCHROMIUM = ( PFNEGLGETSYNCVALUESCHROMIUMPROC ) eglGetProcAddress ( " eglGetSyncValuesCHROMIUM " ) ; <nl> + <nl> + m_usePB = false ; <nl> + return true ; <nl> + } <nl> + <nl> + bool CGLContextEGL : : CreatePB ( ) <nl> + { <nl> + const EGLint configAttribs [ ] = <nl> + { <nl> + EGL_SURFACE_TYPE , EGL_PBUFFER_BIT , <nl> + EGL_BLUE_SIZE , 8 , <nl> + EGL_GREEN_SIZE , 8 , <nl> + EGL_RED_SIZE , 8 , <nl> + EGL_DEPTH_SIZE , 8 , <nl> + EGL_RENDERABLE_TYPE , EGL_OPENGL_BIT , <nl> + EGL_NONE <nl> + } ; <nl> + <nl> + const EGLint pbufferAttribs [ ] = <nl> + { <nl> + EGL_WIDTH , 9 , <nl> + EGL_HEIGHT , 9 , <nl> + EGL_NONE , <nl> + } ; <nl> + <nl> + Destroy ( ) ; <nl> + <nl> + if ( eglGetPlatformDisplayEXT ) <nl> + { <nl> + m_eglDisplay = eglGetPlatformDisplayEXT ( EGL_PLATFORM_X11_EXT , ( EGLNativeDisplayType ) m_dpy , <nl> + NULL ) ; <nl> } <nl> else <nl> + m_eglDisplay = eglGetDisplay ( ( EGLNativeDisplayType ) m_dpy ) ; <nl> + <nl> + if ( m_eglDisplay = = EGL_NO_DISPLAY ) <nl> { <nl> - CLog : : Log ( LOGERROR , " EGL Error : vInfo is NULL ! " ) ; <nl> + CLog : : Log ( LOGERROR , " failed to get egl display " ) ; <nl> + return false ; <nl> + } <nl> + if ( ! eglInitialize ( m_eglDisplay , NULL , NULL ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to initialize egl \ n " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + if ( ! eglBindAPI ( EGL_OPENGL_API ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to initialize egl " ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> } <nl> <nl> - eglGetSyncValuesCHROMIUM = ( PFNEGLGETSYNCVALUESCHROMIUMPROC ) eglGetProcAddress ( " eglGetSyncValuesCHROMIUM " ) ; <nl> - return retVal ; <nl> + EGLint numConfigs ; <nl> + <nl> + eglChooseConfig ( m_eglDisplay , configAttribs , & m_eglConfig , 1 , & numConfigs ) ; <nl> + m_eglSurface = eglCreatePbufferSurface ( m_eglDisplay , m_eglConfig , pbufferAttribs ) ; <nl> + if ( m_eglSurface = = EGL_NO_SURFACE ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " failed to create EGL window surface % d " , eglGetError ( ) ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + m_eglContext = eglCreateContext ( m_eglDisplay , m_eglConfig , EGL_NO_CONTEXT , NULL ) ; <nl> + <nl> + if ( ! eglMakeCurrent ( m_eglDisplay , m_eglSurface , m_eglSurface , m_eglContext ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " Failed to make context current % p % p % p \ n " , m_eglDisplay , m_eglSurface , m_eglContext ) ; <nl> + Destroy ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + m_usePB = true ; <nl> + return true ; <nl> } <nl> <nl> void CGLContextEGL : : Destroy ( ) <nl> void CGLContextEGL : : Destroy ( ) <nl> eglTerminate ( m_eglDisplay ) ; <nl> m_eglDisplay = EGL_NO_DISPLAY ; <nl> } <nl> + <nl> + m_eglConfig = EGL_NO_CONFIG ; <nl> } <nl> <nl> void CGLContextEGL : : Detach ( ) <nl> EGLConfig CGLContextEGL : : GetEGLConfig ( EGLDisplay eglDisplay , XVisualInfo * vInfo ) <nl> CLog : : Log ( LOGERROR , " Failed to query egl configs " ) ; <nl> goto Exit ; <nl> } <nl> - for ( EGLint i = 0 ; i < numConfigs ; + + i ) <nl> + for ( EGLint i = 0 ; i < numConfigs ; + + i ) <nl> { <nl> EGLint value ; <nl> if ( ! eglGetConfigAttrib ( eglDisplay , eglConfigs [ i ] , EGL_NATIVE_VISUAL_ID , & value ) ) <nl> void CGLContextEGL : : SwapBuffers ( ) <nl> if ( ( m_eglDisplay = = EGL_NO_DISPLAY ) | | ( m_eglSurface = = EGL_NO_SURFACE ) ) <nl> return ; <nl> <nl> + if ( m_usePB ) <nl> + { <nl> + eglSwapBuffers ( m_eglDisplay , m_eglSurface ) ; <nl> + usleep ( 20 * 1000 ) ; <nl> + return ; <nl> + } <nl> + <nl> uint64_t ust1 , ust2 ; <nl> uint64_t msc1 , msc2 ; <nl> uint64_t sbc1 , sbc2 ; <nl> mmm a / xbmc / windowing / X11 / GLContextEGL . h <nl> ppp b / xbmc / windowing / X11 / GLContextEGL . h <nl> <nl> <nl> # include " GLContext . h " <nl> # include " EGL / egl . h " <nl> + # include " EGL / eglext . h " <nl> # include " EGL / eglextchromium . h " <nl> # include < X11 / Xutil . h > <nl> <nl> class CGLContextEGL : public CGLContext <nl> explicit CGLContextEGL ( Display * dpy ) ; <nl> ~ CGLContextEGL ( ) override ; <nl> bool Refresh ( bool force , int screen , Window glWindow , bool & newContext ) override ; <nl> + bool CreatePB ( ) override ; <nl> void Destroy ( ) override ; <nl> void Detach ( ) override ; <nl> void SetVSync ( bool enable ) override ; <nl> class CGLContextEGL : public CGLContext <nl> bool IsSuitableVisual ( XVisualInfo * vInfo ) ; <nl> EGLConfig GetEGLConfig ( EGLDisplay eglDisplay , XVisualInfo * vInfo ) ; <nl> PFNEGLGETSYNCVALUESCHROMIUMPROC eglGetSyncValuesCHROMIUM = nullptr ; <nl> + PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = nullptr ; <nl> <nl> struct Sync <nl> { <nl> class CGLContextEGL : public CGLContext <nl> uint64_t msc2 = 0 ; <nl> uint64_t interval = 0 ; <nl> } m_sync ; <nl> + <nl> + bool m_usePB = false ; <nl> } ; <nl> mmm a / xbmc / windowing / X11 / WinSystemX11GLContext . cpp <nl> ppp b / xbmc / windowing / X11 / WinSystemX11GLContext . cpp <nl> EGLConfig CWinSystemX11GLContext : : GetEGLConfig ( ) const <nl> bool CWinSystemX11GLContext : : SetWindow ( int width , int height , bool fullscreen , const std : : string & output , int * winstate ) <nl> { <nl> int newwin = 0 ; <nl> + <nl> CWinSystemX11 : : SetWindow ( width , height , fullscreen , output , & newwin ) ; <nl> if ( newwin ) <nl> { <nl> bool CWinSystemX11GLContext : : RefreshGLContext ( bool force ) <nl> if ( m_pGLContext ) <nl> { <nl> success = m_pGLContext - > Refresh ( force , m_screen , m_glWindow , m_newGlContext ) ; <nl> + if ( ! success ) <nl> + { <nl> + success = m_pGLContext - > CreatePB ( ) ; <nl> + m_newGlContext = true ; <nl> + } <nl> return success ; <nl> } <nl> <nl> bool CWinSystemX11GLContext : : RefreshGLContext ( bool force ) <nl> return true ; <nl> } <nl> } <nl> + else if ( gli ! = " EGL " ) <nl> + { <nl> + success = m_pGLContext - > CreatePB ( ) ; <nl> + if ( success ) <nl> + return true ; <nl> + } <nl> } <nl> <nl> delete m_pGLContext ; <nl>
|
X11 : EGL - create PB if creation of surface for window fails
|
xbmc/xbmc
|
cad68b2df80d67e55f6cacd9428de581f2523b6f
|
2018-10-21T06:52:06Z
|
mmm a / cocos / 2d / CCParticleSystemQuad . cpp <nl> ppp b / cocos / 2d / CCParticleSystemQuad . cpp <nl> THE SOFTWARE . <nl> <nl> <nl> # include " 2d / CCParticleSystemQuad . h " <nl> + <nl> + # include < algorithm > <nl> + <nl> # include " 2d / CCSpriteFrame . h " <nl> # include " 2d / CCParticleBatchNode . h " <nl> # include " renderer / CCTextureAtlas . h " <nl> void ParticleSystemQuad : : initTexCoordsWithRect ( const Rect & pointRect ) <nl> # endif / / ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL <nl> <nl> / / Important . Texture in cocos2d are inverted , so the Y component should be inverted <nl> - CC_SWAP ( top , bottom , float ) ; <nl> + std : : swap ( top , bottom ) ; <nl> <nl> V3F_C4B_T2F_Quad * quads = nullptr ; <nl> unsigned int start = 0 , end = 0 ; <nl> mmm a / cocos / 2d / CCProgressTimer . cpp <nl> ppp b / cocos / 2d / CCProgressTimer . cpp <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # include " 2d / CCProgressTimer . h " <nl> <nl> + # include < algorithm > <nl> + <nl> # include " base / ccMacros . h " <nl> # include " base / CCDirector . h " <nl> # include " 2d / CCSprite . h " <nl> Tex2F ProgressTimer : : textureCoordFromAlphaPoint ( Vec2 alpha ) <nl> Vec2 max = Vec2 ( quad . tr . texCoords . u , quad . tr . texCoords . v ) ; <nl> / / Fix bug # 1303 so that progress timer handles sprite frame texture rotation <nl> if ( _sprite - > isTextureRectRotated ( ) ) { <nl> - CC_SWAP ( alpha . x , alpha . y , float ) ; <nl> + std : : swap ( alpha . x , alpha . y ) ; <nl> } <nl> return Tex2F ( min . x * ( 1 . f - alpha . x ) + max . x * alpha . x , min . y * ( 1 . f - alpha . y ) + max . y * alpha . y ) ; <nl> } <nl> mmm a / cocos / 2d / CCSprite . cpp <nl> ppp b / cocos / 2d / CCSprite . cpp <nl> THE SOFTWARE . <nl> <nl> # include " 2d / CCSprite . h " <nl> <nl> + # include < algorithm > <nl> + <nl> # include " 2d / CCSpriteBatchNode . h " <nl> # include " 2d / CCAnimationCache . h " <nl> # include " 2d / CCSpriteFrame . h " <nl> void Sprite : : setTextureCoords ( Rect rect ) <nl> <nl> if ( _flippedX ) <nl> { <nl> - CC_SWAP ( top , bottom , float ) ; <nl> + std : : swap ( top , bottom ) ; <nl> } <nl> <nl> if ( _flippedY ) <nl> { <nl> - CC_SWAP ( left , right , float ) ; <nl> + std : : swap ( left , right ) ; <nl> } <nl> <nl> _quad . bl . texCoords . u = left ; <nl> void Sprite : : setTextureCoords ( Rect rect ) <nl> <nl> if ( _flippedX ) <nl> { <nl> - CC_SWAP ( left , right , float ) ; <nl> + std : : swap ( left , right ) ; <nl> } <nl> <nl> if ( _flippedY ) <nl> { <nl> - CC_SWAP ( top , bottom , float ) ; <nl> + std : : swap ( top , bottom ) ; <nl> } <nl> <nl> _quad . bl . texCoords . u = left ; <nl> mmm a / cocos / base / ccMacros . h <nl> ppp b / cocos / base / ccMacros . h <nl> THE SOFTWARE . <nl> <nl> / * * @ def CC_SWAP <nl> simple macro that swaps 2 variables <nl> + @ deprecated use std : : swap ( ) instead <nl> * / <nl> # define CC_SWAP ( x , y , type ) \ <nl> { type temp = ( x ) ; \ <nl> mmm a / download - deps . py <nl> ppp b / download - deps . py <nl> <nl> # <nl> # . / download - deps . py <nl> # <nl> - # Download Cocos2D - X resources from github ( https : / / github . com / cocos2d / cocos2d - x - 3rd - party - libs - bin ) and extract from ZIP <nl> + # Downloads Cocos2D - x 3rd party dependencies from github : <nl> + # https : / / github . com / cocos2d / cocos2d - x - 3rd - party - libs - bin ) and extracts the zip <nl> + # file <nl> # <nl> - # Helps prevent repo bloat due to large binary files since they can <nl> - # be hosted separately . <nl> + # Having the dependencies outside the official cocos2d - x repo helps prevent <nl> + # bloating the repo . <nl> # <nl> <nl> " " " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> def unpack_zipfile ( self , extract_dir ) : <nl> else : <nl> # file <nl> data = z . read ( info . filename ) <nl> - f = open ( target , ' wb ' ) <nl> + f = open ( target , ' wb ' ) <nl> try : <nl> f . write ( data ) <nl> finally : <nl> mmm a / tests / cpp - tests / Classes / SpriteTest / SpriteTest . cpp <nl> ppp b / tests / cpp - tests / Classes / SpriteTest / SpriteTest . cpp <nl> void SpriteHybrid : : reparentSprite ( float dt ) <nl> Vector < Node * > retArray ( 250 ) ; <nl> <nl> if ( _usingSpriteBatchNode ) <nl> - CC_SWAP ( p1 , p2 , Node * ) ; <nl> + std : : swap ( p1 , p2 ) ; <nl> <nl> / / / / mmm - CCLOG ( " New parent is : % x " , p2 ) ; <nl> <nl>
|
Using std : : swap instead of CC_SWAP
|
cocos2d/cocos2d-x
|
dcc4c46d5bf31317589d5935ec87bb6a521677c1
|
2014-11-16T17:29:05Z
|
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> test - firefox : & test - firefox <nl> - run : <nl> name : download firefox <nl> command : | <nl> - FF_VERSION = 65 . 0 . 2 <nl> - wget https : / / download - installer . cdn . mozilla . net / pub / firefox / releases / $ FF_VERSION / linux - x86_64 / en - US / firefox - $ FF_VERSION . tar . bz2 <nl> - tar xf firefox - $ FF_VERSION . tar . bz2 <nl> - # wget - O nightly . tar . bz2 " https : / / download . mozilla . org / ? product = firefox - nightly - latest - ssl & os = linux64 & lang = en - US " <nl> - # tar xf nightly . tar . bz2 <nl> + # we should pin a version here , but llvm upstream now emits bulk memory for pthreads <nl> + # which requires very latest nightly as of Jul 13 2019 <nl> + wget - O nightly . tar . bz2 " https : / / download . mozilla . org / ? product = firefox - nightly - latest - ssl & os = linux64 & lang = en - US " <nl> + tar xf nightly . tar . bz2 <nl> - run : <nl> name : configure firefox <nl> command : | <nl> test - firefox : & test - firefox <nl> export EMTEST_BROWSER = " $ HOME / firefox / firefox - profile tmp - firefox - profile / " <nl> export GALLIUM_DRIVER = softpipe # TODO : use the default llvmpipe when it supports more extensions <nl> export EMTEST_LACKS_SOUND_HARDWARE = 1 <nl> + export EMTEST_LACKS_OFFSCREEN_CANVAS = 1 # looks broken in ff nightly <nl> export EMTEST_DETECT_TEMPFILE_LEAKS = 0 <nl> export DISPLAY = : 0 <nl> # Start an X session . Openbox might be optional for now , but <nl> mmm a / src / Fetch . js <nl> ppp b / src / Fetch . js <nl> function __emscripten_fetch_xhr ( fetch , onsuccess , onerror , onprogress , onreadyst <nl> xhr . open ( requestMethod , url_ , ! fetchAttrSynchronous , userNameStr , passwordStr ) ; <nl> if ( ! fetchAttrSynchronous ) xhr . timeout = timeoutMsecs ; / / XHR timeout field is only accessible in async XHRs , and must be set after . open ( ) but before . send ( ) . <nl> xhr . url_ = url_ ; / / Save the url for debugging purposes ( and for comparing to the responseURL that server side advertised ) <nl> - xhr . responseType = fetchAttrStreamData ? ' moz - chunked - arraybuffer ' : ' arraybuffer ' ; <nl> + assert ( ! fetchAttrStreamData , ' streaming uses moz - chunked - arraybuffer which is no longer supported ; TODO : rewrite using fetch ( ) ' ) ; <nl> + xhr . responseType = ' arraybuffer ' ; <nl> <nl> if ( overriddenMimeType ) { <nl> # if FETCH_DEBUG <nl> mmm a / tests / test_browser . py <nl> ppp b / tests / test_browser . py <nl> def decorated ( self ) : <nl> requires_graphics_hardware = unittest . skipIf ( os . getenv ( ' EMTEST_LACKS_GRAPHICS_HARDWARE ' ) , " This test requires graphics hardware " ) <nl> requires_sound_hardware = unittest . skipIf ( os . getenv ( ' EMTEST_LACKS_SOUND_HARDWARE ' ) , " This test requires sound hardware " ) <nl> requires_sync_compilation = unittest . skipIf ( is_chrome ( ) , " This test requires synchronous compilation , which does not work in Chrome ( except for tiny wasms ) " ) <nl> + requires_offscreen_canvas = unittest . skipIf ( os . getenv ( ' EMTEST_LACKS_OFFSCREEN_CANVAS ' ) , " This test requires a browser with OffscreenCanvas " ) <nl> <nl> <nl> class browser ( BrowserCore ) : <nl> def test_TextDecoder ( self ) : <nl> # - DTEST_CHAINED_WEBGL_CONTEXT_PASSING : Tests that it is possible to transfer WebGL canvas in a chain from main thread - > thread 1 - > thread 2 and then init and render WebGL content there . <nl> @ no_chrome ( ' see https : / / crbug . com / 961765 ' ) <nl> @ requires_threads <nl> + @ requires_offscreen_canvas <nl> def test_webgl_offscreen_canvas_in_pthread ( self ) : <nl> for args in [ [ ] , [ ' - DTEST_CHAINED_WEBGL_CONTEXT_PASSING ' ] ] : <nl> self . btest ( ' gl_in_pthread . cpp ' , expected = ' 1 ' , args = args + [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 2 ' , ' - s ' , ' OFFSCREENCANVAS_SUPPORT = 1 ' , ' - lGL ' , ' - s ' , ' DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1 ' ] ) <nl> def test_webgl_offscreen_canvas_in_pthread ( self ) : <nl> # Tests that it is possible to render WebGL content on a < canvas > on the main thread , after it has once been used to render WebGL content in a pthread first <nl> # - DTEST_MAIN_THREAD_EXPLICIT_COMMIT : Test the same ( WebGL on main thread after pthread ) , but by using explicit . commit ( ) to swap on the main thread instead of implicit " swap when rAF ends " logic <nl> @ requires_threads <nl> + @ requires_offscreen_canvas <nl> def test_webgl_offscreen_canvas_in_mainthread_after_pthread ( self ) : <nl> self . skipTest ( ' This test is disabled because current OffscreenCanvas does not allow transfering it after a rendering context has been created for it . ' ) <nl> for args in [ [ ] , [ ' - DTEST_MAIN_THREAD_EXPLICIT_COMMIT ' ] ] : <nl> self . btest ( ' gl_in_mainthread_after_pthread . cpp ' , expected = ' 0 ' , args = args + [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 2 ' , ' - s ' , ' OFFSCREENCANVAS_SUPPORT = 1 ' , ' - lGL ' , ' - s ' , ' DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1 ' ] ) <nl> <nl> @ requires_threads <nl> + @ requires_offscreen_canvas <nl> def test_webgl_offscreen_canvas_only_in_pthread ( self ) : <nl> self . btest ( ' gl_only_in_pthread . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 1 ' , ' - s ' , ' OFFSCREENCANVAS_SUPPORT = 1 ' , ' - lGL ' , ' - s ' , ' DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1 ' , ' - s ' , ' OFFSCREEN_FRAMEBUFFER = 1 ' ] ) <nl> <nl> def test_webgl_array_of_structs_uniform ( self ) : <nl> # - DTEST_OFFSCREEN_CANVAS = 1 : Tests that if a WebGL context is created on a pthread that has the canvas transferred to it via using Emscripten ' s EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES = " # canvas " , then OffscreenCanvas is used <nl> # - DTEST_OFFSCREEN_CANVAS = 2 : Tests that if a WebGL context is created on a pthread that has the canvas transferred to it via automatic transferring of Module . canvas when EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES is not defined , then OffscreenCanvas is also used <nl> @ requires_threads <nl> + @ requires_offscreen_canvas <nl> def test_webgl_offscreen_canvas_in_proxied_pthread ( self ) : <nl> for args in [ [ ] , [ ' - DTEST_OFFSCREEN_CANVAS = 1 ' ] , [ ' - DTEST_OFFSCREEN_CANVAS = 2 ' ] ] : <nl> cmd = args + [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' OFFSCREENCANVAS_SUPPORT = 1 ' , ' - lGL ' , ' - s ' , ' GL_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' , ' - s ' , ' DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1 ' , ' - s ' , ' OFFSCREEN_FRAMEBUFFER = 1 ' ] <nl> def test_webgl_offscreen_canvas_in_proxied_pthread ( self ) : <nl> <nl> @ requires_threads <nl> @ requires_graphics_hardware <nl> + @ requires_offscreen_canvas <nl> def test_webgl_resize_offscreencanvas_from_main_thread ( self ) : <nl> for args1 in [ [ ] , [ ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ] : <nl> for args2 in [ [ ] , [ ' - DTEST_SYNC_BLOCKING_LOOP = 1 ' ] ] : <nl> def test_fetch_response_headers ( self ) : <nl> self . btest ( ' fetch / response_headers . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] , also_asmjs = True ) <nl> <nl> # Test emscripten_fetch ( ) usage to stream a XHR in to memory without storing the full file in memory <nl> - @ no_chrome ( ' depends on moz - chunked - arraybuffer ' ) <nl> def test_fetch_stream_file ( self ) : <nl> + self . skipTest ( ' moz - chunked - arraybuffer was firefox - only and has been removed ' ) <nl> # Strategy : create a large 128MB file , and compile with a small 16MB Emscripten heap , so that the tested file <nl> # won ' t fully fit in the heap . This verifies that streaming works properly . <nl> s = ' 12345678 ' <nl>
|
Fix Firefox on CI ( )
|
emscripten-core/emscripten
|
a4a92f4d338004551b5a9039ceeb2df84ac9628b
|
2019-07-13T23:59:26Z
|
mmm a / tensorflow / core / lib / io / buffered_inputstream . cc <nl> ppp b / tensorflow / core / lib / io / buffered_inputstream . cc <nl> Status BufferedInputStream : : FillBuffer ( ) { <nl> Status s = input_stream_ - > ReadNBytes ( size_ , & buf_ ) ; <nl> pos_ = 0 ; <nl> limit_ = buf_ . size ( ) ; <nl> - if ( buf_ . empty ( ) ) { <nl> - DCHECK ( ! s . ok ( ) ) ; <nl> + if ( ! s . ok ( ) ) { <nl> file_status_ = s ; <nl> } <nl> return s ; <nl> Status BufferedInputStream : : ReadNBytes ( int64 bytes_to_read , tstring * result ) { <nl> bytes_to_read ) ; <nl> } <nl> result - > clear ( ) ; <nl> - if ( ! file_status_ . ok ( ) & & bytes_to_read > 0 ) { <nl> + if ( pos_ = = limit_ & & ! file_status_ . ok ( ) & & bytes_to_read > 0 ) { <nl> return file_status_ ; <nl> } <nl> result - > reserve ( bytes_to_read ) ; <nl> mmm a / tensorflow / core / lib / io / buffered_inputstream_test . cc <nl> ppp b / tensorflow / core / lib / io / buffered_inputstream_test . cc <nl> static std : : vector < int > BufferSizes ( ) { <nl> 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 65536 } ; <nl> } <nl> <nl> + / / This class will only return OutOfRange error once to make sure that <nl> + / / BufferedInputStream is able to cache the error . <nl> + class ReadOnceInputStream : public InputStreamInterface { <nl> + public : <nl> + ReadOnceInputStream ( ) : start_ ( true ) { } <nl> + <nl> + virtual Status ReadNBytes ( int64 bytes_to_read , tstring * result ) { <nl> + if ( bytes_to_read < 11 ) { <nl> + return errors : : InvalidArgument ( " Not reading all bytes : " , bytes_to_read ) ; <nl> + } <nl> + if ( start_ ) { <nl> + * result = " 0123456789 " ; <nl> + start_ = false ; <nl> + return errors : : OutOfRange ( " Out of range . " ) ; <nl> + } <nl> + return errors : : InvalidArgument ( <nl> + " Redudant call to ReadNBytes after an OutOfRange error . " ) ; <nl> + } <nl> + <nl> + int64 Tell ( ) const override { return start_ ? 0 : 10 ; } <nl> + <nl> + / / Resets the stream to the beginning . <nl> + Status Reset ( ) override { <nl> + start_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + private : <nl> + bool start_ ; <nl> + } ; <nl> + <nl> TEST ( BufferedInputStream , ReadLine_Empty ) { <nl> Env * env = Env : : Default ( ) ; <nl> string fname ; <nl> TEST ( BufferedInputStream , ReadNBytes ) { <nl> } <nl> } <nl> <nl> + TEST ( BufferedInputStream , OutOfRangeCache ) { <nl> + for ( auto buf_size : BufferSizes ( ) ) { <nl> + if ( buf_size < 11 ) { <nl> + continue ; <nl> + } <nl> + ReadOnceInputStream input_stream ; <nl> + tstring read ; <nl> + BufferedInputStream in ( & input_stream , buf_size ) ; <nl> + EXPECT_EQ ( 0 , in . Tell ( ) ) ; <nl> + TF_ASSERT_OK ( in . ReadNBytes ( 3 , & read ) ) ; <nl> + EXPECT_EQ ( read , " 012 " ) ; <nl> + EXPECT_EQ ( 3 , in . Tell ( ) ) ; <nl> + TF_ASSERT_OK ( ( in . ReadNBytes ( 7 , & read ) ) ) ; <nl> + EXPECT_EQ ( read , " 3456789 " ) ; <nl> + EXPECT_EQ ( 10 , in . Tell ( ) ) ; <nl> + Status s = in . ReadNBytes ( 5 , & read ) ; <nl> + / / Make sure the read is failing with OUT_OF_RANGE error . If it is failing <nl> + / / with other errors , it is not caching the OUT_OF_RANGE properly . <nl> + EXPECT_EQ ( error : : OUT_OF_RANGE , s . code ( ) ) < < s ; <nl> + EXPECT_EQ ( read , " " ) ; <nl> + / / Empty read shouldn ' t cause an error even at the end of the file . <nl> + TF_ASSERT_OK ( in . ReadNBytes ( 0 , & read ) ) ; <nl> + EXPECT_EQ ( read , " " ) ; <nl> + } <nl> + } <nl> + <nl> TEST ( BufferedInputStream , SkipNBytes ) { <nl> Env * env = Env : : Default ( ) ; <nl> string fname ; <nl>
|
Cache the out - of - range status and avoid repeating reads in BufferedInputStream .
|
tensorflow/tensorflow
|
3e2b03121175aebd965174f2ee55efd5aa903039
|
2020-03-23T23:18:24Z
|
mmm a / README . md <nl> ppp b / README . md <nl> Please make sure you use Python 2 . x . Python 3 . x is not supported currently . <nl> <nl> # # # # macOS <nl> <nl> - To build for macOS , you need [ Xcode 11 beta 6 ] ( https : / / developer . apple . com / xcode / downloads / ) . <nl> + To build for macOS , you need [ Xcode 11 . 2 ] ( https : / / developer . apple . com / xcode / downloads / ) . <nl> The required version of Xcode changes frequently , and is often a beta release . <nl> Check this document or the host information on < https : / / ci . swift . org > for the <nl> current required version . <nl>
|
Update the Xcode version to 11 . 2
|
apple/swift
|
511a26bfb01707ba8afd9c9a981434b78d9e1249
|
2019-11-07T09:51:52Z
|
mmm a / test / mjsunit / regress / regress - 962 . js <nl> ppp b / test / mjsunit / regress / regress - 962 . js <nl> F . prototype . foo = function ( ) { <nl> <nl> var ctx = new F ; <nl> <nl> - for ( var i = 0 ; i < 10000000 ; i + + ) ctx . foo ( ) ; <nl> + for ( var i = 0 ; i < 10000 ; i + + ) ctx . foo ( ) ; <nl>
|
Change the number of iterations in mjsunit / regress - 962
|
v8/v8
|
3b1152aed4afcc55b598d15481067ba96ac79f2c
|
2010-12-14T07:57:14Z
|
mmm a / test / core / security / fetch_oauth2 . cc <nl> ppp b / test / core / security / fetch_oauth2 . cc <nl> <nl> static grpc_call_credentials * create_sts_creds ( const char * json_file_path ) { <nl> grpc : : experimental : : StsCredentialsOptions options ; <nl> if ( strlen ( json_file_path ) = = 0 ) { <nl> - auto status = <nl> - grpc : : experimental : : StsCredentialsOptionsFromEnv ( & options ) ; <nl> + auto status = grpc : : experimental : : StsCredentialsOptionsFromEnv ( & options ) ; <nl> if ( ! status . ok ( ) ) { <nl> gpr_log ( GPR_ERROR , " % s " , status . error_message ( ) . c_str ( ) ) ; <nl> return nullptr ; <nl>
|
Fix formatting issue
|
grpc/grpc
|
fa0c73146c0a064355f238270b8dee6210d3724d
|
2020-06-30T00:28:11Z
|
mmm a / src / Layout . js <nl> ppp b / src / Layout . js <nl> var computeLayout = ( function ( ) { <nl> } <nl> } <nl> child . layout [ pos [ crossAxis ] ] + = leadingCrossDim ; <nl> + } else { <nl> + child . layout [ pos [ crossAxis ] ] + = getPadding ( node , leading [ crossAxis ] ) ; <nl> } <nl> } <nl> <nl> mmm a / src / __tests__ / Layout - test . js <nl> ppp b / src / __tests__ / Layout - test . js <nl> describe ( ' Layout ' , function ( ) { <nl> ) ; <nl> } ) ; <nl> <nl> + it ( ' should layout node with specified width ' , function ( ) { <nl> + testLayout ( <nl> + { style : { padding : 5 } , children : [ <nl> + { style : { position : ' absolute ' } } <nl> + ] } , <nl> + { width : 10 , height : 10 , top : 0 , left : 0 , children : [ <nl> + { width : 0 , height : 0 , top : 5 , left : 5 } <nl> + ] } <nl> + ) ; <nl> + } ) ; <nl> + <nl> it ( ' should layout randomly ' , function ( ) { <nl> function RNG ( seed ) { <nl> this . state = seed ; <nl> describe ( ' Layout ' , function ( ) { <nl> } <nl> function randEnum ( node , chance , attribute , enumValues ) { <nl> if ( rng . nextFloat ( ) < chance ) { <nl> - if ( attribute = = = ' position ' ) { <nl> - return ; <nl> - } <nl> node . style [ attribute ] = enumValues [ Math . floor ( rng . nextFloat ( ) * enumValues . length ) ] ; <nl> } <nl> } <nl>
|
position : absolute should respect cross padding
|
facebook/yoga
|
39cc1e9b01765b56e8773f83634d9dc2cb0af66c
|
2014-04-22T00:31:04Z
|
mmm a / cocos / 2d / ccMacros . h <nl> ppp b / cocos / 2d / ccMacros . h <nl> THE SOFTWARE . <nl> <nl> # ifndef CCASSERT <nl> # if COCOS2D_DEBUG > 0 <nl> - extern bool CC_DLL cc_assert_script_compatible ( const char * msg ) ; <nl> - # define CCASSERT ( cond , msg ) do { \ <nl> - if ( ! ( cond ) ) { \ <nl> - if ( ! cc_assert_script_compatible ( msg ) & & strlen ( msg ) ) \ <nl> - cocos2d : : log ( " Assert failed : % s " , msg ) ; \ <nl> - CC_ASSERT ( cond ) ; \ <nl> - } \ <nl> - } while ( 0 ) <nl> + # if CC_ENABLE_SCRIPT_BINDING <nl> + extern bool CC_DLL cc_assert_script_compatible ( const char * msg ) ; <nl> + # define CCASSERT ( cond , msg ) do { \ <nl> + if ( ! ( cond ) ) { \ <nl> + if ( ! cc_assert_script_compatible ( msg ) & & strlen ( msg ) ) \ <nl> + cocos2d : : log ( " Assert failed : % s " , msg ) ; \ <nl> + CC_ASSERT ( cond ) ; \ <nl> + } \ <nl> + } while ( 0 ) <nl> + # else <nl> + # define CCASSERT ( cond , msg ) CC_ASSERT ( cond ) <nl> + # endif <nl> # else <nl> - # define CCASSERT ( cond , msg ) <nl> + # define CCASSERT ( cond , msg ) <nl> # endif <nl> / / XXX : Backward compatible <nl> # define CCAssert CCASSERT <nl>
|
issue : fix linking error of missing functions .
|
cocos2d/cocos2d-x
|
a218369ecd417f3972904fdfdaebc8f517f5bdde
|
2014-02-20T09:01:13Z
|
mmm a / jstests / libs / retryable_writes_util . js <nl> ppp b / jstests / libs / retryable_writes_util . js <nl> var RetryableWritesUtil = ( function ( ) { <nl> return retryableWriteCommands . has ( cmdName ) ; <nl> } <nl> <nl> - return { isRetryableWriteCmdName : isRetryableWriteCmdName } ; <nl> + const kStorageEnginesWithoutDocumentLocking = new Set ( [ " ephemeralForTest " , " mmapv1 " ] ) ; <nl> + <nl> + / * * <nl> + * Returns true if the given storage engine supports retryable writes ( i . e . supports <nl> + * document - level locking ) . <nl> + * / <nl> + function storageEngineSupportsRetryableWrites ( storageEngineName ) { <nl> + return ! kStorageEnginesWithoutDocumentLocking . has ( storageEngineName ) ; <nl> + } <nl> + <nl> + return { isRetryableWriteCmdName , storageEngineSupportsRetryableWrites } ; <nl> } ) ( ) ; <nl> mmm a / jstests / multiVersion / shell_retryable_writes_downgrade . js <nl> ppp b / jstests / multiVersion / shell_retryable_writes_downgrade . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / noPassthrough / auto_retry_on_network_error . js <nl> ppp b / jstests / noPassthrough / auto_retry_on_network_error . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / noPassthrough / retryable_writes_standalone_api . js <nl> ppp b / jstests / noPassthrough / retryable_writes_standalone_api . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / noPassthrough / shell_can_retry_writes . js <nl> ppp b / jstests / noPassthrough / shell_can_retry_writes . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / noPassthrough / transaction_reaper . js <nl> ppp b / jstests / noPassthrough / transaction_reaper . js <nl> <nl> ( function ( ) { <nl> ' use strict ' ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / replsets / retryable_writes_direct_write_to_config_transactions . js <nl> ppp b / jstests / replsets / retryable_writes_direct_write_to_config_transactions . js <nl> <nl> ( function ( ) { <nl> ' use strict ' ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / replsets / retryable_writes_failover . js <nl> ppp b / jstests / replsets / retryable_writes_failover . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / replsets / rollback_transaction_table . js <nl> ppp b / jstests / replsets / rollback_transaction_table . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / replsets / transaction_table_oplog_replay . js <nl> ppp b / jstests / replsets / transaction_table_oplog_replay . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / move_chunk_find_and_modify_with_write_retryability . js <nl> ppp b / jstests / sharding / move_chunk_find_and_modify_with_write_retryability . js <nl> load ( " jstests / sharding / move_chunk_with_session_helper . js " ) ; <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / move_chunk_insert_with_write_retryability . js <nl> ppp b / jstests / sharding / move_chunk_insert_with_write_retryability . js <nl> load ( " jstests / sharding / move_chunk_with_session_helper . js " ) ; <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / move_chunk_remove_with_write_retryability . js <nl> ppp b / jstests / sharding / move_chunk_remove_with_write_retryability . js <nl> load ( " jstests / sharding / move_chunk_with_session_helper . js " ) ; <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / move_chunk_update_with_write_retryability . js <nl> ppp b / jstests / sharding / move_chunk_update_with_write_retryability . js <nl> load ( " jstests / sharding / move_chunk_with_session_helper . js " ) ; <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / retryable_writes . js <nl> ppp b / jstests / sharding / retryable_writes . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / session_info_in_oplog . js <nl> ppp b / jstests / sharding / session_info_in_oplog . js <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl> mmm a / jstests / sharding / write_transactions_during_migration . js <nl> ppp b / jstests / sharding / write_transactions_during_migration . js <nl> load ( ' . / jstests / libs / chunk_manipulation_util . js ' ) ; <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> - if ( jsTest . options ( ) . storageEngine = = = " mmapv1 " ) { <nl> + load ( " jstests / libs / retryable_writes_util . js " ) ; <nl> + <nl> + if ( ! RetryableWritesUtil . storageEngineSupportsRetryableWrites ( jsTest . options ( ) . storageEngine ) ) { <nl> jsTestLog ( " Retryable writes are not supported , skipping test " ) ; <nl> return ; <nl> } <nl>
|
SERVER - 31941 Don ' t run retryable writes tests with ephemeralForTest storage engine
|
mongodb/mongo
|
aacd508f5092b433df5bf0ea0e1c03844fffc2bb
|
2017-11-21T19:46:24Z
|
new file mode 100644 <nl> index 00000000000 . . 303027b37da <nl> mmm / dev / null <nl> ppp b / Marlin / src / HAL / persistent_store_api . cpp <nl> <nl> + / * * <nl> + * Marlin 3D Printer Firmware <nl> + * Copyright ( C ) 2016 MarlinFirmware [ https : / / github . com / MarlinFirmware / Marlin ] <nl> + * <nl> + * Based on Sprinter and grbl . <nl> + * Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation , either version 3 of the License , or <nl> + * ( at your option ) any later version . <nl> + * <nl> + * This program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + # include " . . / inc / MarlinConfigPre . h " <nl> + <nl> + # if ENABLED ( EEPROM_SETTINGS ) <nl> + <nl> + # include " persistent_store_api . h " <nl> + PersistentStore persistentStore ; <nl> + <nl> + # endif <nl> mmm a / Marlin / src / HAL / persistent_store_api . h <nl> ppp b / Marlin / src / HAL / persistent_store_api . h <nl> <nl> - # ifndef _PERSISTENT_STORE_H_ <nl> - # define _PERSISTENT_STORE_H_ <nl> + / * * <nl> + * Marlin 3D Printer Firmware <nl> + * Copyright ( C ) 2016 MarlinFirmware [ https : / / github . com / MarlinFirmware / Marlin ] <nl> + * <nl> + * Based on Sprinter and grbl . <nl> + * Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation , either version 3 of the License , or <nl> + * ( at your option ) any later version . <nl> + * <nl> + * This program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + # pragma once <nl> <nl> # include < stddef . h > <nl> # include < stdint . h > <nl> class PersistentStore { <nl> } ; <nl> <nl> extern PersistentStore persistentStore ; <nl> - <nl> - # endif / / _PERSISTENT_STORE_H_ <nl> mmm a / Marlin / src / module / configuration_store . cpp <nl> ppp b / Marlin / src / module / configuration_store . cpp <nl> void MarlinSettings : : postprocess ( ) { <nl> <nl> # if ENABLED ( EEPROM_SETTINGS ) <nl> # include " . . / HAL / persistent_store_api . h " <nl> - PersistentStore persistentStore ; <nl> <nl> # define DUMMY_PID_VALUE 3000 . 0f <nl> # define EEPROM_START ( ) int eeprom_index = EEPROM_OFFSET ; persistentStore . access_start ( ) <nl>
|
Followup for persistent_store_api . h
|
MarlinFirmware/Marlin
|
6a8b906318dc182f5566a9777108360514bfbd35
|
2018-08-13T22:43:35Z
|
mmm a / osquery / tables / networking / linux / routes . cpp <nl> ppp b / osquery / tables / networking / linux / routes . cpp <nl> namespace osquery { <nl> namespace tables { <nl> <nl> # define MAX_NETLINK_SIZE 8192 <nl> - # define MAX_NETLINK_LATENCY 2000 <nl> + # define MAX_NETLINK_ATTEMPTS 8 <nl> <nl> std : : string getNetlinkIP ( int family , const char * buffer ) { <nl> char dst [ INET6_ADDRSTRLEN ] ; <nl> Status readNetlink ( int socket_fd , int seq , char * output , size_t * size ) { <nl> <nl> size_t message_size = 0 ; <nl> do { <nl> - int latency = 0 ; <nl> + size_t latency = 0 ; <nl> + size_t total_bytes = 0 ; <nl> ssize_t bytes = 0 ; <nl> while ( bytes = = 0 ) { <nl> bytes = recv ( socket_fd , output , MAX_NETLINK_SIZE - message_size , 0 ) ; <nl> if ( bytes < 0 ) { <nl> + / / Unrecoverable NETLINK error , bail . <nl> return Status ( 1 , " Could not read from NETLINK " ) ; <nl> - } else if ( latency > = MAX_NETLINK_LATENCY ) { <nl> + } <nl> + <nl> + / / Bytes were returned by we might need to read more . <nl> + total_bytes + = bytes ; <nl> + if ( latency > = MAX_NETLINK_ATTEMPTS ) { <nl> + / / Too many attempts to read bytes have occurred . <nl> + / / Prevent the NETLINK socket from handing and bail . <nl> return Status ( 1 , " Netlink timeout " ) ; <nl> } else if ( bytes = = 0 ) { <nl> + if ( total_bytes > 0 ) { <nl> + / / Bytes were read , but now no more are available , attempt to parse <nl> + / / the received NETLINK message . <nl> + break ; <nl> + } <nl> : : usleep ( 20 ) ; <nl> - latency + = 20 ; <nl> + latency + = 1 ; <nl> } <nl> } <nl> <nl> / / Assure valid header response , and not an error type . <nl> - nl_hdr = ( struct nlmsghdr * ) output ; <nl> + nl_hdr = ( struct nlmsghdr * ) output ; <nl> if ( NLMSG_OK ( nl_hdr , bytes ) = = 0 | | nl_hdr - > nlmsg_type = = NLMSG_ERROR ) { <nl> return Status ( 1 , " Read invalid NETLINK message " ) ; <nl> } <nl> Status readNetlink ( int socket_fd , int seq , char * output , size_t * size ) { <nl> if ( ( nl_hdr - > nlmsg_flags & NLM_F_MULTI ) = = 0 ) { <nl> break ; <nl> } <nl> - } while ( static_cast < pid_t > ( nl_hdr - > nlmsg_seq ) ! = seq | | static_cast < pid_t > ( nl_hdr - > nlmsg_pid ) ! = getpid ( ) ) ; <nl> + } while ( static_cast < pid_t > ( nl_hdr - > nlmsg_seq ) ! = seq | | <nl> + static_cast < pid_t > ( nl_hdr - > nlmsg_pid ) ! = getpid ( ) ) ; <nl> <nl> * size = message_size ; <nl> return Status ( 0 , " OK " ) ; <nl> void genNetlinkRoutes ( const struct nlmsghdr * netlink_msg , QueryData & results ) { <nl> int mask = 0 ; <nl> char interface [ IF_NAMESIZE ] ; <nl> <nl> - struct rtmsg * message = static_cast < struct rtmsg * > ( NLMSG_DATA ( netlink_msg ) ) ; <nl> + struct rtmsg * message = static_cast < struct rtmsg * > ( NLMSG_DATA ( netlink_msg ) ) ; <nl> struct rtattr * attr = static_cast < struct rtattr * > ( RTM_RTA ( message ) ) ; <nl> uint32_t attr_size = RTM_PAYLOAD ( netlink_msg ) ; <nl> <nl> mmm a / tools / provision . sh <nl> ppp b / tools / provision . sh <nl> function main ( ) { <nl> <nl> cd " $ SCRIPT_DIR / . . / " <nl> <nl> + sudo pip install - - upgrade pip <nl> sudo pip install - r requirements . txt <nl> <nl> # Reset any work or artifacts from build tests in TP . <nl> mmm a / tools / provision / centos . sh <nl> ppp b / tools / provision / centos . sh <nl> function main_centos ( ) { <nl> package doxygen <nl> package byacc <nl> package flex <nl> - package bison <nl> <nl> if [ [ $ DISTRO = " centos6 " ] ] ; then <nl> remove_package autoconf <nl> function main_centos ( ) { <nl> install_automake <nl> install_libtool <nl> <nl> + install_bison <nl> + <nl> package file - libs <nl> elif [ [ $ DISTRO = " centos7 " ] ] ; then <nl> package autoconf <nl> package automake <nl> package libtool <nl> package file - devel <nl> + <nl> + package bison <nl> fi <nl> <nl> install_snappy <nl>
|
Merge pull request from theopolis / fix_1660
|
osquery/osquery
|
e5bc6410babf96e69a678482cb437c07e99338ba
|
2015-12-03T07:56:39Z
|
mmm a / test / NameBinding / name_lookup . swift <nl> ppp b / test / NameBinding / name_lookup . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift <nl> + / / RUN : % target - typecheck - verify - swift - typo - correction - limit 100 <nl> <nl> class ThisBase1 { <nl> init ( ) { } <nl>
|
Update test with a higher typo correction limit
|
apple/swift
|
7deafb262db176b515b23eb8f8eb1989b555d397
|
2017-07-10T20:14:07Z
|
new file mode 100644 <nl> index 0000000000 . . 117d9bf389 <nl> mmm / dev / null <nl> ppp b / code / data_structures / van_emde_boas_tree / van_emde_boas . cpp <nl> <nl> + # include < iostream > <nl> + # include < math . h > <nl> + <nl> + using namespace std ; <nl> + <nl> + typedef struct VEB { <nl> + int u ; <nl> + int min , max ; <nl> + int count ; <nl> + struct VEB * summary , * * cluster ; <nl> + } VEB ; <nl> + <nl> + int high ( int x , int u ) { <nl> + return ( int ) ( x / ( int ) sqrt ( u ) ) ; <nl> + } <nl> + <nl> + int low ( int x , int u ) { <nl> + return ( x % ( int ) sqrt ( u ) ) ; <nl> + } <nl> + <nl> + int VEBmin ( VEB * V ) { <nl> + return V - > min ; <nl> + } <nl> + <nl> + int VEBmax ( VEB * V ) { <nl> + return V - > max ; <nl> + } <nl> + <nl> + VEB * insert ( VEB * V , int x , int u ) { <nl> + if ( ! V ) { <nl> + V = ( VEB * ) malloc ( sizeof ( VEB ) ) ; <nl> + V - > min = V - > max = x ; <nl> + V - > u = u ; <nl> + V - > count = 1 ; <nl> + if ( u > 2 ) { <nl> + V - > summary = NULL ; <nl> + V - > cluster = ( VEB * * ) calloc ( sqrt ( u ) , sizeof ( VEB * ) ) ; <nl> + } else { <nl> + V - > summary = NULL ; <nl> + V - > cluster = NULL ; <nl> + } <nl> + } else if ( V - > min = = x | | V - > max = = x ) { <nl> + V - > count = 1 ; <nl> + } else { <nl> + if ( x < V - > min ) { <nl> + if ( V - > min = = V - > max ) { <nl> + V - > min = x ; <nl> + V - > count = 1 ; <nl> + return V ; <nl> + } <nl> + } else if ( x > V - > max ) { <nl> + int aux = V - > max ; <nl> + V - > max = x ; <nl> + x = aux ; <nl> + V - > count = 1 ; <nl> + if ( V - > min = = x ) <nl> + return V ; <nl> + } <nl> + if ( V - > u > 2 ) { <nl> + if ( V - > cluster [ high ( x , V - > u ) ] = = NULL ) <nl> + V - > summary = insert ( V - > summary , high ( x , V - > u ) , sqrt ( V - > u ) ) ; <nl> + V - > cluster [ high ( x , V - > u ) ] = <nl> + insert ( V - > cluster [ high ( x , V - > u ) ] , low ( x , V - > u ) , sqrt ( V - > u ) ) ; <nl> + } <nl> + } <nl> + return V ; <nl> + } <nl> + <nl> + VEB * deleteVEB ( VEB * V , int x ) { <nl> + if ( V - > min = = V - > max ) { <nl> + free ( V ) ; <nl> + return NULL ; <nl> + } <nl> + else if ( x = = V - > min | | x = = V - > max ) { <nl> + if ( ! - - V - > count ) { <nl> + if ( V - > summary ) { <nl> + int cluster = VEBmin ( V - > summary ) ; <nl> + int new_min = VEBmin ( V - > cluster [ cluster ] ) ; <nl> + V - > min = cluster * ( int ) sqrt ( V - > u ) + new_min ; <nl> + V - > count = V - > cluster [ cluster ] - > count ; <nl> + ( V - > cluster [ cluster ] ) - > count = 1 ; <nl> + if ( ( V - > cluster [ cluster ] ) - > min = = ( V - > cluster [ cluster ] ) - > max ) <nl> + ( V - > cluster [ cluster ] ) - > count = 1 ; <nl> + V - > cluster [ cluster ] = deleteVEB ( V - > cluster [ cluster ] , new_min ) ; <nl> + if ( V - > cluster [ cluster ] = = NULL ) <nl> + V - > summary = deleteVEB ( V - > summary , cluster ) ; <nl> + } else { <nl> + V - > min = V - > max ; <nl> + V - > count = 1 ; <nl> + } <nl> + } <nl> + } <nl> + else { <nl> + V - > cluster [ high ( x , V - > u ) ] = deleteVEB ( V - > cluster [ high ( x , V - > u ) ] , low ( x , V - > u ) ) ; <nl> + if ( V - > cluster [ high ( x , V - > u ) ] = = NULL ) <nl> + V - > summary = deleteVEB ( V - > summary , high ( x , V - > u ) ) ; <nl> + } <nl> + return V ; <nl> + } <nl> + <nl> + int elements ( VEB * V , int x ) { <nl> + if ( ! V ) <nl> + return 0 ; <nl> + else if ( V - > min = = x | | V - > max = = x ) <nl> + return V - > count ; <nl> + else { <nl> + if ( V - > cluster ) <nl> + return elements ( V - > cluster [ high ( x , V - > u ) ] , low ( x , V - > u ) ) ; <nl> + else <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + void printVEB ( VEB * V , int u ) { <nl> + for ( int i = 0 ; i < u ; + + i ) { <nl> + printf ( " VEB [ % d ] = % d \ n " , i , elements ( V , i ) ) ; <nl> + } <nl> + } <nl> + <nl> + int main ( ) { <nl> + int u = 4 ; <nl> + int sqrt_u = sqrt ( u ) ; <nl> + VEB * V = NULL ; <nl> + <nl> + if ( sqrt_u * sqrt_u ! = u ) { <nl> + printf ( " Invalid ' u ' : Must be a perfect square \ n " ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + V = insert ( V , 0 , u ) ; <nl> + V = insert ( V , 1 , u ) ; <nl> + V = insert ( V , 2 , u ) ; <nl> + <nl> + printVEB ( V , u ) ; <nl> + printf ( " \ n \ n " ) ; <nl> + <nl> + V = deleteVEB ( V , 0 ) ; <nl> + V = deleteVEB ( V , 1 ) ; <nl> + <nl> + printVEB ( V , u ) ; <nl> + return 0 ; <nl> + } <nl> \ No newline at end of file <nl>
|
Merge pull request from Trion129 / master
|
OpenGenus/cosmos
|
684adb18a8dbbb94efc8ef63e6264a0ba7f51da4
|
2017-10-18T11:32:21Z
|
mmm a / docs / SIL . rst <nl> ppp b / docs / SIL . rst <nl> normal uses always before consuming uses . Any such violations of ownership <nl> semantics would trigger a static SILVerifier error allowing us to know that we <nl> do not have any leaks or use - after - frees in the above code . <nl> <nl> + Ownership Kind <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + <nl> The semantics in the previous example is of just one form of ownership semantics <nl> - supported : " owned " semantics . In SIL , we allow for values to have one of four <nl> - different ownership kinds : <nl> + supported : " owned " semantics . In SIL , we map these " ownership semantics " into a <nl> + form that a compiler can reason about by mapping semantics onto a lattice with <nl> + the following elements : ` None ` _ , ` Owned ` _ , ` Guaranteed ` _ , ` Unowned ` _ , ` Any ` _ . We <nl> + call this the lattice of " Ownership Kinds " and each individual value an <nl> + " Ownership Kind " . This lattice is defined as a 3 - level lattice with : : <nl> + <nl> + 1 . None being Top . <nl> + 2 . Any being Bottom . <nl> + 3 . All non - Any , non - None OwnershipKinds being defined as a mid - level elements of the lattice <nl> + <nl> + We can graphically represent the lattice via a diagram like the following : : <nl> + <nl> + + mmm - + <nl> + + mmmmmm - - | None | mmmmmmmmm - - + <nl> + | + mmm - + | <nl> + | | | <nl> + v v v ^ <nl> + + mmmmmm - + + mmm - - + mmmmmm + + mmmmmmmmm + | <nl> + | Owned | | Guaranteed | | Unowned | + mmm Value Ownership Kinds and <nl> + + mmmmmm - + + mmm - - + mmmmmm + + mmmmmmmmm + Ownership Constraints <nl> + | | | <nl> + | v | + mmm Only Ownership Constraints <nl> + | + mmm + | | <nl> + + mmmmmmmmm > | Any | < mmmmmmmmm - - + v <nl> + + mmm + <nl> + <nl> + One moves down the lattice by performing a " meet " operation : : <nl> + <nl> + None meet OtherOwnershipKind - > OtherOwnershipKind <nl> + Unowned meet Owned - > Any <nl> + Owned meet Guaranteed - > Any <nl> + <nl> + and one moves up the lattice by performing a " join " operation , e . x . : : <nl> + <nl> + Any join OtherOwnershipKind - > OtherOwnershipKind <nl> + Owned join Any - > Owned <nl> + Owned join Guaranteed - > None <nl> + <nl> + This lattice is applied to SIL by requiring well formed SIL to : <nl> + <nl> + 1 . Define a static map of each SIL value to an OwnershipKind that classify the <nl> + semantics that the SIL value obeys . We call this subset of OwnershipKind to <nl> + be the set of ` Value Ownership Kind ` _ : ` None ` _ , ` Unowned ` _ , ` Guaranteed ` _ , <nl> + ` Owned ` _ ( note conspiciously missing ` Any ` _ ) . This is because in our model <nl> + ` Any ` _ represents an unknown ownership semantics and since our model is <nl> + statically strict , we do not allow for values to have unknown ownership . <nl> + <nl> + 2 . Define a static map from each operand of a SILInstruction , ` i ` , to an <nl> + ( Ownership Kind , Boolean ) called the operand ' s ` Ownership Constraint ` _ . The <nl> + Ownership Kind element of the ` Ownership Constraint ` _ acts as a a static <nl> + " constraint " on the Value Ownership Kind that the operand ' s value can be mapped <nl> + to . The second boolean value is used to know if an operand will end the <nl> + lifetime of the incoming value when checking dataflow rules . The dataflow <nl> + rules that each ` Value Ownership Kind ` _ obeys is documented for each <nl> + ` Value Ownership Kind ` _ in its detailed description below . <nl> + <nl> + Then we take these static definitions and require that valid SIL has the <nl> + property that given a value ` ` v ` ` , an instruction ` ` i ` ` and said instruction ' s <nl> + operand ` ` operand ( i ) ` ` , that ` ` v ` ` can be used as a value in ` ` operand ( i ) ` ` only <nl> + if the join of the ownership constraint of ` ` operand ( i ) ` ` with ` ` v ` ` is the <nl> + ownership kind of ` ` v ` ` ! In symbols , we must have the following join is <nl> + defined : : <nl> + <nl> + join : ( OwnershipConstraint , ValueOwnershipKind ) - > ValueOwnershipKind <nl> + OwnershipConstraint ( operand ( i ) ) join ValueOwnershipKind ( v ) = ValueOwnershipKind ( v ) <nl> + <nl> + In prose , a value can be passed to an operand if applying the operand ' s <nl> + ownership constraint to the value ' s ownership does not change the value ' s <nl> + ownership . Operationally this has a few interesting effects on SIL : : <nl> + <nl> + 1 . We have defined away invalid value - operand ( aka def - use ) pairing since the <nl> + SILVerifier validates the aforementioned relationship on all SIL values , <nl> + uses at all points of the pipeline until ossa is lowered . <nl> + <nl> + 2 . Many SIL instructions do not care about the ownership kind that their value <nl> + will take . They can just define all of their operand ' s as having an <nl> + ownership constraint of Any . <nl> + <nl> + Now lets go into more depth upon ` Value Ownership Kind ` _ and ` Ownership Constraint ` _ . <nl> + <nl> + Value Ownership Kind <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + <nl> + As mentioned above , each SIL value is statically mapped to an ` Ownership Kind ` _ <nl> + called the value ' s " ValueOwnershipKind " that classify the semantics of the <nl> + value . Below , we map each ValueOwnershipKind to a short summary of the semantics <nl> + implied upon the parent value : <nl> <nl> * * * None * * . This is used to represent values that do not require memory <nl> management and are outside of Ownership SSA invariants . Examples : trivial <nl> different ownership kinds : <nl> bitcasting a trivial type to a non - trivial type . This value should never be <nl> consumed . <nl> <nl> - We describe each of these semantics in more detail below . <nl> - <nl> - Value Ownership Kind <nl> - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + We describe each of these semantics in below in more detail . <nl> <nl> Owned <nl> ` ` ` ` ` <nl> This is a form of ownership that is used to model two different use cases : <nl> trivial pointer to a class . In that case , since we have no reason to assume <nl> that the object will remain alive , we need to make a copy of the value . <nl> <nl> + Ownership Constraint <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + <nl> + NOTE : We assume that one has read the section above on ` Ownership Kind ` _ . <nl> + <nl> + As mentioned above , every operand ` ` operand ( i ) ` ` of a SIL instruction ` ` i ` ` has <nl> + statically mapped to it : <nl> + <nl> + 1 . An ownership kind that acts as an " Ownership Constraint " upon what " Ownership <nl> + Kind " a value can take . <nl> + <nl> + 2 . A boolean value that defines whether or not the execution of the operand ' s <nl> + instruction will cause the operand ' s value to be invalidated . This is often <nl> + times referred to as an operand acting as a " lifetime ending use " . <nl> + <nl> Forwarding Uses <nl> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> <nl> - NOTE : In the following , we assumed that one read the section above , ` Value Ownership Kind ` _ . <nl> + NOTE : In the following , we assumed that one read the section above , ` Ownership <nl> + Kind ` _ , ` Value Ownership Kind ` _ and ` Ownership Constraint ` _ . <nl> <nl> A subset of SIL instructions define the value ownership kind of their results in <nl> terms of the value ownership kind of their operands . Such an instruction is <nl>
|
Merge pull request from gottesmm / pr - 442f09fe972ba38c706b52acd381ab5982bd6e07
|
apple/swift
|
e54dd22073945fcee648201ee31d1884792744b0
|
2020-12-18T04:16:30Z
|
mmm a / tests / lua - tests / src / ExtensionTest / ExtensionTest . lua <nl> ppp b / tests / lua - tests / src / ExtensionTest / ExtensionTest . lua <nl> local function runNotificationCenterTest ( ) <nl> cc . NotificationCenter : getInstance ( ) : postNotification ( NotificationCenterParam . MSG_SWITCH_STATE , selectedItem ) <nl> end <nl> <nl> - local switchlabel1 = cc . LabelTTF : create ( " switch off " , " Marker Felt " , 26 ) <nl> - local switchlabel2 = cc . LabelTTF : create ( " switch on " , " Marker Felt " , 26 ) <nl> + local switchlabel1 = cc . Label : create ( " switch off " , " Marker Felt " , 26 ) <nl> + local switchlabel2 = cc . Label : create ( " switch on " , " Marker Felt " , 26 ) <nl> local switchitem1 = cc . MenuItemLabel : create ( switchlabel1 ) <nl> local switchitem2 = cc . MenuItemLabel : create ( switchlabel2 ) <nl> local switchitem = cc . MenuItemToggle : create ( switchitem1 ) <nl> local function runNotificationCenterTest ( ) <nl> lightArray [ i ] : setPosition ( cc . p ( 100 , s . height / 4 * i ) ) <nl> pLayer : addChild ( lightArray [ i ] ) <nl> <nl> - local connectlabel1 = cc . LabelTTF : create ( " not connected " , " Marker Felt " , 26 ) <nl> + local connectlabel1 = cc . Label : create ( " not connected " , " Marker Felt " , 26 ) <nl> <nl> - local connectlabel2 = cc . LabelTTF : create ( " connected " , " Marker Felt " , 26 ) <nl> + local connectlabel2 = cc . Label : create ( " connected " , " Marker Felt " , 26 ) <nl> local connectitem1 = cc . MenuItemLabel : create ( connectlabel1 ) <nl> local connectitem2 = cc . MenuItemLabel : create ( connectlabel2 ) <nl> local connectitem = cc . MenuItemToggle : create ( connectitem1 ) <nl> local function runCCControlTest ( ) <nl> pLayer : addChild ( pRibbon ) <nl> <nl> - - Add the title <nl> - pSceneTitleLabel = cc . LabelTTF : create ( " Title " , " Arial " , 12 ) <nl> + pSceneTitleLabel = cc . Label : create ( " Title " , " Arial " , 12 ) <nl> pSceneTitleLabel : setPosition ( cc . p ( VisibleRect : center ( ) . x , VisibleRect : top ( ) . y - pSceneTitleLabel : getContentSize ( ) . height / 2 - 5 ) ) <nl> pLayer : addChild ( pSceneTitleLabel , 1 ) <nl> pSceneTitleLabel : setString ( pStrTitle ) <nl> local function runCCControlTest ( ) <nl> <nl> local screenSize = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - - Add a label in which the slider value will be displayed <nl> - local pDisplayValueLabel = cc . LabelTTF : create ( " Move the slider thumb ! \ nThe lower slider is restricted . " , " Marker Felt " , 32 ) <nl> + local pDisplayValueLabel = cc . Label : create ( " Move the slider thumb ! \ nThe lower slider is restricted . " , " Marker Felt " , 32 ) <nl> pDisplayValueLabel : retain ( ) <nl> pDisplayValueLabel : setAnchorPoint ( cc . p ( 0 . 5 , - 1 . 0 ) ) <nl> pDisplayValueLabel : setPosition ( cc . p ( screenSize . width / 1 . 7 , screenSize . height / 2 . 0 ) ) <nl> local function runCCControlTest ( ) <nl> pNode : addChild ( pBackground ) <nl> dLayer_width = dLayer_width + pBackground : getContentSize ( ) . width <nl> <nl> - pColorLabel = cc . LabelTTF : create ( " # color " , " Marker Felt " , 30 ) <nl> + pColorLabel = cc . Label : create ( " # color " , " Marker Felt " , 30 ) <nl> pColorLabel : retain ( ) <nl> pColorLabel : setPosition ( pBackground : getPosition ( ) ) <nl> pNode : addChild ( pColorLabel ) <nl> local function runCCControlTest ( ) <nl> pNode : addChild ( pBackground ) <nl> dLayer_width = dLayer_width + pBackground : getContentSize ( ) . width <nl> <nl> - local pDisplayValueLabel = cc . LabelTTF : create ( " # color " , " Marker Felt " , 30 ) <nl> + local pDisplayValueLabel = cc . Label : create ( " # color " , " Marker Felt " , 30 ) <nl> pDisplayValueLabel : retain ( ) <nl> <nl> pDisplayValueLabel : setPosition ( pBackground : getPosition ( ) ) <nl> local function runCCControlTest ( ) <nl> local pBackgroundButton = cc . Scale9Sprite : create ( " extensions / button . png " ) <nl> local pBackgroundHighlightedButton = cc . Scale9Sprite : create ( " extensions / buttonHighlighted . png " ) <nl> <nl> - pTitleButton = cc . LabelTTF : create ( pStrTitle , " Marker Felt " , 30 ) <nl> + pTitleButton = cc . Label : create ( pStrTitle , " Marker Felt " , 30 ) <nl> <nl> pTitleButton : setColor ( cc . c3b ( 159 , 168 , 176 ) ) <nl> <nl> local function runCCControlTest ( ) <nl> local pBackgroundHighlightedButton = cc . Scale9Sprite : create ( " extensions / buttonHighlighted . png " ) <nl> pBackgroundHighlightedButton : setPreferredSize ( cc . size ( 45 , 45 ) ) <nl> <nl> - local pTitleButton = cc . LabelTTF : create ( pStrTitle , " Marker Felt " , 30 ) <nl> + local pTitleButton = cc . Label : create ( pStrTitle , " Marker Felt " , 30 ) <nl> <nl> pTitleButton : setColor ( cc . c3b ( 159 , 168 , 176 ) ) <nl> <nl> local function runCCControlTest ( ) <nl> <nl> - - Add a label in which the button events will be displayed <nl> local pDisplayValueLabel = nil <nl> - pDisplayValueLabel = cc . LabelTTF : create ( " No Event " , " Marker Felt " , 32 ) <nl> + pDisplayValueLabel = cc . Label : create ( " No Event " , " Marker Felt " , 32 ) <nl> pDisplayValueLabel : setAnchorPoint ( cc . p ( 0 . 5 , - 1 ) ) <nl> pDisplayValueLabel : setPosition ( cc . p ( screenSize . width / 2 . 0 , screenSize . height / 2 . 0 ) ) <nl> pLayer : addChild ( pDisplayValueLabel , 1 ) <nl> local function runCCControlTest ( ) <nl> local pBackgroundButton = cc . Scale9Sprite : create ( " extensions / button . png " ) <nl> local pBackgroundHighlightedButton = cc . Scale9Sprite : create ( " extensions / buttonHighlighted . png " ) <nl> <nl> - local pTitleButtonLabel = cc . LabelTTF : create ( " Touch Me ! " , " Marker Felt " , 30 ) <nl> + local pTitleButtonLabel = cc . Label : create ( " Touch Me ! " , " Marker Felt " , 30 ) <nl> pTitleButtonLabel : setColor ( cc . c3b ( 159 , 168 , 176 ) ) <nl> <nl> local pControlButton = cc . ControlButton : create ( pTitleButtonLabel , pBackgroundButton ) <nl> local function runCCControlTest ( ) <nl> <nl> dLayer_width = dLayer_width + pBackground : getContentSize ( ) . width <nl> <nl> - local pDisplayValueLabel = cc . LabelTTF : create ( " " , " HelveticaNeue - Bold " , 30 ) <nl> + local pDisplayValueLabel = cc . Label : create ( " " , " HelveticaNeue - Bold " , 30 ) <nl> pDisplayValueLabel : setPosition ( pBackground : getPosition ( ) ) <nl> pNode : addChild ( pDisplayValueLabel ) <nl> <nl> local function runCCControlTest ( ) <nl> background : setPosition ( cc . p ( layer_width + background : getContentSize ( ) . width / 2 . 0 , 0 ) ) <nl> pNode : addChild ( background ) <nl> <nl> - local pDisplayValueLabel = cc . LabelTTF : create ( " 0 " , " HelveticaNeue - Bold " , 30 ) <nl> + local pDisplayValueLabel = cc . Label : create ( " 0 " , " HelveticaNeue - Bold " , 30 ) <nl> <nl> pDisplayValueLabel : setPosition ( background : getPosition ( ) ) <nl> pNode : addChild ( pDisplayValueLabel ) <nl> local function runEditBoxTest ( ) <nl> pBg : setPosition ( cc . p ( visibleOrigin . x + visibleSize . width / 2 , visibleOrigin . y + visibleSize . height / 2 ) ) <nl> newLayer : addChild ( pBg ) <nl> <nl> - local TTFShowEditReturn = cc . LabelTTF : create ( " No edit control return ! " , " " , 30 ) <nl> + local TTFShowEditReturn = cc . Label : create ( " No edit control return ! " , " " , 30 ) <nl> TTFShowEditReturn : setPosition ( cc . p ( visibleOrigin . x + visibleSize . width / 2 , visibleOrigin . y + visibleSize . height - 50 ) ) <nl> newLayer : addChild ( TTFShowEditReturn ) <nl> <nl> function TableViewTestLayer . tableCellAtIndex ( table , idx ) <nl> sprite : setPosition ( cc . p ( 0 , 0 ) ) <nl> cell : addChild ( sprite ) <nl> <nl> - label = cc . LabelTTF : create ( strValue , " Helvetica " , 20 . 0 ) <nl> + label = cc . Label : create ( strValue , " Helvetica " , 20 . 0 ) <nl> label : setPosition ( cc . p ( 0 , 0 ) ) <nl> label : setAnchorPoint ( cc . p ( 0 , 0 ) ) <nl> label : setTag ( 123 ) <nl>
|
Use the New Label in the Extension test case
|
cocos2d/cocos2d-x
|
403e96b943fb524b907838b3bb151e72d80a17fa
|
2014-03-29T02:34:52Z
|
mmm a / apps / sft / fpool . cpp <nl> ppp b / apps / sft / fpool . cpp <nl> sft : : ICFFeaturePool : : ICFFeaturePool ( cv : : Size m , int n ) : FeaturePool ( ) , model ( m ) <nl> { <nl> CV_Assert ( m ! = cv : : Size ( ) & & n > 0 ) ; <nl> fill ( nfeatures ) ; <nl> - builder = cv : : ChannelFeatureBuilder : : create ( ) ; <nl> - } <nl> - <nl> - void sft : : ICFFeaturePool : : preprocess ( cv : : InputArray frame , cv : : OutputArray integrals ) const <nl> - { <nl> - ( * builder ) ( frame , integrals ) ; <nl> } <nl> <nl> float sft : : ICFFeaturePool : : apply ( int fi , int si , const Mat & integrals ) const <nl> mmm a / apps / sft / include / sft / fpool . hpp <nl> ppp b / apps / sft / include / sft / fpool . hpp <nl> class ICFFeaturePool : public cv : : FeaturePool <nl> <nl> virtual int size ( ) const { return ( int ) pool . size ( ) ; } <nl> virtual float apply ( int fi , int si , const cv : : Mat & integrals ) const ; <nl> - virtual void preprocess ( cv : : InputArray _frame , cv : : OutputArray _integrals ) const ; <nl> virtual void write ( cv : : FileStorage & fs , int index ) const ; <nl> <nl> virtual ~ ICFFeaturePool ( ) ; <nl> class ICFFeaturePool : public cv : : FeaturePool <nl> <nl> static const unsigned int seed = 0 ; <nl> <nl> - cv : : Ptr < cv : : ChannelFeatureBuilder > builder ; <nl> - <nl> enum { N_CHANNELS = 10 } ; <nl> } ; <nl> <nl> mmm a / apps / sft / sft . cpp <nl> ppp b / apps / sft / sft . cpp <nl> int main ( int argc , char * * argv ) <nl> <nl> typedef cv : : SoftCascadeOctave Octave ; <nl> <nl> - cv : : Ptr < Octave > boost = Octave : : create ( boundingBox , npositives , nnegatives , * it , shrinkage ) ; <nl> + cv : : Ptr < Octave > boost = Octave : : create ( boundingBox , npositives , nnegatives , * it , shrinkage , nfeatures ) ; <nl> <nl> std : : string path = cfg . trainPath ; <nl> sft : : ScaledDataset dataset ( path , * it ) ; <nl> mmm a / modules / softcascade / include / opencv2 / softcascade / softcascade . hpp <nl> ppp b / modules / softcascade / include / opencv2 / softcascade / softcascade . hpp <nl> class CV_EXPORTS FeaturePool <nl> virtual int size ( ) const = 0 ; <nl> virtual float apply ( int fi , int si , const Mat & integrals ) const = 0 ; <nl> virtual void write ( cv : : FileStorage & fs , int index ) const = 0 ; <nl> - <nl> - virtual void preprocess ( InputArray frame , OutputArray integrals ) const = 0 ; <nl> - <nl> virtual ~ FeaturePool ( ) ; <nl> } ; <nl> <nl> class CV_EXPORTS SoftCascadeOctave : public Algorithm <nl> <nl> virtual ~ SoftCascadeOctave ( ) ; <nl> static cv : : Ptr < SoftCascadeOctave > create ( cv : : Rect boundingBox , int npositives , int nnegatives , <nl> - int logScale , int shrinkage ) ; <nl> + int logScale , int shrinkage , int poolSize ) ; <nl> <nl> virtual bool train ( const Dataset * dataset , const FeaturePool * pool , int weaks , int treeDepth ) = 0 ; <nl> virtual void setRejectThresholds ( OutputArray thresholds ) = 0 ; <nl> mmm a / modules / softcascade / src / soft_cascade_octave . cpp <nl> ppp b / modules / softcascade / src / soft_cascade_octave . cpp <nl> using cv : : Mat ; <nl> cv : : FeaturePool : : ~ FeaturePool ( ) { } <nl> cv : : Dataset : : ~ Dataset ( ) { } <nl> <nl> + namespace { <nl> + <nl> + <nl> class BoostedSoftCascadeOctave : public cv : : Boost , public cv : : SoftCascadeOctave <nl> { <nl> public : <nl> <nl> - BoostedSoftCascadeOctave ( cv : : Rect boundingBox = cv : : Rect ( ) , int npositives = 0 , int nnegatives = 0 , int logScale = 0 , int shrinkage = 1 ) ; <nl> + BoostedSoftCascadeOctave ( cv : : Rect boundingBox = cv : : Rect ( ) , int npositives = 0 , int nnegatives = 0 , int logScale = 0 , <nl> + int shrinkage = 1 , int poolSize = 0 ) ; <nl> virtual ~ BoostedSoftCascadeOctave ( ) ; <nl> virtual cv : : AlgorithmInfo * info ( ) const ; <nl> virtual bool train ( const Dataset * dataset , const FeaturePool * pool , int weaks , int treeDepth ) ; <nl> class BoostedSoftCascadeOctave : public cv : : Boost , public cv : : SoftCascadeOctave <nl> virtual bool train ( const cv : : Mat & trainData , const cv : : Mat & responses , const cv : : Mat & varIdx = cv : : Mat ( ) , <nl> const cv : : Mat & sampleIdx = cv : : Mat ( ) , const cv : : Mat & varType = cv : : Mat ( ) , const cv : : Mat & missingDataMask = cv : : Mat ( ) ) ; <nl> <nl> - void processPositives ( const Dataset * dataset , const FeaturePool * pool ) ; <nl> - void generateNegatives ( const Dataset * dataset , const FeaturePool * pool ) ; <nl> + void processPositives ( const Dataset * dataset ) ; <nl> + void generateNegatives ( const Dataset * dataset ) ; <nl> <nl> float predict ( const Mat & _sample , const cv : : Range range ) const ; <nl> private : <nl> class BoostedSoftCascadeOctave : public cv : : Boost , public cv : : SoftCascadeOctave <nl> CvBoostParams params ; <nl> <nl> Mat trainData ; <nl> + <nl> + cv : : Ptr < cv : : ChannelFeatureBuilder > builder ; <nl> } ; <nl> <nl> - BoostedSoftCascadeOctave : : BoostedSoftCascadeOctave ( cv : : Rect bb , int np , int nn , int ls , int shr ) <nl> + BoostedSoftCascadeOctave : : BoostedSoftCascadeOctave ( cv : : Rect bb , int np , int nn , int ls , int shr , int poolSize ) <nl> : logScale ( ls ) , boundingBox ( bb ) , npositives ( np ) , nnegatives ( nn ) , shrinkage ( shr ) <nl> { <nl> int maxSample = npositives + nnegatives ; <nl> BoostedSoftCascadeOctave : : BoostedSoftCascadeOctave ( cv : : Rect bb , int np , int nn , <nl> } <nl> <nl> params = _params ; <nl> + <nl> + builder = cv : : ChannelFeatureBuilder : : create ( ) ; <nl> + <nl> + int w = boundingBox . width ; <nl> + int h = boundingBox . height ; <nl> + <nl> + integrals . create ( poolSize , ( w / shrinkage + 1 ) * ( h / shrinkage * 10 + 1 ) , CV_32SC1 ) ; <nl> } <nl> <nl> BoostedSoftCascadeOctave : : ~ BoostedSoftCascadeOctave ( ) { } <nl> void BoostedSoftCascadeOctave : : setRejectThresholds ( cv : : OutputArray _thresholds ) <nl> } <nl> } <nl> <nl> - void BoostedSoftCascadeOctave : : processPositives ( const Dataset * dataset , const FeaturePool * pool ) <nl> + void BoostedSoftCascadeOctave : : processPositives ( const Dataset * dataset ) <nl> { <nl> - int w = boundingBox . width ; <nl> int h = boundingBox . height ; <nl> <nl> - integrals . create ( pool - > size ( ) , ( w / shrinkage + 1 ) * ( h / shrinkage * 10 + 1 ) , CV_32SC1 ) ; <nl> + cv : : ChannelFeatureBuilder & _builder = * builder ; <nl> <nl> int total = 0 ; <nl> for ( int curr = 0 ; curr < dataset - > available ( Dataset : : POSITIVE ) ; + + curr ) <nl> void BoostedSoftCascadeOctave : : processPositives ( const Dataset * dataset , const Fe <nl> cv : : Mat channels = integrals . row ( total ) . reshape ( 0 , h / shrinkage * 10 + 1 ) ; <nl> sample = sample ( boundingBox ) ; <nl> <nl> - pool - > preprocess ( sample , channels ) ; <nl> + _builder ( sample , channels ) ; <nl> responses . ptr < float > ( total ) [ 0 ] = 1 . f ; <nl> <nl> if ( + + total > = npositives ) break ; <nl> void BoostedSoftCascadeOctave : : processPositives ( const Dataset * dataset , const Fe <nl> # undef USE_LONG_SEEDS <nl> <nl> <nl> - void BoostedSoftCascadeOctave : : generateNegatives ( const Dataset * dataset , const FeaturePool * pool ) <nl> + void BoostedSoftCascadeOctave : : generateNegatives ( const Dataset * dataset ) <nl> { <nl> / / ToDo : set seed , use offsets <nl> sft : : Random : : engine eng ( DX_DY_SEED ) ; <nl> void BoostedSoftCascadeOctave : : generateNegatives ( const Dataset * dataset , const F <nl> <nl> int total = 0 ; <nl> Mat sum ; <nl> + <nl> + cv : : ChannelFeatureBuilder & _builder = * builder ; <nl> for ( int i = npositives ; i < nnegatives + npositives ; + + total ) <nl> { <nl> int curr = iRand ( idxEng ) ; <nl> void BoostedSoftCascadeOctave : : generateNegatives ( const Dataset * dataset , const F <nl> frame = frame ( cv : : Rect ( dx , dy , boundingBox . width , boundingBox . height ) ) ; <nl> <nl> cv : : Mat channels = integrals . row ( i ) . reshape ( 0 , h / shrinkage * 10 + 1 ) ; <nl> - pool - > preprocess ( frame , channels ) ; <nl> + _builder ( frame , channels ) ; <nl> <nl> dprintf ( " generated % d % d \ n " , dx , dy ) ; <nl> / / / / if ( predict ( sum ) ) <nl> bool BoostedSoftCascadeOctave : : train ( const Dataset * dataset , const FeaturePool * <nl> params . weak_count = weaks ; <nl> <nl> / / 1 . fill integrals and classes <nl> - processPositives ( dataset , pool ) ; <nl> - generateNegatives ( dataset , pool ) ; <nl> + processPositives ( dataset ) ; <nl> + generateNegatives ( dataset ) ; <nl> <nl> / / 2 . only simple case ( all features used ) <nl> int nfeatures = pool - > size ( ) ; <nl> void BoostedSoftCascadeOctave : : write ( CvFileStorage * fs , std : : string _name ) cons <nl> CvBoost : : write ( fs , _name . c_str ( ) ) ; <nl> } <nl> <nl> + } <nl> + <nl> CV_INIT_ALGORITHM ( BoostedSoftCascadeOctave , " SoftCascadeOctave . BoostedSoftCascadeOctave " , ) ; <nl> <nl> cv : : SoftCascadeOctave : : ~ SoftCascadeOctave ( ) { } <nl> <nl> cv : : Ptr < cv : : SoftCascadeOctave > cv : : SoftCascadeOctave : : create ( cv : : Rect boundingBox , int npositives , int nnegatives , <nl> - int logScale , int shrinkage ) <nl> + int logScale , int shrinkage , int poolSize ) <nl> { <nl> - cv : : Ptr < cv : : SoftCascadeOctave > octave ( new BoostedSoftCascadeOctave ( boundingBox , npositives , nnegatives , logScale , shrinkage ) ) ; <nl> + cv : : Ptr < cv : : SoftCascadeOctave > octave ( <nl> + new BoostedSoftCascadeOctave ( boundingBox , npositives , nnegatives , logScale , shrinkage , poolSize ) ) ; <nl> return octave ; <nl> } <nl>
|
refactor feature pool
|
opencv/opencv
|
0b039f3c6b5701bacaca957f225674d63fbc6745
|
2013-02-01T10:36:06Z
|
mmm a / src / library_sdl . js <nl> ppp b / src / library_sdl . js <nl> var LibrarySDL = { <nl> / / the browser has already preloaded the audio file . <nl> var channelInfo = SDL . channels [ channel ] ; <nl> channelInfo . audio = audio = audio . cloneNode ( true ) ; <nl> - channelInfo . audio . numChannels = audio . numChannels = info . audio . numChannels ; <nl> - channelInfo . audio . frequency = audio . frequency = info . audio . frequency ; <nl> + audio . numChannels = info . audio . numChannels ; <nl> + audio . frequency = info . audio . frequency ; <nl> if ( SDL . channelFinished ) { <nl> audio [ ' onended ' ] = function ( ) { / / TODO : cache these <nl> Runtime . getFuncWrapper ( SDL . channelFinished , ' vi ' ) ( channel ) ; <nl>
|
simplify audio fix from last commit
|
emscripten-core/emscripten
|
9c746eb4f9b6e1f093abb6db61f926a71f310a83
|
2013-02-28T20:52:14Z
|
mmm a / extensions / CCBReader / CCBReader . cpp <nl> ppp b / extensions / CCBReader / CCBReader . cpp <nl> CCBReader : : CCBReader ( CCBReader * pCCBReader ) <nl> this - > mOwnerOutletNames = pCCBReader - > mOwnerOutletNames ; <nl> this - > mOwnerOutletNodes = pCCBReader - > mOwnerOutletNodes ; <nl> this - > mOwnerOutletNodes - > retain ( ) ; <nl> + <nl> + this - > mCCBRootPath = pCCBReader - > getCCBRootPath ( ) ; <nl> + <nl> init ( ) ; <nl> } <nl> <nl>
|
fix sub ccb node resource root path bug
|
cocos2d/cocos2d-x
|
ab36c433fa8e574740ed3928b8b472aa4f44265e
|
2013-06-27T01:41:38Z
|
mmm a / aten / src / ATen / Formatting . cpp <nl> ppp b / aten / src / ATen / Formatting . cpp <nl> std : : ostream & print ( std : : ostream & stream , const Tensor & tensor_ , int64_t linesi <nl> stream < < " [ Tensor ( empty ) ] " ; <nl> } else { <nl> Tensor tensor = tensor_ . toType ( getType ( kCPU , kDouble ) ) . contiguous ( ) ; <nl> - if ( tensor_ . ndimension ( ) = = 0 ) { <nl> + if ( tensor . ndimension ( ) = = 0 ) { <nl> stream < < std : : defaultfloat < < tensor . data < double > ( ) [ 0 ] < < std : : endl ; <nl> stream < < " [ " < < tensor_ . pImpl - > toString ( ) < < " { } ] " ; <nl> } else if ( tensor . ndimension ( ) = = 1 ) { <nl> mmm a / aten / src / ATen / function_wrapper . py <nl> ppp b / aten / src / ATen / function_wrapper . py <nl> def emit_body ( env , option ) : <nl> # referencing another <nl> seen_names = set ( ) <nl> count = 0 <nl> + is_cuda = backend_type_env [ ' Backend ' ] = = ' CUDA ' <nl> + <nl> + # scalar_check is the heuristic conditions when a result may be a scalar_check <nl> + # if there is a THSize * argument , then its dimensions are used to determine scalar . <nl> + # otherwise , it is true if all the input tensors are scalars , <nl> + scalar_check_is_from_size = False <nl> scalar_check = None <nl> for arg in option [ ' arguments ' ] : <nl> if is_real_argument_to_wrapper ( arg ) : <nl> count + = 1 <nl> if arg [ ' type ' ] = = ' THSize * ' : <nl> + scalar_check_is_from_size = True <nl> scalar_check = ' { } . size ( ) = = 0 ' . format ( arg [ ' name ' ] ) <nl> # only generated checked casts the first time we see it <nl> if not arg [ ' name ' ] in seen_names and requires_checked_cast ( arg ) : <nl> seen_names . add ( arg [ ' name ' ] ) <nl> + <nl> + # make a new allocation of TensorImpl , then wrap a Tensor around it . <nl> if arg . get ( ' allocate ' , False ) : <nl> allocation = CodeTemplate ( <nl> ALLOC_WRAP [ arg [ ' type ' ] ] ) . substitute ( env ) <nl> def emit_body ( env , option ) : <nl> arg [ ' name ' ] , allocation ) ) <nl> body . append ( ' auto { } = Tensor ( { } _ , false ) ; ' . format ( <nl> arg [ ' name ' ] , arg [ ' name ' ] ) ) <nl> + # extract the TensorImpl from an existing tensor ( or Storage , etc . ) <nl> else : <nl> check_cast = CHECKED_CAST [ arg [ ' type ' ] ] . substitute ( <nl> env , arg_name = arg [ ' name ' ] , arg_pos = count ) <nl> body . append ( " auto { } _ = { } ; " . format ( <nl> arg [ ' name ' ] , check_cast ) ) <nl> + <nl> + # resize tensors for special ops that require it <nl> if ' resize ' in arg : <nl> resize = arg [ ' resize ' ] <nl> if type ( resize ) = = str : <nl> - body . append ( " { } . resize_as_ ( { } ) ; " . format ( <nl> + body . append ( " { } . resize_ ( { } . sizes ( ) ) ; " . format ( <nl> arg [ ' name ' ] , resize ) ) <nl> else : <nl> dims = [ ' { } . size ( { } ) ' . format ( name , dim ) <nl> for name , dim in resize ] <nl> body . append ( " { } . resize_ ( { { { } } } ) ; " . format ( <nl> arg [ ' name ' ] , ' , ' . join ( dims ) ) ) <nl> - if arg . get ( ' cpu_zero ' , False ) : <nl> + # also special handling where we zero some outputs . <nl> + if arg . get ( ' cpu_zero ' , False ) and not is_cuda : <nl> body . append ( " { } . zero_ ( ) ; " . format ( arg [ ' name ' ] ) ) <nl> + <nl> # handle scalars that occur on LHS of things like a - b <nl> if ' broadcast ' in arg and ' inplace ' not in arg [ ' broadcast ' ] : <nl> other = arg [ ' broadcast ' ] . split ( ' ' ) [ 0 ] . split ( ' , ' ) [ 0 ] <nl> def emit_body ( env , option ) : <nl> name = arg [ ' name ' ] , <nl> other = other ) ) <nl> <nl> + # dim ( ) = = 0 of all input tensors is and ' d to form <nl> + # the test for whether the output is also a scalar <nl> + if not arg . get ( ' output ' ) and ' Tensor ' in arg [ ' type ' ] and not scalar_check_is_from_size : <nl> + check = ' { } . dim ( ) = = 0 ' . format ( arg [ ' name ' ] ) <nl> + scalar_check = ( check if scalar_check is None <nl> + else scalar_check + ' & & ' + check ) <nl> + <nl> option [ ' derived_actuals ' ] = get_arguments ( option ) <nl> - is_cuda = backend_type_env [ ' Backend ' ] = = ' CUDA ' <nl> is_nn = option [ ' mode ' ] = = ' NN ' <nl> if is_cuda or is_nn : <nl> option [ ' derived_actuals ' ] = [ ' context - > thc_state ' ] + option [ ' derived_actuals ' ] <nl> def emit_body ( env , option ) : <nl> arguments = [ option [ ' arguments ' ] [ argi ] <nl> for argi in arguments_indices ] <nl> if scalar_check is not None : <nl> - for arg in arguments : <nl> + if len ( arguments ) > 1 : <nl> body . append ( " bool maybe_scalar = { } ; " . format ( scalar_check ) ) <nl> - body . append ( " { } _ - > maybeScalar ( maybe_scalar ) ; " . format ( arg [ ' name ' ] ) ) <nl> + scalar_check = ' maybe_scalar ' <nl> + for arg in arguments : <nl> + body . append ( " { } _ - > maybeScalar ( { } ) ; " . format ( arg [ ' name ' ] , scalar_check ) ) <nl> if len ( arguments_indices ) = = 1 : <nl> arg = arguments [ 0 ] <nl> body . append ( " return { } ; " . format ( arg [ ' name ' ] ) ) <nl> def process_option ( option ) : <nl> if not option . get ( ' skip ' , False ) : <nl> try : <nl> process_option ( option ) <nl> - except NYIError as e : <nl> + except NYIError : <nl> pass <nl> return type_object_declarations , type_object_definitions <nl> mmm a / aten / src / ATen / test / basic . cpp <nl> ppp b / aten / src / ATen / test / basic . cpp <nl> static void test ( Type & type ) { <nl> Tensor b = type . rand ( { 3 , 4 } ) ; <nl> std : : cout < < b + a < < std : : endl ; <nl> std : : cout < < a + b < < std : : endl ; <nl> + assert ( ( a + a ) . dim ( ) = = 0 ) ; <nl> + assert ( ( 1 + a ) . dim ( ) = = 0 ) ; <nl> } <nl> <nl> } <nl>
|
add checks for scalars on output
|
pytorch/pytorch
|
622350d3e9846c7cb325e4e52f643c253bed080d
|
2017-11-02T23:53:36Z
|
mmm a / tests / host / common / ArduinoMain . cpp <nl> ppp b / tests / host / common / ArduinoMain . cpp <nl> void help ( const char * argv0 , int exitcode ) <nl> " - b - blocking tty / mocked - uart ( default : not blocking tty ) \ n " <nl> " - S - spiffs size in KBytes ( default : % zd ) \ n " <nl> " - L - littlefs size in KBytes ( default : % zd ) \ n " <nl> - " - v - mock verbose \ n " <nl> - " ( negative value will force mismatched size ) \ n " <nl> + " \ t ( spiffs , littlefs : negative value will force mismatched size ) \ n " <nl> + " - T - show timestamp on output \ n " <nl> + " - v - verbose \ n " <nl> , argv0 , MOCK_PORT_SHIFTER , spiffs_kb , littlefs_kb ) ; <nl> exit ( exitcode ) ; <nl> } <nl> <nl> static struct option options [ ] = <nl> { <nl> - { " help " , no_argument , NULL , ' h ' } , <nl> - { " fast " , no_argument , NULL , ' f ' } , <nl> - { " local " , no_argument , NULL , ' l ' } , <nl> - { " sigint " , no_argument , NULL , ' c ' } , <nl> - { " blockinguart " , no_argument , NULL , ' b ' } , <nl> - { " verbose " , no_argument , NULL , ' v ' } , <nl> - { " interface " , required_argument , NULL , ' i ' } , <nl> - { " spiffskb " , required_argument , NULL , ' S ' } , <nl> - { " littlefskb " , required_argument , NULL , ' L ' } , <nl> - { " portshifter " , required_argument , NULL , ' s ' } , <nl> + { " help " , no_argument , NULL , ' h ' } , <nl> + { " fast " , no_argument , NULL , ' f ' } , <nl> + { " local " , no_argument , NULL , ' l ' } , <nl> + { " sigint " , no_argument , NULL , ' c ' } , <nl> + { " blockinguart " , no_argument , NULL , ' b ' } , <nl> + { " verbose " , no_argument , NULL , ' v ' } , <nl> + { " timestamp " , no_argument , NULL , ' T ' } , <nl> + { " interface " , required_argument , NULL , ' i ' } , <nl> + { " spiffskb " , required_argument , NULL , ' S ' } , <nl> + { " littlefskb " , required_argument , NULL , ' L ' } , <nl> + { " portshifter " , required_argument , NULL , ' s ' } , <nl> } ; <nl> <nl> void cleanup ( ) <nl> int main ( int argc , char * const argv [ ] ) <nl> <nl> for ( ; ; ) <nl> { <nl> - int n = getopt_long ( argc , argv , " hlcfbvi : S : s : L : " , options , NULL ) ; <nl> + int n = getopt_long ( argc , argv , " hlcfbvTi : S : s : L : " , options , NULL ) ; <nl> if ( n < 0 ) <nl> break ; <nl> switch ( n ) <nl> int main ( int argc , char * const argv [ ] ) <nl> case ' v ' : <nl> mockdebug = true ; <nl> break ; <nl> + case ' T ' : <nl> + serial_timestamp = true ; <nl> + break ; <nl> default : <nl> help ( argv [ 0 ] , EXIT_FAILURE ) ; <nl> } <nl> mmm a / tests / host / common / MockUART . cpp <nl> ppp b / tests / host / common / MockUART . cpp <nl> <nl> * / <nl> <nl> # include < unistd . h > / / write <nl> + # include < sys / time . h > / / gettimeofday <nl> + # include < time . h > / / localtime <nl> <nl> # include " Arduino . h " <nl> # include " uart . h " <nl> struct uart_ <nl> struct uart_rx_buffer_ * rx_buffer ; <nl> } ; <nl> <nl> + bool serial_timestamp = false ; <nl> + <nl> / / write one byte to the emulated UART <nl> static void <nl> uart_do_write_char ( const int uart_nr , char c ) <nl> { <nl> + static bool w = false ; <nl> + <nl> if ( uart_nr > = UART0 & & uart_nr < = UART1 ) <nl> - if ( 1 ! = write ( uart_nr + 1 , & c , 1 ) ) <nl> - fprintf ( stderr , " Unable to write character to emulated UART stream : % d \ n " , c ) ; <nl> + { <nl> + if ( serial_timestamp & & ( c = = ' \ n ' | | c = = ' \ r ' ) ) <nl> + { <nl> + if ( w ) <nl> + { <nl> + FILE * out = uart_nr = = UART0 ? stdout : stderr ; <nl> + timeval tv ; <nl> + gettimeofday ( & tv , nullptr ) ; <nl> + const tm * tm = localtime ( & tv . tv_sec ) ; <nl> + fprintf ( out , " \ r \ n % d : % 02d : % 02d . % 06d : " , tm - > tm_hour , tm - > tm_min , tm - > tm_sec , ( int ) tv . tv_usec ) ; <nl> + fflush ( out ) ; <nl> + w = false ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + write ( uart_nr + 1 , & c , 1 ) ; <nl> + w = true ; <nl> + } <nl> + } <nl> } <nl> <nl> / / write a new byte into the RX FIFO buffer <nl> mmm a / tests / host / common / mock . h <nl> ppp b / tests / host / common / mock . h <nl> int ets_printf ( const char * fmt , . . . ) __attribute__ ( ( format ( printf , 1 , 2 ) ) ) ; <nl> int mockverbose ( const char * fmt , . . . ) __attribute__ ( ( format ( printf , 1 , 2 ) ) ) ; <nl> <nl> extern const char * host_interface ; / / cmdline parameter <nl> - <nl> + extern bool serial_timestamp ; <nl> extern int mock_port_shifter ; <nl> <nl> # define NO_GLOBAL_BINDING 0xffffffff <nl>
|
emulation on host : show timestamp on console output ( )
|
esp8266/Arduino
|
0474eb994341013e704e216fb3f72d0e2ad13090
|
2019-09-12T12:00:27Z
|
mmm a / include / osquery / database / results . h <nl> ppp b / include / osquery / database / results . h <nl> <nl> # include < vector > <nl> <nl> # include < boost / property_tree / ptree . hpp > <nl> - # include < boost / lexical_cast . hpp > <nl> <nl> # include " osquery / status . h " <nl> <nl> namespace osquery { <nl> / / Row <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - / * * <nl> - * @ brief The SQLite type affinities are available as macros <nl> - * <nl> - * Type affinities : TEXT , INTEGER , BIGINT <nl> - * <nl> - * You can represent any data that can be lexically casted to a string . <nl> - * Using the type affinity names helps table developers understand the data <nl> - * types they are storing , and more importantly how they are treated at query <nl> - * time . <nl> - * / <nl> - # define TEXT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> - # define INTEGER ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> - # define BIGINT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> - # define UNSIGNED_BIGINT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> - <nl> / * * <nl> * @ brief A variant type for the SQLite type affinities . <nl> * / <nl> new file mode 100644 <nl> index 0000000000 . . 0792dea45c <nl> mmm / dev / null <nl> ppp b / include / osquery / tables . h <nl> <nl> + / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include < map > <nl> + # include < vector > <nl> + <nl> + # include < boost / lexical_cast . hpp > <nl> + <nl> + # include " osquery / database / results . h " <nl> + # include " osquery / status . h " <nl> + <nl> + namespace osquery { <nl> + namespace tables { <nl> + <nl> + / * * <nl> + * @ brief The SQLite type affinities are available as macros <nl> + * <nl> + * Type affinities : TEXT , INTEGER , BIGINT <nl> + * <nl> + * You can represent any data that can be lexically casted to a string . <nl> + * Using the type affinity names helps table developers understand the data <nl> + * types they are storing , and more importantly how they are treated at query <nl> + * time . <nl> + * / <nl> + # define TEXT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> + # define INTEGER ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> + # define BIGINT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> + # define UNSIGNED_BIGINT ( x ) boost : : lexical_cast < std : : string > ( x ) <nl> + <nl> + / / / Literal types are the C + + types . <nl> + # define TEXT_LITERAL std : : string <nl> + # define INTEGER_LITERAL int <nl> + # define BIGINT_LITERAL long long int <nl> + # define UNSIGNED_BIGINT_LITERAL unsigned long long int <nl> + # define AS_LITERAL ( literal , value ) boost : : lexical_cast < literal > ( value ) <nl> + <nl> + enum ConstraintOperators { <nl> + EQUALS = 2 , <nl> + GREATER_THAN = 4 , <nl> + LESS_THAN_OR_EQUALS = 8 , <nl> + LESS_THAN = 16 , <nl> + GREATER_THAN_OR_EQUALS = 32 <nl> + } ; <nl> + <nl> + struct Constraint { <nl> + unsigned char op ; <nl> + std : : string expr ; <nl> + <nl> + Constraint ( unsigned char _op ) { op = _op ; } <nl> + } ; <nl> + <nl> + struct ConstraintList { <nl> + std : : vector < struct Constraint > constraints ; <nl> + / / / The SQLite affinity type . <nl> + std : : string affinity ; <nl> + <nl> + bool matches ( const std : : string & expr ) { <nl> + / / Support each affinity type casting . <nl> + if ( affinity = = " TEXT " ) { <nl> + return literal_matches < TEXT_LITERAL > ( expr ) ; <nl> + } else if ( affinity = = " INTEGER " ) { <nl> + return literal_matches < INTEGER_LITERAL > ( expr ) ; <nl> + } else if ( affinity = = " BIGINT " ) { <nl> + return literal_matches < BIGINT_LITERAL > ( expr ) ; <nl> + } else if ( affinity = = " UNSIGNED_BIGINT " ) { <nl> + return literal_matches < UNSIGNED_BIGINT_LITERAL > ( expr ) ; <nl> + } else { <nl> + / / Unsupprted affinity type . <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + template < typename T > <nl> + bool literal_matches ( const std : : string & base_expr ) { <nl> + bool aggregate = true ; <nl> + T expr = AS_LITERAL ( T , base_expr ) ; <nl> + for ( size_t i = 0 ; i < constraints . size ( ) ; + + i ) { <nl> + T constraint_expr = AS_LITERAL ( T , constraints [ i ] . expr ) ; <nl> + if ( constraints [ i ] . op = = EQUALS ) { <nl> + aggregate = aggregate & & ( expr = = constraint_expr ) ; <nl> + } else if ( constraints [ i ] . op = = GREATER_THAN ) { <nl> + aggregate = aggregate & & ( expr > constraint_expr ) ; <nl> + } else if ( constraints [ i ] . op = = LESS_THAN ) { <nl> + aggregate = aggregate & & ( expr < constraint_expr ) ; <nl> + } else if ( constraints [ i ] . op = = GREATER_THAN_OR_EQUALS ) { <nl> + aggregate = aggregate & & ( expr > = constraint_expr ) ; <nl> + } else if ( constraints [ i ] . op = = LESS_THAN_OR_EQUALS ) { <nl> + aggregate = aggregate & & ( expr < = constraint_expr ) ; <nl> + } else { <nl> + / / Unsupported constraint . <nl> + return false ; <nl> + } <nl> + if ( ! aggregate ) { <nl> + / / Speed up comparison . <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + std : : vector < std : : string > getAll ( ConstraintOperators op ) { <nl> + std : : vector < std : : string > set ; <nl> + for ( size_t i = 0 ; i < constraints . size ( ) ; + + i ) { <nl> + if ( constraints [ i ] . op = = op ) { <nl> + set . push_back ( constraints [ i ] . expr ) ; <nl> + } <nl> + } <nl> + return set ; <nl> + } <nl> + <nl> + void add ( const struct Constraint & constraint ) { <nl> + constraints . push_back ( constraint ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / / Pass a constraint map to the query request . <nl> + typedef std : : map < std : : string , struct ConstraintList > ConstraintMap ; <nl> + / / / Populate a containst list from a query ' s parsed predicate . <nl> + typedef std : : vector < std : : pair < std : : string , struct Constraint > > ConstraintSet ; <nl> + <nl> + struct QueryRequest { <nl> + ConstraintMap constraints ; <nl> + / / / Support a limit to the number of results . <nl> + int limit ; <nl> + } ; <nl> + <nl> + typedef struct QueryRequest QueryRequest ; <nl> + typedef struct Constraint Constraint ; <nl> + <nl> + } <nl> + } <nl> \ No newline at end of file <nl> mmm a / osquery / core / md5 . h <nl> ppp b / osquery / core / md5 . h <nl> static unsigned char PADDING [ 64 ] = { 0x80 , <nl> 0 } ; <nl> <nl> / / F , G , H and I are basic MD5 functions . <nl> - # define F ( x , y , z ) ( ( ( x ) & ( y ) ) | ( ( ~ x ) & ( z ) ) ) <nl> + # define FFF ( x , y , z ) ( ( ( x ) & ( y ) ) | ( ( ~ x ) & ( z ) ) ) <nl> # define G ( x , y , z ) ( ( ( x ) & ( z ) ) | ( ( y ) & ( ~ z ) ) ) <nl> # define H ( x , y , z ) ( ( x ) ^ ( y ) ^ ( z ) ) <nl> # define I ( x , y , z ) ( ( y ) ^ ( ( x ) | ( ~ z ) ) ) <nl> static unsigned char PADDING [ 64 ] = { 0x80 , <nl> / / Rotation is separate from addition to prevent recomputation . <nl> # define FF ( a , b , c , d , x , s , ac ) \ <nl> { \ <nl> - ( a ) + = F ( ( b ) , ( c ) , ( d ) ) + ( x ) + ( UINT4 ) ( ac ) ; \ <nl> + ( a ) + = FFF ( ( b ) , ( c ) , ( d ) ) + ( x ) + ( UINT4 ) ( ac ) ; \ <nl> ( a ) = ROTATE_LEFT ( ( a ) , ( s ) ) ; \ <nl> ( a ) + = ( b ) ; \ <nl> } <nl> mmm a / osquery / core / system . cpp <nl> ppp b / osquery / core / system . cpp <nl> <nl> <nl> # include < boost / algorithm / string / trim . hpp > <nl> # include < boost / filesystem . hpp > <nl> + # include < boost / lexical_cast . hpp > <nl> # include < boost / uuid / uuid . hpp > <nl> # include < boost / uuid / uuid_generators . hpp > <nl> # include < boost / uuid / uuid_io . hpp > <nl> deleted file mode 100644 <nl> index 206cf85079 . . 0000000000 <nl> mmm a / osquery / tables / manual / filesystem . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - # ifndef OSQUERY_TABLES_FILESYSTEM_H <nl> - # define OSQUERY_TABLES_FILESYSTEM_H <nl> - <nl> - # include < sqlite3 . h > <nl> - <nl> - / / Make sure we can call this stuff from C + + . <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / / An sqlite3_filesystem is an abstract type to store an instance of <nl> - / / an integer array . <nl> - typedef struct sqlite3_filesystem sqlite3_filesystem ; <nl> - <nl> - / / Invoke this routine to create a specific instance of an filesystem object . <nl> - / / The new filesystem object is returned by the 3rd parameter . <nl> - / / <nl> - / / Each filesystem object corresponds to a virtual table in the TEMP table <nl> - / / with a name of zName . <nl> - / / <nl> - / / Destroy the filesystem object by dropping the virtual table . If not done <nl> - / / explicitly by the application , the virtual table will be dropped implicitly <nl> - / / by the system when the database connection is closed . <nl> - int sqlite3_filesystem_create ( sqlite3 * db , <nl> - const char * zName , <nl> - sqlite3_filesystem * * ppReturn ) ; <nl> - <nl> - # ifdef __cplusplus <nl> - } / / End of the ' extern " C " ' block <nl> - # endif <nl> - <nl> - # endif / * OSQUERY_TABLES_FILESYSTEM_H * / <nl> deleted file mode 100644 <nl> index 014e4a0067 . . 0000000000 <nl> mmm a / osquery / tables / manual / hash . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - # include " osquery / tables / manual / hash . h " <nl> - # include " osquery / core / md5 . h " <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - # include < iostream > <nl> - # include < cstring > <nl> - # include < sstream > <nl> - <nl> - # include < boost / filesystem / operations . hpp > <nl> - # include < boost / filesystem / path . hpp > <nl> - <nl> - namespace fs = boost : : filesystem ; <nl> - <nl> - / * <nl> - * * Definition of the sqlite3_hash object . <nl> - * * <nl> - * * The internal representation of an hash object is subject <nl> - * * to change , is not externally visible , and should be used by <nl> - * * the implementation of hash only . This object is opaque <nl> - * * to users . <nl> - * / <nl> - struct sqlite3_hash { <nl> - int n ; / * number of elements * / <nl> - std : : vector < std : : string > filename ; / * the full path of a hash object * / <nl> - std : : vector < std : : string > md5 ; / * the hash of the file at the path * / <nl> - } ; <nl> - <nl> - / * <nl> - * Objects used internally by the virtual table implementation <nl> - * <nl> - * we write " typedef struct x x " here so that we can write " x " later instead of <nl> - * " stuct x " <nl> - * * / <nl> - typedef struct hash_vtab hash_vtab ; <nl> - typedef struct hash_cursor hash_cursor ; <nl> - <nl> - / * <nl> - * Our virtual table object <nl> - * * / <nl> - struct hash_vtab { <nl> - / / virtual table implementations will normally subclass this structure to add <nl> - / / additional private and implementation - specific fields <nl> - sqlite3_vtab base ; <nl> - <nl> - / / to get custom functionality , add our own struct as well <nl> - sqlite3_hash * pContent ; <nl> - } ; <nl> - <nl> - / * <nl> - * Our cursor object <nl> - * * / <nl> - struct hash_cursor { <nl> - / / similarly to sqlite3_vtab , practical implementations will likely subclass <nl> - / / this structure to add additional private fields . <nl> - sqlite3_vtab_cursor base ; <nl> - <nl> - / / field that will be used to represent the current cursor position <nl> - int row ; <nl> - / / the path that is being queried <nl> - std : : string path ; <nl> - } ; <nl> - <nl> - / * <nl> - * * Free an sqlite3_hash object . <nl> - * / <nl> - static void hashFree ( sqlite3_hash * p ) { sqlite3_free ( p ) ; } <nl> - <nl> - / * <nl> - * This method releases a connection to a virtual table , just like the <nl> - * xDisconnect method , and it also destroys the underlying table <nl> - * implementation . This method undoes the work of xCreate . <nl> - * / <nl> - static int hashDestroy ( sqlite3_vtab * p ) { <nl> - hash_vtab * pVtab = ( hash_vtab * ) p ; <nl> - sqlite3_free ( pVtab ) ; <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / * <nl> - * * Table constructor for the hash module . <nl> - * / <nl> - static int hashCreate ( sqlite3 * db , / * Database where module is created * / <nl> - void * pAux , / * clientdata for the module * / <nl> - int argc , / * Number of arguments * / <nl> - const char * const * argv , / * Value for all arguments * / <nl> - sqlite3_vtab * * ppVtab , / * Write the new virtual table <nl> - object here * / <nl> - char * * pzErr / * Put error message text here * / <nl> - ) { <nl> - / / this will get overwritten if pVtab was successfully allocated . if pVtab <nl> - / / wasn ' t allocated , it means we have no memory <nl> - int rc = SQLITE_NOMEM ; <nl> - <nl> - / / allocate the correct amount of memory for your virtual table structure <nl> - / / hash_vtab * pVtab = sqlite3_malloc ( sizeof ( hash_vtab ) ) ; <nl> - hash_vtab * pVtab = new hash_vtab ; <nl> - <nl> - / / if the virtual table structure was successfully allocated <nl> - if ( pVtab ) { <nl> - / / overwrite the entire memory that was allocated with zeros <nl> - memset ( pVtab , 0 , sizeof ( hash_vtab ) ) ; <nl> - <nl> - / / the pAux argument is the copy of the client data pointer that was the <nl> - / / fourth argument to the sqlite3_create_module ( ) or <nl> - / / sqlite3_create_module_v2 ( ) call that registered the virtual table <nl> - / / module . This sets the pContent value of the virtual table struct to <nl> - / / whatever that value was <nl> - pVtab - > pContent = ( sqlite3_hash * ) pAux ; <nl> - <nl> - / / this interface is called to declare the format ( the names and datatypes <nl> - / / of the columns ) of the virtual tables they implement <nl> - const char * create_table_statement = <nl> - " CREATE TABLE hash ( " <nl> - " path VARCHAR , " <nl> - " filename VARCHAR , " <nl> - " md5 VARCHAR " <nl> - " ) " ; <nl> - rc = sqlite3_declare_vtab ( db , create_table_statement ) ; <nl> - } <nl> - / / cast your virtual table object back to type sqlite3_vtab and assign it to <nl> - / / the address supplied by the function call <nl> - * ppVtab = ( sqlite3_vtab * ) pVtab ; <nl> - <nl> - / / if all went well , sqlite3_declare_vtab will have returned SQLITE_OK and <nl> - / / that is what will be returned <nl> - return rc ; <nl> - } <nl> - <nl> - / * <nl> - * * Open a new cursor on the hash table . <nl> - * / <nl> - static int hashOpen ( sqlite3_vtab * pVTab , sqlite3_vtab_cursor * * ppCursor ) { <nl> - / / this will get overwritten if pVtab was successfully allocated . if pVtab <nl> - / / wasn ' t allocated , it means we have no memory <nl> - int rc = SQLITE_NOMEM ; <nl> - <nl> - / / declare a value to be used as the virtual table ' s cursor <nl> - hash_cursor * pCur ; <nl> - <nl> - / / allocate the correct amount of memory for your virtual table cursor <nl> - / / pCur = sqlite3_malloc ( sizeof ( hash_cursor ) ) ; <nl> - pCur = new hash_cursor ; <nl> - <nl> - / / if the cursor was successfully allocated <nl> - if ( pCur ) { <nl> - / / overwrite the entire memory that was allocated with zeros <nl> - memset ( pCur , 0 , sizeof ( hash_cursor ) ) ; <nl> - <nl> - / / cast the cursor object back to type sqlite3_vtab_cursor and assign it to <nl> - / / the address that was supplied by the function call <nl> - * ppCursor = ( sqlite3_vtab_cursor * ) pCur ; <nl> - <nl> - / / if you ' ve gotten this far , everything succeeded so we can set rc , which <nl> - / / will be used as our return value , to SQLITE_OK <nl> - rc = SQLITE_OK ; <nl> - } <nl> - <nl> - / / return the value we set to rc , which can either be SQLITE_OK or <nl> - / / SQLITE_NOMEM <nl> - return rc ; <nl> - } <nl> - <nl> - / * <nl> - * * Close a hash table cursor . <nl> - * / <nl> - static int hashClose ( sqlite3_vtab_cursor * cur ) { <nl> - / / the xClose interface accepts a sqlite3_vtab_cursor . if we need to do <nl> - / / something specific to our virtual table to free it , cast it back to <nl> - / / your own cursor type <nl> - hash_cursor * pCur = ( hash_cursor * ) cur ; <nl> - <nl> - / / finally , free the structure using sqlite ' s built - in memory allocation <nl> - / / function <nl> - / / in C , we would use sqlite3_free ( pCur ) ; <nl> - delete pCur ; <nl> - <nl> - / / return SQLITE_OK because everything succeeded <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / * <nl> - * * Retrieve a column of data . <nl> - * / <nl> - static int hashColumn ( sqlite3_vtab_cursor * cur , sqlite3_context * ctx , int col ) { <nl> - hash_cursor * pCur = ( hash_cursor * ) cur ; <nl> - hash_vtab * pVtab = ( hash_vtab * ) cur - > pVtab ; <nl> - <nl> - / / return a specific column from a specific row , depending on the state of <nl> - / / the cursor <nl> - if ( pCur - > row > = 0 & & pCur - > row < pVtab - > pContent - > n ) { <nl> - switch ( col ) { <nl> - / / path <nl> - case 0 : <nl> - sqlite3_result_text ( ctx , ( pCur - > path ) . c_str ( ) , - 1 , nullptr ) ; <nl> - break ; <nl> - / / filename <nl> - case 1 : <nl> - sqlite3_result_text ( <nl> - ctx , ( pVtab - > pContent - > filename [ pCur - > row ] ) . c_str ( ) , - 1 , nullptr ) ; <nl> - break ; <nl> - / / md5 <nl> - case 2 : <nl> - sqlite3_result_text ( <nl> - ctx , ( pVtab - > pContent - > md5 [ pCur - > row ] ) . c_str ( ) , - 1 , nullptr ) ; <nl> - break ; <nl> - } <nl> - } <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / * <nl> - * * Retrieve the current rowid . <nl> - * / <nl> - static int hashRowid ( sqlite3_vtab_cursor * cur , sqlite_int64 * pRowid ) { <nl> - hash_cursor * pCur = ( hash_cursor * ) cur ; <nl> - / / return the value of i , which is set to 0 in xFilter and incremented in <nl> - / / xNext <nl> - * pRowid = pCur - > row ; <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - static int hashEof ( sqlite3_vtab_cursor * cur ) { <nl> - hash_cursor * pCur = ( hash_cursor * ) cur ; <nl> - hash_vtab * pVtab = ( hash_vtab * ) cur - > pVtab ; <nl> - return pCur - > row > = pVtab - > pContent - > n ; <nl> - } <nl> - <nl> - / * <nl> - * * Advance the cursor to the next row . <nl> - * / <nl> - static int hashNext ( sqlite3_vtab_cursor * cur ) { <nl> - hash_cursor * pCur = ( hash_cursor * ) cur ; <nl> - / / increment the value of i , so that xColumn knowns what value to return <nl> - pCur - > row + + ; <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / * <nl> - * This function resets the cursor for a new query . From the documentation : <nl> - * <nl> - * This method begins a search of a virtual table . The first argument is a <nl> - * cursor opened by xOpen . The next two arguments define a particular search <nl> - * index previously chosen by xBestIndex . The specific meanings of idxNum and <nl> - * idxStr are unimportant as long as xFilter and xBestIndex agree on what that <nl> - * meaning is . <nl> - * <nl> - * This method must return SQLITE_OK if successful , or an sqlite error code if <nl> - * an error occurs . <nl> - * * / <nl> - static int hashFilter ( sqlite3_vtab_cursor * pVtabCursor , <nl> - int idxNum , <nl> - const char * idxStr , <nl> - int argc , <nl> - sqlite3_value * * argv ) { <nl> - / / you need to operate on the sqlite3_vtab_cursor object as your own <nl> - / / virtual table ' s cursor type , so cast it back to x_cursor <nl> - hash_cursor * pCur = ( hash_cursor * ) pVtabCursor ; <nl> - hash_vtab * pVtab = ( hash_vtab * ) pVtabCursor - > pVtab ; <nl> - <nl> - / / reset the count value of your cursor ' s structure <nl> - pCur - > row = 0 ; <nl> - <nl> - / / the hash table requires you to have a where clause to specify the <nl> - / / path . if argc is 0 , then no values were specified as valid constraints in <nl> - / / xBestIndex . there ' s currently logic in xBestIndex to prevent execution <nl> - / / from getting this far if that were to happen , but we check argc here as <nl> - / / well to illustrate the requirement <nl> - if ( argc < = 0 ) { <nl> - return SQLITE_MISUSE ; <nl> - } <nl> - <nl> - / / extract the RHS value for the path constraint into the cursor ' s path field <nl> - pCur - > path = std : : string ( ( const char * ) sqlite3_value_text ( argv [ 0 ] ) ) ; <nl> - <nl> - / / if the path doesn ' t exist , return early <nl> - if ( ! fs : : exists ( pCur - > path ) ) { <nl> - std : : cerr < < pCur - > path < < " doesn ' t exist " < < std : : endl ; <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / / iterate through the directory that is being queried upon and gather the <nl> - / / information needed to complete a table scan <nl> - osquery : : md5 : : MD5 md5 ; <nl> - if ( fs : : is_regular_file ( pCur - > path ) ) { <nl> - pVtab - > pContent - > filename . push_back ( pCur - > path ) ; <nl> - const char * filename = pCur - > path . c_str ( ) ; <nl> - const char * md5_value = md5 . digestFile ( filename ) ; <nl> - pVtab - > pContent - > md5 . push_back ( std : : string ( md5_value ) ) ; <nl> - } else if ( fs : : is_directory ( pCur - > path ) ) { <nl> - fs : : directory_iterator end_iter ; <nl> - for ( fs : : directory_iterator dir_itr ( pCur - > path ) ; dir_itr ! = end_iter ; <nl> - + + dir_itr ) { <nl> - pVtab - > pContent - > filename . push_back ( dir_itr - > path ( ) . string ( ) ) ; <nl> - if ( fs : : is_regular_file ( dir_itr - > status ( ) ) ) { <nl> - const char * filename = dir_itr - > path ( ) . string ( ) . c_str ( ) ; <nl> - const char * md5_value = md5 . digestFile ( filename ) ; <nl> - pVtab - > pContent - > md5 . push_back ( std : : string ( md5_value ) ) ; <nl> - } else { <nl> - pVtab - > pContent - > md5 . push_back ( " " ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / set the size of the table based on the amount of results that were queried <nl> - pVtab - > pContent - > n = pVtab - > pContent - > filename . size ( ) ; <nl> - <nl> - / / return SQLITE_OK because everything went as planned <nl> - return SQLITE_OK ; <nl> - } <nl> - <nl> - / * <nl> - * This is executed when you query a virtual table with a WHERE claue . From <nl> - * the documentation : <nl> - * <nl> - * SQLite calls this method when it is running sqlite3_prepare ( ) or the <nl> - * equivalent . By calling this method , the SQLite core is saying to the virtual <nl> - * table that it needs to access some subset of the rows in the virtual table <nl> - * and it wants to know the most efficient way to do that access . The xBestIndex <nl> - * method replies with information that the SQLite core can then use to conduct <nl> - * an efficient search of the virtual table . <nl> - * * / <nl> - static int hashBestIndex ( sqlite3_vtab * tab , sqlite3_index_info * pIdxInfo ) { <nl> - hash_vtab * pVtab = ( hash_vtab * ) tab ; <nl> - <nl> - if ( pIdxInfo - > nConstraint = = 0 ) { <nl> - / / the hash table requires you to have a where clause to specify the <nl> - / / path . if nConstrain is 0 , then there were no where clauses . <nl> - goto fail ; <nl> - } <nl> - <nl> - / / iterate through all of the constraints ( aka where clauses ) and look for <nl> - / / the constraint on the " path " column <nl> - for ( int i = 0 ; i < pIdxInfo - > nConstraint ; i + + ) { <nl> - / / if the " path " column is being queried and it ' s usable <nl> - if ( pIdxInfo - > aConstraint [ i ] . iColumn = = 0 & & <nl> - pIdxInfo - > aConstraint [ i ] . usable ) { <nl> - / / set the argvIndex of the " path " constraint so that it ' s usable to <nl> - / / xBestIndex <nl> - pIdxInfo - > aConstraintUsage [ i ] . argvIndex = <nl> - pIdxInfo - > aConstraint [ i ] . iColumn + 1 ; <nl> - goto finish ; <nl> - } <nl> - } <nl> - <nl> - / / if the code has gotten this far , it means that there were constraints in <nl> - / / the query , but none of them were for the path column , which is required <nl> - goto fail ; <nl> - <nl> - finish : <nl> - return SQLITE_OK ; <nl> - <nl> - fail : <nl> - return SQLITE_MISUSE ; <nl> - } <nl> - <nl> - / * <nl> - * * A virtual table module that merely echoes method calls into TCL <nl> - * * variables . <nl> - * / <nl> - static sqlite3_module hashModule = { <nl> - 0 , / * iVersion * / <nl> - hashCreate , / * xCreate - create a new virtual table * / <nl> - hashCreate , / * xConnect - connect to an existing vtab * / <nl> - hashBestIndex , / * xBestIndex - find the best query index * / <nl> - hashDestroy , / * xDisconnect - disconnect a vtab * / <nl> - hashDestroy , / * xDestroy - destroy a vtab * / <nl> - hashOpen , / * xOpen - open a cursor * / <nl> - hashClose , / * xClose - close a cursor * / <nl> - hashFilter , / * xFilter - configure scan constraints * / <nl> - hashNext , / * xNext - advance a cursor * / <nl> - hashEof , / * xEof * / <nl> - hashColumn , / * xColumn - read data * / <nl> - hashRowid , / * xRowid - read data * / <nl> - 0 , / * xUpdate * / <nl> - 0 , / * xBegin * / <nl> - 0 , / * xSync * / <nl> - 0 , / * xCommit * / <nl> - 0 , / * xRollback * / <nl> - 0 , / * xFindMethod * / <nl> - 0 , / * xRename * / <nl> - } ; <nl> - <nl> - / * <nl> - * * Invoke this routine to create a specific instance of an hash object . <nl> - * * The new hash object is returned by the 3rd parameter . <nl> - * * <nl> - * * Each hash object corresponds to a virtual table in the TEMP table <nl> - * * with a name of zName . <nl> - * * <nl> - * * Destroy the hash object by dropping the virtual table . If not done <nl> - * * explicitly by the application , the virtual table will be dropped implicitly <nl> - * * by the system when the database connection is closed . <nl> - * / <nl> - int sqlite3_hash_create ( sqlite3 * db , <nl> - const char * zName , <nl> - sqlite3_hash * * ppReturn ) { <nl> - int rc = SQLITE_OK ; <nl> - sqlite3_hash * p ; <nl> - <nl> - * ppReturn = p = new sqlite3_hash ; <nl> - <nl> - if ( p = = 0 ) { <nl> - return SQLITE_NOMEM ; <nl> - } <nl> - memset ( p , 0 , sizeof ( * p ) ) ; <nl> - <nl> - rc = sqlite3_create_module_v2 ( <nl> - db , zName , & hashModule , p , ( void ( * ) ( void * ) ) hashFree ) ; <nl> - if ( rc = = SQLITE_OK ) { <nl> - char * zSql ; <nl> - zSql = <nl> - sqlite3_mprintf ( " CREATE VIRTUAL TABLE temp . % Q USING % Q " , zName , zName ) ; <nl> - rc = sqlite3_exec ( db , zSql , 0 , 0 , 0 ) ; <nl> - sqlite3_free ( zSql ) ; <nl> - } <nl> - <nl> - return rc ; <nl> - } <nl> deleted file mode 100644 <nl> index 207dd1528d . . 0000000000 <nl> mmm a / osquery / tables / manual / hash . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - # ifndef OSQUERY_TABLES_HASH_H <nl> - # define OSQUERY_TABLES_HASH_H <nl> - <nl> - # include < sqlite3 . h > <nl> - <nl> - / / Make sure we can call this stuff from C + + . <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / / An sqlite3_hash is an abstract type to store an instance of <nl> - / / an integer array . <nl> - typedef struct sqlite3_hash sqlite3_hash ; <nl> - <nl> - / / Invoke this routine to create a specific instance of an hash object . <nl> - / / The new hash object is returned by the 3rd parameter . <nl> - / / <nl> - / / Each hash object corresponds to a virtual table in the TEMP table <nl> - / / with a name of zName . <nl> - / / <nl> - / / Destroy the hash object by dropping the virtual table . If not done <nl> - / / explicitly by the application , the virtual table will be dropped implicitly <nl> - / / by the system when the database connection is closed . <nl> - int sqlite3_hash_create ( sqlite3 * db , <nl> - const char * zName , <nl> - sqlite3_hash * * ppReturn ) ; <nl> - <nl> - # ifdef __cplusplus <nl> - } / / End of the ' extern " C " ' block <nl> - # endif <nl> - <nl> - # endif / * OSQUERY_TABLES_HASH_H * / <nl> mmm a / osquery / tables / networking / darwin / interfaces . cpp <nl> ppp b / osquery / tables / networking / darwin / interfaces . cpp <nl> <nl> # include < net / if . h > <nl> # include < sys / socket . h > <nl> <nl> - # include < boost / lexical_cast . hpp > <nl> - <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / tables / networking / utils . h " <nl> <nl> namespace osquery { <nl> mmm a / osquery / tables / networking / darwin / listening_ports . cpp <nl> ppp b / osquery / tables / networking / darwin / listening_ports . cpp <nl> <nl> # include < stdlib . h > <nl> # include < libproc . h > <nl> <nl> - # include < boost / lexical_cast . hpp > <nl> - <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl> void genSocket ( pid_t pid , struct socket_fdinfo socket , QueryData & results ) { <nl> struct in6_addr ipv6 = socket . psi . soi_proto . pri_in . insi_laddr . ina_6 ; <nl> <nl> Row r ; <nl> - r [ " pid " ] = boost : : lexical_cast < std : : string > ( pid ) ; <nl> - r [ " port " ] = boost : : lexical_cast < std : : string > ( local ) ; <nl> - r [ " protocol " ] = boost : : lexical_cast < std : : string > ( protocol ) ; <nl> - r [ " family " ] = boost : : lexical_cast < std : : string > ( family ) ; <nl> + r [ " pid " ] = INTEGER ( pid ) ; <nl> + r [ " port " ] = INTEGER ( local ) ; <nl> + r [ " protocol " ] = INTEGER ( protocol ) ; <nl> + r [ " family " ] = INTEGER ( family ) ; <nl> <nl> int octet ; <nl> std : : stringstream addr ; <nl> void genSocket ( pid_t pid , struct socket_fdinfo socket , QueryData & results ) { <nl> / / Parse IPv4 <nl> for ( int i = 0 ; i < 4 ; i + + ) { <nl> octet = ( int ) ipv6 . __u6_addr . __u6_addr8 [ i + 12 ] ; <nl> - addr < < boost : : lexical_cast < std : : string > ( octet ) ; <nl> + addr < < TEXT ( octet ) ; <nl> if ( i < 3 ) { <nl> addr < < " . " ; <nl> } <nl> mmm a / osquery / tables / networking / darwin / routes . cpp <nl> ppp b / osquery / tables / networking / darwin / routes . cpp <nl> <nl> # include < sys / sysctl . h > <nl> <nl> # include < boost / algorithm / string / trim . hpp > <nl> - # include < boost / lexical_cast . hpp > <nl> <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / tables / networking / utils . h " <nl> <nl> namespace osquery { <nl> mmm a / osquery / tables / specs / x / hash . table <nl> ppp b / osquery / tables / specs / x / hash . table <nl> <nl> table_name ( " hash " ) <nl> schema ( [ <nl> - Column ( " path " , TEXT , required = True ) , <nl> - Column ( " sha1 " , TEXT ) , <nl> + Column ( " path " , TEXT , " Must provide a path or directory " , required = True ) , <nl> + Column ( " directory " , TEXT , " Must provide a path or directory " , required = True ) , <nl> + Column ( " md5 " , TEXT ) , <nl> ] ) <nl> implementation ( " utility / hash @ genHash " ) <nl> mmm a / osquery / tables / system / cpuid . cpp <nl> ppp b / osquery / tables / system / cpuid . cpp <nl> <nl> # include < vector > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> # define FEATURE ( name , reg , bit ) std : : make_pair ( name , std : : make_pair ( reg , bit ) ) <nl> <nl> mmm a / osquery / tables / system / darwin / firewall . cpp <nl> ppp b / osquery / tables / system / darwin / firewall . cpp <nl> <nl> <nl> # include < boost / lexical_cast . hpp > <nl> <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / filesystem . h " <nl> - # include " osquery / status . h " <nl> <nl> using osquery : : Status ; <nl> namespace pt = boost : : property_tree ; <nl> mmm a / osquery / tables / system / darwin / kextstat . cpp <nl> ppp b / osquery / tables / system / darwin / kextstat . cpp <nl> <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> extern " C " { <nl> extern CFDictionaryRef OSKextCopyLoadedKextInfo ( CFArrayRef , CFArrayRef ) ; <nl> mmm a / osquery / tables / system / darwin / mounts . cpp <nl> ppp b / osquery / tables / system / darwin / mounts . cpp <nl> <nl> # include < stdio . h > <nl> # include < sys / mount . h > <nl> <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl> mmm a / osquery / tables / system / darwin / osx_version . mm <nl> ppp b / osquery / tables / system / darwin / osx_version . mm <nl> <nl> / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> <nl> - # include " osquery / database / results . h " <nl> - <nl> # include < string > <nl> <nl> # import " osquery / core / darwin / NSProcessInfo + PECocoaBackports . h " <nl> <nl> + # include " osquery / tables . h " <nl> + <nl> namespace osquery { <nl> namespace tables { <nl> <nl> mmm a / osquery / tables / system / darwin / process_open_files . cpp <nl> ppp b / osquery / tables / system / darwin / process_open_files . cpp <nl> <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / filesystem . h " <nl> <nl> # define IPv6_2_IPv4 ( v6 ) ( ( ( uint8_t * ) ( ( struct in6_addr * ) v6 ) - > s6_addr ) + 12 ) <nl> mmm a / osquery / tables / system / darwin / processes . cpp <nl> ppp b / osquery / tables / system / darwin / processes . cpp <nl> <nl> # include < glog / logging . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / filesystem . h " <nl> <nl> namespace osquery { <nl> mmm a / osquery / tables / system / darwin / quarantine . cpp <nl> ppp b / osquery / tables / system / darwin / quarantine . cpp <nl> <nl> # include < sys / stat . h > <nl> # include < sys / xattr . h > <nl> <nl> - # include < boost / lexical_cast . hpp > <nl> # include < boost / filesystem . hpp > <nl> # include < boost / algorithm / string . hpp > <nl> <nl> - # include " osquery / database . h " <nl> + # include " osquery / logger . h " <nl> + # include " osquery / tables . h " <nl> <nl> using std : : string ; <nl> using boost : : lexical_cast ; <nl> QueryData genQuarantine ( ) { <nl> try { <nl> Row r ; <nl> std : : vector < std : : string > values ; <nl> - std : : string filePathQuotes = boost : : lexical_cast < std : : string > ( path ) ; <nl> + std : : string filePathQuotes = TEXT ( path ) ; <nl> std : : string filePath = <nl> filePathQuotes . substr ( 1 , filePathQuotes . length ( ) - 2 ) ; <nl> <nl> QueryData genQuarantine ( ) { <nl> } <nl> } catch ( . . . ) { <nl> LOG ( ERROR ) < < " Couldn ' t handle file " <nl> - < < boost : : lexical_cast < std : : string > ( * it ) ; <nl> + < < TEXT ( * it ) ; <nl> } <nl> try { <nl> + + it ; <nl> } catch ( const std : : exception & ex ) { <nl> LOG ( WARNING ) < < " Permissions error on " <nl> - < < boost : : lexical_cast < std : : string > ( * it ) ; <nl> + < < TEXT ( * it ) ; <nl> it . no_push ( ) ; <nl> } <nl> } <nl> mmm a / osquery / tables / system / darwin / users . mm <nl> ppp b / osquery / tables / system / darwin / users . mm <nl> <nl> # import < OpenDirectory / OpenDirectory . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database / results . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / filesystem . h " <nl> <nl> namespace osquery { <nl> mmm a / osquery / tables / system / last . cpp <nl> ppp b / osquery / tables / system / last . cpp <nl> <nl> # include < utmpx . h > <nl> <nl> # include " osquery / core . h " <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl> mmm a / osquery / tables / templates / default . cpp . in <nl> ppp b / osquery / tables / templates / default . cpp . in <nl> <nl> # include < string > <nl> # include < vector > <nl> <nl> - # include < boost / lexical_cast . hpp > <nl> - <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> # include " osquery / tables / base . h " <nl> # include " osquery / registry / registry . h " <nl> <nl> namespace osquery { namespace tables { <nl> <nl> { % if class_name = = " " % } \ <nl> - osquery : : QueryData { { function } } ( ) ; <nl> + osquery : : QueryData { { function } } ( QueryRequest & request ) ; <nl> { % else % } <nl> class { { class_name } } { <nl> public : <nl> - static osquery : : QueryData { { function } } ( ) ; <nl> + static osquery : : QueryData { { function } } ( QueryRequest & request ) ; <nl> } ; <nl> { % endif % } \ <nl> <nl> struct sqlite3_ { { table_name } } { <nl> { % for col in schema % } \ <nl> std : : vector < { { col . type . type } } > xCol_ { { col . name } } ; <nl> { % endfor % } \ <nl> + ConstraintSet xConstraints ; <nl> } ; <nl> <nl> const std : : string <nl> int { { table_name_cc } } Column ( <nl> return SQLITE_OK ; <nl> } <nl> <nl> + static int { { table_name_cc } } BestIndex ( <nl> + sqlite3_vtab * tab , <nl> + sqlite3_index_info * pIdxInfo <nl> + ) { <nl> + / / Will need to check if required = True for any cols . <nl> + x_vtab < sqlite3_hash > * pVtab = ( x_vtab < sqlite3_hash > * ) tab ; <nl> + <nl> + int expr_index = 0 ; <nl> + for ( int i = 0 ; i < pIdxInfo - > nConstraint ; i + + ) { <nl> + if ( ! pIdxInfo - > aConstraint [ i ] . usable ) { <nl> + continue ; <nl> + } <nl> + <nl> + switch ( pIdxInfo - > aConstraint [ i ] . iColumn ) { <nl> + { % for col in schema % } \ <nl> + case { { loop . index0 } } : / / { { col . name } } <nl> + pVtab - > pContent - > xConstraints . push_back ( <nl> + std : : make_pair ( <nl> + " { { col . name } } " , <nl> + Constraint ( pIdxInfo - > aConstraint [ i ] . op ) <nl> + ) <nl> + ) ; <nl> + pIdxInfo - > aConstraintUsage [ i ] . argvIndex = + + expr_index ; <nl> + break ; <nl> + { % endfor % } \ <nl> + } <nl> + } <nl> + return SQLITE_OK ; <nl> + } <nl> + <nl> int { { table_name_cc } } Filter ( <nl> sqlite3_vtab_cursor * pVtabCursor , <nl> int idxNum , <nl> int { { table_name_cc } } Filter ( <nl> pVtab - > pContent - > xCol_ { { col . name } } . clear ( ) ; <nl> { % endfor % } \ <nl> <nl> + QueryRequest request ; <nl> + for ( size_t i = 0 ; i < argc ; + + i ) { <nl> + auto expr = ( const char * ) sqlite3_value_text ( argv [ i ] ) ; <nl> + / / Set the expression from SQLite ' s now - populated argv . <nl> + pVtab - > pContent - > xConstraints [ i ] . second . expr = std : : string ( expr ) ; <nl> + / / Add the constraint to the column - sorted query request map . <nl> + request . constraints [ pVtab - > pContent - > xConstraints [ i ] . first ] . add ( <nl> + pVtab - > pContent - > xConstraints [ i ] . second ) ; <nl> + } <nl> + <nl> { % if class_name ! = " " % } <nl> - for ( auto & row : osquery : : tables : : { { class_name } } : : { { function } } ( ) ) { <nl> + for ( auto & row : osquery : : tables : : { { class_name } } : : { { function } } ( request ) ) { <nl> { % else % } <nl> - for ( auto & row : osquery : : tables : : { { function } } ( ) ) { <nl> + for ( auto & row : osquery : : tables : : { { function } } ( request ) ) { <nl> { % endif % } <nl> { % for col in schema % } \ <nl> { % if col . type . affinity = = " TEXT " % } \ <nl> int { { table_name_cc } } Filter ( <nl> <nl> static sqlite3_module { { table_name_cc } } Module = { <nl> 0 , <nl> - { { table_name_cc } } Create , / / create a new vtable <nl> - { { table_name_cc } } Create , / / connect to an existing vtable <nl> - xBestIndex , / / find the best query index <nl> - xDestroy < x_vtab < sqlite3_ { { table_name } } > > , / / disconnect a vtable <nl> - xDestroy < x_vtab < sqlite3_ { { table_name } } > > , / / destory a vtable <nl> - xOpen < base_cursor > , / / open a cursor <nl> - xClose < base_cursor > , / / close a cursor <nl> - { { table_name_cc } } Filter , / / configure scan constraints <nl> - xNext < base_cursor > , / / advance the cursor <nl> + { { table_name_cc } } Create , <nl> + { { table_name_cc } } Create , <nl> + { { table_name_cc } } BestIndex , <nl> + xDestroy < x_vtab < sqlite3_ { { table_name } } > > , <nl> + xDestroy < x_vtab < sqlite3_ { { table_name } } > > , <nl> + xOpen < base_cursor > , <nl> + xClose < base_cursor > , <nl> + { { table_name_cc } } Filter , <nl> + xNext < base_cursor > , <nl> xEof < base_cursor , x_vtab < sqlite3_ { { table_name } } > > , <nl> - { { table_name_cc } } Column , / / read data <nl> - xRowid < base_cursor > , / / read data <nl> - 0 , / / update <nl> - 0 , / / begin <nl> - 0 , / / sync <nl> - 0 , / / commit <nl> - 0 , / / rollback <nl> - 0 , / / findmethod <nl> - 0 , / / rename <nl> + { { table_name_cc } } Column , <nl> + xRowid < base_cursor > , <nl> + 0 , <nl> + 0 , <nl> + 0 , <nl> + 0 , <nl> + 0 , <nl> + 0 , <nl> + 0 , <nl> } ; <nl> <nl> class { { table_name_cc } } TablePlugin : public TablePlugin { <nl> REGISTER_TABLE ( <nl> std : : make_shared < { { table_name_cc } } TablePlugin > ( ) <nl> ) ; <nl> <nl> - } } <nl> + } } <nl> \ No newline at end of file <nl> mmm a / osquery / tables / utility / hash . cpp <nl> ppp b / osquery / tables / utility / hash . cpp <nl> <nl> / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> <nl> - # include " osquery / database . h " <nl> + # include " osquery / core / md5 . h " <nl> + <nl> + # include < boost / filesystem . hpp > <nl> + <nl> + # include " osquery / tables . h " <nl> # include " osquery / filesystem . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl> <nl> - <nl> - QueryData genHash ( ) { <nl> + QueryData genHash ( QueryRequest & request ) { <nl> QueryData results ; <nl> + osquery : : md5 : : MD5 digest ; <nl> + <nl> + auto paths = request . constraints [ " path " ] . getAll ( EQUALS ) ; <nl> + for ( const auto & path_string : paths ) { <nl> + boost : : filesystem : : path path = path_string ; <nl> + if ( ! boost : : filesystem : : is_regular_file ( path ) ) { <nl> + continue ; <nl> + } <nl> + Row r ; <nl> + r [ " path " ] = path . string ( ) ; <nl> + r [ " md5 " ] = std : : string ( digest . digestFile ( path . c_str ( ) ) ) ; <nl> + r [ " directory " ] = path . parent_path ( ) . string ( ) ; <nl> + results . push_back ( r ) ; <nl> + } <nl> + <nl> + auto directories = request . constraints [ " directory " ] . getAll ( EQUALS ) ; <nl> + for ( const auto & directory_string : directories ) { <nl> + boost : : filesystem : : path directory = directory_string ; <nl> + if ( ! boost : : filesystem : : is_directory ( directory ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + / / Iterate over the directory and generate a hash for each regular file . <nl> + boost : : filesystem : : directory_iterator begin ( directory ) , end ; <nl> + for ( ; begin ! = end ; + + begin ) { <nl> + Row r ; <nl> + r [ " path " ] = begin - > path ( ) . string ( ) ; <nl> + r [ " directory " ] = directory_string ; <nl> + if ( boost : : filesystem : : is_regular_file ( begin - > status ( ) ) ) { <nl> + r [ " md5 " ] = digest . digestFile ( begin - > path ( ) . string ( ) . c_str ( ) ) ; <nl> + } <nl> + results . push_back ( r ) ; <nl> + } <nl> + } <nl> <nl> return results ; <nl> } <nl> mmm a / osquery / tables / utility / time . cpp <nl> ppp b / osquery / tables / utility / time . cpp <nl> <nl> <nl> # include < ctime > <nl> <nl> - # include " osquery / database . h " <nl> + # include " osquery / tables . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl>
|
Organizing affinity types into tables .
|
osquery/osquery
|
cd8413d48380095ae1df60285722d45a3ff8d654
|
2014-11-30T06:36:05Z
|
mmm a / modules / core / include / opencv2 / core / hal / intrin . hpp <nl> ppp b / modules / core / include / opencv2 / core / hal / intrin . hpp <nl> using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE ; <nl> / / but some of AVX2 intrinsics get v256_ prefix instead of v_ , e . g . v256_load ( ) vs v_load ( ) . <nl> / / Correspondingly , the wide intrinsics ( which are mapped to the " widest " <nl> / / available instruction set ) will get vx_ prefix <nl> - / / ( and will be mapped to v256_ counterparts ) ( e . g . vx_load ( ) = > v245_load ( ) ) <nl> + / / ( and will be mapped to v256_ counterparts ) ( e . g . vx_load ( ) = > v256_load ( ) ) <nl> # if CV_AVX2 <nl> <nl> # include " opencv2 / core / hal / intrin_avx . hpp " <nl> CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN <nl> inline vtyp vx_setzero_ # # short_typ ( ) { return prefix # # _setzero_ # # short_typ ( ) ; } \ <nl> inline vtyp vx_ # # loadsfx ( const typ * ptr ) { return prefix # # _ # # loadsfx ( ptr ) ; } \ <nl> inline vtyp vx_ # # loadsfx # # _aligned ( const typ * ptr ) { return prefix # # _ # # loadsfx # # _aligned ( ptr ) ; } \ <nl> + inline vtyp vx_ # # loadsfx # # _low ( const typ * ptr ) { return prefix # # _ # # loadsfx # # _low ( ptr ) ; } \ <nl> + inline vtyp vx_ # # loadsfx # # _halves ( const typ * ptr0 , const typ * ptr1 ) { return prefix # # _ # # loadsfx # # _halves ( ptr0 , ptr1 ) ; } \ <nl> inline void vx_store ( typ * ptr , const vtyp & v ) { return v_store ( ptr , v ) ; } \ <nl> inline void vx_store_aligned ( typ * ptr , const vtyp & v ) { return v_store_aligned ( ptr , v ) ; } <nl> <nl> # define CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND ( typ , wtyp , prefix ) \ <nl> - inline wtyp vx_load_expand ( const typ * ptr ) { return prefix # # _load_expand ( ptr ) ; } <nl> + inline wtyp vx_load_expand ( const typ * ptr ) { return prefix # # _load_expand ( ptr ) ; } <nl> <nl> # define CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND_Q ( typ , qtyp , prefix ) \ <nl> - inline qtyp vx_load_expand_q ( const typ * ptr ) { return prefix # # _load_expand_q ( ptr ) ; } <nl> + inline qtyp vx_load_expand_q ( const typ * ptr ) { return prefix # # _load_expand_q ( ptr ) ; } <nl> <nl> # define CV_INTRIN_DEFINE_WIDE_INTRIN_WITH_EXPAND ( typ , vtyp , short_typ , wtyp , qtyp , prefix , loadsfx ) \ <nl> CV_INTRIN_DEFINE_WIDE_INTRIN ( typ , vtyp , short_typ , prefix , loadsfx ) \ <nl> template < typename _Tp > struct V_RegTraits <nl> CV_INTRIN_DEFINE_WIDE_INTRIN_ALL_TYPES ( v256 ) <nl> CV_INTRIN_DEFINE_WIDE_INTRIN ( double , v_float64 , f64 , v256 , load ) <nl> inline void vx_cleanup ( ) { v256_cleanup ( ) ; } <nl> - # elif CV_SIMD128 <nl> + # elif CV_SIMD128 | | CV_SIMD128_CPP <nl> typedef v_uint8x16 v_uint8 ; <nl> typedef v_int8x16 v_int8 ; <nl> typedef v_uint16x8 v_uint16 ; <nl> mmm a / modules / core / include / opencv2 / core / hal / intrin_avx . hpp <nl> ppp b / modules / core / include / opencv2 / core / hal / intrin_avx . hpp <nl> inline v_float16x16 v256_load_f16 ( const short * ptr ) <nl> inline v_float16x16 v256_load_f16_aligned ( const short * ptr ) <nl> { return v_float16x16 ( _mm256_load_si256 ( ( const __m256i * ) ptr ) ) ; } <nl> <nl> + inline v_float16x16 v256_load_f16_low ( const short * ptr ) <nl> + { return v_float16x16 ( v256_load_low ( ptr ) . val ) ; } <nl> + inline v_float16x16 v256_load_f16_halves ( const short * ptr0 , const short * ptr1 ) <nl> + { return v_float16x16 ( v256_load_halves ( ptr0 , ptr1 ) . val ) ; } <nl> + <nl> inline void v_store ( short * ptr , const v_float16x16 & a ) <nl> { _mm256_storeu_si256 ( ( __m256i * ) ptr , a . val ) ; } <nl> inline void v_store_aligned ( short * ptr , const v_float16x16 & a ) <nl> OPENCV_HAL_IMPL_AVX_BIN_FUNC ( v_max , v_float64x4 , _mm256_max_pd ) <nl> template < int imm > <nl> inline v_uint8x32 v_rotate_left ( const v_uint8x32 & a , const v_uint8x32 & b ) <nl> { <nl> - __m256i swap = _mm256_permute2x128_si256 ( a . val , b . val , 0x03 ) ; <nl> - <nl> - switch ( imm ) <nl> - { <nl> - case 0 : return a ; <nl> - case 32 : return b ; <nl> - case 16 : return v_uint8x32 ( swap ) ; <nl> - } <nl> + enum { IMM_R = ( 16 - imm ) & 0xFF } ; <nl> + enum { IMM_R2 = ( 32 - imm ) & 0xFF } ; <nl> <nl> - if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( a . val , swap , 16 - imm ) ) ; <nl> - if ( imm < 32 ) return v_uint8x32 ( _mm256_alignr_epi8 ( swap , b . val , 32 - imm ) ) ; <nl> + if ( imm = = 0 ) return a ; <nl> + if ( imm = = 32 ) return b ; <nl> + if ( imm > 32 ) return v_uint8x32 ( ) ; <nl> <nl> - return v_uint8x32 ( ) ; <nl> + __m256i swap = _mm256_permute2x128_si256 ( a . val , b . val , 0x03 ) ; <nl> + if ( imm = = 16 ) return v_uint8x32 ( swap ) ; <nl> + if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( a . val , swap , IMM_R ) ) ; <nl> + return v_uint8x32 ( _mm256_alignr_epi8 ( swap , b . val , IMM_R2 ) ) ; / / imm < 32 <nl> } <nl> <nl> template < int imm > <nl> inline v_uint8x32 v_rotate_right ( const v_uint8x32 & a , const v_uint8x32 & b ) <nl> { <nl> - __m256i swap = _mm256_permute2x128_si256 ( a . val , b . val , 0x21 ) ; <nl> - <nl> - switch ( imm ) <nl> - { <nl> - case 0 : return a ; <nl> - case 32 : return b ; <nl> - case 16 : return v_uint8x32 ( swap ) ; <nl> - } <nl> + enum { IMM_L = ( imm - 16 ) & 0xFF } ; <nl> <nl> - if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( swap , a . val , imm ) ) ; <nl> - if ( imm < 32 ) return v_uint8x32 ( _mm256_alignr_epi8 ( b . val , swap , imm - 16 ) ) ; <nl> + if ( imm = = 0 ) return a ; <nl> + if ( imm = = 32 ) return b ; <nl> + if ( imm > 32 ) return v_uint8x32 ( ) ; <nl> <nl> - return v_uint8x32 ( ) ; <nl> + __m256i swap = _mm256_permute2x128_si256 ( a . val , b . val , 0x21 ) ; <nl> + if ( imm = = 16 ) return v_uint8x32 ( swap ) ; <nl> + if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( swap , a . val , imm ) ) ; <nl> + return v_uint8x32 ( _mm256_alignr_epi8 ( b . val , swap , IMM_L ) ) ; <nl> } <nl> <nl> template < int imm > <nl> inline v_uint8x32 v_rotate_left ( const v_uint8x32 & a ) <nl> { <nl> - v_uint8x32 res ; <nl> + enum { IMM_L = ( imm - 16 ) & 0xFF } ; <nl> + enum { IMM_R = ( 16 - imm ) & 0xFF } ; <nl> + <nl> + if ( imm = = 0 ) return a ; <nl> + if ( imm > 32 ) return v_uint8x32 ( ) ; <nl> + <nl> / / ESAC control [ 3 ] ? [ 127 : 0 ] = 0 <nl> __m256i swapz = _mm256_permute2x128_si256 ( a . val , a . val , _MM_SHUFFLE ( 0 , 0 , 2 , 0 ) ) ; <nl> - <nl> - if ( imm = = 0 ) <nl> - return a ; <nl> - if ( imm = = 16 ) <nl> - res . val = swapz ; <nl> - else if ( imm < 16 ) <nl> - res . val = _mm256_alignr_epi8 ( a . val , swapz , 16 - imm ) ; <nl> - else if ( imm < 32 ) <nl> - res . val = _mm256_slli_si256 ( swapz , imm - 16 ) ; <nl> - else <nl> - return v_uint8x32 ( ) ; <nl> - return res ; <nl> + if ( imm = = 16 ) return v_uint8x32 ( swapz ) ; <nl> + if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( a . val , swapz , IMM_R ) ) ; <nl> + return v_uint8x32 ( _mm256_slli_si256 ( swapz , IMM_L ) ) ; <nl> } <nl> <nl> template < int imm > <nl> inline v_uint8x32 v_rotate_right ( const v_uint8x32 & a ) <nl> { <nl> - v_uint8x32 res ; <nl> + enum { IMM_L = ( imm - 16 ) & 0xFF } ; <nl> + <nl> + if ( imm = = 0 ) return a ; <nl> + if ( imm > 32 ) return v_uint8x32 ( ) ; <nl> + <nl> / / ESAC control [ 3 ] ? [ 127 : 0 ] = 0 <nl> __m256i swapz = _mm256_permute2x128_si256 ( a . val , a . val , _MM_SHUFFLE ( 2 , 0 , 0 , 1 ) ) ; <nl> - <nl> - if ( imm = = 0 ) <nl> - return a ; <nl> - if ( imm = = 16 ) <nl> - res . val = swapz ; <nl> - else if ( imm < 16 ) <nl> - res . val = _mm256_alignr_epi8 ( swapz , a . val , imm ) ; <nl> - else if ( imm < 32 ) <nl> - res . val = _mm256_srli_si256 ( swapz , imm - 16 ) ; <nl> - else <nl> - return v_uint8x32 ( ) ; <nl> - return res ; <nl> - } <nl> - <nl> - # define OPENCV_HAL_IMPL_AVX_ROTATE_CAST ( intrin , _Tpvec , cast ) \ <nl> - template < int imm > \ <nl> - inline _Tpvec intrin ( const _Tpvec & a , const _Tpvec & b ) \ <nl> - { \ <nl> - const int w = sizeof ( typename _Tpvec : : lane_type ) ; \ <nl> - v_uint8x32 ret = intrin < imm * w > ( v_reinterpret_as_u8 ( a ) , \ <nl> - v_reinterpret_as_u8 ( b ) ) ; \ <nl> - return _Tpvec ( cast ( ret . val ) ) ; \ <nl> - } \ <nl> - template < int imm > \ <nl> - inline _Tpvec intrin ( const _Tpvec & a ) \ <nl> - { \ <nl> - const int w = sizeof ( typename _Tpvec : : lane_type ) ; \ <nl> - v_uint8x32 ret = intrin < imm * w > ( v_reinterpret_as_u8 ( a ) ) ; \ <nl> - return _Tpvec ( cast ( ret . val ) ) ; \ <nl> + if ( imm = = 16 ) return v_uint8x32 ( swapz ) ; <nl> + if ( imm < 16 ) return v_uint8x32 ( _mm256_alignr_epi8 ( swapz , a . val , imm ) ) ; <nl> + return v_uint8x32 ( _mm256_srli_si256 ( swapz , IMM_L ) ) ; <nl> + } <nl> + <nl> + # define OPENCV_HAL_IMPL_AVX_ROTATE_CAST ( intrin , _Tpvec , cast ) \ <nl> + template < int imm > \ <nl> + inline _Tpvec intrin ( const _Tpvec & a , const _Tpvec & b ) \ <nl> + { \ <nl> + enum { IMMxW = imm * sizeof ( typename _Tpvec : : lane_type ) } ; \ <nl> + v_uint8x32 ret = intrin < IMMxW > ( v_reinterpret_as_u8 ( a ) , \ <nl> + v_reinterpret_as_u8 ( b ) ) ; \ <nl> + return _Tpvec ( cast ( ret . val ) ) ; \ <nl> + } \ <nl> + template < int imm > \ <nl> + inline _Tpvec intrin ( const _Tpvec & a ) \ <nl> + { \ <nl> + enum { IMMxW = imm * sizeof ( typename _Tpvec : : lane_type ) } ; \ <nl> + v_uint8x32 ret = intrin < IMMxW > ( v_reinterpret_as_u8 ( a ) ) ; \ <nl> + return _Tpvec ( cast ( ret . val ) ) ; \ <nl> } <nl> <nl> # define OPENCV_HAL_IMPL_AVX_ROTATE ( _Tpvec ) \ <nl> mmm a / modules / core / include / opencv2 / core / hal / intrin_neon . hpp <nl> ppp b / modules / core / include / opencv2 / core / hal / intrin_neon . hpp <nl> static inline void cv_vst1_f16 ( void * ptr , float16x4_t a ) <nl> # endif <nl> } <nl> <nl> + # ifndef vdup_n_f16 <nl> + # define vdup_n_f16 ( v ) ( float16x4_t ) { v , v , v , v } <nl> + # endif <nl> <nl> struct v_float16x8 <nl> { <nl> inline v_float16x8 v_load_f16 ( const short * ptr ) <nl> inline v_float16x8 v_load_f16_aligned ( const short * ptr ) <nl> { return v_float16x8 ( cv_vld1q_f16 ( ptr ) ) ; } <nl> <nl> + inline v_float16x8 v_load_f16_low ( const short * ptr ) <nl> + { return v_float16x8 ( vcombine_f16 ( cv_vld1_f16 ( ptr ) , vdup_n_f16 ( ( float16_t ) 0 ) ) ) ; } <nl> + inline v_float16x8 v_load_f16_halves ( const short * ptr0 , const short * ptr1 ) <nl> + { return v_float16x8 ( vcombine_f16 ( cv_vld1_f16 ( ptr0 ) , cv_vld1_f16 ( ptr1 ) ) ) ; } <nl> + <nl> inline void v_store ( short * ptr , const v_float16x8 & a ) <nl> { cv_vst1q_f16 ( ptr , a . val ) ; } <nl> inline void v_store_aligned ( short * ptr , const v_float16x8 & a ) <nl> mmm a / modules / core / include / opencv2 / core / hal / intrin_sse . hpp <nl> ppp b / modules / core / include / opencv2 / core / hal / intrin_sse . hpp <nl> inline v_float16x8 v_load_f16 ( const short * ptr ) <nl> inline v_float16x8 v_load_f16_aligned ( const short * ptr ) <nl> { return v_float16x8 ( _mm_load_si128 ( ( const __m128i * ) ptr ) ) ; } <nl> <nl> + inline v_float16x8 v_load_f16_low ( const short * ptr ) <nl> + { return v_float16x8 ( v_load_low ( ptr ) . val ) ; } <nl> + inline v_float16x8 v_load_f16_halves ( const short * ptr0 , const short * ptr1 ) <nl> + { return v_float16x8 ( v_load_halves ( ptr0 , ptr1 ) . val ) ; } <nl> + <nl> inline void v_store ( short * ptr , const v_float16x8 & a ) <nl> { _mm_storeu_si128 ( ( __m128i * ) ptr , a . val ) ; } <nl> inline void v_store_aligned ( short * ptr , const v_float16x8 & a ) <nl> new file mode 100644 <nl> index 00000000000 . . 9ebfcdf542b <nl> mmm / dev / null <nl> ppp b / modules / core / test / test_intrin . avx2 . cpp <nl> <nl> + / / This file is part of OpenCV project . <nl> + / / It is subject to the license terms in the LICENSE file found in the top - level directory <nl> + / / of this distribution and at http : / / opencv . org / license . html . <nl> + # include " test_precomp . hpp " <nl> + # include " test_intrin . simd . hpp " <nl> \ No newline at end of file <nl> mmm a / modules / core / test / test_intrin . cpp <nl> ppp b / modules / core / test / test_intrin . cpp <nl> <nl> / / It is subject to the license terms in the LICENSE file found in the top - level directory <nl> / / of this distribution and at http : / / opencv . org / license . html . <nl> # include " test_precomp . hpp " <nl> + # include " test_intrin . simd . hpp " <nl> <nl> - # include " test_intrin_utils . hpp " <nl> - <nl> - # define CV_CPU_SIMD_FILENAME " test_intrin_utils . hpp " <nl> + # define CV_CPU_SIMD_FILENAME " test_intrin . simd . hpp " <nl> # define CV_CPU_DISPATCH_MODE FP16 <nl> # include " opencv2 / core / private / cv_cpu_include_simd_declarations . hpp " <nl> <nl> - <nl> - using namespace cv ; <nl> + # define CV_CPU_DISPATCH_MODE AVX2 <nl> + # include " opencv2 / core / private / cv_cpu_include_simd_declarations . hpp " <nl> <nl> namespace opencv_test { namespace hal { <nl> using namespace CV_CPU_OPTIMIZATION_NAMESPACE ; <nl> <nl> - / / = = = = = = = = = = = = = 8 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - TEST ( hal_intrin , uint8x16 ) { <nl> - TheTest < v_uint8x16 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_expand_q ( ) <nl> - . test_addsub ( ) <nl> - . test_addsub_wrap ( ) <nl> - . test_cmp ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_mask ( ) <nl> - . test_popcount ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 3 > ( ) . test_pack < 8 > ( ) <nl> - . test_pack_u < 1 > ( ) . test_pack_u < 2 > ( ) . test_pack_u < 3 > ( ) . test_pack_u < 8 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 8 > ( ) . test_extract < 15 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 8 > ( ) . test_rotate < 15 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , uint8x16 ) <nl> + { test_hal_intrin_uint8 ( ) ; } <nl> <nl> - TEST ( hal_intrin , int8x16 ) { <nl> - TheTest < v_int8x16 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_expand_q ( ) <nl> - . test_addsub ( ) <nl> - . test_addsub_wrap ( ) <nl> - . test_cmp ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_abs ( ) <nl> - . test_mask ( ) <nl> - . test_popcount ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 3 > ( ) . test_pack < 8 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 8 > ( ) . test_extract < 15 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 8 > ( ) . test_rotate < 15 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , int8x16 ) <nl> + { test_hal_intrin_int8 ( ) ; } <nl> <nl> - / / = = = = = = = = = = = = = 16 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - TEST ( hal_intrin , uint16x8 ) { <nl> - TheTest < v_uint16x8 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_addsub ( ) <nl> - . test_addsub_wrap ( ) <nl> - . test_mul ( ) <nl> - . test_mul_expand ( ) <nl> - . test_cmp ( ) <nl> - . test_shift < 1 > ( ) <nl> - . test_shift < 8 > ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_reduce ( ) <nl> - . test_mask ( ) <nl> - . test_popcount ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 7 > ( ) . test_pack < 16 > ( ) <nl> - . test_pack_u < 1 > ( ) . test_pack_u < 2 > ( ) . test_pack_u < 7 > ( ) . test_pack_u < 16 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 4 > ( ) . test_extract < 7 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 4 > ( ) . test_rotate < 7 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , uint16x8 ) <nl> + { test_hal_intrin_uint16 ( ) ; } <nl> <nl> - TEST ( hal_intrin , int16x8 ) { <nl> - TheTest < v_int16x8 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_addsub ( ) <nl> - . test_addsub_wrap ( ) <nl> - . test_mul ( ) <nl> - . test_mul_expand ( ) <nl> - . test_cmp ( ) <nl> - . test_shift < 1 > ( ) <nl> - . test_shift < 8 > ( ) <nl> - . test_dot_prod ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_abs ( ) <nl> - . test_reduce ( ) <nl> - . test_mask ( ) <nl> - . test_popcount ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 7 > ( ) . test_pack < 16 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 4 > ( ) . test_extract < 7 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 4 > ( ) . test_rotate < 7 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , int16x8 ) <nl> + { test_hal_intrin_int16 ( ) ; } <nl> <nl> - / / = = = = = = = = = = = = = 32 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - TEST ( hal_intrin , uint32x4 ) { <nl> - TheTest < v_uint32x4 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_addsub ( ) <nl> - . test_mul ( ) <nl> - . test_mul_expand ( ) <nl> - . test_cmp ( ) <nl> - . test_shift < 1 > ( ) <nl> - . test_shift < 8 > ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_reduce ( ) <nl> - . test_mask ( ) <nl> - . test_popcount ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 15 > ( ) . test_pack < 32 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> - . test_transpose ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , int32x4 ) <nl> + { test_hal_intrin_int32 ( ) ; } <nl> <nl> - TEST ( hal_intrin , int32x4 ) { <nl> - TheTest < v_int32x4 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_expand ( ) <nl> - . test_addsub ( ) <nl> - . test_mul ( ) <nl> - . test_abs ( ) <nl> - . test_cmp ( ) <nl> - . test_popcount ( ) <nl> - . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> - . test_logic ( ) <nl> - . test_min_max ( ) <nl> - . test_absdiff ( ) <nl> - . test_reduce ( ) <nl> - . test_mask ( ) <nl> - . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 15 > ( ) . test_pack < 32 > ( ) <nl> - . test_unpack ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> - . test_float_cvt32 ( ) <nl> - . test_float_cvt64 ( ) <nl> - . test_transpose ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , uint32x4 ) <nl> + { test_hal_intrin_uint32 ( ) ; } <nl> <nl> - / / = = = = = = = = = = = = = 64 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - TEST ( hal_intrin , uint64x2 ) { <nl> - TheTest < v_uint64x2 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_addsub ( ) <nl> - . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> - . test_logic ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , uint64x2 ) <nl> + { test_hal_intrin_uint64 ( ) ; } <nl> <nl> - TEST ( hal_intrin , int64x2 ) { <nl> - TheTest < v_int64x2 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_addsub ( ) <nl> - . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> - . test_logic ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , int64x2 ) <nl> + { test_hal_intrin_int64 ( ) ; } <nl> <nl> - / / = = = = = = = = = = = = = Floating point = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - TEST ( hal_intrin , float32x4 ) { <nl> - TheTest < v_float32x4 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_interleave ( ) <nl> - . test_interleave_2channel ( ) <nl> - . test_addsub ( ) <nl> - . test_mul ( ) <nl> - . test_div ( ) <nl> - . test_cmp ( ) <nl> - . test_sqrt_abs ( ) <nl> - . test_min_max ( ) <nl> - . test_float_absdiff ( ) <nl> - . test_reduce ( ) <nl> - . test_mask ( ) <nl> - . test_unpack ( ) <nl> - . test_float_math ( ) <nl> - . test_float_cvt64 ( ) <nl> - . test_matmul ( ) <nl> - . test_transpose ( ) <nl> - . test_reduce_sum4 ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> - ; <nl> - } <nl> + TEST ( hal_intrin , float32x4 ) <nl> + { test_hal_intrin_float32 ( ) ; } <nl> <nl> - # if CV_SIMD128_64F <nl> - TEST ( hal_intrin , float64x2 ) { <nl> - TheTest < v_float64x2 > ( ) <nl> - . test_loadstore ( ) <nl> - . test_addsub ( ) <nl> - . test_mul ( ) <nl> - . test_div ( ) <nl> - . test_cmp ( ) <nl> - . test_sqrt_abs ( ) <nl> - . test_min_max ( ) <nl> - . test_float_absdiff ( ) <nl> - . test_mask ( ) <nl> - . test_unpack ( ) <nl> - . test_float_math ( ) <nl> - . test_float_cvt32 ( ) <nl> - . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> - . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> - ; <nl> - } <nl> - # endif <nl> + TEST ( hal_intrin , float64x2 ) <nl> + { test_hal_intrin_float64 ( ) ; } <nl> <nl> - TEST ( hal_intrin , float16 ) <nl> + TEST ( hal_intrin , float16x8 ) <nl> { <nl> CV_CPU_CALL_FP16_ ( test_hal_intrin_float16 , ( ) ) ; <nl> throw SkipTestException ( " Unsupported hardware : FP16 is not available " ) ; <nl> } <nl> <nl> - } } <nl> + # define DISPATCH_SIMD_MODES AVX2 <nl> + # define DISPATCH_SIMD_NAME " SIMD256 " <nl> + # define DISPATCH_SIMD ( fun ) \ <nl> + do { \ <nl> + CV_CPU_DISPATCH ( fun , ( ) , DISPATCH_SIMD_MODES ) ; \ <nl> + throw SkipTestException ( \ <nl> + " Unsupported hardware : " \ <nl> + DISPATCH_SIMD_NAME \ <nl> + " is not available " \ <nl> + ) ; \ <nl> + } while ( 0 ) <nl> + <nl> + TEST ( hal_intrin256 , uint8x32 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_uint8 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , int8x32 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_int8 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , uint16x16 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_uint16 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , int16x16 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_int16 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , uint32x8 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_uint32 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , int32x8 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_int32 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , uint64x4 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_uint64 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , int64x4 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_int64 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , float32x8 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_float32 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , float64x4 ) <nl> + { DISPATCH_SIMD ( test_hal_intrin_float64 ) ; } <nl> + <nl> + TEST ( hal_intrin256 , float16x16 ) <nl> + { <nl> + if ( ! CV_CPU_HAS_SUPPORT_FP16 ) <nl> + throw SkipTestException ( " Unsupported hardware : FP16 is not available " ) ; <nl> + DISPATCH_SIMD ( test_hal_intrin_float16 ) ; <nl> + } <nl> + <nl> + } } / / namespace <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 4e0d3a073fb <nl> mmm / dev / null <nl> ppp b / modules / core / test / test_intrin . simd . hpp <nl> <nl> + / / This file is part of OpenCV project . <nl> + / / It is subject to the license terms in the LICENSE file found in the top - level directory <nl> + / / of this distribution and at http : / / opencv . org / license . html . <nl> + # include " test_precomp . hpp " <nl> + # include " test_intrin_utils . hpp " <nl> + <nl> + namespace opencv_test { namespace hal { <nl> + CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN <nl> + <nl> + void test_hal_intrin_uint8 ( ) ; <nl> + void test_hal_intrin_int8 ( ) ; <nl> + void test_hal_intrin_uint16 ( ) ; <nl> + void test_hal_intrin_int16 ( ) ; <nl> + void test_hal_intrin_uint32 ( ) ; <nl> + void test_hal_intrin_int32 ( ) ; <nl> + void test_hal_intrin_uint64 ( ) ; <nl> + void test_hal_intrin_int64 ( ) ; <nl> + void test_hal_intrin_float32 ( ) ; <nl> + void test_hal_intrin_float64 ( ) ; <nl> + <nl> + # ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY <nl> + <nl> + / / = = = = = = = = = = = = = 8 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void test_hal_intrin_uint8 ( ) <nl> + { <nl> + TheTest < v_uint8 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_expand_q ( ) <nl> + . test_addsub ( ) <nl> + . test_addsub_wrap ( ) <nl> + . test_cmp ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_mask ( ) <nl> + . test_popcount ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 3 > ( ) . test_pack < 8 > ( ) <nl> + . test_pack_u < 1 > ( ) . test_pack_u < 2 > ( ) . test_pack_u < 3 > ( ) . test_pack_u < 8 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 8 > ( ) . test_extract < 15 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 8 > ( ) . test_rotate < 15 > ( ) <nl> + ; <nl> + <nl> + # if CV_SIMD256 <nl> + TheTest < v_uint8 > ( ) <nl> + . test_pack < 9 > ( ) . test_pack < 10 > ( ) . test_pack < 13 > ( ) . test_pack < 15 > ( ) <nl> + . test_pack_u < 9 > ( ) . test_pack_u < 10 > ( ) . test_pack_u < 13 > ( ) . test_pack_u < 15 > ( ) <nl> + . test_extract < 16 > ( ) . test_extract < 17 > ( ) . test_extract < 23 > ( ) . test_extract < 31 > ( ) <nl> + . test_rotate < 16 > ( ) . test_rotate < 17 > ( ) . test_rotate < 23 > ( ) . test_rotate < 31 > ( ) <nl> + ; <nl> + # endif <nl> + } <nl> + <nl> + void test_hal_intrin_int8 ( ) <nl> + { <nl> + TheTest < v_int8 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_expand_q ( ) <nl> + . test_addsub ( ) <nl> + . test_addsub_wrap ( ) <nl> + . test_cmp ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_abs ( ) <nl> + . test_mask ( ) <nl> + . test_popcount ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 3 > ( ) . test_pack < 8 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 8 > ( ) . test_extract < 15 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 8 > ( ) . test_rotate < 15 > ( ) <nl> + ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = 16 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void test_hal_intrin_uint16 ( ) <nl> + { <nl> + TheTest < v_uint16 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_addsub ( ) <nl> + . test_addsub_wrap ( ) <nl> + . test_mul ( ) <nl> + . test_mul_expand ( ) <nl> + . test_cmp ( ) <nl> + . test_shift < 1 > ( ) <nl> + . test_shift < 8 > ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_reduce ( ) <nl> + . test_mask ( ) <nl> + . test_popcount ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 7 > ( ) . test_pack < 16 > ( ) <nl> + . test_pack_u < 1 > ( ) . test_pack_u < 2 > ( ) . test_pack_u < 7 > ( ) . test_pack_u < 16 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 4 > ( ) . test_extract < 7 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 4 > ( ) . test_rotate < 7 > ( ) <nl> + ; <nl> + } <nl> + <nl> + void test_hal_intrin_int16 ( ) <nl> + { <nl> + TheTest < v_int16 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_addsub ( ) <nl> + . test_addsub_wrap ( ) <nl> + . test_mul ( ) <nl> + . test_mul_expand ( ) <nl> + . test_cmp ( ) <nl> + . test_shift < 1 > ( ) <nl> + . test_shift < 8 > ( ) <nl> + . test_dot_prod ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_abs ( ) <nl> + . test_reduce ( ) <nl> + . test_mask ( ) <nl> + . test_popcount ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 7 > ( ) . test_pack < 16 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 4 > ( ) . test_extract < 7 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 4 > ( ) . test_rotate < 7 > ( ) <nl> + ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = 32 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void test_hal_intrin_uint32 ( ) <nl> + { <nl> + TheTest < v_uint32 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_addsub ( ) <nl> + . test_mul ( ) <nl> + . test_mul_expand ( ) <nl> + . test_cmp ( ) <nl> + . test_shift < 1 > ( ) <nl> + . test_shift < 8 > ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_reduce ( ) <nl> + . test_mask ( ) <nl> + . test_popcount ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 15 > ( ) . test_pack < 32 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> + . test_transpose ( ) <nl> + ; <nl> + } <nl> + <nl> + void test_hal_intrin_int32 ( ) <nl> + { <nl> + TheTest < v_int32 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_expand ( ) <nl> + . test_addsub ( ) <nl> + . test_mul ( ) <nl> + . test_abs ( ) <nl> + . test_cmp ( ) <nl> + . test_popcount ( ) <nl> + . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> + . test_logic ( ) <nl> + . test_min_max ( ) <nl> + . test_absdiff ( ) <nl> + . test_reduce ( ) <nl> + . test_mask ( ) <nl> + . test_pack < 1 > ( ) . test_pack < 2 > ( ) . test_pack < 15 > ( ) . test_pack < 32 > ( ) <nl> + . test_unpack ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> + . test_float_cvt32 ( ) <nl> + . test_float_cvt64 ( ) <nl> + . test_transpose ( ) <nl> + ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = 64 - bit integer = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void test_hal_intrin_uint64 ( ) <nl> + { <nl> + TheTest < v_uint64 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_addsub ( ) <nl> + . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> + . test_logic ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> + ; <nl> + } <nl> + <nl> + void test_hal_intrin_int64 ( ) <nl> + { <nl> + TheTest < v_int64 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_addsub ( ) <nl> + . test_shift < 1 > ( ) . test_shift < 8 > ( ) <nl> + . test_logic ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> + ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = Floating point = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + void test_hal_intrin_float32 ( ) <nl> + { <nl> + TheTest < v_float32 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_interleave ( ) <nl> + . test_interleave_2channel ( ) <nl> + . test_addsub ( ) <nl> + . test_mul ( ) <nl> + . test_div ( ) <nl> + . test_cmp ( ) <nl> + . test_sqrt_abs ( ) <nl> + . test_min_max ( ) <nl> + . test_float_absdiff ( ) <nl> + . test_reduce ( ) <nl> + . test_mask ( ) <nl> + . test_unpack ( ) <nl> + . test_float_math ( ) <nl> + . test_float_cvt64 ( ) <nl> + . test_matmul ( ) <nl> + . test_transpose ( ) <nl> + . test_reduce_sum4 ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> + ; <nl> + <nl> + # if CV_SIMD256 <nl> + TheTest < v_float32 > ( ) <nl> + . test_extract < 4 > ( ) . test_extract < 5 > ( ) . test_extract < 6 > ( ) . test_extract < 7 > ( ) <nl> + . test_rotate < 4 > ( ) . test_rotate < 5 > ( ) . test_rotate < 6 > ( ) . test_rotate < 7 > ( ) <nl> + ; <nl> + # endif <nl> + } <nl> + <nl> + void test_hal_intrin_float64 ( ) <nl> + { <nl> + # if CV_SIMD_64F <nl> + TheTest < v_float64 > ( ) <nl> + . test_loadstore ( ) <nl> + . test_addsub ( ) <nl> + . test_mul ( ) <nl> + . test_div ( ) <nl> + . test_cmp ( ) <nl> + . test_sqrt_abs ( ) <nl> + . test_min_max ( ) <nl> + . test_float_absdiff ( ) <nl> + . test_mask ( ) <nl> + . test_unpack ( ) <nl> + . test_float_math ( ) <nl> + . test_float_cvt32 ( ) <nl> + . test_extract < 0 > ( ) . test_extract < 1 > ( ) <nl> + . test_rotate < 0 > ( ) . test_rotate < 1 > ( ) <nl> + ; <nl> + <nl> + # if CV_SIMD256 <nl> + TheTest < v_float64 > ( ) <nl> + . test_extract < 2 > ( ) . test_extract < 3 > ( ) <nl> + . test_rotate < 2 > ( ) . test_rotate < 3 > ( ) <nl> + ; <nl> + # endif / / CV_SIMD256 <nl> + <nl> + # endif <nl> + } <nl> + <nl> + # if CV_FP16 & & CV_SIMD_WIDTH > 16 <nl> + void test_hal_intrin_float16 ( ) <nl> + { <nl> + TheTest < v_float16 > ( ) <nl> + . test_loadstore_fp16 ( ) <nl> + . test_float_cvt_fp16 ( ) <nl> + ; <nl> + } <nl> + # endif <nl> + <nl> + # endif / / CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY <nl> + <nl> + CV_CPU_OPTIMIZATION_NAMESPACE_END <nl> + <nl> + } } / / namespace <nl> \ No newline at end of file <nl> mmm a / modules / core / test / test_intrin_utils . hpp <nl> ppp b / modules / core / test / test_intrin_utils . hpp <nl> void test_hal_intrin_float16 ( ) ; <nl> template < typename R > struct Data ; <nl> template < int N > struct initializer ; <nl> <nl> + template < > struct initializer < 64 > <nl> + { <nl> + template < typename R > static R init ( const Data < R > & d ) <nl> + { <nl> + return R ( d [ 0 ] , d [ 1 ] , d [ 2 ] , d [ 3 ] , d [ 4 ] , d [ 5 ] , d [ 6 ] , d [ 7 ] , d [ 8 ] , d [ 9 ] , d [ 10 ] , d [ 11 ] , d [ 12 ] , d [ 13 ] , d [ 14 ] , d [ 15 ] , <nl> + d [ 16 ] , d [ 17 ] , d [ 18 ] , d [ 19 ] , d [ 20 ] , d [ 21 ] , d [ 22 ] , d [ 23 ] , d [ 24 ] , d [ 25 ] , d [ 26 ] , d [ 27 ] , d [ 28 ] , d [ 29 ] , d [ 30 ] , d [ 31 ] , <nl> + d [ 32 ] , d [ 33 ] , d [ 34 ] , d [ 35 ] , d [ 36 ] , d [ 37 ] , d [ 38 ] , d [ 39 ] , d [ 40 ] , d [ 41 ] , d [ 42 ] , d [ 43 ] , d [ 44 ] , d [ 45 ] , d [ 46 ] , d [ 47 ] , <nl> + d [ 48 ] , d [ 49 ] , d [ 50 ] , d [ 51 ] , d [ 52 ] , d [ 53 ] , d [ 54 ] , d [ 55 ] , d [ 56 ] , d [ 57 ] , d [ 58 ] , d [ 59 ] , d [ 50 ] , d [ 51 ] , d [ 52 ] , d [ 53 ] , <nl> + d [ 54 ] , d [ 55 ] , d [ 56 ] , d [ 57 ] , d [ 58 ] , d [ 59 ] , d [ 60 ] , d [ 61 ] , d [ 62 ] , d [ 63 ] ) ; <nl> + } <nl> + } ; <nl> + <nl> + template < > struct initializer < 32 > <nl> + { <nl> + template < typename R > static R init ( const Data < R > & d ) <nl> + { <nl> + return R ( d [ 0 ] , d [ 1 ] , d [ 2 ] , d [ 3 ] , d [ 4 ] , d [ 5 ] , d [ 6 ] , d [ 7 ] , d [ 8 ] , d [ 9 ] , d [ 10 ] , d [ 11 ] , d [ 12 ] , d [ 13 ] , d [ 14 ] , d [ 15 ] , <nl> + d [ 16 ] , d [ 17 ] , d [ 18 ] , d [ 19 ] , d [ 20 ] , d [ 21 ] , d [ 22 ] , d [ 23 ] , d [ 24 ] , d [ 25 ] , d [ 26 ] , d [ 27 ] , d [ 28 ] , d [ 29 ] , d [ 30 ] , d [ 31 ] ) ; <nl> + } <nl> + } ; <nl> + <nl> template < > struct initializer < 16 > <nl> { <nl> template < typename R > static R init ( const Data < R > & d ) <nl> template < typename R > struct Data <nl> { <nl> return d + R : : nlanes / 2 ; <nl> } <nl> + LaneType sum ( int s , int c ) <nl> + { <nl> + LaneType res = 0 ; <nl> + for ( int i = s ; i < s + c ; + + i ) <nl> + res + = d [ i ] ; <nl> + return res ; <nl> + } <nl> + LaneType sum ( ) <nl> + { <nl> + return sum ( 0 , R : : nlanes ) ; <nl> + } <nl> bool operator = = ( const Data < R > & other ) const <nl> { <nl> for ( int i = 0 ; i < R : : nlanes ; + + i ) <nl> template < typename R > struct Data <nl> return false ; <nl> return true ; <nl> } <nl> - <nl> LaneType d [ R : : nlanes ] ; <nl> } ; <nl> <nl> template < typename R > struct AlignedData <nl> { <nl> - Data < R > CV_DECL_ALIGNED ( 16 ) a ; / / aligned <nl> + Data < R > CV_DECL_ALIGNED ( CV_SIMD_WIDTH ) a ; / / aligned <nl> char dummy ; <nl> Data < R > u ; / / unaligned <nl> } ; <nl> template < typename R > struct TheTest <nl> AlignedData < R > out ; <nl> <nl> / / check if addresses are aligned and unaligned respectively <nl> - EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & data . a . d % 16 ) ; <nl> - EXPECT_NE ( ( size_t ) 0 , ( size_t ) & data . u . d % 16 ) ; <nl> - EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & out . a . d % 16 ) ; <nl> - EXPECT_NE ( ( size_t ) 0 , ( size_t ) & out . u . d % 16 ) ; <nl> + EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & data . a . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_NE ( ( size_t ) 0 , ( size_t ) & data . u . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & out . a . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_NE ( ( size_t ) 0 , ( size_t ) & out . u . d % CV_SIMD_WIDTH ) ; <nl> <nl> / / check some initialization methods <nl> R r1 = data . a ; <nl> - R r2 = v_load ( data . u . d ) ; <nl> - R r3 = v_load_aligned ( data . a . d ) ; <nl> + R r2 = vx_load ( data . u . d ) ; <nl> + R r3 = vx_load_aligned ( data . a . d ) ; <nl> R r4 ( r2 ) ; <nl> EXPECT_EQ ( data . a [ 0 ] , r1 . get0 ( ) ) ; <nl> EXPECT_EQ ( data . u [ 0 ] , r2 . get0 ( ) ) ; <nl> EXPECT_EQ ( data . a [ 0 ] , r3 . get0 ( ) ) ; <nl> EXPECT_EQ ( data . u [ 0 ] , r4 . get0 ( ) ) ; <nl> <nl> - R r_low = v_load_low ( ( LaneType * ) data . u . d ) ; <nl> + R r_low = vx_load_low ( ( LaneType * ) data . u . d ) ; <nl> EXPECT_EQ ( data . u [ 0 ] , r_low . get0 ( ) ) ; <nl> v_store ( out . u . d , r_low ) ; <nl> for ( int i = 0 ; i < R : : nlanes / 2 ; + + i ) <nl> template < typename R > struct TheTest <nl> EXPECT_EQ ( ( LaneType ) data . u [ i ] , ( LaneType ) out . u [ i ] ) ; <nl> } <nl> <nl> - R r_low_align8byte = v_load_low ( ( LaneType * ) ( ( char * ) data . u . d + 8 ) ) ; <nl> + R r_low_align8byte = vx_load_low ( ( LaneType * ) ( ( char * ) data . u . d + ( CV_SIMD_WIDTH / 2 ) ) ) ; <nl> EXPECT_EQ ( data . u [ R : : nlanes / 2 ] , r_low_align8byte . get0 ( ) ) ; <nl> v_store ( out . u . d , r_low_align8byte ) ; <nl> for ( int i = 0 ; i < R : : nlanes / 2 ; + + i ) <nl> template < typename R > struct TheTest <nl> <nl> / / check halves load correctness <nl> res . clear ( ) ; <nl> - R r6 = v_load_halves ( d . d , d . mid ( ) ) ; <nl> + R r6 = vx_load_halves ( d . d , d . mid ( ) ) ; <nl> v_store ( res . d , r6 ) ; <nl> EXPECT_EQ ( d , res ) ; <nl> <nl> template < typename R > struct TheTest <nl> } <nl> <nl> / / reinterpret_as <nl> - v_uint8x16 vu8 = v_reinterpret_as_u8 ( r1 ) ; out . a . clear ( ) ; v_store ( ( uchar * ) out . a . d , vu8 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_int8x16 vs8 = v_reinterpret_as_s8 ( r1 ) ; out . a . clear ( ) ; v_store ( ( schar * ) out . a . d , vs8 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_uint16x8 vu16 = v_reinterpret_as_u16 ( r1 ) ; out . a . clear ( ) ; v_store ( ( ushort * ) out . a . d , vu16 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_int16x8 vs16 = v_reinterpret_as_s16 ( r1 ) ; out . a . clear ( ) ; v_store ( ( short * ) out . a . d , vs16 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_uint32x4 vu32 = v_reinterpret_as_u32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( unsigned * ) out . a . d , vu32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_int32x4 vs32 = v_reinterpret_as_s32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( int * ) out . a . d , vs32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_uint64x2 vu64 = v_reinterpret_as_u64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( uint64 * ) out . a . d , vu64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_int64x2 vs64 = v_reinterpret_as_s64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( int64 * ) out . a . d , vs64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - v_float32x4 vf32 = v_reinterpret_as_f32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( float * ) out . a . d , vf32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> - # if CV_SIMD128_64F <nl> - v_float64x2 vf64 = v_reinterpret_as_f64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( double * ) out . a . d , vf64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_uint8 vu8 = v_reinterpret_as_u8 ( r1 ) ; out . a . clear ( ) ; v_store ( ( uchar * ) out . a . d , vu8 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_int8 vs8 = v_reinterpret_as_s8 ( r1 ) ; out . a . clear ( ) ; v_store ( ( schar * ) out . a . d , vs8 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_uint16 vu16 = v_reinterpret_as_u16 ( r1 ) ; out . a . clear ( ) ; v_store ( ( ushort * ) out . a . d , vu16 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_int16 vs16 = v_reinterpret_as_s16 ( r1 ) ; out . a . clear ( ) ; v_store ( ( short * ) out . a . d , vs16 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_uint32 vu32 = v_reinterpret_as_u32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( unsigned * ) out . a . d , vu32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_int32 vs32 = v_reinterpret_as_s32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( int * ) out . a . d , vs32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_uint64 vu64 = v_reinterpret_as_u64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( uint64 * ) out . a . d , vu64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_int64 vs64 = v_reinterpret_as_s64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( int64 * ) out . a . d , vs64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + v_float32 vf32 = v_reinterpret_as_f32 ( r1 ) ; out . a . clear ( ) ; v_store ( ( float * ) out . a . d , vf32 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> + # if CV_SIMD_64F <nl> + v_float64 vf64 = v_reinterpret_as_f64 ( r1 ) ; out . a . clear ( ) ; v_store ( ( double * ) out . a . d , vf64 ) ; EXPECT_EQ ( data . a , out . a ) ; <nl> # endif <nl> <nl> return * this ; <nl> template < typename R > struct TheTest <nl> Data < R > dataA ; <nl> R a = dataA ; <nl> <nl> - Data < Rx2 > resB = v_load_expand ( dataA . d ) ; <nl> + Data < Rx2 > resB = vx_load_expand ( dataA . d ) ; <nl> <nl> Rx2 c , d ; <nl> v_expand ( a , c , d ) ; <nl> template < typename R > struct TheTest <nl> { <nl> typedef typename V_RegTraits < R > : : q_reg Rx4 ; <nl> Data < R > data ; <nl> - Data < Rx4 > out = v_load_expand_q ( data . d ) ; <nl> + Data < Rx4 > out = vx_load_expand_q ( data . d ) ; <nl> const int n = Rx4 : : nlanes ; <nl> for ( int i = 0 ; i < n ; + + i ) <nl> EXPECT_EQ ( data [ i ] , out [ i ] ) ; <nl> template < typename R > struct TheTest <nl> <nl> TheTest & test_popcount ( ) <nl> { <nl> - static unsigned popcountTable [ ] = { 0 , 1 , 2 , 4 , 5 , 7 , 9 , 12 , 13 , 15 , 17 , 20 , 22 , 25 , 28 , 32 , 33 } ; <nl> + static unsigned popcountTable [ ] = { <nl> + 0 , 1 , 2 , 4 , 5 , 7 , 9 , 12 , 13 , 15 , 17 , 20 , 22 , 25 , 28 , 32 , 33 , <nl> + 35 , 37 , 40 , 42 , 45 , 48 , 52 , 54 , 57 , 60 , 64 , 67 , 71 , 75 , 80 , 81 , <nl> + 83 , 85 , 88 , 90 , 93 , 96 , 100 , 102 , 105 , 108 , 112 , 115 , 119 , 123 , <nl> + 128 , 130 , 133 , 136 , 140 , 143 , 147 , 151 , 156 , 159 , 163 , 167 , 172 , <nl> + 176 , 181 , 186 , 192 , 193 <nl> + } ; <nl> Data < R > dataA ; <nl> R a = dataA ; <nl> <nl> template < typename R > struct TheTest <nl> <nl> TheTest & test_float_cvt32 ( ) <nl> { <nl> - typedef v_float32x4 Rt ; <nl> + typedef v_float32 Rt ; <nl> Data < R > dataA ; <nl> dataA * = 1 . 1 ; <nl> R a = dataA ; <nl> template < typename R > struct TheTest <nl> <nl> TheTest & test_float_cvt64 ( ) <nl> { <nl> - # if CV_SIMD128_64F <nl> - typedef v_float64x2 Rt ; <nl> + # if CV_SIMD_64F <nl> + typedef v_float64 Rt ; <nl> Data < R > dataA ; <nl> dataA * = 1 . 1 ; <nl> R a = dataA ; <nl> template < typename R > struct TheTest <nl> R v = dataV , a = dataA , b = dataB , c = dataC , d = dataD ; <nl> <nl> Data < R > res = v_matmul ( v , a , b , c , d ) ; <nl> - for ( int i = 0 ; i < R : : nlanes ; + + i ) <nl> + for ( int i = 0 ; i < R : : nlanes ; i + = 4 ) <nl> { <nl> - LaneType val = dataV [ 0 ] * dataA [ i ] <nl> - + dataV [ 1 ] * dataB [ i ] <nl> - + dataV [ 2 ] * dataC [ i ] <nl> - + dataV [ 3 ] * dataD [ i ] ; <nl> - EXPECT_DOUBLE_EQ ( val , res [ i ] ) ; <nl> + for ( int j = i ; j < i + 4 ; + + j ) <nl> + { <nl> + LaneType val = dataV [ i ] * dataA [ j ] <nl> + + dataV [ i + 1 ] * dataB [ j ] <nl> + + dataV [ i + 2 ] * dataC [ j ] <nl> + + dataV [ i + 3 ] * dataD [ j ] ; <nl> + EXPECT_COMPARE_EQ ( val , res [ j ] ) ; <nl> + } <nl> } <nl> <nl> Data < R > resAdd = v_matmuladd ( v , a , b , c , d ) ; <nl> - for ( int i = 0 ; i < R : : nlanes ; + + i ) <nl> + for ( int i = 0 ; i < R : : nlanes ; i + = 4 ) <nl> { <nl> - LaneType val = dataV [ 0 ] * dataA [ i ] <nl> - + dataV [ 1 ] * dataB [ i ] <nl> - + dataV [ 2 ] * dataC [ i ] <nl> - + dataD [ i ] ; <nl> - EXPECT_DOUBLE_EQ ( val , resAdd [ i ] ) ; <nl> + for ( int j = i ; j < i + 4 ; + + j ) <nl> + { <nl> + LaneType val = dataV [ i ] * dataA [ j ] <nl> + + dataV [ i + 1 ] * dataB [ j ] <nl> + + dataV [ i + 2 ] * dataC [ j ] <nl> + + dataD [ j ] ; <nl> + EXPECT_COMPARE_EQ ( val , resAdd [ j ] ) ; <nl> + } <nl> } <nl> return * this ; <nl> } <nl> template < typename R > struct TheTest <nl> e , f , g , h ) ; <nl> <nl> Data < R > res [ 4 ] = { e , f , g , h } ; <nl> - for ( int i = 0 ; i < R : : nlanes ; + + i ) <nl> + for ( int i = 0 ; i < R : : nlanes ; i + = 4 ) <nl> { <nl> - EXPECT_EQ ( dataA [ i ] , res [ i ] [ 0 ] ) ; <nl> - EXPECT_EQ ( dataB [ i ] , res [ i ] [ 1 ] ) ; <nl> - EXPECT_EQ ( dataC [ i ] , res [ i ] [ 2 ] ) ; <nl> - EXPECT_EQ ( dataD [ i ] , res [ i ] [ 3 ] ) ; <nl> + for ( int j = 0 ; j < 4 ; + + j ) <nl> + { <nl> + EXPECT_EQ ( dataA [ i + j ] , res [ j ] [ i ] ) ; <nl> + EXPECT_EQ ( dataB [ i + j ] , res [ j ] [ i + 1 ] ) ; <nl> + EXPECT_EQ ( dataC [ i + j ] , res [ j ] [ i + 2 ] ) ; <nl> + EXPECT_EQ ( dataD [ i + j ] , res [ j ] [ i + 3 ] ) ; <nl> + } <nl> } <nl> return * this ; <nl> } <nl> <nl> TheTest & test_reduce_sum4 ( ) <nl> { <nl> - R a ( 0 . 1f , 0 . 02f , 0 . 003f , 0 . 0004f ) ; <nl> - R b ( 1 , 20 , 300 , 4000 ) ; <nl> - R c ( 10 , 2 , 0 . 3f , 0 . 04f ) ; <nl> - R d ( 1 , 2 , 3 , 4 ) ; <nl> - <nl> - R sum = v_reduce_sum4 ( a , b , c , d ) ; <nl> - <nl> - Data < R > res = sum ; <nl> - EXPECT_EQ ( 0 . 1234f , res [ 0 ] ) ; <nl> - EXPECT_EQ ( 4321 . 0f , res [ 1 ] ) ; <nl> - EXPECT_EQ ( 12 . 34f , res [ 2 ] ) ; <nl> - EXPECT_EQ ( 10 . 0f , res [ 3 ] ) ; <nl> + Data < R > dataA , dataB , dataC , dataD ; <nl> + dataB * = 0 . 01f ; <nl> + dataC * = 0 . 001f ; <nl> + dataD * = 0 . 002f ; <nl> + <nl> + R a = dataA , b = dataB , c = dataC , d = dataD ; <nl> + Data < R > res = v_reduce_sum4 ( a , b , c , d ) ; <nl> + <nl> + for ( int i = 0 ; i < R : : nlanes ; i + = 4 ) <nl> + { <nl> + EXPECT_COMPARE_EQ ( dataA . sum ( i , 4 ) , res [ i ] ) ; <nl> + EXPECT_COMPARE_EQ ( dataB . sum ( i , 4 ) , res [ i + 1 ] ) ; <nl> + EXPECT_COMPARE_EQ ( dataC . sum ( i , 4 ) , res [ i + 2 ] ) ; <nl> + EXPECT_COMPARE_EQ ( dataD . sum ( i , 4 ) , res [ i + 3 ] ) ; <nl> + } <nl> return * this ; <nl> } <nl> <nl> template < typename R > struct TheTest <nl> AlignedData < R > out ; <nl> <nl> / / check if addresses are aligned and unaligned respectively <nl> - EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & data . a . d % 16 ) ; <nl> - EXPECT_NE ( ( size_t ) 0 , ( size_t ) & data . u . d % 16 ) ; <nl> - EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & out . a . d % 16 ) ; <nl> - EXPECT_NE ( ( size_t ) 0 , ( size_t ) & out . u . d % 16 ) ; <nl> + EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & data . a . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_NE ( ( size_t ) 0 , ( size_t ) & data . u . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_EQ ( ( size_t ) 0 , ( size_t ) & out . a . d % CV_SIMD_WIDTH ) ; <nl> + EXPECT_NE ( ( size_t ) 0 , ( size_t ) & out . u . d % CV_SIMD_WIDTH ) ; <nl> <nl> / / check some initialization methods <nl> R r1 = data . u ; <nl> - R r2 = v_load_f16 ( data . a . d ) ; <nl> + R r2 = vx_load_f16 ( data . a . d ) ; <nl> R r3 ( r2 ) ; <nl> EXPECT_EQ ( data . u [ 0 ] , r1 . get0 ( ) ) ; <nl> EXPECT_EQ ( data . a [ 0 ] , r2 . get0 ( ) ) ; <nl>
|
Merge pull request from seiko2plus : coreExpandTests
|
opencv/opencv
|
dbf3362c4d91d3ec8861cda91e58b5274afde218
|
2018-07-30T16:23:11Z
|
mmm a / core / dvector . h <nl> ppp b / core / dvector . h <nl> class DVector { <nl> w [ bs + i ] = r [ i ] ; <nl> } <nl> <nl> + DVector < T > subarray ( int p_from , int p_to ) { <nl> + <nl> + if ( p_from < 0 ) { <nl> + p_from = size ( ) + p_from ; <nl> + } <nl> + if ( p_to < 0 ) { <nl> + p_to = size ( ) + p_to ; <nl> + } <nl> + if ( p_from < 0 | | p_from > = size ( ) ) { <nl> + DVector < T > & aux = * ( ( DVector < T > * ) 0 ) ; / / nullreturn <nl> + ERR_FAIL_COND_V ( p_from < 0 | | p_from > = size ( ) , aux ) <nl> + } <nl> + if ( p_to < 0 | | p_to > = size ( ) ) { <nl> + DVector < T > & aux = * ( ( DVector < T > * ) 0 ) ; / / nullreturn <nl> + ERR_FAIL_COND_V ( p_to < 0 | | p_to > = size ( ) , aux ) <nl> + } <nl> + <nl> + DVector < T > slice ; <nl> + int span = 1 + p_to - p_from ; <nl> + slice . resize ( span ) ; <nl> + Read r = read ( ) ; <nl> + Write w = slice . write ( ) ; <nl> + for ( int i = 0 ; i < span ; + + i ) { <nl> + w [ i ] = r [ p_from + i ] ; <nl> + } <nl> + <nl> + return slice ; <nl> + } <nl> <nl> Error insert ( int p_pos , const T & p_val ) { <nl> <nl> mmm a / core / variant_call . cpp <nl> ppp b / core / variant_call . cpp <nl> static void _call_ # # m_type # # _ # # m_method ( Variant & r_ret , Variant & p_self , const Var <nl> VCALL_LOCALMEM1 ( ByteArray , append ) ; <nl> VCALL_LOCALMEM1 ( ByteArray , append_array ) ; <nl> VCALL_LOCALMEM0 ( ByteArray , invert ) ; <nl> + VCALL_LOCALMEM2R ( ByteArray , subarray ) ; <nl> <nl> VCALL_LOCALMEM0R ( IntArray , size ) ; <nl> VCALL_LOCALMEM2 ( IntArray , set ) ; <nl> _VariantCall : : addfunc ( Variant : : m_vtype , Variant : : m_ret , _SCS ( # m_method ) , VCALL ( m_cl <nl> ADDFUNC2 ( RAW_ARRAY , INT , ByteArray , insert , INT , " idx " , INT , " byte " , varray ( ) ) ; <nl> ADDFUNC1 ( RAW_ARRAY , NIL , ByteArray , resize , INT , " idx " , varray ( ) ) ; <nl> ADDFUNC0 ( RAW_ARRAY , NIL , ByteArray , invert , varray ( ) ) ; <nl> + ADDFUNC2 ( RAW_ARRAY , RAW_ARRAY , ByteArray , subarray , INT , " from " , INT , " to " , varray ( ) ) ; <nl> <nl> ADDFUNC0 ( RAW_ARRAY , STRING , ByteArray , get_string_from_ascii , varray ( ) ) ; <nl> ADDFUNC0 ( RAW_ARRAY , STRING , ByteArray , get_string_from_utf8 , varray ( ) ) ; <nl> mmm a / doc / base / classes . xml <nl> ppp b / doc / base / classes . xml <nl> <nl> Return the size of the array . <nl> < / description > <nl> < / method > <nl> + < method name = " subarray " > <nl> + < return type = " RawArray " > <nl> + < / return > <nl> + < argument index = " 0 " name = " from " type = " int " > <nl> + < / argument > <nl> + < argument index = " 1 " name = " to " type = " int " > <nl> + < / argument > <nl> + < description > <nl> + Returns the slice of the [ RawArray ] between indices ( inclusive ) as a new [ RawArray ] . Any negative index is considered to be from the end of the array . <nl> + < / description > <nl> + < / method > <nl> < / methods > <nl> < constants > <nl> < / constants > <nl>
|
Merge pull request from gau - veldt / subarray_patch
|
godotengine/godot
|
6abd1437cd2d8a0448f37c6b6f2b8bf00a652b84
|
2016-09-10T15:22:31Z
|
mmm a / cocos2dx / textures / CCTextureCache . cpp <nl> ppp b / cocos2dx / textures / CCTextureCache . cpp <nl> void CCTextureCache : : addImageAsync ( const char * path , CCObject * target , SEL_CallF <nl> if ( s_pSem = = NULL ) <nl> { <nl> # if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE <nl> - s_pSem = sem_open ( CC_ASYNC_TEXTURE_CACHE_SEMAPHORE , O_CREAT | O_EXCL , 0644 , 0 ) ; <nl> + s_pSem = sem_open ( CC_ASYNC_TEXTURE_CACHE_SEMAPHORE , O_CREAT , 0644 , 0 ) ; <nl> if ( s_pSem = = SEM_FAILED ) <nl> { <nl> CCLOG ( " CCTextureCache async thread semaphore init error : % s \ n " , strerror ( errno ) ) ; <nl>
|
fixed : use flag O_CREAT when creating named semaphore
|
cocos2d/cocos2d-x
|
07c46bb445752f2179798996d6ef9a9184deeb06
|
2012-05-30T03:21:36Z
|
mmm a / cmake / modules / AddSwift . cmake <nl> ppp b / cmake / modules / AddSwift . cmake <nl> function ( _set_target_prefix_and_suffix target kind sdk ) <nl> endif ( ) <nl> endfunction ( ) <nl> <nl> - function ( is_darwin_based_sdk sdk_name out_var ) <nl> - if ( " $ { sdk_name } " STREQUAL " OSX " OR <nl> - " $ { sdk_name } " STREQUAL " IOS " OR <nl> - " $ { sdk_name } " STREQUAL " IOS_SIMULATOR " OR <nl> - " $ { sdk_name } " STREQUAL " TVOS " OR <nl> - " $ { sdk_name } " STREQUAL " TVOS_SIMULATOR " OR <nl> - " $ { sdk_name } " STREQUAL " WATCHOS " OR <nl> - " $ { sdk_name } " STREQUAL " WATCHOS_SIMULATOR " ) <nl> - set ( $ { out_var } TRUE PARENT_SCOPE ) <nl> - else ( ) <nl> - set ( $ { out_var } FALSE PARENT_SCOPE ) <nl> - endif ( ) <nl> - endfunction ( ) <nl> - <nl> # Usage : <nl> # _add_host_variant_c_compile_link_flags ( name ) <nl> function ( _add_host_variant_c_compile_link_flags name ) <nl> - is_darwin_based_sdk ( " $ { SWIFT_HOST_VARIANT_SDK } " IS_DARWIN ) <nl> - if ( IS_DARWIN ) <nl> + if ( SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS ) <nl> set ( DEPLOYMENT_VERSION " $ { SWIFT_SDK_ $ { SWIFT_HOST_VARIANT_SDK } _DEPLOYMENT_VERSION } " ) <nl> endif ( ) <nl> <nl> function ( _add_host_variant_c_compile_link_flags name ) <nl> <nl> set ( _sysroot <nl> " $ { SWIFT_SDK_ $ { SWIFT_HOST_VARIANT_SDK } _ARCH_ $ { SWIFT_HOST_VARIANT_ARCH } _PATH } " ) <nl> - if ( IS_DARWIN ) <nl> + if ( SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS ) <nl> target_compile_options ( $ { name } PRIVATE - isysroot ; $ { _sysroot } ) <nl> elseif ( NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT " $ { _sysroot } " STREQUAL " / " ) <nl> target_compile_options ( $ { name } PRIVATE - - sysroot = $ { _sysroot } ) <nl> function ( _add_host_variant_c_compile_link_flags name ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> - if ( IS_DARWIN ) <nl> + if ( SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS ) <nl> # We collate - F with the framework path to avoid unwanted deduplication <nl> # of options by target_compile_options - - this way no undesired <nl> # side effects are introduced should a new search path be added . <nl> mmm a / stdlib / cmake / modules / AddSwiftStdlib . cmake <nl> ppp b / stdlib / cmake / modules / AddSwiftStdlib . cmake <nl> <nl> include ( AddSwift ) <nl> include ( SwiftSource ) <nl> <nl> + function ( is_darwin_based_sdk sdk_name out_var ) <nl> + if ( " $ { sdk_name } " STREQUAL " OSX " OR <nl> + " $ { sdk_name } " STREQUAL " IOS " OR <nl> + " $ { sdk_name } " STREQUAL " IOS_SIMULATOR " OR <nl> + " $ { sdk_name } " STREQUAL " TVOS " OR <nl> + " $ { sdk_name } " STREQUAL " TVOS_SIMULATOR " OR <nl> + " $ { sdk_name } " STREQUAL " WATCHOS " OR <nl> + " $ { sdk_name } " STREQUAL " WATCHOS_SIMULATOR " ) <nl> + set ( $ { out_var } TRUE PARENT_SCOPE ) <nl> + else ( ) <nl> + set ( $ { out_var } FALSE PARENT_SCOPE ) <nl> + endif ( ) <nl> + endfunction ( ) <nl> + <nl> function ( add_dependencies_multiple_targets ) <nl> cmake_parse_arguments ( <nl> ADMT # prefix <nl>
|
Merge pull request from compnerd / uniformity
|
apple/swift
|
e9548b019b75e6ed98e77b93e89255d59f4ceef8
|
2020-06-04T20:43:58Z
|
mmm a / ports / chakracore / CONTROL <nl> ppp b / ports / chakracore / CONTROL <nl> <nl> Source : chakracore <nl> - Version : 1 . 3 . 1 <nl> + Version : 1 . 4 . 0 <nl> Description : Core part of the Chakra Javascript engine <nl> \ No newline at end of file <nl> mmm a / ports / chakracore / portfile . cmake <nl> ppp b / ports / chakracore / portfile . cmake <nl> <nl> endif ( ) <nl> include ( vcpkg_common_functions ) <nl> <nl> - set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / ChakraCore - 1 . 3 . 1 ) <nl> + set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / ChakraCore - 1 . 4 . 0 ) <nl> vcpkg_download_distfile ( ARCHIVE_FILE <nl> - URLS " https : / / github . com / Microsoft / ChakraCore / archive / v1 . 3 . 1 . tar . gz " <nl> - FILENAME " ChakraCore - 1 . 3 . 1 . tar . gz " <nl> - SHA512 52216a03333e44bce235917cfae5ccd6a756056678d9b81c63ec272d9ce5c6afabc673e7910dd3da54fda7927ea62ede980a4371dbb08f6ce4907121c27dbc53 <nl> + URLS " https : / / github . com / Microsoft / ChakraCore / archive / v1 . 4 . 0 . tar . gz " <nl> + FILENAME " ChakraCore - 1 . 4 . 0 . tar . gz " <nl> + SHA512 d515d56ff1c5776ca4663e27daa4d1c7ca58c57f097799de756980771b5701e35639eefa4db5921d7327e6607b8920df3b30677eb467123e04536df0d971cebc <nl> ) <nl> vcpkg_extract_source_archive ( $ { ARCHIVE_FILE } ) <nl> <nl>
|
[ chakracore ] upgrade to 1 . 4 . 0
|
microsoft/vcpkg
|
cab893dd2055c9286266ada6fced6b3ee7f92613
|
2017-01-02T15:58:26Z
|
mmm a / docs / README . android <nl> ppp b / docs / README . android <nl> common scenario . <nl> The - - install - dir option ( and therefore the < android - toolchain - arm > / < android - toolchain - x86 > value ) <nl> specifies where the resulting toolchain should be installed ( your choice ) . <nl> <nl> - [ NOTICE ] Kodi uses the android API Version 21 and gcc version 4 . 9 ! <nl> + [ NOTICE ] Kodi uses the android API Version 21 and clang version 5 . 0 ! <nl> <nl> Building for arm architecture : <nl> <nl>
|
[ docs ] android uses clang 5 . 0 since d32bd6656f
|
xbmc/xbmc
|
81d49bdbe9963250fc2d2c169b378766f1e077bb
|
2017-12-29T18:30:00Z
|
mmm a / include / grpc / grpc_security . h <nl> ppp b / include / grpc / grpc_security . h <nl> int grpc_auth_context_set_peer_identity_property_name ( grpc_auth_context * ctx , <nl> / * mmm Auth Metadata Processing mmm * / <nl> <nl> / * Callback function that is called when the metadata processing is done . <nl> - success is 1 if processing succeeded , 0 otherwise . <nl> - Consumed metadata will be removed from the set of metadata available on the <nl> - call . * / <nl> + - Consumed metadata will be removed from the set of metadata available on the <nl> + call . consumed_md may be NULL if no metadata has been consumed . <nl> + - Response metadata will be set on the response . response_md may be NULL . <nl> + - status is GRPC_STATUS_OK for success or a specific status for an error . <nl> + Common error status for auth metadata processing is either <nl> + GRPC_STATUS_UNAUTHENTICATED in case of an authentication failure or <nl> + GRPC_STATUS PERMISSION_DENIED in case of an authorization failure . <nl> + - error_details gives details about the error . May be NULL . * / <nl> typedef void ( * grpc_process_auth_metadata_done_cb ) ( <nl> void * user_data , const grpc_metadata * consumed_md , size_t num_consumed_md , <nl> - int success ) ; <nl> + const grpc_metadata * response_md , size_t num_response_md , <nl> + grpc_status_code status , const char * error_details ) ; <nl> <nl> / * Pluggable server - side metadata processor object . * / <nl> typedef struct { <nl> mmm a / src / core / security / server_auth_filter . c <nl> ppp b / src / core / security / server_auth_filter . c <nl> static grpc_mdelem * remove_consumed_md ( void * user_data , grpc_mdelem * md ) { <nl> return md ; <nl> } <nl> <nl> - static void on_md_processing_done ( void * user_data , <nl> - const grpc_metadata * consumed_md , <nl> - size_t num_consumed_md , int success ) { <nl> + static void on_md_processing_done ( <nl> + void * user_data , const grpc_metadata * consumed_md , size_t num_consumed_md , <nl> + const grpc_metadata * response_md , size_t num_response_md , <nl> + grpc_status_code status , const char * error_details ) { <nl> grpc_call_element * elem = user_data ; <nl> call_data * calld = elem - > call_data ; <nl> <nl> - if ( success ) { <nl> + / * TODO ( jboeuf ) : Implement support for response_md . * / <nl> + if ( response_md ! = NULL & & num_response_md > 0 ) { <nl> + gpr_log ( GPR_INFO , <nl> + " response_md in auth metadata processing not supported for now . " <nl> + " Ignoring . . . " ) ; <nl> + } <nl> + <nl> + if ( status = = GRPC_STATUS_OK ) { <nl> calld - > consumed_md = consumed_md ; <nl> calld - > num_consumed_md = num_consumed_md ; <nl> grpc_metadata_batch_filter ( & calld - > md_op - > data . metadata , remove_consumed_md , <nl> elem ) ; <nl> - calld - > on_done_recv - > cb ( calld - > on_done_recv - > cb_arg , success ) ; <nl> + calld - > on_done_recv - > cb ( calld - > on_done_recv - > cb_arg , 1 ) ; <nl> } else { <nl> - gpr_slice message = gpr_slice_from_copied_string ( <nl> - " Authentication metadata processing failed . " ) ; <nl> + gpr_slice message ; <nl> + error_details = error_details ! = NULL <nl> + ? error_details <nl> + : " Authentication metadata processing failed . " ; <nl> + message = gpr_slice_from_copied_string ( error_details ) ; <nl> grpc_sopb_reset ( calld - > recv_ops ) ; <nl> - grpc_transport_stream_op_add_close ( & calld - > transport_op , <nl> - GRPC_STATUS_UNAUTHENTICATED , & message ) ; <nl> + grpc_transport_stream_op_add_close ( & calld - > transport_op , status , & message ) ; <nl> grpc_call_next_op ( elem , & calld - > transport_op ) ; <nl> } <nl> } <nl> mmm a / test / core / end2end / fixtures / chttp2_fake_security . c <nl> ppp b / test / core / end2end / fixtures / chttp2_fake_security . c <nl> static void process_auth_failure ( void * state , grpc_auth_context * ctx , <nl> grpc_process_auth_metadata_done_cb cb , <nl> void * user_data ) { <nl> GPR_ASSERT ( state = = NULL ) ; <nl> - cb ( user_data , NULL , 0 , 0 ) ; <nl> + cb ( user_data , NULL , 0 , NULL , 0 , GRPC_STATUS_UNAUTHENTICATED , NULL ) ; <nl> } <nl> <nl> static void chttp2_init_client_secure_fullstack ( grpc_end2end_test_fixture * f , <nl> mmm a / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack . c <nl> ppp b / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack . c <nl> static void process_auth_failure ( void * state , grpc_auth_context * ctx , <nl> grpc_process_auth_metadata_done_cb cb , <nl> void * user_data ) { <nl> GPR_ASSERT ( state = = NULL ) ; <nl> - cb ( user_data , NULL , 0 , 0 ) ; <nl> + cb ( user_data , NULL , 0 , NULL , 0 , GRPC_STATUS_UNAUTHENTICATED , NULL ) ; <nl> } <nl> <nl> static void chttp2_init_client_secure_fullstack ( grpc_end2end_test_fixture * f , <nl> mmm a / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack_with_poll . c <nl> ppp b / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack_with_poll . c <nl> static void process_auth_failure ( void * state , grpc_auth_context * ctx , <nl> grpc_process_auth_metadata_done_cb cb , <nl> void * user_data ) { <nl> GPR_ASSERT ( state = = NULL ) ; <nl> - cb ( user_data , NULL , 0 , 0 ) ; <nl> + cb ( user_data , NULL , 0 , NULL , 0 , GRPC_STATUS_UNAUTHENTICATED , NULL ) ; <nl> } <nl> <nl> static void chttp2_init_client_secure_fullstack ( grpc_end2end_test_fixture * f , <nl> mmm a / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack_with_proxy . c <nl> ppp b / test / core / end2end / fixtures / chttp2_simple_ssl_fullstack_with_proxy . c <nl> static void process_auth_failure ( void * state , grpc_auth_context * ctx , <nl> grpc_process_auth_metadata_done_cb cb , <nl> void * user_data ) { <nl> GPR_ASSERT ( state = = NULL ) ; <nl> - cb ( user_data , NULL , 0 , 0 ) ; <nl> + cb ( user_data , NULL , 0 , NULL , 0 , GRPC_STATUS_UNAUTHENTICATED , NULL ) ; <nl> } <nl> <nl> static void chttp2_init_client_secure_fullstack ( grpc_end2end_test_fixture * f , <nl> mmm a / test / core / end2end / fixtures / chttp2_simple_ssl_with_oauth2_fullstack . c <nl> ppp b / test / core / end2end / fixtures / chttp2_simple_ssl_with_oauth2_fullstack . c <nl> static void process_oauth2_success ( void * state , grpc_auth_context * ctx , <nl> client_identity ) ; <nl> GPR_ASSERT ( grpc_auth_context_set_peer_identity_property_name ( <nl> ctx , client_identity_property_name ) = = 1 ) ; <nl> - cb ( user_data , oauth2 , 1 , 1 ) ; <nl> + cb ( user_data , oauth2 , 1 , NULL , 0 , GRPC_STATUS_OK , NULL ) ; <nl> } <nl> <nl> static void process_oauth2_failure ( void * state , grpc_auth_context * ctx , <nl> static void process_oauth2_failure ( void * state , grpc_auth_context * ctx , <nl> find_metadata ( md , md_count , " Authorization " , oauth2_md ) ; <nl> GPR_ASSERT ( state = = NULL ) ; <nl> GPR_ASSERT ( oauth2 ! = NULL ) ; <nl> - cb ( user_data , oauth2 , 1 , 0 ) ; <nl> + cb ( user_data , oauth2 , 1 , NULL , 0 , GRPC_STATUS_UNAUTHENTICATED , NULL ) ; <nl> } <nl> <nl> static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack ( <nl>
|
Have a richer interface for auth metadata processors .
|
grpc/grpc
|
ee3dbb00789b463119242ea74c6c7317b42bee48
|
2015-08-20T05:17:03Z
|
mmm a / docs / linalg . rst <nl> ppp b / docs / linalg . rst <nl> Matrices <nl> - ` ` ti . Matrix ` ` are for small matrices ( e . g . ` 3x3 ` ) only . If you have ` 64x64 ` matrices , you should consider using a 2D tensor of scalars . <nl> - ` ` ti . Vector ` ` is the same as ` ` ti . Matrix ` ` , except that it has only one column . <nl> - Differentiate element - wise product ` ` * ` ` and matrix product ` ` @ ` ` . <nl> - - ` ` ti . Matrix . transposed ( A ) ` ` <nl> - - ` ` ti . Matrix . inverse ( A ) ` ` <nl> + - ` ` ti . transposed ( A ) ` ` <nl> + - ` ` ti . inverse ( A ) ` ` <nl> - ` ` ti . Matrix . abs ( A ) ` ` <nl> - ` ` ti . Matrix . trace ( A ) ` ` <nl> - - ` ` ti . Matrix . determinant ( A , type ) ` ` <nl> + - ` ` ti . determinant ( A , type ) ` ` <nl> - ` ` ti . Matrix . cast ( A , type ) ` ` <nl> <nl> Vectors <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> Vectors are special matrices with only 1 column . In fact , ` ` ti . Vector ` ` is just an alias of ` ` ti . Matrix ` ` . <nl> <nl> - - Dot product : ` ` a . dot ( b ) ` ` , where ` a ` and ` b ` are vectors . ` ` ti . Matrix . transposed ( a ) @ b ` ` will give you a ` matrix ` of size 1x1 , which is not a ` scalar ` . <nl> - - ` ` ti . Vector . outer_product ( a , b ) ` ` <nl> \ No newline at end of file <nl> + - Dot product : ` ` a . dot ( b ) ` ` , where ` a ` and ` b ` are vectors . ` ` ti . transposed ( a ) @ b ` ` will give you a ` matrix ` of size 1x1 , which is not a ` scalar ` . <nl> + - ` ` ti . outer_product ( a , b ) ` ` <nl> \ No newline at end of file <nl> mmm a / docs / tensor_matrix . rst <nl> ppp b / docs / tensor_matrix . rst <nl> Tensors are global variables provided by Taichi . Tensors can be either sparse or <nl> Although mathematically matrices are treated as 2D tensors , in Taichi , * * tensor * * and * * matrix * * are two completely different things . Matrices can be used as tensor elements , so you have tensors of matrices . <nl> <nl> Tensors of Scalars <nl> mmmmmmmmmmmmmmm <nl> + mmmmmmmmmmmmmmmmmmmmm - <nl> * Every global variable is an N - dimensional tensor . <nl> * Global ` scalars ` are treated as 0 - D tensors of scalars . <nl> * Tensors are accessed using indices , e . g . ` ` x [ i , j , k ] ` ` if ` ` x ` ` is a scalar 3D tensor . For a 0 - D tensor , access it as ` ` x [ None ] ` ` . <nl> Suppose you have a ` ` 128 x 64 ` ` global grid ` ` A ` ` , each node containing a ` ` 3 x <nl> * For a tensor ` ` F ` ` of element ` ` ti . Matrix ` ` , make sure you first index the tensor dimensions , and then the matrix dimensions : ` ` F [ i , j , k ] [ 0 , 2 ] ` ` . ( Assuming ` ` F ` ` is a 3D tensor with ` ` ti . Matrix ` ` of size ` ` 3x3 ` ` as elements ) <nl> * ` ` ti . Vector ` ` is simply an alias of ` ` ti . Matrix ` ` . <nl> * See : ref : ` linalg ` for more on matrices . <nl> + <nl> + <nl> + Matrix size <nl> + mmmmmmmmmmmmmmmmmmmmm - <nl> + For performance reasons matrix operations will be unrolled , therefore we suggest using only small matrices . <nl> + For example , ` ` 2x1 ` ` , ` ` 3x3 ` ` , ` ` 4x4 ` ` matrices are fine , yet ` ` 32x6 ` ` is probably too big as a matrix size . <nl> + <nl> + If you have a dimension that is too large ( e . g . ` ` 64 ` ` ) , it ' s better to declare a tensor of size ` ` 64 ` ` . <nl> + E . g . , instead of declaring ` ` ti . Matrix ( 64 , 32 , dt = ti . f32 , shape = ( 3 , 2 ) ) ` ` , declare ` ` ti . Matrix ( 3 , 2 , dt = ti . f32 , shape = ( 64 , 32 ) ) ` ` . <nl> + Try to put large dimensions to tensors instead of matrices . <nl>
|
update doc
|
taichi-dev/taichi
|
67c9ce0b0d51b0ef54bdf88242a4c0e1e1cde79e
|
2019-12-15T07:27:47Z
|
mmm a / samples / Cpp / TestCpp / Classes / ShaderTest / ShaderTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ShaderTest / ShaderTest . cpp <nl> <nl> # include " ShaderTest . h " <nl> # include " . . / testResource . h " <nl> # include " cocos2d . h " <nl> + # include " renderer / CCCustomCommand . h " <nl> + # include " renderer / CCRenderer . h " <nl> <nl> static int sceneIdx = - 1 ; <nl> <nl> void ShaderNode : : setPosition ( const Point & newPosition ) <nl> <nl> void ShaderNode : : draw ( ) <nl> { <nl> - CC_NODE_DRAW_SETUP ( ) ; <nl> + CustomCommand * cmd = CustomCommand : : getCommandPool ( ) . generateCommand ( ) ; <nl> + cmd - > init ( 0 , _vertexZ ) ; <nl> + cmd - > func = CC_CALLBACK_0 ( ShaderNode : : onDraw , this ) ; <nl> + Director : : getInstance ( ) - > getRenderer ( ) - > addCommand ( cmd ) ; <nl> + } <nl> <nl> + void ShaderNode : : onDraw ( ) <nl> + { <nl> + CC_NODE_DRAW_SETUP ( ) ; <nl> + <nl> float w = SIZE_X , h = SIZE_Y ; <nl> GLfloat vertices [ 12 ] = { 0 , 0 , w , 0 , w , h , 0 , 0 , 0 , h , w , h } ; <nl> - <nl> + <nl> / / <nl> / / Uniforms <nl> / / <nl> getShaderProgram ( ) - > setUniformLocationWith2f ( _uniformCenter , _center . x , _center . y ) ; <nl> getShaderProgram ( ) - > setUniformLocationWith2f ( _uniformResolution , _resolution . x , _resolution . y ) ; <nl> - <nl> + <nl> / / time changes all the time , so it is Ok to call OpenGL directly , and not the " cached " version <nl> glUniform1f ( _uniformTime , _time ) ; <nl> - <nl> + <nl> GL : : enableVertexAttribs ( cocos2d : : GL : : VERTEX_ATTRIB_FLAG_POSITION ) ; <nl> - <nl> + <nl> glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_POSITION , 2 , GL_FLOAT , GL_FALSE , 0 , vertices ) ; <nl> - <nl> + <nl> glDrawArrays ( GL_TRIANGLES , 0 , 6 ) ; <nl> <nl> CC_INCREMENT_GL_DRAWS ( 1 ) ; <nl> } <nl> <nl> - <nl> / / / ShaderMonjori <nl> <nl> ShaderMonjori : : ShaderMonjori ( ) <nl> class SpriteBlur : public Sprite <nl> <nl> GLuint blurLocation ; <nl> GLuint subLocation ; <nl> + protected : <nl> + void onDraw ( ) ; <nl> } ; <nl> <nl> SpriteBlur : : ~ SpriteBlur ( ) <nl> void SpriteBlur : : initProgram ( ) <nl> } <nl> <nl> void SpriteBlur : : draw ( ) <nl> + { <nl> + CustomCommand * cmd = CustomCommand : : getCommandPool ( ) . generateCommand ( ) ; <nl> + cmd - > init ( 0 , _vertexZ ) ; <nl> + cmd - > func = CC_CALLBACK_0 ( SpriteBlur : : onDraw , this ) ; <nl> + Director : : getInstance ( ) - > getRenderer ( ) - > addCommand ( cmd ) ; <nl> + } <nl> + <nl> + void SpriteBlur : : onDraw ( ) <nl> { <nl> GL : : enableVertexAttribs ( cocos2d : : GL : : VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ) ; <nl> BlendFunc blend = getBlendFunc ( ) ; <nl> GL : : blendFunc ( blend . src , blend . dst ) ; <nl> - <nl> + <nl> getShaderProgram ( ) - > use ( ) ; <nl> getShaderProgram ( ) - > setUniformsForBuiltins ( ) ; <nl> getShaderProgram ( ) - > setUniformLocationWith2f ( blurLocation , blur_ . x , blur_ . y ) ; <nl> getShaderProgram ( ) - > setUniformLocationWith4fv ( subLocation , sub_ , 1 ) ; <nl> - <nl> + <nl> GL : : bindTexture2D ( getTexture ( ) - > getName ( ) ) ; <nl> - <nl> + <nl> / / <nl> / / Attributes <nl> / / <nl> # define kQuadSize sizeof ( _quad . bl ) <nl> long offset = ( long ) & _quad ; <nl> - <nl> + <nl> / / vertex <nl> int diff = offsetof ( V3F_C4B_T2F , vertices ) ; <nl> glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_POSITION , 3 , GL_FLOAT , GL_FALSE , kQuadSize , ( void * ) ( offset + diff ) ) ; <nl> - <nl> + <nl> / / texCoods <nl> diff = offsetof ( V3F_C4B_T2F , texCoords ) ; <nl> glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_TEX_COORDS , 2 , GL_FLOAT , GL_FALSE , kQuadSize , ( void * ) ( offset + diff ) ) ; <nl> - <nl> + <nl> / / color <nl> diff = offsetof ( V3F_C4B_T2F , colors ) ; <nl> glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_COLOR , 4 , GL_UNSIGNED_BYTE , GL_TRUE , kQuadSize , ( void * ) ( offset + diff ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> glDrawArrays ( GL_TRIANGLE_STRIP , 0 , 4 ) ; <nl> - <nl> + <nl> CC_INCREMENT_GL_DRAWS ( 1 ) ; <nl> } <nl> <nl> mmm a / samples / Cpp / TestCpp / Classes / ShaderTest / ShaderTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ShaderTest / ShaderTest . h <nl> class ShaderNode : public Node <nl> <nl> static ShaderNode * shaderNodeWithVertex ( const char * vert , const char * frag ) ; <nl> <nl> + protected : <nl> + void onDraw ( ) ; <nl> + <nl> private : <nl> <nl> Vertex2F _center ; <nl>
|
Merge pull request from dabingnn / develop_FixTestCase_ShaderNode
|
cocos2d/cocos2d-x
|
01bd8792b78a44f1fa2ca9a1d27100473a03f730
|
2013-12-25T08:57:51Z
|
mmm a / dbms / include / DB / Storages / MergeTree / MergeTreeReader . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / MergeTreeReader . h <nl> class MergeTreeReader <nl> } <nl> } <nl> <nl> - if ( aio_threshold = = 0 | | estimated_size < aio_threshold ) <nl> - memory . resize ( buffer_size ) ; <nl> - else <nl> - memory . resize ( 2 * Memory : : align ( buffer_size + DEFAULT_AIO_FILE_BLOCK_SIZE , <nl> - DEFAULT_AIO_FILE_BLOCK_SIZE ) ) ; <nl> - <nl> if ( uncompressed_cache ) <nl> { <nl> cached_buffer = std : : make_unique < CachedCompressedReadBuffer > ( <nl> class MergeTreeReader <nl> } <nl> else <nl> { <nl> + if ( aio_threshold = = 0 | | estimated_size < aio_threshold ) <nl> + memory . resize ( buffer_size ) ; <nl> + else <nl> + memory . resize ( 2 * Memory : : align ( buffer_size + DEFAULT_AIO_FILE_BLOCK_SIZE , <nl> + DEFAULT_AIO_FILE_BLOCK_SIZE ) ) ; <nl> + <nl> + / * * @ todo CompressedReadBufferFromFile creates buffer for decompressed blocks , consider providing another <nl> + * instance of Memory type for it * / <nl> non_cached_buffer = std : : make_unique < CompressedReadBufferFromFile > ( <nl> path_prefix + " . bin " , estimated_size , aio_threshold , buffer_size , & memory [ 0 ] ) ; <nl> data_buffer = non_cached_buffer . get ( ) ; <nl> class MergeTreeReader <nl> return ; <nl> <nl> const auto buffer_idx = streams . size ( ) ; <nl> - if ( buffer_idx > = buffers . size ( ) ) <nl> + if ( buffer_idx = = buffers . size ( ) ) <nl> buffers . push_back ( std : : make_unique < Memory > ( 0 , DEFAULT_AIO_FILE_BLOCK_SIZE ) ) ; <nl> <nl> / / / Для массивов используются отдельные потоки для размеров . <nl>
|
Merge
|
ClickHouse/ClickHouse
|
cbe8fb0b6790066e02af503ce39b6ccddf450f0c
|
2015-09-01T14:15:07Z
|
mmm a / src / heap / heap - inl . h <nl> ppp b / src / heap / heap - inl . h <nl> AllocationResult Heap : : AllocateOneByteInternalizedString ( <nl> / / Compute map and object size . <nl> Map * map = one_byte_internalized_string_map ( ) ; <nl> int size = SeqOneByteString : : SizeFor ( str . length ( ) ) ; <nl> - AllocationSpace space = SelectSpace ( size , TENURED ) ; <nl> <nl> / / Allocate string . <nl> HeapObject * result = nullptr ; <nl> { <nl> - AllocationResult allocation = AllocateRaw ( size , space , OLD_SPACE ) ; <nl> + AllocationResult allocation = AllocateRaw ( size , OLD_SPACE , OLD_SPACE ) ; <nl> if ( ! allocation . To ( & result ) ) return allocation ; <nl> } <nl> <nl> AllocationResult Heap : : AllocateTwoByteInternalizedString ( Vector < const uc16 > str , <nl> / / Compute map and object size . <nl> Map * map = internalized_string_map ( ) ; <nl> int size = SeqTwoByteString : : SizeFor ( str . length ( ) ) ; <nl> - AllocationSpace space = SelectSpace ( size , TENURED ) ; <nl> <nl> / / Allocate string . <nl> HeapObject * result = nullptr ; <nl> { <nl> - AllocationResult allocation = AllocateRaw ( size , space , OLD_SPACE ) ; <nl> + AllocationResult allocation = AllocateRaw ( size , OLD_SPACE , OLD_SPACE ) ; <nl> if ( ! allocation . To ( & result ) ) return allocation ; <nl> } <nl> <nl> AllocationResult Heap : : AllocateRaw ( int size_in_bytes , AllocationSpace space , <nl> isolate_ - > counters ( ) - > objs_since_last_young ( ) - > Increment ( ) ; <nl> # endif <nl> <nl> + bool large_object = size_in_bytes > Page : : kMaxRegularHeapObjectSize ; <nl> HeapObject * object = nullptr ; <nl> AllocationResult allocation ; <nl> if ( NEW_SPACE = = space ) { <nl> - allocation = new_space_ . AllocateRaw ( size_in_bytes , alignment ) ; <nl> - if ( always_allocate ( ) & & allocation . IsRetry ( ) & & retry_space ! = NEW_SPACE ) { <nl> - space = retry_space ; <nl> - } else { <nl> - if ( allocation . To ( & object ) ) { <nl> - OnAllocationEvent ( object , size_in_bytes ) ; <nl> + if ( ! large_object ) { <nl> + allocation = new_space_ . AllocateRaw ( size_in_bytes , alignment ) ; <nl> + if ( always_allocate ( ) & & allocation . IsRetry ( ) & & <nl> + retry_space ! = NEW_SPACE ) { <nl> + space = retry_space ; <nl> + } else { <nl> + if ( allocation . To ( & object ) ) { <nl> + OnAllocationEvent ( object , size_in_bytes ) ; <nl> + } <nl> + return allocation ; <nl> } <nl> - return allocation ; <nl> + } else { <nl> + space = LO_SPACE ; <nl> } <nl> } <nl> <nl> if ( OLD_SPACE = = space ) { <nl> - allocation = old_space_ - > AllocateRaw ( size_in_bytes , alignment ) ; <nl> + if ( ! large_object ) { <nl> + allocation = old_space_ - > AllocateRaw ( size_in_bytes , alignment ) ; <nl> + } else { <nl> + allocation = lo_space_ - > AllocateRaw ( size_in_bytes , NOT_EXECUTABLE ) ; <nl> + } <nl> } else if ( CODE_SPACE = = space ) { <nl> - if ( size_in_bytes < = code_space ( ) - > AreaSize ( ) ) { <nl> + if ( ! large_object ) { <nl> allocation = code_space_ - > AllocateRawUnaligned ( size_in_bytes ) ; <nl> } else { <nl> - / / Large code objects are allocated in large object space . <nl> allocation = lo_space_ - > AllocateRaw ( size_in_bytes , EXECUTABLE ) ; <nl> } <nl> } else if ( LO_SPACE = = space ) { <nl> + DCHECK ( large_object ) ; <nl> allocation = lo_space_ - > AllocateRaw ( size_in_bytes , NOT_EXECUTABLE ) ; <nl> - } else { <nl> - DCHECK ( MAP_SPACE = = space ) ; <nl> + } else if ( MAP_SPACE = = space ) { <nl> allocation = map_space_ - > AllocateRawUnaligned ( size_in_bytes ) ; <nl> } <nl> if ( allocation . To ( & object ) ) { <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> AllocationResult Heap : : AllocateHeapNumber ( double value , MutableMode mode , <nl> int size = HeapNumber : : kSize ; <nl> STATIC_ASSERT ( HeapNumber : : kSize < = Page : : kMaxRegularHeapObjectSize ) ; <nl> <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> HeapObject * result = nullptr ; <nl> { <nl> AllocationResult Heap : : AllocateHeapNumber ( double value , MutableMode mode , <nl> int size = Type : : kSize ; \ <nl> STATIC_ASSERT ( Type : : kSize < = Page : : kMaxRegularHeapObjectSize ) ; \ <nl> \ <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; \ <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; \ <nl> \ <nl> HeapObject * result = nullptr ; \ <nl> { \ <nl> AllocationResult Heap : : AllocateByteArray ( int length , PretenureFlag pretenure ) { <nl> v8 : : internal : : Heap : : FatalProcessOutOfMemory ( " invalid array length " , true ) ; <nl> } <nl> int size = ByteArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> HeapObject * result = nullptr ; <nl> { <nl> AllocationResult allocation = AllocateRaw ( size , space , OLD_SPACE ) ; <nl> AllocationResult Heap : : AllocateFixedTypedArrayWithExternalPointer ( <nl> int length , ExternalArrayType array_type , void * external_pointer , <nl> PretenureFlag pretenure ) { <nl> int size = FixedTypedArrayBase : : kHeaderSize ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> HeapObject * result = nullptr ; <nl> { <nl> AllocationResult allocation = AllocateRaw ( size , space , OLD_SPACE ) ; <nl> AllocationResult Heap : : AllocateFixedTypedArray ( int length , <nl> ForFixedTypedArray ( array_type , & element_size , & elements_kind ) ; <nl> int size = OBJECT_POINTER_ALIGN ( length * element_size + <nl> FixedTypedArrayBase : : kDataOffset ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> HeapObject * object = nullptr ; <nl> AllocationResult allocation = AllocateRaw ( <nl> AllocationResult Heap : : AllocateJSObjectFromMap ( <nl> FixedArray * properties = empty_fixed_array ( ) ; <nl> <nl> / / Allocate the JSObject . <nl> - int size = map - > instance_size ( ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> JSObject * js_obj = nullptr ; <nl> AllocationResult allocation = Allocate ( map , space , allocation_site ) ; <nl> if ( ! allocation . To ( & js_obj ) ) return allocation ; <nl> AllocationResult Heap : : AllocateInternalizedStringImpl ( T t , int chars , <nl> map = internalized_string_map ( ) ; <nl> size = SeqTwoByteString : : SizeFor ( chars ) ; <nl> } <nl> - AllocationSpace space = SelectSpace ( size , TENURED ) ; <nl> <nl> / / Allocate string . <nl> HeapObject * result = nullptr ; <nl> { <nl> - AllocationResult allocation = AllocateRaw ( size , space , OLD_SPACE ) ; <nl> + AllocationResult allocation = AllocateRaw ( size , OLD_SPACE , OLD_SPACE ) ; <nl> if ( ! allocation . To ( & result ) ) return allocation ; <nl> } <nl> <nl> AllocationResult Heap : : AllocateRawOneByteString ( int length , <nl> DCHECK_GE ( String : : kMaxLength , length ) ; <nl> int size = SeqOneByteString : : SizeFor ( length ) ; <nl> DCHECK ( size < = SeqOneByteString : : kMaxSize ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> HeapObject * result = nullptr ; <nl> { <nl> AllocationResult Heap : : AllocateRawTwoByteString ( int length , <nl> DCHECK_GE ( String : : kMaxLength , length ) ; <nl> int size = SeqTwoByteString : : SizeFor ( length ) ; <nl> DCHECK ( size < = SeqTwoByteString : : kMaxSize ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> HeapObject * result = nullptr ; <nl> { <nl> AllocationResult Heap : : AllocateRawFixedArray ( int length , <nl> v8 : : internal : : Heap : : FatalProcessOutOfMemory ( " invalid array length " , true ) ; <nl> } <nl> int size = FixedArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> return AllocateRaw ( size , space , OLD_SPACE ) ; <nl> } <nl> AllocationResult Heap : : AllocateRawFixedDoubleArray ( int length , <nl> kDoubleAligned ) ; <nl> } <nl> int size = FixedDoubleArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = SelectSpace ( size , pretenure ) ; <nl> + AllocationSpace space = SelectSpace ( pretenure ) ; <nl> <nl> HeapObject * object = nullptr ; <nl> { <nl> AllocationResult Heap : : AllocateStruct ( InstanceType type ) { <nl> return exception ( ) ; <nl> } <nl> int size = map - > instance_size ( ) ; <nl> - AllocationSpace space = SelectSpace ( size , TENURED ) ; <nl> Struct * result = nullptr ; <nl> { <nl> - AllocationResult allocation = Allocate ( map , space ) ; <nl> + AllocationResult allocation = Allocate ( map , OLD_SPACE ) ; <nl> if ( ! allocation . To ( & result ) ) return allocation ; <nl> } <nl> result - > InitializeBody ( size ) ; <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class Heap { <nl> static void ScavengeStoreBufferCallback ( Heap * heap , MemoryChunk * page , <nl> StoreBufferEvent event ) ; <nl> <nl> - / / Selects the proper allocation space depending on the given object <nl> - / / size and pretenuring decision . <nl> - static AllocationSpace SelectSpace ( int object_size , PretenureFlag pretenure ) { <nl> - if ( object_size > Page : : kMaxRegularHeapObjectSize ) return LO_SPACE ; <nl> + / / Selects the proper allocation space based on the pretenuring decision . <nl> + static AllocationSpace SelectSpace ( PretenureFlag pretenure ) { <nl> return ( pretenure = = TENURED ) ? OLD_SPACE : NEW_SPACE ; <nl> } <nl> <nl>
|
[ heap ] Move large object space selection into AllocateRaw .
|
v8/v8
|
e4f7ebb000432cc2011ecaaa71a69e2e60f416f0
|
2015-09-25T13:54:09Z
|
mmm a / arangod / Aql / Functions . cpp <nl> ppp b / arangod / Aql / Functions . cpp <nl> AqlValue Functions : : Sleep ( ExpressionContext * expressionContext , <nl> return AqlValue ( AqlValueHintNull ( ) ) ; <nl> } <nl> <nl> - double const until = TRI_microtime ( ) + value . toDouble ( ) ; <nl> + double now = TRI_microtime ( ) ; <nl> + double const until = now + value . toDouble ( ) ; <nl> <nl> - while ( TRI_microtime ( ) < until ) { <nl> - std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 300 ) ) ; <nl> + while ( now < until ) { <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 100 ) ) ; <nl> <nl> if ( expressionContext - > killed ( ) ) { <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_QUERY_KILLED ) ; <nl> } else if ( application_features : : ApplicationServer : : isStopping ( ) ) { <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_SHUTTING_DOWN ) ; <nl> } <nl> + now = TRI_microtime ( ) ; <nl> } <nl> return AqlValue ( AqlValueHintNull ( ) ) ; <nl> } <nl>
|
make sleeping more accurate
|
arangodb/arangodb
|
02f9eb06f84df2dfed5a02650c91eb755a5025ad
|
2019-09-24T13:18:21Z
|
mmm a / src / commands / cmd_duplicate_layer . cpp <nl> ppp b / src / commands / cmd_duplicate_layer . cpp <nl> void DuplicateLayerCommand : : onExecute ( Context * context ) <nl> / / Create a new layer <nl> UniquePtr < LayerImage > newLayerPtr ( new LayerImage ( sprite ) ) ; <nl> <nl> - / / Copy the layer name <nl> - newLayerPtr - > setName ( sourceLayer - > getName ( ) + " Copy " ) ; <nl> - <nl> / / Copy the layer content ( cels + images ) <nl> - document - > copyLayerContent ( sourceLayer , newLayerPtr ) ; <nl> + document - > copyLayerContent ( sourceLayer , document , newLayerPtr ) ; <nl> + <nl> + / / Copy the layer name <nl> + newLayerPtr - > setName ( newLayerPtr - > getName ( ) + " Copy " ) ; <nl> <nl> / / Add the new layer in the sprite . <nl> if ( undo - > isEnabled ( ) ) <nl> mmm a / src / document . cpp <nl> ppp b / src / document . cpp <nl> void Document : : setMaskVisible ( bool visible ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Copying <nl> <nl> - void Document : : copyLayerContent ( const LayerImage * sourceLayer , LayerImage * destLayer ) const <nl> + void Document : : copyLayerContent ( const Layer * sourceLayer0 , Document * destDoc , Layer * destLayer0 ) const <nl> { <nl> - / / copy cels <nl> - CelConstIterator it = sourceLayer - > getCelBegin ( ) ; <nl> - CelConstIterator end = sourceLayer - > getCelEnd ( ) ; <nl> + / / Copy the layer name <nl> + destLayer0 - > setName ( sourceLayer0 - > getName ( ) ) ; <nl> <nl> - for ( ; it ! = end ; + + it ) { <nl> - const Cel * sourceCel = * it ; <nl> - Cel * newCel = new Cel ( * sourceCel ) ; <nl> + if ( sourceLayer0 - > is_image ( ) & & destLayer0 - > is_image ( ) ) { <nl> + const LayerImage * sourceLayer = static_cast < const LayerImage * > ( sourceLayer0 ) ; <nl> + LayerImage * destLayer = static_cast < LayerImage * > ( destLayer0 ) ; <nl> <nl> - ASSERT ( ( sourceCel - > getImage ( ) > = 0 ) & & <nl> - ( sourceCel - > getImage ( ) < sourceLayer - > getSprite ( ) - > getStock ( ) - > size ( ) ) ) ; <nl> + / / copy cels <nl> + CelConstIterator it = sourceLayer - > getCelBegin ( ) ; <nl> + CelConstIterator end = sourceLayer - > getCelEnd ( ) ; <nl> <nl> - const Image * sourceImage = sourceLayer - > getSprite ( ) - > getStock ( ) - > getImage ( sourceCel - > getImage ( ) ) ; <nl> - ASSERT ( sourceImage ! = NULL ) ; <nl> + for ( ; it ! = end ; + + it ) { <nl> + const Cel * sourceCel = * it ; <nl> + UniquePtr < Cel > newCel ( new Cel ( * sourceCel ) ) ; <nl> + <nl> + ASSERT ( ( sourceCel - > getImage ( ) > = 0 ) & & <nl> + ( sourceCel - > getImage ( ) < sourceLayer - > getSprite ( ) - > getStock ( ) - > size ( ) ) ) ; <nl> + <nl> + const Image * sourceImage = sourceLayer - > getSprite ( ) - > getStock ( ) - > getImage ( sourceCel - > getImage ( ) ) ; <nl> + ASSERT ( sourceImage ! = NULL ) ; <nl> <nl> - Image * newImage = image_new_copy ( sourceImage ) ; <nl> + Image * newImage = image_new_copy ( sourceImage ) ; <nl> <nl> - newCel - > setImage ( destLayer - > getSprite ( ) - > getStock ( ) - > addImage ( newImage ) ) ; <nl> + newCel - > setImage ( destLayer - > getSprite ( ) - > getStock ( ) - > addImage ( newImage ) ) ; <nl> <nl> - if ( m_undoHistory - > isEnabled ( ) ) <nl> - m_undoHistory - > undo_add_image ( destLayer - > getSprite ( ) - > getStock ( ) , newCel - > getImage ( ) ) ; <nl> + if ( destDoc - > getUndoHistory ( ) - > isEnabled ( ) ) <nl> + destDoc - > getUndoHistory ( ) - > undo_add_image ( destLayer - > getSprite ( ) - > getStock ( ) , <nl> + newCel - > getImage ( ) ) ; <nl> <nl> - destLayer - > addCel ( newCel ) ; <nl> + destLayer - > addCel ( newCel ) ; <nl> + newCel . release ( ) ; <nl> + } <nl> + } <nl> + else if ( sourceLayer0 - > is_folder ( ) & & destLayer0 - > is_folder ( ) ) { <nl> + const LayerFolder * sourceLayer = static_cast < const LayerFolder * > ( sourceLayer0 ) ; <nl> + LayerFolder * destLayer = static_cast < LayerFolder * > ( destLayer0 ) ; <nl> + <nl> + LayerConstIterator it = sourceLayer - > get_layer_begin ( ) ; <nl> + LayerConstIterator end = sourceLayer - > get_layer_end ( ) ; <nl> + <nl> + for ( ; it ! = end ; + + it ) { <nl> + Layer * sourceChild = * it ; <nl> + UniquePtr < Layer > destChild ( NULL ) ; <nl> + <nl> + if ( sourceChild - > is_image ( ) ) { <nl> + destChild . reset ( new LayerImage ( destLayer - > getSprite ( ) ) ) ; <nl> + copyLayerContent ( sourceChild , destDoc , destChild ) ; <nl> + } <nl> + else if ( sourceChild - > is_folder ( ) ) { <nl> + destChild . reset ( new LayerFolder ( destLayer - > getSprite ( ) ) ) ; <nl> + copyLayerContent ( sourceChild , destDoc , destChild ) ; <nl> + } <nl> + else { <nl> + ASSERT ( false ) ; <nl> + } <nl> + <nl> + ASSERT ( destChild ! = NULL ) ; <nl> + <nl> + / / Add the new layer in the sprite . <nl> + if ( destDoc - > getUndoHistory ( ) - > isEnabled ( ) ) <nl> + destDoc - > getUndoHistory ( ) - > undo_add_layer ( destLayer , destChild ) ; <nl> + <nl> + destLayer - > add_layer ( destChild ) ; <nl> + destChild . release ( ) ; <nl> + } <nl> + } <nl> + else { <nl> + ASSERT ( false & & " Trying to copy two incompatible layers " ) ; <nl> } <nl> } <nl> <nl> Document * Document : : duplicate ( DuplicateType type ) const <nl> { <nl> const Sprite * sourceSprite = getSprite ( ) ; <nl> - UniquePtr < Sprite > spriteCopy ( new Sprite ( sourceSprite - > getImgType ( ) , <nl> - sourceSprite - > getWidth ( ) , <nl> - sourceSprite - > getHeight ( ) , sourceSprite - > getPalette ( 0 ) - > size ( ) ) ) ; <nl> + UniquePtr < Sprite > spriteCopyPtr ( new Sprite ( sourceSprite - > getImgType ( ) , <nl> + sourceSprite - > getWidth ( ) , <nl> + sourceSprite - > getHeight ( ) , sourceSprite - > getPalette ( 0 ) - > size ( ) ) ) ; <nl> + UniquePtr < Document > documentCopy ( new Document ( spriteCopyPtr ) ) ; <nl> + Sprite * spriteCopy = spriteCopyPtr . release ( ) ; <nl> <nl> spriteCopy - > setTotalFrames ( sourceSprite - > getTotalFrames ( ) ) ; <nl> spriteCopy - > setCurrentFrame ( sourceSprite - > getCurrentFrame ( ) ) ; <nl> Document * Document : : duplicate ( DuplicateType type ) const <nl> switch ( type ) { <nl> <nl> case DuplicateExactCopy : <nl> + / / Disable the undo <nl> + documentCopy - > getUndoHistory ( ) - > setEnabled ( false ) ; <nl> + <nl> + / / Copy the layer folder <nl> + copyLayerContent ( getSprite ( ) - > getFolder ( ) , documentCopy , spriteCopy - > getFolder ( ) ) ; <nl> + <nl> + / / Set as current layer the same layer as the source <nl> { <nl> - / / TODO IMPLEMENT THIS <nl> + int index = sourceSprite - > layerToIndex ( sourceSprite - > getCurrentLayer ( ) ) ; <nl> + spriteCopy - > setCurrentLayer ( spriteCopy - > indexToLayer ( index ) ) ; <nl> } <nl> + <nl> + / / Re - enable the undo <nl> + documentCopy - > getUndoHistory ( ) - > setEnabled ( true ) ; <nl> break ; <nl> <nl> case DuplicateWithFlattenLayers : <nl> Document * Document : : duplicate ( DuplicateType type ) const <nl> break ; <nl> } <nl> <nl> - UniquePtr < Document > documentCopy ( new Document ( spriteCopy ) ) ; <nl> - spriteCopy . release ( ) ; <nl> - <nl> documentCopy - > setMask ( getMask ( ) ) ; <nl> documentCopy - > m_maskVisible = m_maskVisible ; <nl> documentCopy - > m_preferred = m_preferred ; <nl> mmm a / src / document . h <nl> ppp b / src / document . h <nl> <nl> class Cel ; <nl> class FormatOptions ; <nl> class Image ; <nl> - class LayerImage ; <nl> + class Layer ; <nl> class Mask ; <nl> class Mutex ; <nl> class Sprite ; <nl> class Document <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Copying <nl> <nl> - void copyLayerContent ( const LayerImage * sourceLayer , LayerImage * destLayer ) const ; <nl> - <nl> + void copyLayerContent ( const Layer * sourceLayer , Document * destDoc , Layer * destLayer ) const ; <nl> Document * duplicate ( DuplicateType type ) const ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl>
|
Implement duplicate sprite with all layers ( it was removed
|
aseprite/aseprite
|
236ee6bb7bdcfeaea830fe686215e0af34542f56
|
2011-03-29T02:31:16Z
|
mmm a / src / node / src / client . js <nl> ppp b / src / node / src / client . js <nl> var Readable = stream . Readable ; <nl> var Writable = stream . Writable ; <nl> var Duplex = stream . Duplex ; <nl> var util = require ( ' util ' ) ; <nl> + var version = require ( ' . . / package . json ' ) . version ; <nl> <nl> util . inherits ( ClientWritableStream , Writable ) ; <nl> <nl> function makeClientConstructor ( methods , serviceName ) { <nl> callback ( null , metadata ) ; <nl> } ; <nl> } <nl> - <nl> + if ( ! options ) { <nl> + options = { } ; <nl> + } <nl> + options . GRPC_ARG_PRIMARY_USER_AGENT_STRING = ' grpc - node / ' + version ; <nl> this . server_address = address . replace ( / \ / $ / , ' ' ) ; <nl> this . channel = new grpc . Channel ( address , options ) ; <nl> this . auth_uri = this . server_address + ' / ' + serviceName ; <nl> mmm a / src / node / test / surface_test . js <nl> ppp b / src / node / test / surface_test . js <nl> describe ( ' Echo metadata ' , function ( ) { <nl> } ) ; <nl> call . end ( ) ; <nl> } ) ; <nl> + it ( ' shows the correct user - agent string ' , function ( done ) { <nl> + var version = require ( ' . . / package . json ' ) . version ; <nl> + var call = client . unary ( { } , function ( err , data ) { <nl> + assert . ifError ( err ) ; <nl> + } , { key : [ ' value ' ] } ) ; <nl> + call . on ( ' metadata ' , function ( metadata ) { <nl> + assert ( _ . startsWith ( metadata [ ' user - agent ' ] , ' grpc - node / ' + version ) ) ; <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> } ) ; <nl> describe ( ' Other conditions ' , function ( ) { <nl> var client ; <nl>
|
Added user - agent setting code , and a test for it
|
grpc/grpc
|
198a1ad966cb38ccc1697961914fa5b8b854df2f
|
2015-07-21T21:27:56Z
|
mmm a / arangod / Ahuacatl / ahuacatl - context . cpp <nl> ppp b / arangod / Ahuacatl / ahuacatl - context . cpp <nl> char * TRI_RegisterStringAql ( TRI_aql_context_t * const context , <nl> / / / @ brief register a combined string <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - char * TRI_RegisterString2Aql ( TRI_aql_context_t * const context , <nl> - const char * const s1 , <nl> - const char * const s2 ) { <nl> - char * copy ; <nl> - <nl> - copy = TRI_Concatenate2StringZ ( TRI_UNKNOWN_MEM_ZONE , s1 , s2 ) ; <nl> - <nl> - if ( copy = = NULL ) { <nl> - ABORT_OOM <nl> - } <nl> - <nl> - if ( TRI_PushBackVectorPointer ( & context - > _memory . _strings , copy ) ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_FreeString ( TRI_UNKNOWN_MEM_ZONE , copy ) ; <nl> - ABORT_OOM <nl> - } <nl> - <nl> - return copy ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> char * TRI_RegisterString3Aql ( TRI_aql_context_t * const context , <nl> const char * const s1 , <nl> const char * const s2 , <nl> mmm a / arangod / Ahuacatl / ahuacatl - context . h <nl> ppp b / arangod / Ahuacatl / ahuacatl - context . h <nl> char * TRI_RegisterStringAql ( TRI_aql_context_t * const , <nl> / / / @ brief register a combined string <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - char * TRI_RegisterString2Aql ( TRI_aql_context_t * const , <nl> - const char * const , <nl> - const char * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> char * TRI_RegisterString3Aql ( TRI_aql_context_t * const , <nl> const char * const , <nl> const char * const , <nl> mmm a / arangod / Aql / Parser . cpp <nl> ppp b / arangod / Aql / Parser . cpp <nl> Parser : : Parser ( Query * query ) <nl> _buffer ( query - > queryString ( ) ) , <nl> _remainingLength ( query - > queryLength ( ) ) , <nl> _offset ( 0 ) , <nl> - _marker ( nullptr ) { <nl> + _marker ( nullptr ) , <nl> + _uniqueId ( 0 ) , <nl> + _stack ( ) { <nl> <nl> - / / Aqlllex_init ( & context - > _parser - > _scanner ) ; <nl> - / / Aqlset_extra ( context , context - > _parser - > _scanner ) ; <nl> + Aqllex_init ( & _scanner ) ; <nl> + Aqlset_extra ( this , _scanner ) ; <nl> + <nl> + _stack . reserve ( 16 ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> Parser : : Parser ( Query * query ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> Parser : : ~ Parser ( ) { <nl> - / / Aqllex_destroy ( parser - > _scanner ) ; <nl> + Aqllex_destroy ( _scanner ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> Parser : : ~ Parser ( ) { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a parse error <nl> + / / / @ brief parse the query <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool Parser : : parse ( ) { <nl> + scopes ( ) - > start ( AQL_SCOPE_MAIN ) ; <nl> + <nl> + if ( Aqlparse ( this ) ) { <nl> + / / lexing / parsing failed <nl> + return false ; <nl> + } <nl> + <nl> + scopes ( ) - > endCurrent ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate a new unique name <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + char * Parser : : generateName ( ) { <nl> + char buffer [ 16 ] ; <nl> + int n = snprintf ( buffer , sizeof ( buffer ) - 1 , " _ % d " , ( int ) + + _uniqueId ) ; <nl> + <nl> + / / register the string and return a copy of it <nl> + return registerString ( buffer , static_cast < size_t > ( n ) , false ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief register a parse error , position is specified as line / column <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void Parser : : registerError ( char const * message , <nl> void Parser : : registerError ( char const * message , <nl> line , <nl> column + 1 ) ; <nl> <nl> - _query - > registerError ( TRI_ERROR_QUERY_PARSE , std : : string ( buffer ) , __FILE__ , __LINE__ ) ; <nl> + _query - > registerError ( TRI_ERROR_QUERY_PARSE , std : : string ( buffer ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief register a non - parse error <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Parser : : registerError ( int code , <nl> + char const * message ) { <nl> + <nl> + if ( message = = nullptr ) { <nl> + _query - > registerError ( code ) ; <nl> + } <nl> + else { <nl> + _query - > registerError ( code , std : : string ( message ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief push a temporary value on the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Parser : : pushStack ( void * value ) { <nl> + _stack . push_back ( value ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief pop a temporary value from the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void * Parser : : popStack ( ) { <nl> + TRI_ASSERT ( ! _stack . empty ( ) ) ; <nl> + <nl> + void * result = _stack . back ( ) ; <nl> + _stack . pop_back ( ) ; <nl> + return result ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief peek at a temporary value from the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void * Parser : : peekStack ( ) { <nl> + TRI_ASSERT ( ! _stack . empty ( ) ) ; <nl> + <nl> + return _stack . back ( ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / arangod / Aql / Parser . h <nl> ppp b / arangod / Aql / Parser . h <nl> <nl> <nl> # include " Basics / Common . h " <nl> # include " Aql / Query . h " <nl> + # include " Aql / Scopes . h " <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - forwards <nl> namespace triagens { <nl> <nl> public : <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief return the scopes during parsing <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + inline Scopes * scopes ( ) { <nl> + return _query - > scopes ( ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief return the scanner <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace triagens { <nl> <nl> bool parse ( ) ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate a new unique name <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + char * generateName ( ) ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief register a parse error , position is specified as line / column <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace triagens { <nl> void registerError ( int , <nl> char const * = nullptr ) ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief push a temporary value on the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void pushStack ( void * ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief pop a temporary value from the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void * popStack ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief peek at a temporary value from the parser ' s stack <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void * peekStack ( ) ; <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - private variables <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> namespace triagens { <nl> size_t _remainingLength ; / / remaining length of the query string , modified during parsing <nl> size_t _offset ; / / current parse position <nl> char const * _marker ; / / a position used temporarily during parsing <nl> + <nl> + size_t _uniqueId ; / / a counter to generate unique ( temporary ) variable names <nl> + <nl> + <nl> + std : : vector < void * > _stack ; <nl> } ; <nl> <nl> } <nl> mmm a / arangod / Aql / Query . cpp <nl> ppp b / arangod / Aql / Query . cpp <nl> Query : : Query ( TRI_vocbase_t * vocbase , <nl> _queryLength ( queryLength ) , <nl> _type ( AQL_QUERY_READ ) , <nl> _bindParameters ( bindParameters ) , <nl> - _error ( ) { <nl> + _error ( ) , <nl> + _scopes ( ) { <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void Query : : explain ( ) { <nl> void Query : : parseQuery ( ) { <nl> Parser parser ( this ) ; <nl> <nl> - / / TODO : handle result <nl> bool result = parser . parse ( ) ; <nl> - } <nl> - <nl> - / * <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shortcut macro for signalling out of memory <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define ABORT_OOM \ <nl> - TRI_SetErrorContextAql ( \ <nl> - __FILE__ , __LINE__ , context , TRI_ERROR_OUT_OF_MEMORY , NULL ) ; \ <nl> - return NULL ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - private functions <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief free all collection memory <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void FreeCollections ( TRI_aql_context_t * const context ) { <nl> - size_t i = context - > _collections . _length ; <nl> - <nl> - while ( i - - ) { <nl> - TRI_aql_collection_t * collection = ( TRI_aql_collection_t * ) context - > _collections . _buffer [ i ] ; <nl> - <nl> - if ( collection ! = NULL ) { <nl> - TRI_FreeCollectionAql ( collection ) ; <nl> - } <nl> - } <nl> - TRI_DestroyVectorPointer ( & context - > _collections ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief free all strings <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void FreeStrings ( TRI_aql_context_t * const context ) { <nl> - size_t i = context - > _memory . _strings . _length ; <nl> - <nl> - while ( i - - ) { <nl> - void * string = context - > _memory . _strings . _buffer [ i ] ; <nl> - <nl> - if ( string ) { <nl> - TRI_Free ( TRI_UNKNOWN_MEM_ZONE , context - > _memory . _strings . _buffer [ i ] ) ; <nl> - } <nl> - } <nl> - TRI_DestroyVectorPointer ( & context - > _memory . _strings ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief free all nodes <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void FreeNodes ( TRI_aql_context_t * const context ) { <nl> - size_t i = context - > _memory . _nodes . _length ; <nl> - <nl> - while ( i - - ) { <nl> - TRI_aql_node_t * node = ( TRI_aql_node_t * ) context - > _memory . _nodes . _buffer [ i ] ; <nl> - <nl> - if ( node = = NULL ) { <nl> - continue ; <nl> - } <nl> - <nl> - TRI_DestroyVectorPointer ( & node - > _members ) ; <nl> - <nl> - if ( node - > _type = = TRI_AQL_NODE_COLLECTION ) { <nl> - / / free attached collection hint <nl> - TRI_aql_collection_hint_t * hint = ( TRI_aql_collection_hint_t * ) ( TRI_AQL_NODE_DATA ( node ) ) ; <nl> - <nl> - if ( hint ! = NULL ) { <nl> - TRI_FreeCollectionHintAql ( hint ) ; <nl> - } <nl> - } <nl> - else if ( node - > _type = = TRI_AQL_NODE_FOR ) { <nl> - / / free attached for hint <nl> - TRI_aql_for_hint_t * hint = ( TRI_aql_for_hint_t * ) ( TRI_AQL_NODE_DATA ( node ) ) ; <nl> - <nl> - if ( hint ! = NULL ) { <nl> - TRI_FreeForHintScopeAql ( hint ) ; <nl> - } <nl> - } <nl> - <nl> - / / free node itself <nl> - delete node ; <nl> - } <nl> - <nl> - TRI_DestroyVectorPointer ( & context - > _memory . _nodes ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief process options from the context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void ProcessOptions ( TRI_aql_context_t * context ) { <nl> - TRI_json_t * value ; <nl> - <nl> - / / default values <nl> - context - > _fullCount = false ; <nl> - <nl> - value = TRI_GetOptionContextAql ( context , " fullCount " ) ; <nl> - <nl> - if ( value ! = NULL & & value - > _type = = TRI_JSON_BOOLEAN ) { <nl> - context - > _fullCount = value - > _value . _boolean ; <nl> - } <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - constructors / destructors <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief create and initialize a context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - TRI_aql_context_t * TRI_CreateContextAql ( TRI_vocbase_t * vocbase , <nl> - const char * const query , <nl> - const size_t queryLength , <nl> - bool isCoordinator , <nl> - TRI_json_t * userOptions ) { <nl> - TRI_aql_context_t * context ; <nl> - int res ; <nl> - <nl> - TRI_ASSERT ( vocbase ! = NULL ) ; <nl> - TRI_ASSERT ( query ! = NULL ) ; <nl> - <nl> - LOG_TRACE ( " creating context " ) ; <nl> - <nl> - context = ( TRI_aql_context_t * ) TRI_Allocate ( TRI_UNKNOWN_MEM_ZONE , sizeof ( TRI_aql_context_t ) , false ) ; <nl> - <nl> - if ( context = = NULL ) { <nl> - return NULL ; <nl> - } <nl> - <nl> - context - > _type = TRI_AQL_QUERY_READ ; <nl> - context - > _vocbase = vocbase ; <nl> - context - > _userOptions = userOptions ; <nl> - context - > _writeOptions = NULL ; <nl> - context - > _writeCollection = NULL ; <nl> - <nl> - context - > _variableIndex = 0 ; <nl> - context - > _scopeIndex = 0 ; <nl> - context - > _subQueries = 0 ; <nl> - <nl> - / / actual bind parameter values <nl> - res = TRI_InitAssociativePointer ( & context - > _parameters . _values , <nl> - TRI_UNKNOWN_MEM_ZONE , <nl> - & TRI_HashStringKeyAssociativePointer , <nl> - & TRI_HashBindParameterAql , <nl> - & TRI_EqualBindParameterAql , <nl> - 0 ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_Free ( TRI_UNKNOWN_MEM_ZONE , context ) ; <nl> - <nl> - return NULL ; <nl> - } <nl> - <nl> - / / bind parameter names used in the query <nl> - res = TRI_InitAssociativePointer ( & context - > _parameters . _names , <nl> - TRI_UNKNOWN_MEM_ZONE , <nl> - & TRI_HashStringKeyAssociativePointer , <nl> - & TRI_HashStringKeyAssociativePointer , <nl> - & TRI_EqualStringKeyAssociativePointer , <nl> - 0 ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_DestroyAssociativePointer ( & context - > _parameters . _values ) ; <nl> - TRI_Free ( TRI_UNKNOWN_MEM_ZONE , context ) ; <nl> - <nl> - return NULL ; <nl> - } <nl> - <nl> - / / collections <nl> - res = TRI_InitAssociativePointer ( & context - > _collectionNames , <nl> - TRI_UNKNOWN_MEM_ZONE , <nl> - & TRI_HashStringKeyAssociativePointer , <nl> - & TRI_HashStringKeyAssociativePointer , <nl> - & TRI_EqualStringKeyAssociativePointer , <nl> - 0 ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_DestroyAssociativePointer ( & context - > _parameters . _names ) ; <nl> - TRI_DestroyAssociativePointer ( & context - > _parameters . _values ) ; <nl> - TRI_Free ( TRI_UNKNOWN_MEM_ZONE , context ) ; <nl> - <nl> - return NULL ; <nl> - } <nl> - <nl> - TRI_InitVectorPointer2 ( & context - > _memory . _nodes , TRI_UNKNOWN_MEM_ZONE , 16 ) ; <nl> - TRI_InitVectorPointer2 ( & context - > _memory . _strings , TRI_UNKNOWN_MEM_ZONE , 16 ) ; <nl> - TRI_InitVectorPointer ( & context - > _collections , TRI_UNKNOWN_MEM_ZONE ) ; <nl> - <nl> - TRI_InitErrorAql ( & context - > _error ) ; <nl> - <nl> - context - > _parser = NULL ; <nl> - context - > _statements = NULL ; <nl> - context - > _query = query ; <nl> - <nl> - TRI_InitScopesAql ( context ) ; <nl> - <nl> - context - > _parser = TRI_CreateParserAql ( context - > _query , queryLength ) ; <nl> - <nl> - if ( context - > _parser = = NULL ) { <nl> - / / could not create the parser <nl> - TRI_FreeContextAql ( context ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - if ( ! TRI_InitParserAql ( context ) ) { <nl> - / / could not initialise the lexer <nl> - TRI_FreeContextAql ( context ) ; <nl> - <nl> - return NULL ; <nl> - } <nl> - <nl> - context - > _statements = TRI_CreateStatementListAql ( ) ; <nl> - <nl> - if ( context - > _statements = = NULL ) { <nl> - / / could not create statement list <nl> - TRI_FreeContextAql ( context ) ; <nl> - <nl> - return NULL ; <nl> - } <nl> - <nl> - ProcessOptions ( context ) ; <nl> - <nl> - context - > _isCoordinator = isCoordinator ; <nl> - <nl> - return context ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief free a context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_FreeContextAql ( TRI_aql_context_t * const context ) { <nl> - TRI_ASSERT ( context ! = NULL ) ; <nl> - <nl> - LOG_TRACE ( " freeing context " ) ; <nl> - <nl> - / / release all scopes <nl> - TRI_FreeScopesAql ( context ) ; <nl> - <nl> - FreeStrings ( context ) ; <nl> - FreeNodes ( context ) ; <nl> - <nl> - / / free parameter names hash <nl> - TRI_DestroyAssociativePointer ( & context - > _parameters . _names ) ; <nl> - <nl> - / / free collection names <nl> - TRI_DestroyAssociativePointer ( & context - > _collectionNames ) ; <nl> <nl> - FreeCollections ( context ) ; <nl> - <nl> - / / free parameter values <nl> - TRI_FreeBindParametersAql ( context ) ; <nl> - TRI_DestroyAssociativePointer ( & context - > _parameters . _values ) ; <nl> - <nl> - / / free parser / lexer <nl> - TRI_FreeParserAql ( context - > _parser ) ; <nl> - <nl> - / / free statement list <nl> - TRI_FreeStatementListAql ( context - > _statements ) ; <nl> - <nl> - / / free error struct <nl> - TRI_DestroyErrorAql ( & context - > _error ) ; <nl> - <nl> - TRI_Free ( TRI_UNKNOWN_MEM_ZONE , context ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief parse & validate the query string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_ValidateQueryContextAql ( TRI_aql_context_t * const context ) { <nl> - if ( context - > _parser - > _length = = 0 ) { <nl> - / / query is empty , no need to parse it <nl> - TRI_SetErrorContextAql ( __FILE__ , __LINE__ , context , TRI_ERROR_QUERY_EMPTY , NULL ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / parse the query <nl> - if ( ! TRI_ParseAql ( context ) ) { <nl> - / / lexing / parsing failed <nl> - return false ; <nl> - } <nl> - <nl> - if ( context - > _error . _code ) { <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief add bind parameters to the query context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_BindQueryContextAql ( TRI_aql_context_t * const context , <nl> - const TRI_json_t * const parameters ) { <nl> - <nl> - / / add the bind parameters <nl> - if ( ! TRI_AddParameterValuesAql ( context , parameters ) ) { <nl> - / / adding parameters failed <nl> - return false ; <nl> - } <nl> - <nl> - / / validate the bind parameters used / passed <nl> - if ( ! TRI_ValidateBindParametersAql ( context ) ) { <nl> - / / invalid bind parameters <nl> - return false ; <nl> - } <nl> - <nl> - / / inject the bind parameter values into the query AST <nl> - if ( ! TRI_InjectBindParametersAql ( context ) ) { <nl> - / / bind parameter injection failed <nl> - return false ; <nl> - } <nl> - <nl> - if ( context - > _error . _code ) { <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief perform some AST optimisations <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_OptimiseQueryContextAql ( TRI_aql_context_t * const context ) { <nl> - <nl> - / / do some basic optimisations in the AST <nl> - if ( ! TRI_OptimiseAql ( context ) ) { <nl> - / / constant folding failed <nl> - return false ; <nl> - } <nl> - <nl> - if ( context - > _error . _code ) { <nl> - return false ; <nl> - } <nl> - <nl> - TRI_CompactStatementListAql ( context - > _statements ) ; <nl> - TRI_PulloutStatementListAql ( context - > _statements ) ; <nl> - <nl> - / / TRI_DumpStatementsAql ( context - > _statements ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief set up all collections used in the query <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_SetupCollectionsContextAql ( TRI_aql_context_t * const context ) { <nl> - / / mark all used collections as being used <nl> - if ( ! TRI_SetupCollectionsAql ( context ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - if ( context - > _error . _code ) { <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a node <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_RegisterNodeContextAql ( TRI_aql_context_t * const context , <nl> - void * const node ) { <nl> - TRI_ASSERT ( context ! = NULL ) ; <nl> - TRI_ASSERT ( node ! = NULL ) ; <nl> - <nl> - TRI_PushBackVectorPointer ( & context - > _memory . _nodes , node ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterStringAql ( TRI_aql_context_t * const context , <nl> - const char * const value , <nl> - const size_t length , <nl> - const bool deescape ) { <nl> - char * copy ; <nl> - <nl> - if ( value = = NULL ) { <nl> - ABORT_OOM <nl> - } <nl> - <nl> - if ( deescape & & length > 0 ) { <nl> - size_t outLength ; <nl> - <nl> - copy = TRI_UnescapeUtf8StringZ ( TRI_UNKNOWN_MEM_ZONE , value , length , & outLength ) ; <nl> + if ( ! result ) { <nl> + std : : cout < < " PARSE ERROR IN QUERY " < < std : : endl ; <nl> } <nl> else { <nl> - copy = TRI_DuplicateString2Z ( TRI_UNKNOWN_MEM_ZONE , value , length ) ; <nl> - } <nl> - <nl> - if ( copy = = NULL ) { <nl> - ABORT_OOM <nl> - } <nl> - <nl> - if ( TRI_PushBackVectorPointer ( & context - > _memory . _strings , copy ) ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_FreeString ( TRI_UNKNOWN_MEM_ZONE , copy ) ; <nl> - ABORT_OOM <nl> - } <nl> - <nl> - return copy ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterString2Aql ( TRI_aql_context_t * const context , <nl> - const char * const s1 , <nl> - const char * const s2 ) { <nl> - char * copy ; <nl> - <nl> - copy = TRI_Concatenate2StringZ ( TRI_UNKNOWN_MEM_ZONE , s1 , s2 ) ; <nl> - <nl> - if ( copy = = NULL ) { <nl> - ABORT_OOM <nl> - } <nl> - <nl> - if ( TRI_PushBackVectorPointer ( & context - > _memory . _strings , copy ) ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_FreeString ( TRI_UNKNOWN_MEM_ZONE , copy ) ; <nl> - ABORT_OOM <nl> - } <nl> - <nl> - return copy ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterString3Aql ( TRI_aql_context_t * const context , <nl> - const char * const s1 , <nl> - const char * const s2 , <nl> - const char * const s3 ) { <nl> - char * copy ; <nl> - <nl> - copy = TRI_Concatenate3StringZ ( TRI_UNKNOWN_MEM_ZONE , s1 , s2 , s3 ) ; <nl> - <nl> - if ( copy = = NULL ) { <nl> - ABORT_OOM <nl> + std : : cout < < " QUERY PARSED SUCCESSFULLY " < < std : : endl ; <nl> } <nl> - <nl> - if ( TRI_PushBackVectorPointer ( & context - > _memory . _strings , copy ) ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_FreeString ( TRI_UNKNOWN_MEM_ZONE , copy ) ; <nl> - ABORT_OOM <nl> - } <nl> - <nl> - return copy ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register an error <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_SetErrorContextAql ( const char * file , <nl> - int line , <nl> - TRI_aql_context_t * const context , <nl> - const int code , <nl> - const char * const data ) { <nl> - <nl> - TRI_ASSERT ( context ! = NULL ) ; <nl> - TRI_ASSERT ( code > 0 ) ; <nl> - <nl> - if ( context - > _error . _code = = 0 ) { <nl> - / / do not overwrite previous error <nl> - TRI_set_errno ( code ) ; <nl> - context - > _error . _code = code ; <nl> - context - > _error . _message = ( char * ) TRI_last_error ( ) ; <nl> - context - > _error . _file = file ; <nl> - context - > _error . _line = line ; <nl> - <nl> - if ( data ) { <nl> - context - > _error . _data = TRI_DuplicateStringZ ( TRI_UNKNOWN_MEM_ZONE , data ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief get the value of an option variable <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - TRI_json_t * TRI_GetOptionContextAql ( TRI_aql_context_t * const context , <nl> - const char * name ) { <nl> - if ( context - > _userOptions = = NULL | | context - > _userOptions - > _type ! = TRI_JSON_ARRAY ) { <nl> - return NULL ; <nl> - } <nl> - <nl> - return TRI_LookupArrayJson ( context - > _userOptions , name ) ; <nl> - } <nl> - * / <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - END - OF - FILE <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / arangod / Aql / Query . h <nl> ppp b / arangod / Aql / Query . h <nl> <nl> <nl> # include " Basics / Common . h " <nl> # include " Aql / QueryError . h " <nl> + # include " Aql / Scopes . h " <nl> <nl> struct TRI_json_s ; <nl> struct TRI_vocbase_s ; <nl> namespace triagens { <nl> <nl> public : <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief get the query scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + inline Scopes * scopes ( ) { <nl> + return & _scopes ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief get the query type <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace triagens { <nl> struct TRI_json_s * _bindParameters ; <nl> <nl> QueryError _error ; <nl> - } ; <nl> - <nl> - / * <nl> - typedef struct TRI_aql_context_s { <nl> - struct TRI_vocbase_s * _vocbase ; <nl> - struct TRI_aql_parser_s * _parser ; <nl> - TRI_aql_statement_list_t * _statements ; <nl> - TRI_aql_error_t _error ; <nl> - TRI_vector_pointer_t _collections ; <nl> - TRI_associative_pointer_t _collectionNames ; <nl> - <nl> - struct { <nl> - TRI_vector_pointer_t _nodes ; <nl> - TRI_vector_pointer_t _strings ; <nl> - TRI_vector_pointer_t _scopes ; <nl> - } <nl> - _memory ; <nl> - <nl> - TRI_vector_pointer_t _currentScopes ; <nl> - <nl> - struct { <nl> - TRI_associative_pointer_t _values ; <nl> - TRI_associative_pointer_t _names ; <nl> - } <nl> - _parameters ; <nl> - <nl> - const char * _query ; <nl> - <nl> - size_t _variableIndex ; <nl> - size_t _scopeIndex ; <nl> - size_t _subQueries ; <nl> - <nl> - TRI_aql_query_type_e _type ; <nl> - char * _writeCollection ; <nl> - struct TRI_aql_node_t * _writeOptions ; <nl> - <nl> - struct TRI_json_s * _userOptions ; <nl> - bool _fullCount ; <nl> - bool _isCoordinator ; <nl> - } <nl> - TRI_aql_context_t ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - constructors / destructors <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief create and initialize a context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - TRI_aql_context_t * TRI_CreateContextAql ( struct TRI_vocbase_s * , <nl> - const char * const , <nl> - const size_t , <nl> - bool , <nl> - struct TRI_json_s * ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief parse & validate the query string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_ValidateQueryContextAql ( TRI_aql_context_t * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief add bind parameters to the query context <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_BindQueryContextAql ( TRI_aql_context_t * const , <nl> - const struct TRI_json_s * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief perform some AST optimisations <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_OptimiseQueryContextAql ( TRI_aql_context_t * const ) ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief set up all collections used in the query <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_SetupCollectionsContextAql ( TRI_aql_context_t * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterStringAql ( TRI_aql_context_t * const , <nl> - const char * const , <nl> - const size_t , <nl> - const bool ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterString2Aql ( TRI_aql_context_t * const , <nl> - const char * const , <nl> - const char * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a combined string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char * TRI_RegisterString3Aql ( TRI_aql_context_t * const , <nl> - const char * const , <nl> - const char * const , <nl> - const char * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register a node <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool TRI_RegisterNodeContextAql ( TRI_aql_context_t * const , <nl> - void * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief register an error <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_SetErrorContextAql ( const char * file , <nl> - int line , <nl> - TRI_aql_context_t * const , <nl> - const int , <nl> - const char * const ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief get the value of an option variable <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - struct TRI_json_s * TRI_GetOptionContextAql ( TRI_aql_context_t * const , <nl> - const char * ) ; <nl> - <nl> - * / <nl> + Scopes _scopes ; <nl> + } ; <nl> <nl> } <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 5c0ec8c1427 <nl> mmm / dev / null <nl> ppp b / arangod / Aql / Scopes . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Aql , scopes <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2014 , ArangoDB GmbH , Cologne , Germany <nl> + / / / @ author Copyright 2012 - 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Aql / Scopes . h " <nl> + <nl> + using namespace triagens : : aql ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors / destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scope : : Scope ( ScopeType type , <nl> + size_t level ) <nl> + : _type ( type ) , <nl> + _level ( level ) { <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief destroy the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scope : : ~ Scope ( ) { <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public functions <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief adds a variable to the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Scope : : addVariable ( char const * name ) { <nl> + _variables . insert ( std : : make_pair ( std : : string ( name ) , std : : string ( name ) ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief end a scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief checks if a variable exists in the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool Scope : : existsVariable ( char const * name ) const { <nl> + auto it = _variables . find ( std : : string ( name ) ) ; <nl> + <nl> + return ( it ! = _variables . end ( ) ) ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors / destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create the scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scopes : : Scopes ( ) <nl> + : _level ( 0 ) , <nl> + _activeScopes ( ) , <nl> + _allScopes ( ) { <nl> + <nl> + _allScopes . reserve ( 8 ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief destroy the scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scopes : : ~ Scopes ( ) { <nl> + for ( auto it = _allScopes . begin ( ) ; it ! = _allScopes . end ( ) ; + + it ) { <nl> + delete ( * it ) ; <nl> + } <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public functions <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief start a new scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Scopes : : start ( ScopeType type ) { <nl> + if ( type = = AQL_SCOPE_FOR & & ! _activeScopes . empty ( ) ) { <nl> + / / check if a FOR scope must be converted in a FOR_NESTED scope <nl> + auto last = _activeScopes . back ( ) ; <nl> + <nl> + if ( last - > type ( ) = = AQL_SCOPE_FOR | | <nl> + last - > type ( ) = = AQL_SCOPE_FOR_NESTED ) { <nl> + type = AQL_SCOPE_FOR_NESTED ; <nl> + } <nl> + } <nl> + <nl> + auto scope = new Scope ( type , _level ) ; <nl> + _allScopes . push_back ( scope ) ; <nl> + <nl> + _activeScopes . push_back ( scope ) ; <nl> + + + _level ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief end the current scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scope * Scopes : : endCurrent ( ) { <nl> + TRI_ASSERT ( ! _activeScopes . empty ( ) ) ; <nl> + <nl> + Scope * result = _activeScopes . back ( ) ; <nl> + _activeScopes . pop_back ( ) ; <nl> + - - _level ; <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief end the current scope plus any FOR scopes it is nested in <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Scopes : : endNested ( ) { <nl> + TRI_ASSERT ( ! _activeScopes . empty ( ) ) ; <nl> + <nl> + auto scope = _activeScopes . back ( ) ; <nl> + if ( scope - > type ( ) = = AQL_SCOPE_MAIN | | <nl> + scope - > type ( ) = = AQL_SCOPE_SUBQUERY ) { <nl> + / / nothing to do <nl> + return ; <nl> + } <nl> + <nl> + while ( ! _activeScopes . empty ( ) ) { <nl> + scope = endCurrent ( ) ; <nl> + <nl> + if ( scope - > type ( ) ! = AQL_SCOPE_FOR_NESTED ) { <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief adds a variable to the current scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool Scopes : : addVariable ( char const * name ) { <nl> + TRI_ASSERT ( ! _activeScopes . empty ( ) ) ; <nl> + <nl> + for ( auto it = _activeScopes . rend ( ) ; it ! = _activeScopes . rbegin ( ) ; + + it ) { <nl> + auto scope = ( * it ) ; <nl> + <nl> + if ( scope - > existsVariable ( name ) ) { <nl> + / / duplicate variable name <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + _activeScopes . back ( ) - > addVariable ( name ) ; <nl> + return true ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief checks whether a variable exists in any scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool Scopes : : existsVariable ( char const * name ) const { <nl> + TRI_ASSERT ( ! _activeScopes . empty ( ) ) ; <nl> + <nl> + for ( auto it = _activeScopes . rend ( ) ; it ! = _activeScopes . rbegin ( ) ; + + it ) { <nl> + auto scope = ( * it ) ; <nl> + <nl> + if ( scope - > existsVariable ( name ) ) { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - END - OF - FILE <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ page \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 6f410bd07e1 <nl> mmm / dev / null <nl> ppp b / arangod / Aql / Scopes . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Aql , scopes <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2014 , ArangoDB GmbH , Cologne , Germany <nl> + / / / @ author Copyright 2012 - 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_AQL_SCOPES_H <nl> + # define ARANGODB_AQL_SCOPES_H 1 <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + namespace triagens { <nl> + namespace aql { <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public types <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + enum ScopeType { <nl> + AQL_SCOPE_MAIN , <nl> + AQL_SCOPE_SUBQUERY , <nl> + AQL_SCOPE_FOR , <nl> + AQL_SCOPE_FOR_NESTED <nl> + } ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - class Scope <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + class Scope { <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors / destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create a scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scope ( ScopeType , <nl> + size_t ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief destroy the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ~ Scope ( ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief return the scope type <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + inline ScopeType type ( ) const { <nl> + return _type ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief adds a variable to the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void addVariable ( char const * ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief checks if a variable exists in the scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool existsVariable ( char const * ) const ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - private variables <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + private : <nl> + <nl> + ScopeType const _type ; <nl> + <nl> + size_t const _level ; <nl> + <nl> + std : : unordered_map < std : : string , std : : string > _variables ; <nl> + } ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - class Scopes <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief scope management <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + class Scopes { <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors / destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create the scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scopes ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief destroy the scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ~ Scopes ( ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief start a new scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void start ( ScopeType ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief end the current scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Scope * endCurrent ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief end the current scope plus any FOR scopes it is nested in <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void endNested ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief adds a variable to the current scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool addVariable ( char const * ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief checks whether a variable exists in any scope <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool existsVariable ( char const * ) const ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - private variables <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + private : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief current nesting level <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + size_t _level ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief currently active scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : vector < Scope * > _activeScopes ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief all scopes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : vector < Scope * > _allScopes ; <nl> + <nl> + } ; <nl> + <nl> + } <nl> + } <nl> + <nl> + # endif <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - END - OF - FILE <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ page \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } " <nl> + / / End : <nl> mmm a / arangod / Aql / grammar . y <nl> ppp b / arangod / Aql / grammar . y <nl> <nl> # include " Ahuacatl / ahuacatl - node . h " <nl> # include " Ahuacatl / ahuacatl - ast - node . h " <nl> # include " Ahuacatl / ahuacatl - context . h " <nl> - # include " Ahuacatl / ahuacatl - parser . h " <nl> - # include " Ahuacatl / ahuacatl - parser - functions . h " <nl> - # include " Ahuacatl / ahuacatl - scope . h " <nl> # include " Aql / Parser . h " <nl> % } <nl> <nl> statement_block_statement : <nl> for_statement : <nl> T_FOR variable_name T_IN expression { <nl> TRI_aql_context_t * context = nullptr ; <nl> - if ( ! TRI_StartScopeAql ( context , TRI_AQL_SCOPE_FOR ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > start ( triagens : : aql : : AQL_SCOPE_FOR ) ; <nl> <nl> TRI_aql_node_t * node = TRI_CreateNodeForAql ( context , $ 2 , $ 4 ) ; <nl> if ( node = = nullptr ) { <nl> collect_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } collect_list optional_into { <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * node = TRI_CreateNodeCollectAql ( <nl> - context , <nl> - static_cast < const TRI_aql_node_t * const > <nl> - ( TRI_PopStackParseAql ( context ) ) , <nl> - $ 4 ) ; <nl> + TRI_aql_node_t * node = TRI_CreateNodeCollectAql ( context , static_cast < const TRI_aql_node_t * const > ( parser - > popStack ( ) ) , $ 4 ) ; <nl> if ( node = = nullptr ) { <nl> ABORT_OOM <nl> } <nl> sort_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } sort_list { <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * list <nl> - = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + TRI_aql_node_t * list = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> TRI_aql_node_t * node = TRI_CreateNodeSortAql ( context , list ) ; <nl> if ( node = = nullptr ) { <nl> ABORT_OOM <nl> return_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> ; <nl> <nl> remove_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> ; <nl> <nl> insert_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> ; <nl> <nl> update_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> | T_UPDATE expression T_WITH expression in_or_into_collection query_options { <nl> TRI_aql_context_t * context = nullptr ; <nl> update_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> ; <nl> <nl> replace_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> | T_REPLACE expression T_WITH expression in_or_into_collection query_options { <nl> TRI_aql_context_t * context = nullptr ; <nl> replace_statement : <nl> ABORT_OOM <nl> } <nl> <nl> - if ( ! TRI_EndScopeByReturnAql ( context ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > endNested ( ) ; <nl> } <nl> ; <nl> <nl> expression : <nl> } <nl> | T_OPEN { <nl> TRI_aql_context_t * context = nullptr ; <nl> - if ( ! TRI_StartScopeAql ( context , TRI_AQL_SCOPE_SUBQUERY ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > scopes ( ) - > start ( triagens : : aql : : AQL_SCOPE_SUBQUERY ) ; <nl> <nl> context - > _subQueries + + ; <nl> <nl> expression : <nl> <nl> context - > _subQueries - - ; <nl> <nl> - if ( ! TRI_EndScopeAql ( context ) ) { <nl> + if ( ! parser - > scopes ( ) - > endCurrent ( ) ) { <nl> ABORT_OOM <nl> } <nl> <nl> function_name : <nl> } <nl> } <nl> | function_name T_SCOPE T_STRING { <nl> - TRI_aql_context_t * context = nullptr ; <nl> if ( $ 1 = = nullptr | | $ 3 = = nullptr ) { <nl> ABORT_OOM <nl> } <nl> <nl> - $ $ = TRI_RegisterString3Aql ( context , $ 1 , " : : " , $ 3 ) ; <nl> + std : : string temp ( $ 1 ) ; <nl> + temp . append ( " : : " ) ; <nl> + temp . append ( $ 3 ) ; <nl> + $ $ = parser - > registerString ( temp . c_str ( ) , temp . size ( ) , false ) ; <nl> <nl> if ( $ $ = = nullptr ) { <nl> ABORT_OOM <nl> function_name : <nl> function_call : <nl> function_name { <nl> TRI_aql_context_t * context = nullptr ; <nl> - if ( ! TRI_PushStackParseAql ( context , $ 1 ) ) { <nl> - ABORT_OOM <nl> - } <nl> + parser - > pushStack ( $ 1 ) ; <nl> <nl> TRI_aql_node_t * node = TRI_CreateNodeListAql ( context ) ; <nl> if ( node = = nullptr ) { <nl> ABORT_OOM <nl> } <nl> <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } T_OPEN optional_function_call_arguments T_CLOSE % prec FUNCCALL { <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * list <nl> - = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> - TRI_aql_node_t * node = TRI_CreateNodeFcallAql ( context , <nl> - static_cast < char const * const > <nl> - ( TRI_PopStackParseAql ( context ) ) , <nl> - list ) ; <nl> + TRI_aql_node_t * list = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> + TRI_aql_node_t * node = TRI_CreateNodeFcallAql ( context , static_cast < char const * const > ( parser - > popStack ( ) ) , list ) ; <nl> if ( node = = nullptr ) { <nl> ABORT_OOM <nl> } <nl> list : <nl> ABORT_OOM <nl> } <nl> <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } optional_list_elements T_LIST_CLOSE { <nl> - TRI_aql_context_t * context = nullptr ; <nl> - $ $ = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + $ $ = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> } <nl> ; <nl> <nl> array : <nl> ABORT_OOM <nl> } <nl> <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } optional_array_elements T_DOC_CLOSE { <nl> - TRI_aql_context_t * context = nullptr ; <nl> - $ $ = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + $ $ = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> } <nl> ; <nl> <nl> reference : <nl> | reference { <nl> / / expanded variable access , e . g . variable [ * ] <nl> TRI_aql_context_t * context = nullptr ; <nl> - char * varname = TRI_GetNameParseAql ( context ) ; <nl> + char * varname = parser - > generateName ( ) ; <nl> <nl> if ( varname = = nullptr ) { <nl> ABORT_OOM <nl> } <nl> <nl> / / push the varname onto the stack <nl> - TRI_PushStackParseAql ( context , varname ) ; <nl> + parser - > pushStack ( varname ) ; <nl> <nl> / / push on the stack what ' s going to be expanded ( will be popped when we come back ) <nl> - TRI_PushStackParseAql ( context , $ 1 ) ; <nl> + parser - > pushStack ( $ 1 ) ; <nl> <nl> / / create a temporary variable for the row iterator ( will be popped by " expansion " rule " ) <nl> TRI_aql_node_t * node = TRI_CreateNodeReferenceAql ( context , varname ) ; <nl> reference : <nl> } <nl> <nl> / / push the variable <nl> - TRI_PushStackParseAql ( context , node ) ; <nl> + parser - > pushStack ( node ) ; <nl> } T_EXPAND expansion { <nl> / / return from the " expansion " subrule <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * expanded = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> - char * varname = static_cast < char * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + TRI_aql_node_t * expanded = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> + char * varname = static_cast < char * > ( parser - > popStack ( ) ) ; <nl> <nl> / / push the actual expand node into the statement list <nl> TRI_aql_node_t * expand = TRI_CreateNodeExpandAql ( context , varname , expanded , $ 4 ) ; <nl> single_reference : <nl> TRI_aql_context_t * context = nullptr ; <nl> TRI_aql_node_t * node ; <nl> <nl> - if ( TRI_VariableExistsScopeAql ( context , $ 1 ) ) { <nl> + if ( parser - > scopes ( ) - > existsVariable ( $ 1 ) ) { <nl> node = TRI_CreateNodeReferenceAql ( context , $ 1 ) ; <nl> } <nl> else { <nl> expansion : <nl> ' . ' T_STRING % prec REFERENCE { <nl> / / named variable access , continuation from * expansion , e . g . [ * ] . variable . reference <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> <nl> $ $ = TRI_CreateNodeAttributeAccessAql ( context , node , $ 2 ) ; <nl> <nl> expansion : <nl> | ' . ' bind_parameter % prec REFERENCE { <nl> / / named variable access w / bind parameter , continuation from * expansion , e . g . [ * ] . variable . @ reference <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> <nl> $ $ = TRI_CreateNodeBoundAttributeAccessAql ( context , node , $ 2 ) ; <nl> <nl> expansion : <nl> | T_LIST_OPEN expression T_LIST_CLOSE % prec INDEXED { <nl> / / indexed variable access , continuation from * expansion , e . g . [ * ] . variable [ index ] <nl> TRI_aql_context_t * context = nullptr ; <nl> - TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( TRI_PopStackParseAql ( context ) ) ; <nl> + TRI_aql_node_t * node = static_cast < TRI_aql_node_t * > ( parser - > popStack ( ) ) ; <nl> <nl> $ $ = TRI_CreateNodeIndexedAql ( context , node , $ 2 ) ; <nl> <nl> mmm a / arangod / CMakeLists . txt <nl> ppp b / arangod / CMakeLists . txt <nl> add_executable ( <nl> Aql / grammar . cpp <nl> Aql / Parser . cpp <nl> Aql / Query . cpp <nl> + Aql / Scopes . cpp <nl> Aql / tokens . cpp <nl> BitIndexes / bitarray . cpp <nl> BitIndexes / bitarrayIndex . cpp <nl> mmm a / arangod / Makefile . files <nl> ppp b / arangod / Makefile . files <nl> arangod_libarangod_a_SOURCES = \ <nl> arangod / Aql / grammar . cpp \ <nl> arangod / Aql / Parser . cpp \ <nl> arangod / Aql / Query . cpp \ <nl> + arangod / Aql / Scopes . cpp \ <nl> arangod / Aql / tokens . cpp \ <nl> arangod / BitIndexes / bitarray . cpp \ <nl> arangod / BitIndexes / bitarrayIndex . cpp \ <nl>
|
re - added scopes
|
arangodb/arangodb
|
5d79df9e2f63e5d29c837e30fbf65d9dd0b26716
|
2014-07-24T14:39:16Z
|
mmm a / modules / imgproc / src / templmatch . cpp <nl> ppp b / modules / imgproc / src / templmatch . cpp <nl> static bool ocl_matchTemplate ( InputArray _img , InputArray _templ , OutputArray _ <nl> typedef IppStatus ( CV_STDCALL * ippiGetBufferSize ) ( IppiSize , IppiSize , IppEnum , int * ) ; <nl> typedef IppStatus ( CV_STDCALL * ippimatchTemplate ) ( const void * , int , IppiSize , const void * , int , IppiSize , Ipp32f * , int , IppEnum , Ipp8u * ) ; <nl> <nl> - <nl> static bool ipp_matchTemplate ( const Mat & src , const Mat & tpl , Mat & dst , int method ) <nl> { <nl> if ( src . channels ( ) ! = 1 | | ( method ! = CV_TM_SQDIFF & & method ! = CV_TM_CCORR ) ) <nl> static bool ipp_matchTemplate ( const Mat & src , const Mat & tpl , Mat & dst , int meth <nl> <nl> pBuffer = ippsMalloc_8u ( bufSize ) ; <nl> <nl> - status = ippFunc ( src . data , ( int ) src . step , srcRoiSize , tpl . data , ( int ) tpl . step , tplRoiSize , ( Ipp32f * ) dst . data , dst . step , funCfg , pBuffer ) ; <nl> - if ( status < 0 ) <nl> - return false ; <nl> + status = ippFunc ( src . data , ( int ) src . step , srcRoiSize , tpl . data , ( int ) tpl . step , tplRoiSize , ( Ipp32f * ) dst . data , ( int ) dst . step , funCfg , pBuffer ) ; <nl> <nl> ippsFree ( pBuffer ) ; <nl> - return true ; <nl> + return status > = 0 ; <nl> } <nl> <nl> # endif <nl>
|
fixed
|
opencv/opencv
|
6119ae0ea9c400154600d41a516044c3f1e83e53
|
2014-04-09T07:09:51Z
|
mmm a / Source / ActionsLib / ActionsLib . vcxproj <nl> ppp b / Source / ActionsLib / ActionsLib . vcxproj <nl> <nl> < AdditionalLibraryDirectories > $ ( MSMPI_LIB64 ) ; $ ( OutDir ) ; $ ( NvmlLibPath ) < / AdditionalLibraryDirectories > <nl> < / Link > <nl> < / ItemDefinitionGroup > <nl> - < ItemDefinitionGroup Condition = " ' $ ( CNTK_ENABLE_ASGD ) ' = = ' true ' " > <nl> - < ClCompile > <nl> - < AdditionalIncludeDirectories > $ ( SolutionDir ) Source \ multiverso ; % ( AdditionalIncludeDirectories ) < / AdditionalIncludeDirectories > <nl> - < / ClCompile > <nl> - < / ItemDefinitionGroup > <nl> < ItemDefinitionGroup > <nl> < ClCompile > <nl> < PrecompiledHeader > <nl> mmm a / Source / CNTK / CNTK . vcxproj <nl> ppp b / Source / CNTK / CNTK . vcxproj <nl> <nl> < AdditionalLibraryDirectories > $ ( MSMPI_LIB64 ) ; $ ( OutDir ) ; $ ( NvmlLibPath ) < / AdditionalLibraryDirectories > <nl> < / Link > <nl> < / ItemDefinitionGroup > <nl> - < ItemDefinitionGroup Condition = " ' $ ( CNTK_ENABLE_ASGD ) ' = = ' true ' " > <nl> - < ClCompile > <nl> - < AdditionalIncludeDirectories > $ ( SolutionDir ) Source \ multiverso ; % ( AdditionalIncludeDirectories ) < / AdditionalIncludeDirectories > <nl> - < / ClCompile > <nl> - < / ItemDefinitionGroup > <nl> < ItemDefinitionGroup Condition = " $ ( DebugBuild ) " > <nl> < ClCompile > <nl> < PrecompiledHeader > <nl>
|
remove the unused ItemDefinition in CNTK and SGDLib
|
microsoft/CNTK
|
bffa012ece65410075413b438cfb14a4b9586237
|
2016-04-28T06:31:21Z
|
mmm a / tensorflow / compiler / mlir / lite / transforms / optimize . cc <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / optimize . cc <nl> DenseElementsAttr GetShape ( Value output_val ) { <nl> llvm : : makeArrayRef ( shape ) ) ; <nl> } <nl> <nl> - static Type getShapeStrippedType ( TypeAttr type_attr ) <nl> - { <nl> + static Type GetShapeStrippedType ( TypeAttr type_attr ) { <nl> auto type = type_attr . getValue ( ) ; <nl> auto shaped_type = type . dyn_cast < ShapedType > ( ) ; <nl> if ( shaped_type ) { <nl> static Type getShapeStrippedType ( TypeAttr type_attr ) <nl> bool NotFromQuantOpDifferentQuant ( Value val , TypeAttr qtype_attr ) { <nl> auto val_defn_op = val . getDefiningOp ( ) ; <nl> TFL : : QuantizeOp q_op = llvm : : dyn_cast_or_null < TFL : : QuantizeOp > ( val_defn_op ) ; <nl> - if ( ! q_op ) <nl> + if ( ! q_op ) <nl> return true ; <nl> <nl> / / Ignore shape details - weŕe really only trying to <nl> / / check if quantization is the same . <nl> - auto stripped_src_qtype = getShapeStrippedType ( q_op . qtypeAttr ( ) ) ; <nl> - auto stripped_qtype = getShapeStrippedType ( qtype_attr ) ; <nl> + auto stripped_src_qtype = GetShapeStrippedType ( q_op . qtypeAttr ( ) ) ; <nl> + auto stripped_qtype = GetShapeStrippedType ( qtype_attr ) ; <nl> return stripped_src_qtype = = stripped_qtype ; <nl> } <nl> <nl> mmm a / tensorflow / compiler / mlir / lite / transforms / prepare_quantize . cc <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / prepare_quantize . cc <nl> void PrepareQuantizePass : : SanityCheckAndAdjustment ( FuncOp func ) { <nl> } <nl> auto dq_arg = dq_op . getOperand ( ) ; <nl> <nl> - if ( ! dq_arg . hasOneUse ( ) ) { <nl> + if ( ! dq_arg . hasOneUse ( ) ) { <nl> / / The initial quanization is used sompleace else . . . so it might be <nl> / / reasonable for it to requantized for another purpose . <nl> / / TODO : ideally would want to still check whether requanization narrows <nl> void PrepareQuantizePass : : SanityCheckAndAdjustment ( FuncOp func ) { <nl> <nl> / / Invariant : <nl> / / isa < quant : : QuantizeCastOp > ( dq_arg . getDefiningOp ( ) ) - - > <nl> - / / getdq_arg . getType ( ) ! = q_op . getResult ( ) . getType ( ) <nl> + / / getdq_arg . getType ( ) ! = q_op . getResult ( ) . getType ( ) <nl> / / <nl> / / as otherwise qdq pair would have been optimized away . <nl> - <nl> auto qd_arg_def_q_op = <nl> dyn_cast_or_null < quant : : QuantizeCastOp > ( dq_arg . getDefiningOp ( ) ) ; <nl> - if ( ! qd_arg_def_q_op ) { <nl> + if ( ! qd_arg_def_q_op ) { <nl> return ; <nl> } <nl> <nl> mmm a / tensorflow / compiler / mlir / lite / transforms / prepare_tf . cc <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / prepare_tf . cc <nl> struct FetchConstantMinMaxInputs { <nl> using AttrType = DenseFPElementsAttr ; <nl> bool operator ( ) ( TFFakeQuantOp tf_op , AttrType & min_value , AttrType & max_value ) const { <nl> Value min = tf_op . min ( ) , max = tf_op . max ( ) ; <nl> - ; <nl> - / / TODO This is likely redundant ( Identity elimination rule are in <nl> - / / prepare_patterns . td . If not , its certainly , incomplete as neither <nl> - / / IdentityN ops Nor chains of Identiy * ( not sooo rare ) are handled <nl> + <nl> + / / TODO : incomplete neither IdentityN ops <nl> + / / nor chains of Identity * ( not rare ) are handled <nl> if ( auto id1 = dyn_cast_or_null < TF : : IdentityOp > ( min . getDefiningOp ( ) ) ) <nl> min = id1 . input ( ) ; <nl> if ( auto id2 = dyn_cast_or_null < TF : : IdentityOp > ( max . getDefiningOp ( ) ) ) <nl> struct InsertTFLQuantOpsAfterTFFakeQuantOp <nl> / / <nl> / / Three instances of the rule to cover the three different types of <nl> / / TF : : FakeQuant operators <nl> - / / <nl> - using PreparePerTensorFakeQuant = <nl> - InsertTFLQuantOpsAfterTFFakeQuantOp < TF : : FakeQuantWithMinMaxVarsOp , <nl> - false , <nl> - FetchConstantMinMaxInputs < TF : : FakeQuantWithMinMaxVarsOp > <nl> - > ; <nl> - <nl> - using PreparePerChannelFakeQuant = <nl> - InsertTFLQuantOpsAfterTFFakeQuantOp < TF : : FakeQuantWithMinMaxVarsPerChannelOp , <nl> - true , <nl> - FetchConstantMinMaxInputs < TF : : FakeQuantWithMinMaxVarsPerChannelOp > <nl> - > ; <nl> + / / <nl> + using PreparePerTensorFakeQuant = InsertTFLQuantOpsAfterTFFakeQuantOp < <nl> + TF : : FakeQuantWithMinMaxVarsOp , false , <nl> + FetchConstantMinMaxInputs < TF : : FakeQuantWithMinMaxVarsOp > > ; <nl> <nl> - using PreparePerTensorFakeQuantWithMinMaxArgs = <nl> - InsertTFLQuantOpsAfterTFFakeQuantOp < TF : : FakeQuantWithMinMaxArgsOp , <nl> - false , <nl> - FetchMinMaxAttrs < TF : : FakeQuantWithMinMaxArgsOp > <nl> - > ; <nl> + using PreparePerChannelFakeQuant = InsertTFLQuantOpsAfterTFFakeQuantOp < <nl> + TF : : FakeQuantWithMinMaxVarsPerChannelOp , true , <nl> + FetchConstantMinMaxInputs < TF : : FakeQuantWithMinMaxVarsPerChannelOp > > ; <nl> <nl> + using PreparePerTensorFakeQuantWithMinMaxArgs = <nl> + InsertTFLQuantOpsAfterTFFakeQuantOp < <nl> + TF : : FakeQuantWithMinMaxArgsOp , false , <nl> + FetchMinMaxAttrs < TF : : FakeQuantWithMinMaxArgsOp > > ; <nl> <nl> / / Templated class for declaring a converter from some TensorFlow convolution <nl> / / op into its counterpart in TensorFlow Lite . <nl> void PrepareTFPass : : runOnFunction ( ) { <nl> / / parameters from the TF Quant ops , thus this pattern should run with the <nl> / / first ` applyPatternsGreedily ` method , which would otherwise removes the <nl> / / TF FakeQuant ops by the constant folding . <nl> - patterns . insert < PreparePerTensorFakeQuant , PreparePerChannelFakeQuant , PreparePerTensorFakeQuantWithMinMaxArgs > ( ctx ) ; <nl> - <nl> + patterns . insert < PreparePerTensorFakeQuant , PreparePerChannelFakeQuant , <nl> + PreparePerTensorFakeQuantWithMinMaxArgs > ( ctx ) ; <nl> <nl> / / This pattern will try to identify and optimize for dilated convolution . <nl> / / e . g . Patterns like " SpaceToBatchND - > Conv2D - > BatchToSpaceND " will be <nl>
|
Fix : resolve formatting / naming nits from review
|
tensorflow/tensorflow
|
e8c854a5cceb3be6fd827d54d4743c365abf0043
|
2020-05-12T10:59:37Z
|
mmm a / documentation / sphinx / source / developer - guide . rst <nl> ppp b / documentation / sphinx / source / developer - guide . rst <nl> If you see one of those errors , the best way of action is to fail the client . <nl> <nl> At a first glance this looks very similar to an ` ` commit_unknown_result ` ` . However , these errors lack the one guarantee ` ` commit_unknown_result ` ` still gives to the user : if the commit has already been sent to the database , the transaction could get committed at a later point in time . This means that if you retry the transaction , your new transaction might race with the old transaction . While this technically doesn ' t violate any consistency guarantees , abandoning a transaction means that there are no causality guaranatees . <nl> <nl> - . . [ # conflicting_keys ] In practice it probably committed successfully , but if you ' re running multiple resolvers then it ' s possible that a transaction can cause another transaction to abort without committing successfully . <nl> + . . [ # conflicting_keys ] In practice , the transaction probably committed successfully . However , if you ' re running multiple resolvers then it ' s possible for a transaction to cause another to abort even if it doesn ' t commit successfully . <nl>
|
Clarify footnote
|
apple/foundationdb
|
1ec5d0ef41a95a5dc47d6dd8ba9b404ba51a430b
|
2020-05-27T23:30:04Z
|
mmm a / cocos / 2d / CCTextureAtlas . cpp <nl> ppp b / cocos / 2d / CCTextureAtlas . cpp <nl> void TextureAtlas : : setupIndices ( ) <nl> <nl> for ( int i = 0 ; i < _capacity ; i + + ) <nl> { <nl> - # if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> - _indices [ i * 6 + 0 ] = i * 4 + 0 ; <nl> - _indices [ i * 6 + 1 ] = i * 4 + 0 ; <nl> - _indices [ i * 6 + 2 ] = i * 4 + 2 ; <nl> - _indices [ i * 6 + 3 ] = i * 4 + 1 ; <nl> - _indices [ i * 6 + 4 ] = i * 4 + 3 ; <nl> - _indices [ i * 6 + 5 ] = i * 4 + 3 ; <nl> - # else <nl> _indices [ i * 6 + 0 ] = i * 4 + 0 ; <nl> _indices [ i * 6 + 1 ] = i * 4 + 1 ; <nl> _indices [ i * 6 + 2 ] = i * 4 + 2 ; <nl> void TextureAtlas : : setupIndices ( ) <nl> _indices [ i * 6 + 3 ] = i * 4 + 3 ; <nl> _indices [ i * 6 + 4 ] = i * 4 + 2 ; <nl> _indices [ i * 6 + 5 ] = i * 4 + 1 ; <nl> - # endif <nl> } <nl> } <nl> <nl> void TextureAtlas : : drawNumberOfQuads ( ssize_t numberOfQuads , ssize_t start ) <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _buffersVBO [ 1 ] ) ; <nl> # endif <nl> <nl> - # if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> - glDrawElements ( GL_TRIANGLE_STRIP , ( GLsizei ) numberOfQuads * 6 , GL_UNSIGNED_SHORT , ( GLvoid * ) ( start * 6 * sizeof ( _indices [ 0 ] ) ) ) ; <nl> - # else <nl> glDrawElements ( GL_TRIANGLES , ( GLsizei ) numberOfQuads * 6 , GL_UNSIGNED_SHORT , ( GLvoid * ) ( start * 6 * sizeof ( _indices [ 0 ] ) ) ) ; <nl> - # endif / / CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> <nl> # if CC_REBIND_INDICES_BUFFER <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) ; <nl> void TextureAtlas : : drawNumberOfQuads ( ssize_t numberOfQuads , ssize_t start ) <nl> <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _buffersVBO [ 1 ] ) ; <nl> <nl> - # if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> - glDrawElements ( GL_TRIANGLE_STRIP , ( GLsizei ) numberOfQuads * 6 , GL_UNSIGNED_SHORT , ( GLvoid * ) ( start * 6 * sizeof ( _indices [ 0 ] ) ) ) ; <nl> - # else <nl> glDrawElements ( GL_TRIANGLES , ( GLsizei ) numberOfQuads * 6 , GL_UNSIGNED_SHORT , ( GLvoid * ) ( start * 6 * sizeof ( _indices [ 0 ] ) ) ) ; <nl> - # endif / / CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> <nl> glBindBuffer ( GL_ARRAY_BUFFER , 0 ) ; <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) ; <nl> mmm a / cocos / 2d / ccConfig . h <nl> ppp b / cocos / 2d / ccConfig . h <nl> Only valid for cocos2d - mac . Not supported on cocos2d - ios . <nl> # define CC_SPRITEBATCHNODE_RENDER_SUBPIXEL 1 <nl> # endif <nl> <nl> - / * * @ def CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> - Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas . <nl> - It seems it is the recommend way , but it is much slower , so , enable it at your own risk <nl> - <nl> - To enable set it to a value different than 0 . Disabled by default . <nl> - <nl> - * / <nl> - # ifndef CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP <nl> - # define CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP 0 <nl> - # endif <nl> - <nl> / * * @ def CC_TEXTURE_ATLAS_USE_VAO <nl> By default , TextureAtlas ( used by many cocos2d classes ) will use VAO ( Vertex Array Objects ) . <nl> Apple recommends its usage but they might consume a lot of memory , specially if you use many of them . <nl>
|
removes CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP support
|
cocos2d/cocos2d-x
|
219ef6d8975da9f5e104f5afa09331a333ee0f4b
|
2014-03-01T06:09:18Z
|
mmm a / src / core / surface / completion_queue . c <nl> ppp b / src / core / surface / completion_queue . c <nl> grpc_event grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> return ret ; <nl> } <nl> <nl> - static void add_plucker ( grpc_completion_queue * cc , void * tag , <nl> - grpc_pollset_worker * worker ) { <nl> - GPR_ASSERT ( cc - > num_pluckers ! = GRPC_MAX_COMPLETION_QUEUE_PLUCKERS ) ; <nl> + static int add_plucker ( grpc_completion_queue * cc , void * tag , <nl> + grpc_pollset_worker * worker ) { <nl> + if ( cc - > num_pluckers = = GRPC_MAX_COMPLETION_QUEUE_PLUCKERS ) { <nl> + return 0 ; <nl> + } <nl> cc - > pluckers [ cc - > num_pluckers ] . tag = tag ; <nl> cc - > pluckers [ cc - > num_pluckers ] . worker = worker ; <nl> cc - > num_pluckers + + ; <nl> + return 1 ; <nl> } <nl> <nl> static void del_plucker ( grpc_completion_queue * cc , void * tag , <nl> grpc_event grpc_completion_queue_pluck ( grpc_completion_queue * cc , void * tag , <nl> ret . type = GRPC_QUEUE_SHUTDOWN ; <nl> break ; <nl> } <nl> - add_plucker ( cc , tag , & worker ) ; <nl> + if ( ! add_plucker ( cc , tag , & worker ) ) { <nl> + gpr_log ( GPR_DEBUG , <nl> + " Too many outstanding grpc_completion_queue_pluck calls : maximum is % d " . <nl> + GRPC_MAX_COMPLETION_QUEUE_PLUCKERS ) ; <nl> + gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> + memset ( & ret , 0 , sizeof ( ret ) ) ; <nl> + / * TODO ( ctiller ) : should we use a different result here * / <nl> + ret . type = GRPC_QUEUE_TIMEOUT ; <nl> + break ; <nl> + } <nl> if ( ! grpc_pollset_work ( & cc - > pollset , & worker , deadline ) ) { <nl> del_plucker ( cc , tag , & worker ) ; <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl>
|
Dont crash on too many pluckers
|
grpc/grpc
|
791e78ad94d394716c32e04d877fe628b13ef254
|
2015-08-01T23:21:43Z
|
mmm a / include / v8 . h <nl> ppp b / include / v8 . h <nl> class V8_EXPORT Isolate { <nl> * / <nl> enum UseCounterFeature { <nl> kUseAsm = 0 , <nl> + kBreakIterator = 1 , <nl> kUseCounterFeatureCount / / This enum value must be last . <nl> } ; <nl> <nl> mmm a / src / i18n . cc <nl> ppp b / src / i18n . cc <nl> icu : : BreakIterator * CreateICUBreakIterator ( <nl> return NULL ; <nl> } <nl> <nl> + isolate - > CountUsage ( v8 : : Isolate : : UseCounterFeature : : kBreakIterator ) ; <nl> + <nl> return break_iterator ; <nl> } <nl> <nl> mmm a / test / cctest / test - strings . cc <nl> ppp b / test / cctest / test - strings . cc <nl> TEST ( RobustSubStringStub ) { <nl> } <nl> <nl> <nl> + namespace { <nl> + <nl> + int * global_use_counts = NULL ; <nl> + <nl> + void MockUseCounterCallback ( v8 : : Isolate * isolate , <nl> + v8 : : Isolate : : UseCounterFeature feature ) { <nl> + + + global_use_counts [ feature ] ; <nl> + } <nl> + } <nl> + <nl> + <nl> + TEST ( CountBreakIterator ) { <nl> + CcTest : : InitializeVM ( ) ; <nl> + v8 : : HandleScope scope ( CcTest : : isolate ( ) ) ; <nl> + LocalContext context ; <nl> + int use_counts [ v8 : : Isolate : : kUseCounterFeatureCount ] = { } ; <nl> + global_use_counts = use_counts ; <nl> + CcTest : : isolate ( ) - > SetUseCounterCallback ( MockUseCounterCallback ) ; <nl> + CHECK_EQ ( 0 , use_counts [ v8 : : Isolate : : kBreakIterator ] ) ; <nl> + v8 : : Local < v8 : : Value > result = CompileRun ( <nl> + " var iterator = Intl . v8BreakIterator ( [ ' en ' ] ) ; " <nl> + " iterator . adoptText ( ' Now is the time ' ) ; " <nl> + " iterator . next ( ) ; " <nl> + " iterator . next ( ) ; " ) ; <nl> + CHECK ( result - > IsNumber ( ) ) ; <nl> + CHECK_EQ ( 1 , use_counts [ v8 : : Isolate : : kBreakIterator ] ) ; <nl> + } <nl> + <nl> + <nl> TEST ( StringReplaceAtomTwoByteResult ) { <nl> CcTest : : InitializeVM ( ) ; <nl> v8 : : HandleScope scope ( CcTest : : isolate ( ) ) ; <nl>
|
Add a use counter for Intl . v8BreakIterator
|
v8/v8
|
43257b61aee0948fdf9a4bcfb9a9d6559454fc72
|
2014-10-03T10:29:12Z
|
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class AbstractStorageDecl : public ValueDecl { <nl> <nl> protected : <nl> AbstractStorageDecl ( DeclKind Kind , DeclContext * DC , DeclName Name , <nl> - SourceLoc NameLoc , bool supportsMutation ) <nl> + SourceLoc NameLoc , StorageIsMutable_t supportsMutation ) <nl> : ValueDecl ( Kind , DC , Name , NameLoc ) { <nl> Bits . AbstractStorageDecl . HasStorage = true ; <nl> Bits . AbstractStorageDecl . SupportsMutation = supportsMutation ; <nl> class AbstractStorageDecl : public ValueDecl { <nl> Bits . AbstractStorageDecl . IsSetterMutating = true ; <nl> } <nl> <nl> - void setSupportsMutationIfStillStored ( bool supportsMutation ) { <nl> + void setSupportsMutationIfStillStored ( StorageIsMutable_t supportsMutation ) { <nl> if ( auto ptr = Accessors . getPointer ( ) ) { <nl> auto impl = ptr - > getImplInfo ( ) ; <nl> if ( ! impl . isSimpleStored ( ) ) return ; <nl> class AbstractStorageDecl : public ValueDecl { <nl> / / / don ' t support mutation ( e . g . to initialize them ) , and sometimes we <nl> / / / can ' t mutate things that do support mutation ( e . g . because their <nl> / / / setter is private ) . <nl> - bool supportsMutation ( ) const { <nl> - return Bits . AbstractStorageDecl . SupportsMutation ; <nl> + StorageIsMutable_t supportsMutation ( ) const { <nl> + return StorageIsMutable_t ( Bits . AbstractStorageDecl . SupportsMutation ) ; <nl> } <nl> <nl> / / / Are there any accessors for this declaration , including implicit ones ? <nl> class VarDecl : public AbstractStorageDecl { <nl> <nl> VarDecl ( DeclKind Kind , bool IsStatic , Specifier Sp , bool IsCaptureList , <nl> SourceLoc NameLoc , Identifier Name , DeclContext * DC ) <nl> - : AbstractStorageDecl ( Kind , DC , Name , NameLoc , ! isImmutableSpecifier ( Sp ) ) <nl> + : AbstractStorageDecl ( Kind , DC , Name , NameLoc , <nl> + StorageIsMutable_t ( ! isImmutableSpecifier ( Sp ) ) ) <nl> { <nl> Bits . VarDecl . IsStatic = IsStatic ; <nl> Bits . VarDecl . Specifier = static_cast < unsigned > ( Sp ) ; <nl> class SubscriptDecl : public GenericContext , public AbstractStorageDecl { <nl> GenericParamList * GenericParams ) <nl> : GenericContext ( DeclContextKind : : SubscriptDecl , Parent ) , <nl> AbstractStorageDecl ( DeclKind : : Subscript , Parent , Name , SubscriptLoc , <nl> - / * supports mutation ( will be overwritten ) * / true ) , <nl> + / * will be overwritten * / StorageIsNotMutable ) , <nl> ArrowLoc ( ArrowLoc ) , Indices ( nullptr ) , ElementTy ( ElementTy ) { <nl> setIndices ( Indices ) ; <nl> setGenericParams ( GenericParams ) ; <nl> mmm a / include / swift / AST / StorageImpl . h <nl> ppp b / include / swift / AST / StorageImpl . h <nl> <nl> <nl> namespace swift { <nl> <nl> + enum StorageIsMutable_t : bool { <nl> + StorageIsNotMutable = false , <nl> + StorageIsMutable = true <nl> + } ; <nl> + <nl> / / Note that the values of these enums line up with % select values in <nl> / / diagnostics . <nl> enum class AccessorKind { <nl> class StorageImplInfo { <nl> # endif <nl> } <nl> <nl> - static StorageImplInfo getSimpleStored ( bool supportsMutation ) { <nl> + static StorageImplInfo getSimpleStored ( StorageIsMutable_t isMutable ) { <nl> return { ReadImplKind : : Stored , <nl> - supportsMutation ? WriteImplKind : : Stored <nl> - : WriteImplKind : : Immutable , <nl> - supportsMutation ? ReadWriteImplKind : : Stored <nl> - : ReadWriteImplKind : : Immutable } ; <nl> + isMutable ? WriteImplKind : : Stored <nl> + : WriteImplKind : : Immutable , <nl> + isMutable ? ReadWriteImplKind : : Stored <nl> + : ReadWriteImplKind : : Immutable } ; <nl> } <nl> <nl> - static StorageImplInfo getOpaque ( bool supportsMutation ) { <nl> - return ( supportsMutation ? getMutableOpaque ( ) : getImmutableOpaque ( ) ) ; <nl> + static StorageImplInfo getOpaque ( StorageIsMutable_t isMutable ) { <nl> + return ( isMutable ? getMutableOpaque ( ) <nl> + : getImmutableOpaque ( ) ) ; <nl> } <nl> <nl> / / / Describe the implementation of a immutable property implemented opaquely . <nl> class StorageImplInfo { <nl> ReadWriteImplKind : : MaterializeForSet } ; <nl> } <nl> <nl> - static StorageImplInfo getComputed ( bool supportsMutation ) { <nl> - return ( supportsMutation ? getMutableComputed ( ) : getImmutableComputed ( ) ) ; <nl> + static StorageImplInfo getComputed ( StorageIsMutable_t isMutable ) { <nl> + return ( isMutable ? getMutableComputed ( ) <nl> + : getImmutableComputed ( ) ) ; <nl> } <nl> <nl> / / / Describe the implementation of an immutable property implemented <nl> class StorageImplInfo { <nl> } <nl> <nl> / / / Does this describe storage that supports mutation ? <nl> - bool supportsMutation ( ) const { <nl> - return getWriteImpl ( ) ! = WriteImplKind : : Immutable ; <nl> + StorageIsMutable_t supportsMutation ( ) const { <nl> + return StorageIsMutable_t ( getWriteImpl ( ) ! = WriteImplKind : : Immutable ) ; <nl> } <nl> <nl> ReadImplKind getReadImpl ( ) const { <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> bool VarDecl : : isSelfParameter ( ) const { <nl> <nl> void VarDecl : : setSpecifier ( Specifier specifier ) { <nl> Bits . VarDecl . Specifier = static_cast < unsigned > ( specifier ) ; <nl> - setSupportsMutationIfStillStored ( ! isImmutableSpecifier ( specifier ) ) ; <nl> + setSupportsMutationIfStillStored ( <nl> + StorageIsMutable_t ( ! isImmutableSpecifier ( specifier ) ) ) ; <nl> } <nl> <nl> bool VarDecl : : isAnonClosureParam ( ) const { <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> Parser : : ParsedAccessors : : classify ( Parser & P , AbstractStorageDecl * storage , <nl> / / Allow the sil_stored attribute to override all the accessors we parsed <nl> / / when making the final classification . <nl> if ( attrs . hasAttribute < SILStoredAttr > ( ) ) { <nl> - return StorageImplInfo : : getSimpleStored ( Set ! = nullptr ) ; <nl> + return StorageImplInfo : : getSimpleStored ( StorageIsMutable_t ( Set ! = nullptr ) ) ; <nl> } <nl> <nl> return StorageImplInfo ( readImpl , writeImpl , readWriteImpl ) ; <nl> mmm a / lib / Sema / CodeSynthesis . cpp <nl> ppp b / lib / Sema / CodeSynthesis . cpp <nl> static void maybeAddAccessorsToBehaviorStorage ( TypeChecker & TC , VarDecl * var ) { <nl> <nl> SmallVector < AccessorDecl * , 2 > accessors ; <nl> accessors . push_back ( getter ) ; <nl> - if ( setter ) accessors . push_back ( setter ) ; <nl> - var - > setAccessors ( StorageImplInfo : : getComputed ( setter ! = nullptr ) , <nl> + auto isMutable = StorageIsMutable_t ( setter ! = nullptr ) ; <nl> + if ( isMutable ) accessors . push_back ( setter ) ; <nl> + var - > setAccessors ( StorageImplInfo : : getComputed ( isMutable ) , <nl> SourceLoc ( ) , accessors , SourceLoc ( ) ) ; <nl> <nl> / / Save the conformance and ' value ' decl for later type checking . <nl>
|
Pass around whether storage is mutable as an enum instead of a bool .
|
apple/swift
|
5d8252b8c61f2ccee1e3c30b66b4efff7ef8f931
|
2018-08-16T06:13:54Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.