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 / compiler / common - operator . cc <nl> ppp b / src / compiler / common - operator . cc <nl> struct CommonOperatorGlobalCache FINAL { <nl> Name # # Operator k # # Name # # Operator ; <nl> CACHED_OP_LIST ( CACHED ) <nl> # undef CACHED <nl> + <nl> + template < BranchHint kBranchHint > <nl> + struct BranchOperator FINAL : public Operator1 < BranchHint > { <nl> + BranchOperator ( ) <nl> + : Operator1 < BranchHint > ( / / - - <nl> + IrOpcode : : kBranch , Operator : : kFoldable , / / opcode <nl> + " Branch " , / / name <nl> + 1 , 0 , 1 , 0 , 0 , 2 , / / counts <nl> + kBranchHint ) { } / / parameter <nl> + } ; <nl> + BranchOperator < BranchHint : : kNone > kBranchNoneOperator ; <nl> + BranchOperator < BranchHint : : kTrue > kBranchTrueOperator ; <nl> + BranchOperator < BranchHint : : kFalse > kBranchFalseOperator ; <nl> } ; <nl> <nl> <nl> CACHED_OP_LIST ( CACHED ) <nl> <nl> <nl> const Operator * CommonOperatorBuilder : : Branch ( BranchHint hint ) { <nl> - return new ( zone ( ) ) Operator1 < BranchHint > ( <nl> - IrOpcode : : kBranch , Operator : : kFoldable , " Branch " , 1 , 0 , 1 , 0 , 0 , 2 , hint ) ; <nl> + switch ( hint ) { <nl> + case BranchHint : : kNone : <nl> + return & cache_ . kBranchNoneOperator ; <nl> + case BranchHint : : kTrue : <nl> + return & cache_ . kBranchTrueOperator ; <nl> + case BranchHint : : kFalse : <nl> + return & cache_ . kBranchFalseOperator ; <nl> + } <nl> + UNREACHABLE ( ) ; <nl> + return nullptr ; <nl> } <nl> <nl> <nl> | [ turbofan ] Cache the Branch operator ( s ) . | v8/v8 | 0a020550c6734315fd1022300ee599c7c89c631d | 2014-12-02T12:41:44Z |
deleted file mode 100644 <nl> index cb5fcfe37b7 . . 00000000000 <nl> mmm a / tests / test_astar . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * test_astar . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * https : / / godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2020 Godot Engine contributors ( cf . AUTHORS . md ) . * / <nl> - / * * / <nl> - / * Permission is hereby granted , free of charge , to any person obtaining * / <nl> - / * a copy of this software and associated documentation files ( the * / <nl> - / * " Software " ) , to deal in the Software without restriction , including * / <nl> - / * without limitation the rights to use , copy , modify , merge , publish , * / <nl> - / * distribute , sublicense , and / or sell copies of the Software , and to * / <nl> - / * permit persons to whom the Software is furnished to do so , subject to * / <nl> - / * the following conditions : * / <nl> - / * * / <nl> - / * The above copyright notice and this permission notice shall be * / <nl> - / * included in all copies or substantial portions of the Software . * / <nl> - / * * / <nl> - / * THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , * / <nl> - / * EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * / <nl> - / * MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " test_astar . h " <nl> - <nl> - # include " core / math / a_star . h " <nl> - # include " core / math / math_funcs . h " <nl> - # include " core / os / os . h " <nl> - <nl> - # include < math . h > <nl> - # include < stdio . h > <nl> - <nl> - namespace TestAStar { <nl> - <nl> - class ABCX : public AStar { <nl> - public : <nl> - enum { A , <nl> - B , <nl> - C , <nl> - X } ; <nl> - <nl> - ABCX ( ) { <nl> - add_point ( A , Vector3 ( 0 , 0 , 0 ) ) ; <nl> - add_point ( B , Vector3 ( 1 , 0 , 0 ) ) ; <nl> - add_point ( C , Vector3 ( 0 , 1 , 0 ) ) ; <nl> - add_point ( X , Vector3 ( 0 , 0 , 1 ) ) ; <nl> - connect_points ( A , B ) ; <nl> - connect_points ( A , C ) ; <nl> - connect_points ( B , C ) ; <nl> - connect_points ( X , A ) ; <nl> - } <nl> - <nl> - / / Disable heuristic completely <nl> - float _compute_cost ( int p_from , int p_to ) { <nl> - if ( p_from = = A & & p_to = = C ) { <nl> - return 1000 ; <nl> - } <nl> - return 100 ; <nl> - } <nl> - } ; <nl> - <nl> - bool test_abc ( ) { <nl> - ABCX abcx ; <nl> - Vector < int > path = abcx . get_id_path ( ABCX : : A , ABCX : : C ) ; <nl> - bool ok = path . size ( ) = = 3 ; <nl> - int i = 0 ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : A ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : B ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : C ; <nl> - return ok ; <nl> - } <nl> - <nl> - bool test_abcx ( ) { <nl> - ABCX abcx ; <nl> - Vector < int > path = abcx . get_id_path ( ABCX : : X , ABCX : : C ) ; <nl> - bool ok = path . size ( ) = = 4 ; <nl> - int i = 0 ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : X ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : A ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : B ; <nl> - ok = ok & & path [ i + + ] = = ABCX : : C ; <nl> - return ok ; <nl> - } <nl> - <nl> - bool test_add_remove ( ) { <nl> - AStar a ; <nl> - bool ok = true ; <nl> - <nl> - / / Manual tests <nl> - a . add_point ( 1 , Vector3 ( 0 , 0 , 0 ) ) ; <nl> - a . add_point ( 2 , Vector3 ( 0 , 1 , 0 ) ) ; <nl> - a . add_point ( 3 , Vector3 ( 1 , 1 , 0 ) ) ; <nl> - a . add_point ( 4 , Vector3 ( 2 , 0 , 0 ) ) ; <nl> - a . connect_points ( 1 , 2 , true ) ; <nl> - a . connect_points ( 1 , 3 , true ) ; <nl> - a . connect_points ( 1 , 4 , false ) ; <nl> - <nl> - ok = ok & & ( a . are_points_connected ( 2 , 1 ) ) ; <nl> - ok = ok & & ( a . are_points_connected ( 4 , 1 ) ) ; <nl> - ok = ok & & ( a . are_points_connected ( 2 , 1 , false ) ) ; <nl> - ok = ok & & ( a . are_points_connected ( 4 , 1 , false ) = = false ) ; <nl> - <nl> - a . disconnect_points ( 1 , 2 , true ) ; <nl> - ok = ok & & ( a . get_point_connections ( 1 ) . size ( ) = = 2 ) ; / / 3 , 4 <nl> - ok = ok & & ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> - <nl> - a . disconnect_points ( 4 , 1 , false ) ; <nl> - ok = ok & & ( a . get_point_connections ( 1 ) . size ( ) = = 2 ) ; / / 3 , 4 <nl> - ok = ok & & ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> - <nl> - a . disconnect_points ( 4 , 1 , true ) ; <nl> - ok = ok & & ( a . get_point_connections ( 1 ) . size ( ) = = 1 ) ; / / 3 <nl> - ok = ok & & ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> - <nl> - a . connect_points ( 2 , 3 , false ) ; <nl> - ok = ok & & ( a . get_point_connections ( 2 ) . size ( ) = = 1 ) ; / / 3 <nl> - ok = ok & & ( a . get_point_connections ( 3 ) . size ( ) = = 1 ) ; / / 1 <nl> - <nl> - a . connect_points ( 2 , 3 , true ) ; <nl> - ok = ok & & ( a . get_point_connections ( 2 ) . size ( ) = = 1 ) ; / / 3 <nl> - ok = ok & & ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> - <nl> - a . disconnect_points ( 2 , 3 , false ) ; <nl> - ok = ok & & ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> - ok = ok & & ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> - <nl> - a . connect_points ( 4 , 3 , true ) ; <nl> - ok = ok & & ( a . get_point_connections ( 3 ) . size ( ) = = 3 ) ; / / 1 , 2 , 4 <nl> - ok = ok & & ( a . get_point_connections ( 4 ) . size ( ) = = 1 ) ; / / 3 <nl> - <nl> - a . disconnect_points ( 3 , 4 , false ) ; <nl> - ok = ok & & ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> - ok = ok & & ( a . get_point_connections ( 4 ) . size ( ) = = 1 ) ; / / 3 <nl> - <nl> - a . remove_point ( 3 ) ; <nl> - ok = ok & & ( a . get_point_connections ( 1 ) . size ( ) = = 0 ) ; <nl> - ok = ok & & ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> - ok = ok & & ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> - <nl> - a . add_point ( 0 , Vector3 ( 0 , - 1 , 0 ) ) ; <nl> - a . add_point ( 3 , Vector3 ( 2 , 1 , 0 ) ) ; <nl> - / / 0 : ( 0 , - 1 ) <nl> - / / 1 : ( 0 , 0 ) <nl> - / / 2 : ( 0 , 1 ) <nl> - / / 3 : ( 2 , 1 ) <nl> - / / 4 : ( 2 , 0 ) <nl> - <nl> - / / Tests for get_closest_position_in_segment <nl> - a . connect_points ( 2 , 3 ) ; <nl> - ok = ok & & ( a . get_closest_position_in_segment ( Vector3 ( 0 . 5 , 0 . 5 , 0 ) ) = = Vector3 ( 0 . 5 , 1 , 0 ) ) ; <nl> - <nl> - a . connect_points ( 3 , 4 ) ; <nl> - a . connect_points ( 0 , 3 ) ; <nl> - a . connect_points ( 1 , 4 ) ; <nl> - a . disconnect_points ( 1 , 4 , false ) ; <nl> - a . disconnect_points ( 4 , 3 , false ) ; <nl> - a . disconnect_points ( 3 , 4 , false ) ; <nl> - / / Remaining edges : < 2 , 3 > , < 0 , 3 > , < 1 , 4 > ( directed ) <nl> - ok = ok & & ( a . get_closest_position_in_segment ( Vector3 ( 2 , 0 . 5 , 0 ) ) = = Vector3 ( 1 . 75 , 0 . 75 , 0 ) ) ; <nl> - ok = ok & & ( a . get_closest_position_in_segment ( Vector3 ( - 1 , 0 . 2 , 0 ) ) = = Vector3 ( 0 , 0 , 0 ) ) ; <nl> - ok = ok & & ( a . get_closest_position_in_segment ( Vector3 ( 3 , 2 , 0 ) ) = = Vector3 ( 2 , 1 , 0 ) ) ; <nl> - <nl> - Math : : seed ( 0 ) ; <nl> - <nl> - / / Random tests for connectivity checks <nl> - for ( int i = 0 ; i < 20000 ; i + + ) { <nl> - int u = Math : : rand ( ) % 5 ; <nl> - int v = Math : : rand ( ) % 4 ; <nl> - if ( u = = v ) { <nl> - v = 4 ; <nl> - } <nl> - if ( Math : : rand ( ) % 2 = = 1 ) { <nl> - / / Add a ( possibly existing ) directed edge and confirm connectivity <nl> - a . connect_points ( u , v , false ) ; <nl> - ok = ok & & ( a . are_points_connected ( u , v , false ) ) ; <nl> - } else { <nl> - / / Remove a ( possibly nonexistent ) directed edge and confirm disconnectivity <nl> - a . disconnect_points ( u , v , false ) ; <nl> - ok = ok & & ( a . are_points_connected ( u , v , false ) = = false ) ; <nl> - } <nl> - } <nl> - <nl> - / / Random tests for point removal <nl> - for ( int i = 0 ; i < 20000 ; i + + ) { <nl> - a . clear ( ) ; <nl> - for ( int j = 0 ; j < 5 ; j + + ) { <nl> - a . add_point ( j , Vector3 ( 0 , 0 , 0 ) ) ; <nl> - } <nl> - <nl> - / / Add or remove random edges <nl> - for ( int j = 0 ; j < 10 ; j + + ) { <nl> - int u = Math : : rand ( ) % 5 ; <nl> - int v = Math : : rand ( ) % 4 ; <nl> - if ( u = = v ) { <nl> - v = 4 ; <nl> - } <nl> - if ( Math : : rand ( ) % 2 = = 1 ) { <nl> - a . connect_points ( u , v , false ) ; <nl> - } else { <nl> - a . disconnect_points ( u , v , false ) ; <nl> - } <nl> - } <nl> - <nl> - / / Remove point 0 <nl> - a . remove_point ( 0 ) ; <nl> - / / White box : this will check all edges remaining in the segments set <nl> - for ( int j = 1 ; j < 5 ; j + + ) { <nl> - ok = ok & & ( a . are_points_connected ( 0 , j , true ) = = false ) ; <nl> - } <nl> - } <nl> - <nl> - / / It ' s been great work , cheers \ ( ^ ^ ) / <nl> - return ok ; <nl> - } <nl> - <nl> - bool test_solutions ( ) { <nl> - / / Random stress tests with Floyd - Warshall <nl> - <nl> - const int N = 30 ; <nl> - Math : : seed ( 0 ) ; <nl> - <nl> - for ( int test = 0 ; test < 1000 ; test + + ) { <nl> - AStar a ; <nl> - Vector3 p [ N ] ; <nl> - bool adj [ N ] [ N ] = { { false } } ; <nl> - <nl> - / / Assign initial coordinates <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - p [ u ] . x = Math : : rand ( ) % 100 ; <nl> - p [ u ] . y = Math : : rand ( ) % 100 ; <nl> - p [ u ] . z = Math : : rand ( ) % 100 ; <nl> - a . add_point ( u , p [ u ] ) ; <nl> - } <nl> - <nl> - / / Generate a random sequence of operations <nl> - for ( int i = 0 ; i < 1000 ; i + + ) { <nl> - / / Pick two different vertices <nl> - int u , v ; <nl> - u = Math : : rand ( ) % N ; <nl> - v = Math : : rand ( ) % ( N - 1 ) ; <nl> - if ( u = = v ) { <nl> - v = N - 1 ; <nl> - } <nl> - <nl> - / / Pick a random operation <nl> - int op = Math : : rand ( ) ; <nl> - switch ( op % 9 ) { <nl> - case 0 : <nl> - case 1 : <nl> - case 2 : <nl> - case 3 : <nl> - case 4 : <nl> - case 5 : <nl> - / / Add edge ( u , v ) ; possibly bidirectional <nl> - a . connect_points ( u , v , op % 2 ) ; <nl> - adj [ u ] [ v ] = true ; <nl> - if ( op % 2 ) { <nl> - adj [ v ] [ u ] = true ; <nl> - } <nl> - break ; <nl> - case 6 : <nl> - case 7 : <nl> - / / Remove edge ( u , v ) ; possibly bidirectional <nl> - a . disconnect_points ( u , v , op % 2 ) ; <nl> - adj [ u ] [ v ] = false ; <nl> - if ( op % 2 ) { <nl> - adj [ v ] [ u ] = false ; <nl> - } <nl> - break ; <nl> - case 8 : <nl> - / / Remove point u and add it back ; clears adjacent edges and changes coordinates <nl> - a . remove_point ( u ) ; <nl> - p [ u ] . x = Math : : rand ( ) % 100 ; <nl> - p [ u ] . y = Math : : rand ( ) % 100 ; <nl> - p [ u ] . z = Math : : rand ( ) % 100 ; <nl> - a . add_point ( u , p [ u ] ) ; <nl> - for ( v = 0 ; v < N ; v + + ) { <nl> - adj [ u ] [ v ] = adj [ v ] [ u ] = false ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / Floyd - Warshall <nl> - float d [ N ] [ N ] ; <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - for ( int v = 0 ; v < N ; v + + ) { <nl> - d [ u ] [ v ] = ( u = = v | | adj [ u ] [ v ] ) ? p [ u ] . distance_to ( p [ v ] ) : INFINITY ; <nl> - } <nl> - } <nl> - <nl> - for ( int w = 0 ; w < N ; w + + ) { <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - for ( int v = 0 ; v < N ; v + + ) { <nl> - if ( d [ u ] [ v ] > d [ u ] [ w ] + d [ w ] [ v ] ) { <nl> - d [ u ] [ v ] = d [ u ] [ w ] + d [ w ] [ v ] ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / Display statistics <nl> - int count = 0 ; <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - for ( int v = 0 ; v < N ; v + + ) { <nl> - if ( adj [ u ] [ v ] ) { <nl> - count + + ; <nl> - } <nl> - } <nl> - } <nl> - printf ( " Test # % 4d : % 3d edges , " , test + 1 , count ) ; <nl> - count = 0 ; <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - for ( int v = 0 ; v < N ; v + + ) { <nl> - if ( ! Math : : is_inf ( d [ u ] [ v ] ) ) { <nl> - count + + ; <nl> - } <nl> - } <nl> - } <nl> - printf ( " % 3d / % d pairs of reachable points \ n " , count - N , N * ( N - 1 ) ) ; <nl> - <nl> - / / Check A * ' s output <nl> - bool match = true ; <nl> - for ( int u = 0 ; u < N ; u + + ) { <nl> - for ( int v = 0 ; v < N ; v + + ) { <nl> - if ( u ! = v ) { <nl> - Vector < int > route = a . get_id_path ( u , v ) ; <nl> - if ( ! Math : : is_inf ( d [ u ] [ v ] ) ) { <nl> - / / Reachable <nl> - if ( route . size ( ) = = 0 ) { <nl> - printf ( " From % d to % d : A * did not find a path \ n " , u , v ) ; <nl> - match = false ; <nl> - goto exit ; <nl> - } <nl> - float astar_dist = 0 ; <nl> - for ( int i = 1 ; i < route . size ( ) ; i + + ) { <nl> - if ( ! adj [ route [ i - 1 ] ] [ route [ i ] ] ) { <nl> - printf ( " From % d to % d : edge ( % d , % d ) does not exist \ n " , <nl> - u , v , route [ i - 1 ] , route [ i ] ) ; <nl> - match = false ; <nl> - goto exit ; <nl> - } <nl> - astar_dist + = p [ route [ i - 1 ] ] . distance_to ( p [ route [ i ] ] ) ; <nl> - } <nl> - if ( ! Math : : is_equal_approx ( astar_dist , d [ u ] [ v ] ) ) { <nl> - printf ( " From % d to % d : Floyd - Warshall gives % . 6f , A * gives % . 6f \ n " , <nl> - u , v , d [ u ] [ v ] , astar_dist ) ; <nl> - match = false ; <nl> - goto exit ; <nl> - } <nl> - } else { <nl> - / / Unreachable <nl> - if ( route . size ( ) > 0 ) { <nl> - printf ( " From % d to % d : A * somehow found a nonexistent path \ n " , u , v ) ; <nl> - match = false ; <nl> - goto exit ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - exit : <nl> - if ( ! match ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - typedef bool ( * TestFunc ) ( ) ; <nl> - <nl> - TestFunc test_funcs [ ] = { <nl> - test_abc , <nl> - test_abcx , <nl> - test_add_remove , <nl> - test_solutions , <nl> - nullptr <nl> - } ; <nl> - <nl> - MainLoop * test ( ) { <nl> - int count = 0 ; <nl> - int passed = 0 ; <nl> - <nl> - while ( true ) { <nl> - if ( ! test_funcs [ count ] ) { <nl> - break ; <nl> - } <nl> - bool pass = test_funcs [ count ] ( ) ; <nl> - if ( pass ) { <nl> - passed + + ; <nl> - } <nl> - OS : : get_singleton ( ) - > print ( " \ t % s \ n " , pass ? " PASS " : " FAILED " ) ; <nl> - <nl> - count + + ; <nl> - } <nl> - OS : : get_singleton ( ) - > print ( " \ n " ) ; <nl> - OS : : get_singleton ( ) - > print ( " Passed % i of % i tests \ n " , passed , count ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - } / / namespace TestAStar <nl> mmm a / tests / test_astar . h <nl> ppp b / tests / test_astar . h <nl> <nl> # ifndef TEST_ASTAR_H <nl> # define TEST_ASTAR_H <nl> <nl> - # include " core / os / main_loop . h " <nl> + # include " core / math / a_star . h " <nl> + # include " core / math / math_funcs . h " <nl> + # include " core / os / os . h " <nl> + <nl> + # include < math . h > <nl> + # include < stdio . h > <nl> + <nl> + # include " tests / test_macros . h " <nl> <nl> namespace TestAStar { <nl> <nl> - MainLoop * test ( ) ; <nl> + class ABCX : public AStar { <nl> + public : <nl> + enum { <nl> + A , <nl> + B , <nl> + C , <nl> + X , <nl> + } ; <nl> + <nl> + ABCX ( ) { <nl> + add_point ( A , Vector3 ( 0 , 0 , 0 ) ) ; <nl> + add_point ( B , Vector3 ( 1 , 0 , 0 ) ) ; <nl> + add_point ( C , Vector3 ( 0 , 1 , 0 ) ) ; <nl> + add_point ( X , Vector3 ( 0 , 0 , 1 ) ) ; <nl> + connect_points ( A , B ) ; <nl> + connect_points ( A , C ) ; <nl> + connect_points ( B , C ) ; <nl> + connect_points ( X , A ) ; <nl> + } <nl> + <nl> + / / Disable heuristic completely . <nl> + float _compute_cost ( int p_from , int p_to ) { <nl> + if ( p_from = = A & & p_to = = C ) { <nl> + return 1000 ; <nl> + } <nl> + return 100 ; <nl> + } <nl> + } ; <nl> + <nl> + TEST_CASE ( " [ AStar ] ABC path " ) { <nl> + ABCX abcx ; <nl> + Vector < int > path = abcx . get_id_path ( ABCX : : A , ABCX : : C ) ; <nl> + REQUIRE ( path . size ( ) = = 3 ) ; <nl> + CHECK ( path [ 0 ] = = ABCX : : A ) ; <nl> + CHECK ( path [ 1 ] = = ABCX : : B ) ; <nl> + CHECK ( path [ 2 ] = = ABCX : : C ) ; <nl> + } <nl> + <nl> + TEST_CASE ( " [ AStar ] ABCX path " ) { <nl> + ABCX abcx ; <nl> + Vector < int > path = abcx . get_id_path ( ABCX : : X , ABCX : : C ) ; <nl> + REQUIRE ( path . size ( ) = = 4 ) ; <nl> + CHECK ( path [ 0 ] = = ABCX : : X ) ; <nl> + CHECK ( path [ 1 ] = = ABCX : : A ) ; <nl> + CHECK ( path [ 2 ] = = ABCX : : B ) ; <nl> + CHECK ( path [ 3 ] = = ABCX : : C ) ; <nl> + } <nl> + <nl> + TEST_CASE ( " [ AStar ] Add / Remove " ) { <nl> + AStar a ; <nl> + <nl> + / / Manual tests . <nl> + a . add_point ( 1 , Vector3 ( 0 , 0 , 0 ) ) ; <nl> + a . add_point ( 2 , Vector3 ( 0 , 1 , 0 ) ) ; <nl> + a . add_point ( 3 , Vector3 ( 1 , 1 , 0 ) ) ; <nl> + a . add_point ( 4 , Vector3 ( 2 , 0 , 0 ) ) ; <nl> + a . connect_points ( 1 , 2 , true ) ; <nl> + a . connect_points ( 1 , 3 , true ) ; <nl> + a . connect_points ( 1 , 4 , false ) ; <nl> + <nl> + CHECK ( a . are_points_connected ( 2 , 1 ) ) ; <nl> + CHECK ( a . are_points_connected ( 4 , 1 ) ) ; <nl> + CHECK ( a . are_points_connected ( 2 , 1 , false ) ) ; <nl> + CHECK_FALSE ( a . are_points_connected ( 4 , 1 , false ) ) ; <nl> + <nl> + a . disconnect_points ( 1 , 2 , true ) ; <nl> + CHECK ( a . get_point_connections ( 1 ) . size ( ) = = 2 ) ; / / 3 , 4 <nl> + CHECK ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> + <nl> + a . disconnect_points ( 4 , 1 , false ) ; <nl> + CHECK ( a . get_point_connections ( 1 ) . size ( ) = = 2 ) ; / / 3 , 4 <nl> + CHECK ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> + <nl> + a . disconnect_points ( 4 , 1 , true ) ; <nl> + CHECK ( a . get_point_connections ( 1 ) . size ( ) = = 1 ) ; / / 3 <nl> + CHECK ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> + <nl> + a . connect_points ( 2 , 3 , false ) ; <nl> + CHECK ( a . get_point_connections ( 2 ) . size ( ) = = 1 ) ; / / 3 <nl> + CHECK ( a . get_point_connections ( 3 ) . size ( ) = = 1 ) ; / / 1 <nl> + <nl> + a . connect_points ( 2 , 3 , true ) ; <nl> + CHECK ( a . get_point_connections ( 2 ) . size ( ) = = 1 ) ; / / 3 <nl> + CHECK ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> + <nl> + a . disconnect_points ( 2 , 3 , false ) ; <nl> + CHECK ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> + CHECK ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> + <nl> + a . connect_points ( 4 , 3 , true ) ; <nl> + CHECK ( a . get_point_connections ( 3 ) . size ( ) = = 3 ) ; / / 1 , 2 , 4 <nl> + CHECK ( a . get_point_connections ( 4 ) . size ( ) = = 1 ) ; / / 3 <nl> + <nl> + a . disconnect_points ( 3 , 4 , false ) ; <nl> + CHECK ( a . get_point_connections ( 3 ) . size ( ) = = 2 ) ; / / 1 , 2 <nl> + CHECK ( a . get_point_connections ( 4 ) . size ( ) = = 1 ) ; / / 3 <nl> + <nl> + a . remove_point ( 3 ) ; <nl> + CHECK ( a . get_point_connections ( 1 ) . size ( ) = = 0 ) ; <nl> + CHECK ( a . get_point_connections ( 2 ) . size ( ) = = 0 ) ; <nl> + CHECK ( a . get_point_connections ( 4 ) . size ( ) = = 0 ) ; <nl> + <nl> + a . add_point ( 0 , Vector3 ( 0 , - 1 , 0 ) ) ; <nl> + a . add_point ( 3 , Vector3 ( 2 , 1 , 0 ) ) ; <nl> + / / 0 : ( 0 , - 1 ) <nl> + / / 1 : ( 0 , 0 ) <nl> + / / 2 : ( 0 , 1 ) <nl> + / / 3 : ( 2 , 1 ) <nl> + / / 4 : ( 2 , 0 ) <nl> + <nl> + / / Tests for get_closest_position_in_segment . <nl> + a . connect_points ( 2 , 3 ) ; <nl> + CHECK ( a . get_closest_position_in_segment ( Vector3 ( 0 . 5 , 0 . 5 , 0 ) ) = = Vector3 ( 0 . 5 , 1 , 0 ) ) ; <nl> + <nl> + a . connect_points ( 3 , 4 ) ; <nl> + a . connect_points ( 0 , 3 ) ; <nl> + a . connect_points ( 1 , 4 ) ; <nl> + a . disconnect_points ( 1 , 4 , false ) ; <nl> + a . disconnect_points ( 4 , 3 , false ) ; <nl> + a . disconnect_points ( 3 , 4 , false ) ; <nl> + / / Remaining edges : < 2 , 3 > , < 0 , 3 > , < 1 , 4 > ( directed ) . <nl> + CHECK ( a . get_closest_position_in_segment ( Vector3 ( 2 , 0 . 5 , 0 ) ) = = Vector3 ( 1 . 75 , 0 . 75 , 0 ) ) ; <nl> + CHECK ( a . get_closest_position_in_segment ( Vector3 ( - 1 , 0 . 2 , 0 ) ) = = Vector3 ( 0 , 0 , 0 ) ) ; <nl> + CHECK ( a . get_closest_position_in_segment ( Vector3 ( 3 , 2 , 0 ) ) = = Vector3 ( 2 , 1 , 0 ) ) ; <nl> + <nl> + Math : : seed ( 0 ) ; <nl> + <nl> + / / Random tests for connectivity checks <nl> + for ( int i = 0 ; i < 20000 ; i + + ) { <nl> + int u = Math : : rand ( ) % 5 ; <nl> + int v = Math : : rand ( ) % 4 ; <nl> + if ( u = = v ) { <nl> + v = 4 ; <nl> + } <nl> + if ( Math : : rand ( ) % 2 = = 1 ) { <nl> + / / Add a ( possibly existing ) directed edge and confirm connectivity . <nl> + a . connect_points ( u , v , false ) ; <nl> + CHECK ( a . are_points_connected ( u , v , false ) ) ; <nl> + } else { <nl> + / / Remove a ( possibly nonexistent ) directed edge and confirm disconnectivity . <nl> + a . disconnect_points ( u , v , false ) ; <nl> + CHECK_FALSE ( a . are_points_connected ( u , v , false ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / Random tests for point removal . <nl> + for ( int i = 0 ; i < 20000 ; i + + ) { <nl> + a . clear ( ) ; <nl> + for ( int j = 0 ; j < 5 ; j + + ) { <nl> + a . add_point ( j , Vector3 ( 0 , 0 , 0 ) ) ; <nl> + } <nl> + <nl> + / / Add or remove random edges . <nl> + for ( int j = 0 ; j < 10 ; j + + ) { <nl> + int u = Math : : rand ( ) % 5 ; <nl> + int v = Math : : rand ( ) % 4 ; <nl> + if ( u = = v ) { <nl> + v = 4 ; <nl> + } <nl> + if ( Math : : rand ( ) % 2 = = 1 ) { <nl> + a . connect_points ( u , v , false ) ; <nl> + } else { <nl> + a . disconnect_points ( u , v , false ) ; <nl> + } <nl> + } <nl> + <nl> + / / Remove point 0 . <nl> + a . remove_point ( 0 ) ; <nl> + / / White box : this will check all edges remaining in the segments set . <nl> + for ( int j = 1 ; j < 5 ; j + + ) { <nl> + CHECK_FALSE ( a . are_points_connected ( 0 , j , true ) ) ; <nl> + } <nl> + } <nl> + / / It ' s been great work , cheers . \ ( ^ ^ ) / <nl> + } <nl> + <nl> + TEST_CASE ( " [ Stress ] [ AStar ] Find paths " ) { <nl> + / / Random stress tests with Floyd - Warshall . <nl> + const int N = 30 ; <nl> + Math : : seed ( 0 ) ; <nl> + <nl> + for ( int test = 0 ; test < 1000 ; test + + ) { <nl> + AStar a ; <nl> + Vector3 p [ N ] ; <nl> + bool adj [ N ] [ N ] = { { false } } ; <nl> + <nl> + / / Assign initial coordinates . <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + p [ u ] . x = Math : : rand ( ) % 100 ; <nl> + p [ u ] . y = Math : : rand ( ) % 100 ; <nl> + p [ u ] . z = Math : : rand ( ) % 100 ; <nl> + a . add_point ( u , p [ u ] ) ; <nl> + } <nl> + / / Generate a random sequence of operations . <nl> + for ( int i = 0 ; i < 1000 ; i + + ) { <nl> + / / Pick two different vertices . <nl> + int u , v ; <nl> + u = Math : : rand ( ) % N ; <nl> + v = Math : : rand ( ) % ( N - 1 ) ; <nl> + if ( u = = v ) { <nl> + v = N - 1 ; <nl> + } <nl> + / / Pick a random operation . <nl> + int op = Math : : rand ( ) ; <nl> + switch ( op % 9 ) { <nl> + case 0 : <nl> + case 1 : <nl> + case 2 : <nl> + case 3 : <nl> + case 4 : <nl> + case 5 : <nl> + / / Add edge ( u , v ) ; possibly bidirectional . <nl> + a . connect_points ( u , v , op % 2 ) ; <nl> + adj [ u ] [ v ] = true ; <nl> + if ( op % 2 ) { <nl> + adj [ v ] [ u ] = true ; <nl> + } <nl> + break ; <nl> + case 6 : <nl> + case 7 : <nl> + / / Remove edge ( u , v ) ; possibly bidirectional . <nl> + a . disconnect_points ( u , v , op % 2 ) ; <nl> + adj [ u ] [ v ] = false ; <nl> + if ( op % 2 ) { <nl> + adj [ v ] [ u ] = false ; <nl> + } <nl> + break ; <nl> + case 8 : <nl> + / / Remove point u and add it back ; clears adjacent edges and changes coordinates . <nl> + a . remove_point ( u ) ; <nl> + p [ u ] . x = Math : : rand ( ) % 100 ; <nl> + p [ u ] . y = Math : : rand ( ) % 100 ; <nl> + p [ u ] . z = Math : : rand ( ) % 100 ; <nl> + a . add_point ( u , p [ u ] ) ; <nl> + for ( v = 0 ; v < N ; v + + ) { <nl> + adj [ u ] [ v ] = adj [ v ] [ u ] = false ; <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + / / Floyd - Warshall . <nl> + float d [ N ] [ N ] ; <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + for ( int v = 0 ; v < N ; v + + ) { <nl> + d [ u ] [ v ] = ( u = = v | | adj [ u ] [ v ] ) ? p [ u ] . distance_to ( p [ v ] ) : INFINITY ; <nl> + } <nl> + } <nl> + for ( int w = 0 ; w < N ; w + + ) { <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + for ( int v = 0 ; v < N ; v + + ) { <nl> + if ( d [ u ] [ v ] > d [ u ] [ w ] + d [ w ] [ v ] ) { <nl> + d [ u ] [ v ] = d [ u ] [ w ] + d [ w ] [ v ] ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + / / Display statistics . <nl> + int count = 0 ; <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + for ( int v = 0 ; v < N ; v + + ) { <nl> + if ( adj [ u ] [ v ] ) { <nl> + count + + ; <nl> + } <nl> + } <nl> + } <nl> + print_verbose ( vformat ( " Test # % 4d : % 3d edges , " , test + 1 , count ) ) ; <nl> + count = 0 ; <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + for ( int v = 0 ; v < N ; v + + ) { <nl> + if ( ! Math : : is_inf ( d [ u ] [ v ] ) ) { <nl> + count + + ; <nl> + } <nl> + } <nl> + } <nl> + print_verbose ( vformat ( " % 3d / % d pairs of reachable points \ n " , count - N , N * ( N - 1 ) ) ) ; <nl> + <nl> + / / Check A * ' s output . <nl> + bool match = true ; <nl> + for ( int u = 0 ; u < N ; u + + ) { <nl> + for ( int v = 0 ; v < N ; v + + ) { <nl> + if ( u ! = v ) { <nl> + Vector < int > route = a . get_id_path ( u , v ) ; <nl> + if ( ! Math : : is_inf ( d [ u ] [ v ] ) ) { <nl> + / / Reachable . <nl> + if ( route . size ( ) = = 0 ) { <nl> + print_verbose ( vformat ( " From % d to % d : A * did not find a path \ n " , u , v ) ) ; <nl> + match = false ; <nl> + goto exit ; <nl> + } <nl> + float astar_dist = 0 ; <nl> + for ( int i = 1 ; i < route . size ( ) ; i + + ) { <nl> + if ( ! adj [ route [ i - 1 ] ] [ route [ i ] ] ) { <nl> + print_verbose ( vformat ( " From % d to % d : edge ( % d , % d ) does not exist \ n " , <nl> + u , v , route [ i - 1 ] , route [ i ] ) ) ; <nl> + match = false ; <nl> + goto exit ; <nl> + } <nl> + astar_dist + = p [ route [ i - 1 ] ] . distance_to ( p [ route [ i ] ] ) ; <nl> + } <nl> + if ( ! Math : : is_equal_approx ( astar_dist , d [ u ] [ v ] ) ) { <nl> + print_verbose ( vformat ( " From % d to % d : Floyd - Warshall gives % . 6f , A * gives % . 6f \ n " , <nl> + u , v , d [ u ] [ v ] , astar_dist ) ) ; <nl> + match = false ; <nl> + goto exit ; <nl> + } <nl> + } else { <nl> + / / Unreachable . <nl> + if ( route . size ( ) > 0 ) { <nl> + print_verbose ( vformat ( " From % d to % d : A * somehow found a nonexistent path \ n " , u , v ) ) ; <nl> + match = false ; <nl> + goto exit ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + exit : <nl> + CHECK_MESSAGE ( match , " Found all paths . " ) ; <nl> + } <nl> } <nl> <nl> - # endif <nl> + } / / namespace TestAStar <nl> + <nl> + # endif / / TEST_ASTAR_H <nl> | Port AStar tests to use doctest | godotengine/godot | 3645317036082709a9c55b4458a4fde439915c76 | 2020-07-30T23:09:40Z |
mmm a / docs / api / clipboard . md <nl> ppp b / docs / api / clipboard . md <nl> Writes ` markup ` to the clipboard . <nl> <nl> * ` type ` String ( optional ) <nl> <nl> - Returns ` NativeImage ` - The content in the clipboard as a [ NativeImage ] ( native - image . md ) . <nl> + Returns [ ` NativeImage ` ] ( native - image . md ) - The image content in the clipboard . <nl> <nl> # # # ` clipboard . writeImage ( image [ , type ] ) ` <nl> <nl> mmm a / docs / api / net . md <nl> ppp b / docs / api / net . md <nl> The ` net ` module has the following methods : <nl> <nl> * ` options ` ( Object | String ) - The ` ClientRequest ` constructor options . <nl> <nl> - Returns ` ClientRequest ` <nl> + Returns [ ` ClientRequest ` ] ( . / client - request . md ) <nl> <nl> Creates a [ ` ClientRequest ` ] ( . / client - request . md ) instance using the provided <nl> ` options ` which are directly forwarded to the ` ClientRequest ` constructor . <nl> mmm a / docs / api / remote . md <nl> ppp b / docs / api / remote . md <nl> Returns ` any ` - The object returned by ` require ( module ) ` in the main process . <nl> <nl> # # # ` remote . getCurrentWindow ( ) ` <nl> <nl> - Returns ` BrowserWindow ` - The [ ` BrowserWindow ` ] ( browser - window . md ) object to which this web page <nl> + Returns [ ` BrowserWindow ` ] ( browser - window . md ) - The window to which this web page <nl> belongs . <nl> <nl> # # # ` remote . getCurrentWebContents ( ) ` <nl> <nl> - Returns ` WebContents ` - The [ ` WebContents ` ] ( web - contents . md ) object of this web page . <nl> + Returns [ ` WebContents ` ] ( web - contents . md ) - The web contents of this web page . <nl> <nl> # # # ` remote . getGlobal ( name ) ` <nl> <nl> mmm a / docs / api / screen . md <nl> ppp b / docs / api / screen . md <nl> The current absolute position of the mouse pointer . <nl> <nl> # # # ` screen . getPrimaryDisplay ( ) ` <nl> <nl> - Returns ` Display ` - The primary display . <nl> + Returns [ ` Display ` ] ( structures / display . md ) - The primary display . <nl> <nl> # # # ` screen . getAllDisplays ( ) ` <nl> <nl> - Returns ` Display [ ] ` - An array of displays that are currently available . <nl> + Returns [ ` Display [ ] ` ] ( structures / display . md ) - An array of displays that are currently available . <nl> <nl> # # # ` screen . getDisplayNearestPoint ( point ) ` <nl> <nl> Returns ` Display [ ] ` - An array of displays that are currently available . <nl> * ` x ` Integer <nl> * ` y ` Integer <nl> <nl> - Returns ` Display ` - The display nearest the specified point . <nl> + Returns [ ` Display ` ] ( structures / display . md ) - The display nearest the specified point . <nl> <nl> # # # ` screen . getDisplayMatching ( rect ) ` <nl> <nl> * ` rect ` [ Rectangle ] ( structures / rectangle . md ) <nl> <nl> - Returns ` Display ` - The display that most closely intersects the provided bounds . <nl> + Returns ` Display ` ] ( structures / display . md ) - The display that most closely <nl> + intersects the provided bounds . <nl> mmm a / docs / api / web - view - tag . md <nl> ppp b / docs / api / web - view - tag . md <nl> Shows pop - up dictionary that searches the selected word on the page . <nl> <nl> # # # ` < webview > . getWebContents ( ) ` <nl> <nl> - Returns ` WebContents ` - The [ WebContents ] ( web - contents . md ) associated with this ` webview ` . <nl> + Returns [ ` WebContents ` ] ( web - contents . md ) - The web contents associated with <nl> + this ` webview ` . <nl> <nl> # # DOM events <nl> <nl> mmm a / docs / api / window - open . md <nl> ppp b / docs / api / window - open . md <nl> string . <nl> * ` frameName ` String ( optional ) <nl> * ` features ` String ( optional ) <nl> <nl> - Returns ` BrowserWindowProxy ` - Creates a new window and returns an instance of ` BrowserWindowProxy ` class . <nl> + Returns [ ` BrowserWindowProxy ` ] ( browser - window - proxy . md ) - Creates a new window <nl> + and returns an instance of ` BrowserWindowProxy ` class . <nl> <nl> The ` features ` string follows the format of standard browser , but each feature <nl> has to be a field of ` BrowserWindow ` ' s options . <nl> | Merge pull request from electron / doc - links | electron/electron | 78a89c666bef8dbfbf202fdfc8ca7973a0117420 | 2016-12-19T18:48:27Z |
mmm a / PowerEditor / installer / nppSetup . nsi <nl> ppp b / PowerEditor / installer / nppSetup . nsi <nl> <nl> <nl> ; Define the application name <nl> ! define APPNAME " Notepad + + " <nl> - ! define APPNAMEANDVERSION " Notepad + + v4 . 8 . 2 " <nl> + ! define APPNAMEANDVERSION " Notepad + + v4 . 8 . 5 " <nl> <nl> ! define VERSION_MAJOR 4 <nl> - ! define VERSION_MINOR 82 <nl> + ! define VERSION_MINOR 85 <nl> <nl> ; Main Install settings <nl> Name " $ { APPNAMEANDVERSION } " <nl> InstallDir " $ PROGRAMFILES \ Notepad + + " <nl> InstallDirRegKey HKLM " Software \ $ { APPNAME } " " " <nl> - OutFile " . . \ bin \ npp . 4 . 8 . 2 . Installer . exe " <nl> + OutFile " . . \ bin \ npp . 4 . 8 . 5 . Installer . exe " <nl> <nl> ; GetWindowsVersion <nl> ; <nl> GLOBAL_INST : <nl> CreateShortCut " $ SMPROGRAMS \ Notepad + + \ Uninstall . lnk " " $ INSTDIR \ uninstall . exe " <nl> <nl> ; remove unstable plugins <nl> + Delete " $ INSTDIR \ plugins \ HexEditorPlugin . dll " <nl> Delete " $ INSTDIR \ plugins \ HexEditor . dll " <nl> + Delete " $ INSTDIR \ plugins \ MultiClipboard . dll " <nl> <nl> ; detect the right of <nl> UserInfo : : GetAccountType <nl> mmm a / PowerEditor / src / WinControls / DockingWnd / DockingManager . cpp <nl> ppp b / PowerEditor / src / WinControls / DockingWnd / DockingManager . cpp <nl> LRESULT DockingManager : : runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM l <nl> } <nl> case WM_DESTROY : <nl> { <nl> + / * unregister window event hooking BEFORE EVERYTHING ELSE * / <nl> + if ( hWndServer = = hwnd ) { <nl> + UnhookWindowsHookEx ( gWinCallHook ) ; <nl> + gWinCallHook = NULL ; <nl> + hWndServer = NULL ; <nl> + } <nl> + <nl> / * destroy imagelist if it exists * / <nl> if ( _hImageList ! = NULL ) <nl> { <nl> LRESULT DockingManager : : runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM l <nl> _vContainer [ i - 1 ] - > destroy ( ) ; <nl> delete _vContainer [ i - 1 ] ; <nl> } <nl> - <nl> - / * unregister window event hooking * / <nl> - if ( hWndServer = = hwnd ) { <nl> - UnhookWindowsHookEx ( gWinCallHook ) ; <nl> - gWinCallHook = NULL ; <nl> - hWndServer = NULL ; <nl> - } <nl> CoUninitialize ( ) ; <nl> break ; <nl> } <nl> int DockingManager : : FindEmptyContainer ( void ) <nl> return iRetCont ; <nl> } <nl> <nl> + <nl> mmm a / PowerEditor / src / resource . h <nl> ppp b / PowerEditor / src / resource . h <nl> <nl> # ifndef RESOURCE_H <nl> # define RESOURCE_H <nl> <nl> - # define NOTEPAD_PLUS_VERSION " Notepad + + v4 . 8 . 2 " <nl> - # define VERSION_VALUE " 4 . 82 \ 0 " / / should be X . Y : ie . if VERSION_DIGITALVALUE = = 4 , 7 , 1 , 0 , then X = 4 , Y = 71 <nl> - # define VERSION_DIGITALVALUE 4 , 8 , 2 , 0 <nl> + # define NOTEPAD_PLUS_VERSION " Notepad + + v4 . 8 . 5 " <nl> + # define VERSION_VALUE " 4 . 85 \ 0 " / / should be X . Y : ie . if VERSION_DIGITALVALUE = = 4 , 7 , 1 , 0 , then X = 4 , Y = 71 <nl> + # define VERSION_DIGITALVALUE 4 , 8 , 5 , 0 <nl> <nl> # ifndef IDC_STATIC <nl> # define IDC_STATIC - 1 <nl> | [ BUG_FIXED ] Fix a crash bug by inserting a new feature . | notepad-plus-plus/notepad-plus-plus | 7a07e38f4fc8998696969d0734815299ad2b1146 | 2008-03-30T23:46:07Z |
mmm a / src / symbol / graph_executor . cc <nl> ppp b / src / symbol / graph_executor . cc <nl> void GraphExecutor : : InitGraph ( const Symbol & symbol , <nl> } <nl> } <nl> } <nl> + <nl> / / assign context , this will change the graph . <nl> std : : vector < Context > ctx_assignment ; <nl> this - > AssignContext ( default_ctx , ctx_map , <nl> void GraphExecutor : : InitGraph ( const Symbol & symbol , <nl> for ( uint32_t nid : topo ) { <nl> if ( finished . count ( nid ) = = 0 ) topo_order_ . push_back ( nid ) ; <nl> } <nl> - <nl> / / setup all the operator nodes data structure <nl> op_nodes_ . resize ( graph_ . nodes . size ( ) ) ; <nl> for ( size_t i = 0 ; i < graph_ . nodes . size ( ) ; + + i ) { <nl> void GraphExecutor : : InitDataEntryInfo ( const std : : vector < NDArray > & in_args , <nl> op_nodes_ [ e . source_id ] . activated = true ; <nl> } <nl> } <nl> + if ( graph_ . nodes [ nid ] . is_backward ( ) ) { <nl> + op_nodes_ [ graph_ . nodes [ nid ] . backward_source_id ] . activated = true ; <nl> + } <nl> } <nl> / / shape inference <nl> std : : vector < std : : vector < TShape > > out_shapes ( op_nodes_ . size ( ) ) ; <nl> void GraphExecutor : : InitDataEntryInfo ( const std : : vector < NDArray > & in_args , <nl> op_nodes_ [ i ] . outputs [ j ] . shape = out_shapes [ i ] [ j ] ; <nl> } <nl> } <nl> - <nl> / / bind aux args <nl> size_t aux_ndarray_idx = 0 ; <nl> for ( auto i : topo_order_ ) { <nl> mmm a / src / symbol / static_graph . cc <nl> ppp b / src / symbol / static_graph . cc <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> int do_mirror = dmlc : : GetEnv ( " MXNET_BACKWARD_DO_MIRROR " , 0 ) ; <nl> int mirror_step = dmlc : : GetEnv ( " MXNET_BACKWARD_MIRROR_STEP " , 100 ) ; <nl> int counter = 0 ; <nl> + int * pcounter = & counter ; <nl> <nl> - auto need_mirror = [ this , do_mirror , & counter , mirror_step ] ( uint32_t nid ) { <nl> + auto need_mirror = [ this , do_mirror , pcounter , mirror_step ] ( uint32_t nid ) { <nl> if ( do_mirror = = 0 ) return false ; <nl> if ( ! nodes [ nid ] . is_forward ( ) ) return false ; <nl> std : : string type = nodes [ nid ] . op - > TypeString ( ) ; <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> if ( type = = " Dropout " ) return false ; <nl> if ( type = = " Concat " ) return false ; <nl> if ( type = = " SoftmaxOutput " ) return false ; <nl> - counter = counter + 1 ; <nl> - if ( counter % mirror_step = = 0 ) return false ; <nl> + + + pcounter [ 0 ] ; <nl> + if ( pcounter [ 0 ] % mirror_step = = 0 ) return false ; <nl> return true ; <nl> } ; <nl> <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> / / do backward pass traverse <nl> for ( auto it = topo_order . rbegin ( ) ; it ! = topo_order . rend ( ) ; + + it ) { <nl> uint32_t nid = * it ; <nl> + uint32_t mirror_nid = mirror_map [ nid ] ; <nl> / / skip variables <nl> if ( nodes [ nid ] . is_variable ( ) ) continue ; <nl> CHECK ( nodes [ nid ] . is_forward ( ) ) < < " Do not support Backward of Backward " ; <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> int ntotal = nodes [ nid ] . op - > NumOutputs ( ) ; <nl> / / check all outpus <nl> for ( int i = 0 ; i < ntotal ; + + i ) { <nl> - DataEntry odata ( mirror_map [ nid ] , static_cast < uint32_t > ( i ) ) ; <nl> + DataEntry odata ( mirror_nid , static_cast < uint32_t > ( i ) ) ; <nl> DataEntry okey ( nid , static_cast < uint32_t > ( i ) ) ; <nl> out_data . push_back ( odata ) ; <nl> if ( i > = nvisible ) continue ; <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> / / Create a gradient backward node <nl> Node grad_node ; <nl> / / Point to the corresponding source <nl> - grad_node . backward_source_id = nid ; <nl> + grad_node . backward_source_id = mirror_nid ; <nl> <nl> std : : vector < DataEntry > source_inputs ; <nl> for ( const DataEntry & e : nodes [ nid ] . inputs ) { <nl> source_inputs . push_back ( DataEntry ( mirror_map [ e . source_id ] , e . index ) ) ; <nl> } <nl> / / select out the dependent inputs <nl> - grad_node . inputs = nodes [ nid ] . op - > BackwardInputs ( <nl> + grad_node . inputs = nodes [ mirror_nid ] . op - > BackwardInputs ( <nl> out_grad , source_inputs , out_data ) ; <nl> <nl> - grad_node . name = nodes [ nid ] . name + " _backward " ; <nl> + grad_node . name = nodes [ mirror_nid ] . name + " _backward " ; <nl> uint32_t grad_node_id = static_cast < uint32_t > ( nodes . size ( ) ) ; <nl> nodes . push_back ( std : : move ( grad_node ) ) ; <nl> / / update gradient map <nl> void StaticGraph : : MakeBackwardPass ( std : : vector < uint32_t > * head_grad_nodes , <nl> arg_grads - > at ( i ) = DataEntry ( agg_node_id , 0 ) ; <nl> } <nl> } <nl> - LOG ( INFO ) < < " FINSIHED " ; <nl> } <nl> <nl> void StaticGraph : : Node : : Save ( dmlc : : JSONWriter * writer ) const { <nl> | [ EXECUTOR ] mirror fix of mirror direction | apache/incubator-mxnet | 3a48d268ba9f6cb8bb6c1083d6704a5ade0b9d00 | 2015-12-18T08:20:03Z |
mmm a / bindings / flow / fdb_flow . actor . cpp <nl> ppp b / bindings / flow / fdb_flow . actor . cpp <nl> <nl> <nl> # include " flow / DeterministicRandom . h " <nl> # include " flow / SystemMonitor . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> # include " flow / actorcompiler . h " / / This must be the last # include . <nl> <nl> using namespace FDB ; <nl> void fdb_flow_test ( ) { <nl> fdb - > setupNetwork ( ) ; <nl> startThread ( networkThread , fdb ) ; <nl> <nl> - g_network = newNet2 ( false ) ; <nl> + g_network = newNet2 ( TLSConfig ( ) ) ; <nl> <nl> openTraceFile ( NetworkAddress ( ) , 1000000 , 1000000 , " . " ) ; <nl> systemMonitor ( ) ; <nl> mmm a / bindings / flow / tester / Tester . actor . cpp <nl> ppp b / bindings / flow / tester / Tester . actor . cpp <nl> <nl> # include " bindings / flow / FDBLoanerTypes . h " <nl> # include " fdbrpc / fdbrpc . h " <nl> # include " flow / DeterministicRandom . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> # include " flow / actorcompiler . h " / / This must be the last # include . <nl> <nl> / / Otherwise we have to type setupNetwork ( ) , FDB : : open ( ) , etc . <nl> ACTOR void startTest ( std : : string clusterFilename , StringRef prefix , int apiVersi <nl> populateOpsThatCreateDirectories ( ) ; / / FIXME <nl> <nl> / / This is " our " network <nl> - g_network = newNet2 ( false ) ; <nl> + g_network = newNet2 ( TLSConfig ( ) ) ; <nl> <nl> ASSERT ( ! API : : isAPIVersionSelected ( ) ) ; <nl> try { <nl> ACTOR void startTest ( std : : string clusterFilename , StringRef prefix , int apiVersi <nl> <nl> ACTOR void _test_versionstamp ( ) { <nl> try { <nl> - g_network = newNet2 ( false ) ; <nl> + g_network = newNet2 ( TLSConfig ( ) ) ; <nl> <nl> API * fdb = FDB : : API : : selectAPIVersion ( 620 ) ; <nl> <nl> mmm a / fdbbackup / backup . actor . cpp <nl> ppp b / fdbbackup / backup . actor . cpp <nl> <nl> # include " flow / IRandom . h " <nl> # include " flow / genericactors . actor . h " <nl> # include " flow / SignalSafeUnwind . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> <nl> # include " fdbclient / FDBTypes . h " <nl> # include " fdbclient / BackupAgent . actor . h " <nl> int main ( int argc , char * argv [ ] ) { <nl> blobCredentials . push_back ( args - > OptionArg ( ) ) ; <nl> break ; <nl> # ifndef TLS_DISABLED <nl> - case TLSParams : : OPT_TLS_PLUGIN : <nl> + case TLSConfig : : OPT_TLS_PLUGIN : <nl> args - > OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CERTIFICATES : <nl> + case TLSConfig : : OPT_TLS_CERTIFICATES : <nl> tlsCertPath = args - > OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_PASSWORD : <nl> + case TLSConfig : : OPT_TLS_PASSWORD : <nl> tlsPassword = args - > OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CA_FILE : <nl> + case TLSConfig : : OPT_TLS_CA_FILE : <nl> tlsCAPath = args - > OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_KEY : <nl> + case TLSConfig : : OPT_TLS_KEY : <nl> tlsKeyPath = args - > OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_VERIFY_PEERS : <nl> + case TLSConfig : : OPT_TLS_VERIFY_PEERS : <nl> tlsVerifyPeers = args - > OptionArg ( ) ; <nl> break ; <nl> # endif <nl> mmm a / fdbcli / fdbcli . actor . cpp <nl> ppp b / fdbcli / fdbcli . actor . cpp <nl> <nl> # include " flow / SignalSafeUnwind . h " <nl> # include " fdbrpc / Platform . h " <nl> <nl> + # include " flow / TLSConfig . actor . h " <nl> # include " flow / SimpleOpt . h " <nl> <nl> # include " fdbcli / FlowLineNoise . h " <nl> struct CLIOptions { <nl> <nl> # ifndef TLS_DISABLED <nl> / / TLS Options <nl> - case TLSParams : : OPT_TLS_PLUGIN : <nl> + case TLSConfig : : OPT_TLS_PLUGIN : <nl> args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CERTIFICATES : <nl> + case TLSConfig : : OPT_TLS_CERTIFICATES : <nl> tlsCertPath = args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CA_FILE : <nl> + case TLSConfig : : OPT_TLS_CA_FILE : <nl> tlsCAPath = args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_KEY : <nl> + case TLSConfig : : OPT_TLS_KEY : <nl> tlsKeyPath = args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_PASSWORD : <nl> + case TLSConfig : : OPT_TLS_PASSWORD : <nl> tlsPassword = args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_VERIFY_PEERS : <nl> + case TLSConfig : : OPT_TLS_VERIFY_PEERS : <nl> tlsVerifyPeers = args . OptionArg ( ) ; <nl> break ; <nl> # endif <nl> mmm a / fdbclient / NativeAPI . actor . cpp <nl> ppp b / fdbclient / NativeAPI . actor . cpp <nl> <nl> # include " flow / Knobs . h " <nl> # include " flow / Platform . h " <nl> # include " flow / SystemMonitor . h " <nl> - # include " flow / TLSPolicy . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> # include " flow / UnitTest . h " <nl> <nl> # if defined ( CMAKE_BUILD ) | | ! defined ( WIN32 ) <nl> using std : : min ; <nl> using std : : pair ; <nl> <nl> NetworkOptions networkOptions ; <nl> - TLSParams tlsParams ; <nl> - static Reference < TLSPolicy > tlsPolicy ; <nl> - <nl> - static void initTLSPolicy ( ) { <nl> - # ifndef TLS_DISABLED <nl> - if ( ! tlsPolicy ) { <nl> - tlsPolicy = Reference < TLSPolicy > ( new TLSPolicy ( TLSPolicy : : Is : : CLIENT ) ) ; <nl> - } <nl> - # endif <nl> - } <nl> + TLSConfig tlsConfig ( TLSEndpointType : : CLIENT ) ; <nl> <nl> / / The default values , TRACE_DEFAULT_ROLL_SIZE and TRACE_DEFAULT_MAX_LOGS_SIZE are located in Trace . h . <nl> NetworkOptions : : NetworkOptions ( ) <nl> void setNetworkOption ( FDBNetworkOptions : : Option option , Optional < StringRef > valu <nl> break ; <nl> case FDBNetworkOptions : : TLS_CERT_PATH : <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsCertBytes = " " ; <nl> - tlsParams . tlsCertPath = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setCertificatePath ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> case FDBNetworkOptions : : TLS_CERT_BYTES : { <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsCertPath = " " ; <nl> - tlsParams . tlsCertBytes = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setCertificateBytes ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> } <nl> case FDBNetworkOptions : : TLS_CA_PATH : { <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsCABytes = " " ; <nl> - tlsParams . tlsCAPath = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setCAPath ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> } <nl> case FDBNetworkOptions : : TLS_CA_BYTES : { <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsCAPath = " " ; <nl> - tlsParams . tlsCABytes = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setCABytes ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> } <nl> case FDBNetworkOptions : : TLS_PASSWORD : <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsPassword = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setPassword ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> case FDBNetworkOptions : : TLS_KEY_PATH : <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsKeyBytes = " " ; <nl> - tlsParams . tlsKeyPath = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setKeyPath ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> case FDBNetworkOptions : : TLS_KEY_BYTES : { <nl> validateOptionValue ( value , true ) ; <nl> - tlsParams . tlsKeyPath = " " ; <nl> - tlsParams . tlsKeyBytes = value . get ( ) . toString ( ) ; <nl> + tlsConfig . setKeyBytes ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> } <nl> case FDBNetworkOptions : : TLS_VERIFY_PEERS : <nl> validateOptionValue ( value , true ) ; <nl> - initTLSPolicy ( ) ; <nl> - # ifndef TLS_DISABLED <nl> - tlsPolicy - > set_verify_peers ( { value . get ( ) . toString ( ) } ) ; <nl> - # endif <nl> + tlsConfig . clearVerifyPeers ( ) ; <nl> + tlsConfig . addVerifyPeers ( value . get ( ) . toString ( ) ) ; <nl> break ; <nl> case FDBNetworkOptions : : CLIENT_BUGGIFY_ENABLE : <nl> enableBuggify ( true , BuggifyType : : Client ) ; <nl> void setupNetwork ( uint64_t transportId , bool useMetrics ) { <nl> if ( ! networkOptions . logClientInfo . present ( ) ) <nl> networkOptions . logClientInfo = true ; <nl> <nl> - initTLSPolicy ( ) ; <nl> - <nl> - g_network = newNet2 ( false , useMetrics | | networkOptions . traceDirectory . present ( ) , tlsPolicy , tlsParams ) ; <nl> + g_network = newNet2 ( tlsConfig , false , useMetrics | | networkOptions . traceDirectory . present ( ) ) ; <nl> FlowTransport : : createInstance ( true , transportId ) ; <nl> Net2FileSystem : : newFileSystem ( ) ; <nl> } <nl> mmm a / fdbrpc / sim2 . actor . cpp <nl> ppp b / fdbrpc / sim2 . actor . cpp <nl> <nl> # include " fdbrpc / TraceFileIO . h " <nl> # include " flow / FaultInjection . h " <nl> # include " flow / network . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> # include " fdbrpc / Net2FileSystem . h " <nl> # include " fdbrpc / Replication . h " <nl> # include " fdbrpc / ReplicationUtils . h " <nl> class Sim2 : public ISimulator , public INetworkConnections { <nl> Sim2 ( ) : time ( 0 . 0 ) , timerTime ( 0 . 0 ) , taskCount ( 0 ) , yielded ( false ) , yield_limit ( 0 ) , currentTaskID ( TaskPriority : : Zero ) { <nl> / / Not letting currentProcess be NULL eliminates some annoying special cases <nl> currentProcess = new ProcessInfo ( " NoMachine " , LocalityData ( Optional < Standalone < StringRef > > ( ) , StringRef ( ) , StringRef ( ) , StringRef ( ) ) , ProcessClass ( ) , { NetworkAddress ( ) } , this , " " , " " ) ; <nl> - g_network = net2 = newNet2 ( false , true ) ; <nl> + g_network = net2 = newNet2 ( TLSConfig ( ) , false , true ) ; <nl> Net2FileSystem : : newFileSystem ( ) ; <nl> check_yield ( TaskPriority : : Zero ) ; <nl> } <nl> mmm a / fdbserver / fdbserver . actor . cpp <nl> ppp b / fdbserver / fdbserver . actor . cpp <nl> <nl> # include " fdbrpc / AsyncFileCached . actor . h " <nl> # include " fdbserver / CoroFlow . h " <nl> # include " flow / SignalSafeUnwind . h " <nl> - # include " flow / TLSPolicy . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> # if defined ( CMAKE_BUILD ) | | ! defined ( WIN32 ) <nl> # include " versions . h " <nl> # endif <nl> int main ( int argc , char * argv [ ] ) { <nl> int minTesterCount = 1 ; <nl> bool testOnServers = false ; <nl> <nl> - Reference < TLSPolicy > tlsPolicy = Reference < TLSPolicy > ( new TLSPolicy ( TLSPolicy : : Is : : SERVER ) ) ; <nl> - TLSParams tlsParams ; <nl> + TLSConfig tlsConfig ( TLSEndpointType : : SERVER ) ; <nl> std : : vector < std : : string > tlsVerifyPeers ; <nl> double fileIoTimeout = 0 . 0 ; <nl> bool fileIoWarnOnly = false ; <nl> int main ( int argc , char * argv [ ] ) { <nl> whitelistBinPaths = args . OptionArg ( ) ; <nl> break ; <nl> # ifndef TLS_DISABLED <nl> - case TLSParams : : OPT_TLS_PLUGIN : <nl> + case TLSConfig : : OPT_TLS_PLUGIN : <nl> args . OptionArg ( ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CERTIFICATES : <nl> - tlsParams . tlsCertPath = args . OptionArg ( ) ; <nl> + case TLSConfig : : OPT_TLS_CERTIFICATES : <nl> + tlsConfig . setCertificatePath ( args . OptionArg ( ) ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_PASSWORD : <nl> - tlsParams . tlsPassword = args . OptionArg ( ) ; <nl> + case TLSConfig : : OPT_TLS_PASSWORD : <nl> + tlsConfig . setPassword ( args . OptionArg ( ) ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_CA_FILE : <nl> - tlsParams . tlsCAPath = args . OptionArg ( ) ; <nl> + case TLSConfig : : OPT_TLS_CA_FILE : <nl> + tlsConfig . setCAPath ( args . OptionArg ( ) ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_KEY : <nl> - tlsParams . tlsKeyPath = args . OptionArg ( ) ; <nl> + case TLSConfig : : OPT_TLS_KEY : <nl> + tlsConfig . setKeyPath ( args . OptionArg ( ) ) ; <nl> break ; <nl> - case TLSParams : : OPT_TLS_VERIFY_PEERS : <nl> - tlsVerifyPeers . push_back ( args . OptionArg ( ) ) ; <nl> + case TLSConfig : : OPT_TLS_VERIFY_PEERS : <nl> + tlsConfig . addVerifyPeers ( args . OptionArg ( ) ) ; <nl> break ; <nl> # endif <nl> } <nl> int main ( int argc , char * argv [ ] ) { <nl> startNewSimulator ( ) ; <nl> openTraceFile ( NetworkAddress ( ) , rollsize , maxLogsSize , logFolder , " trace " , logGroup ) ; <nl> } else { <nl> - # ifndef TLS_DISABLED <nl> - if ( tlsVerifyPeers . size ( ) ) { <nl> - try { <nl> - tlsPolicy - > set_verify_peers ( tlsVerifyPeers ) ; <nl> - } catch ( Error & e ) { <nl> - fprintf ( stderr , " ERROR : The format of the - - tls_verify_peers option is incorrect . \ n " ) ; <nl> - printHelpTeaser ( argv [ 0 ] ) ; <nl> - flushAndExit ( FDB_EXIT_ERROR ) ; <nl> - } <nl> - } <nl> - # endif <nl> - g_network = newNet2 ( useThreadPool , true , tlsPolicy , tlsParams ) ; <nl> + g_network = newNet2 ( tlsConfig , useThreadPool , true ) ; <nl> FlowTransport : : createInstance ( false , 1 ) ; <nl> <nl> const bool expectsPublicAddress = ( role = = FDBD | | role = = NetworkTestServer | | role = = Restore ) ; <nl> mmm a / flow / CMakeLists . txt <nl> ppp b / flow / CMakeLists . txt <nl> set ( FLOW_SRCS <nl> SystemMonitor . h <nl> TDMetric . actor . h <nl> TDMetric . cpp <nl> + TLSConfig . actor . cpp <nl> + TLSConfig . actor . h <nl> ThreadHelper . actor . h <nl> ThreadHelper . cpp <nl> ThreadPrimitives . cpp <nl> set ( FLOW_SRCS <nl> ThreadSafeQueue . h <nl> Trace . cpp <nl> Trace . h <nl> - TLSPolicy . h <nl> - TLSPolicy . cpp <nl> UnitTest . cpp <nl> UnitTest . h <nl> - XmlTraceLogFormatter . h <nl> XmlTraceLogFormatter . cpp <nl> + XmlTraceLogFormatter . h <nl> actorcompiler . h <nl> error_definitions . h <nl> - flat_buffers . h <nl> flat_buffers . cpp <nl> + flat_buffers . h <nl> flow . cpp <nl> flow . h <nl> genericactors . actor . cpp <nl> genericactors . actor . h <nl> network . cpp <nl> network . h <nl> - serialize . h <nl> serialize . cpp <nl> + serialize . h <nl> stacktrace . amalgamation . cpp <nl> stacktrace . h <nl> version . cpp ) <nl> mmm a / flow / Net2 . actor . cpp <nl> ppp b / flow / Net2 . actor . cpp <nl> <nl> # include " flow / AsioReactor . h " <nl> # include " flow / Profiler . h " <nl> # include " flow / ProtocolVersion . h " <nl> - # include " flow / TLSPolicy . h " <nl> + # include " flow / TLSConfig . actor . h " <nl> + # include " flow / genericactors . actor . h " <nl> + <nl> + / / See the comment in TLSConfig . actor . h for the explanation of why this module breaking include was done . <nl> + # include " fdbrpc / IAsyncFile . h " <nl> <nl> # ifdef WIN32 <nl> # include < mmsystem . h > <nl> thread_local INetwork * thread_network = 0 ; <nl> class Net2 sealed : public INetwork , public INetworkConnections { <nl> <nl> public : <nl> - Net2 ( bool useThreadPool , bool useMetrics , Reference < TLSPolicy > tlsPolicy , const TLSParams & tlsParams ) ; <nl> + Net2 ( const TLSConfig & tlsConfig , bool useThreadPool , bool useMetrics ) ; <nl> void initTLS ( ) ; <nl> void run ( ) ; <nl> void initMetrics ( ) ; <nl> class Net2 sealed : public INetwork , public INetworkConnections { <nl> <nl> ASIOReactor reactor ; <nl> # ifndef TLS_DISABLED <nl> - boost : : asio : : ssl : : context sslContext ; <nl> + AsyncVar < Reference < ReferencedObject < boost : : asio : : ssl : : context > > > sslContextVar ; <nl> # endif <nl> - Reference < TLSPolicy > tlsPolicy ; <nl> - TLSParams tlsParams ; <nl> + TLSConfig tlsConfig ; <nl> + Future < Void > backgroundCertRefresh ; <nl> bool tlsInitialized ; <nl> <nl> - std : : string get_password ( ) const { <nl> - return tlsParams . tlsPassword ; <nl> - } <nl> - <nl> INetworkConnections * network ; / / initially this , but can be changed <nl> <nl> int64_t tsc_begin , tsc_end ; <nl> class SSLConnection : public IConnection , ReferenceCounted < SSLConnection > { <nl> closeSocket ( ) ; <nl> } <nl> <nl> - explicit SSLConnection ( boost : : asio : : io_service & io_service , boost : : asio : : ssl : : context & context ) <nl> - : id ( nondeterministicRandom ( ) - > randomUniqueID ( ) ) , socket ( io_service ) , ssl_sock ( socket , context ) <nl> + explicit SSLConnection ( boost : : asio : : io_service & io_service , Reference < ReferencedObject < boost : : asio : : ssl : : context > > context ) <nl> + : id ( nondeterministicRandom ( ) - > randomUniqueID ( ) ) , socket ( io_service ) , ssl_sock ( socket , context - > mutate ( ) ) , sslContext ( context ) <nl> { <nl> } <nl> <nl> / / This is not part of the IConnection interface , because it is wrapped by INetwork : : connect ( ) <nl> - ACTOR static Future < Reference < IConnection > > connect ( boost : : asio : : io_service * ios , boost : : asio : : ssl : : context * context , NetworkAddress addr ) { <nl> + ACTOR static Future < Reference < IConnection > > connect ( boost : : asio : : io_service * ios , Reference < ReferencedObject < boost : : asio : : ssl : : context > > context , NetworkAddress addr ) { <nl> std : : pair < IPAddress , uint16_t > peerIP = std : : make_pair ( addr . ip , addr . port ) ; <nl> auto iter ( g_network - > networkInfo . serverTLSConnectionThrottler . find ( peerIP ) ) ; <nl> if ( iter ! = g_network - > networkInfo . serverTLSConnectionThrottler . end ( ) ) { <nl> class SSLConnection : public IConnection , ReferenceCounted < SSLConnection > { <nl> } <nl> } <nl> <nl> - state Reference < SSLConnection > self ( new SSLConnection ( * ios , * context ) ) ; <nl> + state Reference < SSLConnection > self ( new SSLConnection ( * ios , context ) ) ; <nl> self - > peer_address = addr ; <nl> <nl> try { <nl> class SSLConnection : public IConnection , ReferenceCounted < SSLConnection > { <nl> tcp : : socket socket ; <nl> ssl_socket ssl_sock ; <nl> NetworkAddress peer_address ; <nl> + Reference < ReferencedObject < boost : : asio : : ssl : : context > > sslContext ; <nl> <nl> struct SendBufferIterator { <nl> typedef boost : : asio : : const_buffer value_type ; <nl> class SSLListener : public IListener , ReferenceCounted < SSLListener > { <nl> boost : : asio : : io_context & io_service ; <nl> NetworkAddress listenAddress ; <nl> tcp : : acceptor acceptor ; <nl> - boost : : asio : : ssl : : context * context ; <nl> + AsyncVar < Reference < ReferencedObject < boost : : asio : : ssl : : context > > > * contextVar ; <nl> <nl> public : <nl> - SSLListener ( boost : : asio : : io_context & io_service , boost : : asio : : ssl : : context * context , NetworkAddress listenAddress ) <nl> - : io_service ( io_service ) , listenAddress ( listenAddress ) , acceptor ( io_service , tcpEndpoint ( listenAddress ) ) , context ( context ) <nl> + SSLListener ( boost : : asio : : io_context & io_service , AsyncVar < Reference < ReferencedObject < boost : : asio : : ssl : : context > > > * contextVar , NetworkAddress listenAddress ) <nl> + : io_service ( io_service ) , listenAddress ( listenAddress ) , acceptor ( io_service , tcpEndpoint ( listenAddress ) ) , contextVar ( contextVar ) <nl> { <nl> platform : : setCloseOnExec ( acceptor . native_handle ( ) ) ; <nl> } <nl> class SSLListener : public IListener , ReferenceCounted < SSLListener > { <nl> <nl> private : <nl> ACTOR static Future < Reference < IConnection > > doAccept ( SSLListener * self ) { <nl> - state Reference < SSLConnection > conn ( new SSLConnection ( self - > io_service , * self - > context ) ) ; <nl> + state Reference < SSLConnection > conn ( new SSLConnection ( self - > io_service , self - > contextVar - > get ( ) ) ) ; <nl> state tcp : : acceptor : : endpoint_type peer_endpoint ; <nl> try { <nl> BindPromise p ( " N2_AcceptError " , UID ( ) ) ; <nl> bool insecurely_always_accept ( bool _1 , boost : : asio : : ssl : : verify_context & _2 ) { <nl> } <nl> # endif <nl> <nl> - Net2 : : Net2 ( bool useThreadPool , bool useMetrics , Reference < TLSPolicy > tlsPolicy , const TLSParams & tlsParams ) <nl> + Net2 : : Net2 ( const TLSConfig & tlsConfig , bool useThreadPool , bool useMetrics ) <nl> : useThreadPool ( useThreadPool ) , <nl> network ( this ) , <nl> reactor ( this ) , <nl> Net2 : : Net2 ( bool useThreadPool , bool useMetrics , Reference < TLSPolicy > tlsPolicy , <nl> lastMinTaskID ( TaskPriority : : Zero ) , <nl> numYields ( 0 ) , <nl> tlsInitialized ( false ) , <nl> - tlsPolicy ( tlsPolicy ) , <nl> - tlsParams ( tlsParams ) <nl> + tlsConfig ( tlsConfig ) <nl> # ifndef TLS_DISABLED <nl> - , sslContext ( boost : : asio : : ssl : : context ( boost : : asio : : ssl : : context : : tls ) ) <nl> + , sslContextVar ( { ReferencedObject < boost : : asio : : ssl : : context > : : from ( boost : : asio : : ssl : : context ( boost : : asio : : ssl : : context : : tls ) ) } ) <nl> # endif <nl> <nl> { <nl> Net2 : : Net2 ( bool useThreadPool , bool useMetrics , Reference < TLSPolicy > tlsPolicy , <nl> <nl> } <nl> <nl> - void Net2 : : initTLS ( ) { <nl> - if ( tlsInitialized ) { <nl> - return ; <nl> - } <nl> # ifndef TLS_DISABLED <nl> + void ConfigureSSLContext ( const LoadedTLSConfig & loaded , boost : : asio : : ssl : : context * context ) { <nl> try { <nl> - const char * defaultCertFileName = " fdb . pem " ; <nl> + context - > set_options ( boost : : asio : : ssl : : context : : default_workarounds ) ; <nl> + context - > set_verify_mode ( boost : : asio : : ssl : : context : : verify_peer | boost : : asio : : ssl : : verify_fail_if_no_peer_cert ) ; <nl> <nl> - if ( tlsPolicy & & ! tlsPolicy - > rules . size ( ) ) { <nl> - std : : string verify_peers ; <nl> - if ( platform : : getEnvironmentVar ( " FDB_TLS_VERIFY_PEERS " , verify_peers ) ) { <nl> - tlsPolicy - > set_verify_peers ( { verify_peers } ) ; <nl> - } else { <nl> - tlsPolicy - > set_verify_peers ( { std : : string ( " Check . Valid = 1 " ) } ) ; <nl> - } <nl> - } <nl> + if ( loaded . isTLSEnabled ( ) ) { <nl> + Reference < TLSPolicy > tlsPolicy = Reference < TLSPolicy > ( new TLSPolicy ( loaded . getEndpointType ( ) ) ) ; <nl> + tlsPolicy - > set_verify_peers ( { loaded . getVerifyPeers ( ) } ) ; <nl> <nl> - sslContext . set_options ( boost : : asio : : ssl : : context : : default_workarounds ) ; <nl> - sslContext . set_verify_mode ( boost : : asio : : ssl : : context : : verify_peer | boost : : asio : : ssl : : verify_fail_if_no_peer_cert ) ; <nl> - if ( tlsPolicy ) { <nl> - Reference < TLSPolicy > policy = tlsPolicy ; <nl> - sslContext . set_verify_callback ( [ policy ] ( bool preverified , boost : : asio : : ssl : : verify_context & ctx ) { <nl> - return policy - > verify_peer ( preverified , ctx . native_handle ( ) ) ; <nl> - } ) ; <nl> + context - > set_verify_callback ( [ policy = tlsPolicy ] ( bool preverified , boost : : asio : : ssl : : verify_context & ctx ) { <nl> + return policy - > verify_peer ( preverified , ctx . native_handle ( ) ) ; <nl> + } ) ; <nl> } else { <nl> - sslContext . set_verify_callback ( boost : : bind ( & insecurely_always_accept , _1 , _2 ) ) ; <nl> + context - > set_verify_callback ( boost : : bind ( & insecurely_always_accept , _1 , _2 ) ) ; <nl> } <nl> <nl> - if ( ! tlsParams . tlsPassword . size ( ) ) { <nl> - platform : : getEnvironmentVar ( " FDB_TLS_PASSWORD " , tlsParams . tlsPassword ) ; <nl> - } <nl> - sslContext . set_password_callback ( std : : bind ( & Net2 : : get_password , this ) ) ; <nl> + context - > set_password_callback ( <nl> + [ password = loaded . getPassword ( ) ] ( size_t , boost : : asio : : ssl : : context : : password_purpose ) { <nl> + return password ; <nl> + } ) ; <nl> <nl> - if ( tlsParams . tlsCertBytes . size ( ) ) { <nl> - sslContext . use_certificate_chain ( boost : : asio : : buffer ( tlsParams . tlsCertBytes . data ( ) , tlsParams . tlsCertBytes . size ( ) ) ) ; <nl> + const std : : string & certBytes = loaded . getCertificateBytes ( ) ; <nl> + if ( certBytes . size ( ) ) { <nl> + context - > use_certificate_chain ( boost : : asio : : buffer ( certBytes . data ( ) , certBytes . size ( ) ) ) ; <nl> } <nl> - else { <nl> - if ( ! tlsParams . tlsCertPath . size ( ) ) { <nl> - if ( ! platform : : getEnvironmentVar ( " FDB_TLS_CERTIFICATE_FILE " , tlsParams . tlsCertPath ) ) { <nl> - if ( fileExists ( defaultCertFileName ) ) { <nl> - tlsParams . tlsCertPath = defaultCertFileName ; <nl> - } else if ( fileExists ( joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ) ) { <nl> - tlsParams . tlsCertPath = joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ; <nl> - } <nl> - } <nl> - } <nl> - if ( tlsParams . tlsCertPath . size ( ) ) { <nl> - sslContext . use_certificate_chain_file ( tlsParams . tlsCertPath ) ; <nl> - } <nl> + <nl> + const std : : string & CABytes = loaded . getCABytes ( ) ; <nl> + if ( CABytes . size ( ) ) { <nl> + context - > add_certificate_authority ( boost : : asio : : buffer ( CABytes . data ( ) , CABytes . size ( ) ) ) ; <nl> } <nl> <nl> - if ( tlsParams . tlsCABytes . size ( ) ) { <nl> - sslContext . add_certificate_authority ( boost : : asio : : buffer ( tlsParams . tlsCABytes . data ( ) , tlsParams . tlsCABytes . size ( ) ) ) ; <nl> + const std : : string & keyBytes = loaded . getKeyBytes ( ) ; <nl> + if ( keyBytes . size ( ) ) { <nl> + context - > use_private_key ( boost : : asio : : buffer ( keyBytes . data ( ) , keyBytes . size ( ) ) , boost : : asio : : ssl : : context : : pem ) ; <nl> } <nl> - else { <nl> - if ( ! tlsParams . tlsCAPath . size ( ) ) { <nl> - platform : : getEnvironmentVar ( " FDB_TLS_CA_FILE " , tlsParams . tlsCAPath ) ; <nl> + } catch ( boost : : system : : system_error & e ) { <nl> + TraceEvent ( " TLSConfigureError " ) . detail ( " What " , e . what ( ) ) . detail ( " Value " , e . code ( ) . value ( ) ) . detail ( " WhichMeans " , TLSPolicy : : ErrorString ( e . code ( ) ) ) ; <nl> + throw tls_error ( ) ; <nl> + } <nl> + } <nl> + <nl> + ACTOR static Future < Void > watchFileForChanges ( std : : string filename , AsyncTrigger * fileChanged ) { <nl> + if ( filename = = " " ) { <nl> + return Never ( ) ; <nl> + } <nl> + state std : : time_t lastModTime = wait ( IAsyncFileSystem : : filesystem ( ) - > lastWriteTime ( filename ) ) ; <nl> + loop { <nl> + wait ( delay ( FLOW_KNOBS - > TLS_CERT_REFRESH_DELAY_SECONDS ) ) ; <nl> + try { <nl> + std : : time_t modtime = wait ( IAsyncFileSystem : : filesystem ( ) - > lastWriteTime ( filename ) ) ; <nl> + if ( lastModTime ! = modtime ) { <nl> + lastModTime = modtime ; <nl> + fileChanged - > trigger ( ) ; <nl> } <nl> - if ( tlsParams . tlsCAPath . size ( ) ) { <nl> - try { <nl> - std : : string cert = readFileBytes ( tlsParams . tlsCAPath , FLOW_KNOBS - > CERT_FILE_MAX_SIZE ) ; <nl> - sslContext . add_certificate_authority ( boost : : asio : : buffer ( cert . data ( ) , cert . size ( ) ) ) ; <nl> - } <nl> - catch ( Error & e ) { <nl> - TraceEvent ( " Net2TLSReadCAError " ) . error ( e ) . detail ( " CAPath " , tlsParams . tlsCAPath ) ; <nl> - throw tls_error ( ) ; <nl> - } <nl> + } catch ( Error & e ) { <nl> + if ( e . code ( ) = = error_code_io_error ) { <nl> + / / EACCES , ELOOP , ENOENT all come out as io_error ( ) , but are more of a system <nl> + / / configuration issue than an FDB problem . If we managed to load valid <nl> + / / certificates , then there ' s no point in crashing , but we should complain <nl> + / / loudly . IAsyncFile will log the error , but not necessarily as a warning . <nl> + TraceEvent ( SevWarnAlways , " TLSCertificateRefreshStatError " ) . detail ( " File " , filename ) ; <nl> + } else { <nl> + throw ; <nl> } <nl> } <nl> + } <nl> + } <nl> <nl> - if ( tlsParams . tlsKeyBytes . size ( ) ) { <nl> - sslContext . use_private_key ( boost : : asio : : buffer ( tlsParams . tlsKeyBytes . data ( ) , tlsParams . tlsKeyBytes . size ( ) ) , boost : : asio : : ssl : : context : : pem ) ; <nl> - } else { <nl> - if ( ! tlsParams . tlsKeyPath . size ( ) ) { <nl> - if ( ! platform : : getEnvironmentVar ( " FDB_TLS_KEY_FILE " , tlsParams . tlsKeyPath ) ) { <nl> - if ( fileExists ( defaultCertFileName ) ) { <nl> - tlsParams . tlsKeyPath = defaultCertFileName ; <nl> - } else if ( fileExists ( joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ) ) { <nl> - tlsParams . tlsKeyPath = joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ; <nl> - } <nl> - } <nl> - } <nl> - if ( tlsParams . tlsKeyPath . size ( ) ) { <nl> - sslContext . use_private_key_file ( tlsParams . tlsKeyPath , boost : : asio : : ssl : : context : : pem ) ; <nl> + ACTOR static Future < Void > reloadCertificatesOnChange ( TLSConfig config , AsyncVar < Reference < ReferencedObject < boost : : asio : : ssl : : context > > > * contextVar ) { <nl> + if ( FLOW_KNOBS - > TLS_CERT_REFRESH_DELAY_SECONDS < = 0 ) { <nl> + return Void ( ) ; <nl> + } <nl> + loop { <nl> + / / Early in bootup , the filesystem might not be initialized yet . Wait until it is . <nl> + if ( IAsyncFileSystem : : filesystem ( ) ! = nullptr ) { <nl> + break ; <nl> + } <nl> + wait ( delay ( 1 . 0 ) ) ; <nl> + } <nl> + state int mismatches = 0 ; <nl> + state AsyncTrigger fileChanged ; <nl> + state std : : vector < Future < Void > > lifetimes ; <nl> + lifetimes . push_back ( watchFileForChanges ( config . getCertificatePathSync ( ) , & fileChanged ) ) ; <nl> + lifetimes . push_back ( watchFileForChanges ( config . getKeyPathSync ( ) , & fileChanged ) ) ; <nl> + lifetimes . push_back ( watchFileForChanges ( config . getCAPathSync ( ) , & fileChanged ) ) ; <nl> + loop { <nl> + wait ( fileChanged . onTrigger ( ) ) ; <nl> + TraceEvent ( " TLSCertificateRefreshBegin " ) ; <nl> + <nl> + try { <nl> + LoadedTLSConfig loaded = wait ( config . loadAsync ( ) ) ; <nl> + boost : : asio : : ssl : : context context ( boost : : asio : : ssl : : context : : tls ) ; <nl> + ConfigureSSLContext ( loaded , & context ) ; <nl> + TraceEvent ( SevInfo , " TLSCertificateRefreshSucceeded " ) ; <nl> + mismatches = 0 ; <nl> + contextVar - > set ( ReferencedObject < boost : : asio : : ssl : : context > : : from ( std : : move ( context ) ) ) ; <nl> + } catch ( Error & e ) { <nl> + if ( e . code ( ) = = error_code_actor_cancelled ) { <nl> + throw ; <nl> } <nl> + / / Some files didn ' t match up , they should in the future , and we ' ll retry then . <nl> + mismatches + + ; <nl> + TraceEvent ( SevWarn , " TLSCertificateRefreshMismatch " ) . error ( e ) . detail ( " mismatches " , mismatches ) ; <nl> } <nl> - } catch ( boost : : system : : system_error e ) { <nl> - TraceEvent ( " Net2TLSInitError " ) . detail ( " Message " , e . what ( ) ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> + void Net2 : : initTLS ( ) { <nl> + if ( tlsInitialized ) { <nl> + return ; <nl> + } <nl> + # ifndef TLS_DISABLED <nl> + try { <nl> + boost : : asio : : ssl : : context newContext ( boost : : asio : : ssl : : context : : tls ) ; <nl> + ConfigureSSLContext ( tlsConfig . loadSync ( ) , & newContext ) ; <nl> + sslContextVar . set ( ReferencedObject < boost : : asio : : ssl : : context > : : from ( std : : move ( newContext ) ) ) ; <nl> + backgroundCertRefresh = reloadCertificatesOnChange ( tlsConfig , & sslContextVar ) ; <nl> + } catch ( Error & e ) { <nl> + TraceEvent ( " Net2TLSInitError " ) . error ( e ) ; <nl> throw tls_error ( ) ; <nl> } <nl> # endif <nl> Future < Reference < IConnection > > Net2 : : connect ( NetworkAddress toAddr , std : : stri <nl> # ifndef TLS_DISABLED <nl> initTLS ( ) ; <nl> if ( toAddr . isTLS ( ) ) { <nl> - return SSLConnection : : connect ( & this - > reactor . ios , & this - > sslContext , toAddr ) ; <nl> + return SSLConnection : : connect ( & this - > reactor . ios , this - > sslContextVar . get ( ) , toAddr ) ; <nl> } <nl> # endif <nl> <nl> Reference < IListener > Net2 : : listen ( NetworkAddress localAddr ) { <nl> # ifndef TLS_DISABLED <nl> initTLS ( ) ; <nl> if ( localAddr . isTLS ( ) ) { <nl> - return Reference < IListener > ( new SSLListener ( reactor . ios , & this - > sslContext , localAddr ) ) ; <nl> + return Reference < IListener > ( new SSLListener ( reactor . ios , & this - > sslContextVar , localAddr ) ) ; <nl> } <nl> # endif <nl> return Reference < IListener > ( new Listener ( reactor . ios , localAddr ) ) ; <nl> void ASIOReactor : : wake ( ) { <nl> <nl> } / / namespace net2 <nl> <nl> - INetwork * newNet2 ( bool useThreadPool , bool useMetrics , Reference < TLSPolicy > policy , const TLSParams & tlsParams ) { <nl> + INetwork * newNet2 ( const TLSConfig & tlsConfig , bool useThreadPool , bool useMetrics ) { <nl> try { <nl> - N2 : : g_net2 = new N2 : : Net2 ( useThreadPool , useMetrics , policy , tlsParams ) ; <nl> + N2 : : g_net2 = new N2 : : Net2 ( tlsConfig , useThreadPool , useMetrics ) ; <nl> } <nl> catch ( boost : : system : : system_error e ) { <nl> TraceEvent ( " Net2InitError " ) . detail ( " Message " , e . what ( ) ) ; <nl> similarity index 75 % <nl> rename from flow / TLSPolicy . cpp <nl> rename to flow / TLSConfig . actor . cpp <nl> mmm a / flow / TLSPolicy . cpp <nl> ppp b / flow / TLSConfig . actor . cpp <nl> <nl> / * <nl> - * TLSPolicy . cpp <nl> + * TLSConfig . actor . cpp <nl> * <nl> * This source file is part of the FoundationDB open source project <nl> * <nl> <nl> * limitations under the License . <nl> * / <nl> <nl> - # include " flow / TLSPolicy . h " <nl> + # define PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP public <nl> + # include " flow / TLSConfig . actor . h " <nl> + # undef PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP <nl> <nl> + / / To force typeinfo to only be emitted once . <nl> TLSPolicy : : ~ TLSPolicy ( ) { } <nl> <nl> # ifndef TLS_DISABLED <nl> TLSPolicy : : ~ TLSPolicy ( ) { } <nl> # include < string > <nl> # include < sstream > <nl> # include < utility > <nl> + # include < boost / asio / ssl / context . hpp > <nl> + <nl> + / / This include breaks module dependencies , but we need to do async file reads . <nl> + / / So either we include fdbrpc here , or this file is moved to fdbrpc / , and then <nl> + / / Net2 , which depends on us , includes fdbrpc / . <nl> + / / <nl> + / / Either way , the only way to break this dependency cycle is to move all of <nl> + / / AsyncFile to flow / <nl> + # include " fdbrpc / IAsyncFile . h " <nl> + # include " flow / Platform . h " <nl> <nl> # include " flow / FastRef . h " <nl> # include " flow / Trace . h " <nl> + # include " flow / genericactors . actor . h " <nl> + # include " flow / actorcompiler . h " / / This must be the last # include . <nl> + <nl> + <nl> + std : : vector < std : : string > LoadedTLSConfig : : getVerifyPeers ( ) const { <nl> + if ( tlsVerifyPeers . size ( ) ) { <nl> + return tlsVerifyPeers ; <nl> + } <nl> + <nl> + std : : string envVerifyPeers ; <nl> + if ( platform : : getEnvironmentVar ( " FDB_TLS_VERIFY_PEERS " , envVerifyPeers ) ) { <nl> + return { envVerifyPeers } ; <nl> + } <nl> + <nl> + return { " Check . Valid = 1 " } ; <nl> + } <nl> + <nl> + std : : string LoadedTLSConfig : : getPassword ( ) const { <nl> + if ( tlsPassword . size ( ) ) { <nl> + return tlsPassword ; <nl> + } <nl> + <nl> + std : : string envPassword ; <nl> + platform : : getEnvironmentVar ( " FDB_TLS_PASSWORD " , envPassword ) ; <nl> + return envPassword ; <nl> + } <nl> + <nl> + std : : string TLSConfig : : getCertificatePathSync ( ) const { <nl> + if ( tlsCertPath . size ( ) ) { <nl> + return tlsCertPath ; <nl> + } <nl> + <nl> + std : : string envCertPath ; <nl> + if ( platform : : getEnvironmentVar ( " FDB_TLS_CERTIFICATE_FILE " , envCertPath ) ) { <nl> + return envCertPath ; <nl> + } <nl> + <nl> + const char * defaultCertFileName = " fdb . pem " ; <nl> + if ( fileExists ( defaultCertFileName ) ) { <nl> + return defaultCertFileName ; <nl> + } <nl> + <nl> + if ( fileExists ( joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ) ) { <nl> + return joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ; <nl> + } <nl> + <nl> + return std : : string ( ) ; <nl> + } <nl> + <nl> + std : : string TLSConfig : : getKeyPathSync ( ) const { <nl> + if ( tlsKeyPath . size ( ) ) { <nl> + return tlsKeyPath ; <nl> + } <nl> + <nl> + std : : string envKeyPath ; <nl> + if ( platform : : getEnvironmentVar ( " FDB_TLS_KEY_FILE " , envKeyPath ) ) { <nl> + return envKeyPath ; <nl> + } <nl> + <nl> + const char * defaultCertFileName = " fdb . pem " ; <nl> + if ( fileExists ( defaultCertFileName ) ) { <nl> + return defaultCertFileName ; <nl> + } <nl> + <nl> + if ( fileExists ( joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ) ) { <nl> + return joinPath ( platform : : getDefaultConfigPath ( ) , defaultCertFileName ) ; <nl> + } <nl> + <nl> + return std : : string ( ) ; <nl> + } <nl> + <nl> + std : : string TLSConfig : : getCAPathSync ( ) const { <nl> + if ( tlsCAPath . size ( ) ) { <nl> + return tlsCAPath ; <nl> + } <nl> + <nl> + std : : string envCAPath ; <nl> + platform : : getEnvironmentVar ( " FDB_TLS_CA_FILE " , envCAPath ) ; <nl> + return envCAPath ; <nl> + } <nl> + <nl> + LoadedTLSConfig TLSConfig : : loadSync ( ) const { <nl> + LoadedTLSConfig loaded ; <nl> + <nl> + const std : : string certPath = getCertificatePathSync ( ) ; <nl> + if ( certPath . size ( ) ) { <nl> + loaded . tlsCertBytes = readFileBytes ( certPath , FLOW_KNOBS - > CERT_FILE_MAX_SIZE ) ; <nl> + } else { <nl> + loaded . tlsCertBytes = tlsCertBytes ; <nl> + } <nl> + <nl> + const std : : string keyPath = getKeyPathSync ( ) ; <nl> + if ( keyPath . size ( ) ) { <nl> + loaded . tlsKeyBytes = readFileBytes ( keyPath , FLOW_KNOBS - > CERT_FILE_MAX_SIZE ) ; <nl> + } else { <nl> + loaded . tlsKeyBytes = tlsKeyBytes ; <nl> + } <nl> + <nl> + const std : : string CAPath = getCAPathSync ( ) ; <nl> + if ( CAPath . size ( ) ) { <nl> + loaded . tlsCABytes = readFileBytes ( CAPath , FLOW_KNOBS - > CERT_FILE_MAX_SIZE ) ; <nl> + } else { <nl> + loaded . tlsCABytes = tlsCABytes ; <nl> + } <nl> + <nl> + loaded . tlsPassword = tlsPassword ; <nl> + loaded . tlsVerifyPeers = tlsVerifyPeers ; <nl> + loaded . endpointType = endpointType ; <nl> + <nl> + return loaded ; <nl> + } <nl> + <nl> + / / And now do the same thing , but async . . . <nl> + <nl> + ACTOR static Future < Void > readEntireFile ( std : : string filename , std : : string * destination ) { <nl> + state Reference < IAsyncFile > file = wait ( IAsyncFileSystem : : filesystem ( ) - > open ( filename , IAsyncFile : : OPEN_READONLY | IAsyncFile : : OPEN_UNCACHED , 0 ) ) ; <nl> + state int64_t filesize = wait ( file - > size ( ) ) ; <nl> + if ( filesize > FLOW_KNOBS - > CERT_FILE_MAX_SIZE ) { <nl> + throw file_too_large ( ) ; <nl> + } <nl> + destination - > resize ( filesize ) ; <nl> + wait ( success ( file - > read ( const_cast < char * > ( destination - > c_str ( ) ) , filesize , 0 ) ) ) ; <nl> + return Void ( ) ; <nl> + } <nl> + <nl> + ACTOR Future < LoadedTLSConfig > TLSConfig : : loadAsync ( const TLSConfig * self ) { <nl> + state LoadedTLSConfig loaded ; <nl> + state std : : vector < Future < Void > > reads ; <nl> + <nl> + const std : : string & certPath = self - > getCertificatePathSync ( ) ; <nl> + if ( certPath . size ( ) ) { <nl> + reads . push_back ( readEntireFile ( certPath , & loaded . tlsCertBytes ) ) ; <nl> + } else { <nl> + loaded . tlsCertBytes = self - > tlsCertBytes ; <nl> + } <nl> + <nl> + const std : : string & keyPath = self - > getKeyPathSync ( ) ; <nl> + if ( keyPath . size ( ) ) { <nl> + reads . push_back ( readEntireFile ( keyPath , & loaded . tlsKeyBytes ) ) ; <nl> + } else { <nl> + loaded . tlsKeyBytes = self - > tlsKeyBytes ; <nl> + } <nl> + <nl> + const std : : string & CAPath = self - > getCAPathSync ( ) ; <nl> + if ( CAPath . size ( ) ) { <nl> + reads . push_back ( readEntireFile ( CAPath , & loaded . tlsCABytes ) ) ; <nl> + } else { <nl> + loaded . tlsCABytes = self - > tlsKeyBytes ; <nl> + } <nl> + <nl> + wait ( waitForAll ( reads ) ) ; <nl> + <nl> + loaded . tlsPassword = self - > tlsPassword ; <nl> + loaded . tlsVerifyPeers = self - > tlsVerifyPeers ; <nl> + loaded . endpointType = self - > endpointType ; <nl> + <nl> + return loaded ; <nl> + } <nl> <nl> std : : string TLSPolicy : : ErrorString ( boost : : system : : error_code e ) { <nl> char * str = ERR_error_string ( e . value ( ) , NULL ) ; <nl> return std : : string ( str ) ; <nl> } <nl> <nl> - / / To force typeinfo to only be emitted once . <nl> - <nl> - <nl> std : : string TLSPolicy : : toString ( ) const { <nl> std : : stringstream ss ; <nl> ss < < " TLSPolicy { Rules = [ " ; <nl> new file mode 100644 <nl> index 0000000000 . . 667a6f2822 <nl> mmm / dev / null <nl> ppp b / flow / TLSConfig . actor . h <nl> <nl> + / * <nl> + * TLSConfig . actor . h <nl> + * <nl> + * This source file is part of the FoundationDB open source project <nl> + * <nl> + * Copyright 2013 - 2020 Apple Inc . and the FoundationDB project authors <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * / <nl> + <nl> + / / When actually compiled ( NO_INTELLISENSE ) , include the generated version of this file . In intellisense use the source version . <nl> + # if defined ( NO_INTELLISENSE ) & & ! defined ( FLOW_TLS_CONFIG_ACTOR_G_H ) <nl> + # define FLOW_TLS_CONFIG_ACTOR_G_H <nl> + # include " flow / TLSConfig . actor . g . h " <nl> + # elif ! defined ( FLOW_TLS_CONFIG_ACTOR_H ) <nl> + # define FLOW_TLS_CONFIG_ACTOR_H <nl> + <nl> + # pragma once <nl> + <nl> + # include < map > <nl> + # include < string > <nl> + # include < vector > <nl> + # include < boost / system / system_error . hpp > <nl> + # include " flow / FastRef . h " <nl> + # include " flow / Knobs . h " <nl> + # include " flow / flow . h " <nl> + <nl> + # ifndef TLS_DISABLED <nl> + <nl> + # include < openssl / x509 . h > <nl> + typedef int NID ; <nl> + <nl> + enum class MatchType { <nl> + EXACT , <nl> + PREFIX , <nl> + SUFFIX , <nl> + } ; <nl> + <nl> + enum class X509Location { <nl> + / / This NID is located within a X509_NAME <nl> + NAME , <nl> + / / This NID is an X509 extension , and should be parsed accordingly <nl> + EXTENSION , <nl> + } ; <nl> + <nl> + struct Criteria { <nl> + Criteria ( const std : : string & s ) <nl> + : criteria ( s ) , match_type ( MatchType : : EXACT ) , location ( X509Location : : NAME ) { } <nl> + Criteria ( const std : : string & s , MatchType mt ) <nl> + : criteria ( s ) , match_type ( mt ) , location ( X509Location : : NAME ) { } <nl> + Criteria ( const std : : string & s , X509Location loc ) <nl> + : criteria ( s ) , match_type ( MatchType : : EXACT ) , location ( loc ) { } <nl> + Criteria ( const std : : string & s , MatchType mt , X509Location loc ) <nl> + : criteria ( s ) , match_type ( mt ) , location ( loc ) { } <nl> + <nl> + std : : string criteria ; <nl> + MatchType match_type ; <nl> + X509Location location ; <nl> + <nl> + bool operator = = ( const Criteria & c ) const { <nl> + return criteria = = c . criteria & & match_type = = c . match_type & & location = = c . location ; <nl> + } <nl> + } ; <nl> + # endif <nl> + <nl> + # include " flow / actorcompiler . h " / / This must be the last # include . <nl> + <nl> + enum class TLSEndpointType { <nl> + UNSET = 0 , <nl> + CLIENT , <nl> + SERVER <nl> + } ; <nl> + <nl> + class TLSConfig ; <nl> + template < typename T > class LoadAsyncActorState ; <nl> + / / TODO : Remove this once this code is merged with master / to - be 7 . 0 and actors can access private variables . <nl> + # ifndef PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP <nl> + # define PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP private <nl> + # endif <nl> + <nl> + class LoadedTLSConfig { <nl> + public : <nl> + std : : string getCertificateBytes ( ) const { <nl> + return tlsCertBytes ; <nl> + } <nl> + <nl> + std : : string getKeyBytes ( ) const { <nl> + return tlsKeyBytes ; <nl> + } <nl> + <nl> + std : : string getCABytes ( ) const { <nl> + return tlsCABytes ; <nl> + } <nl> + <nl> + / / Return the explicitly set verify peers string . <nl> + / / If no verify peers string was set , return the environment setting <nl> + / / If no environment setting exists , return " Check . Valid = 1 " <nl> + std : : vector < std : : string > getVerifyPeers ( ) const ; <nl> + <nl> + / / Return the explicitly set password . <nl> + / / If no password was set , return the environment setting <nl> + / / If no environment setting exists , return an empty string <nl> + std : : string getPassword ( ) const ; <nl> + <nl> + TLSEndpointType getEndpointType ( ) const { <nl> + return endpointType ; <nl> + } <nl> + <nl> + bool isTLSEnabled ( ) const { <nl> + return endpointType ! = TLSEndpointType : : UNSET ; <nl> + } <nl> + <nl> + PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP : <nl> + std : : string tlsCertBytes , tlsKeyBytes , tlsCABytes ; <nl> + std : : string tlsPassword ; <nl> + std : : vector < std : : string > tlsVerifyPeers ; <nl> + TLSEndpointType endpointType = TLSEndpointType : : UNSET ; <nl> + <nl> + friend class TLSConfig ; <nl> + template < typename T > <nl> + friend class LoadAsyncActorState ; <nl> + } ; <nl> + <nl> + class TLSConfig { <nl> + public : <nl> + enum { OPT_TLS = 100000 , OPT_TLS_PLUGIN , OPT_TLS_CERTIFICATES , OPT_TLS_KEY , OPT_TLS_VERIFY_PEERS , OPT_TLS_CA_FILE , OPT_TLS_PASSWORD } ; <nl> + <nl> + TLSConfig ( ) = default ; <nl> + explicit TLSConfig ( TLSEndpointType endpointType ) <nl> + : endpointType ( endpointType ) { <nl> + } <nl> + <nl> + void setCertificatePath ( const std : : string & path ) { <nl> + tlsCertPath = path ; <nl> + tlsCertBytes = " " ; <nl> + } <nl> + <nl> + void setCertificateBytes ( const std : : string & bytes ) { <nl> + tlsCertBytes = bytes ; <nl> + tlsCertPath = " " ; <nl> + } <nl> + <nl> + void setKeyPath ( const std : : string & path ) { <nl> + tlsKeyPath = path ; <nl> + tlsKeyBytes = " " ; <nl> + } <nl> + <nl> + void setKeyBytes ( const std : : string & bytes ) { <nl> + tlsKeyBytes = bytes ; <nl> + tlsKeyPath = " " ; <nl> + } <nl> + <nl> + void setCAPath ( const std : : string & path ) { <nl> + tlsCAPath = path ; <nl> + tlsCABytes = " " ; <nl> + } <nl> + <nl> + void setCABytes ( const std : : string & bytes ) { <nl> + tlsCABytes = bytes ; <nl> + tlsCAPath = " " ; <nl> + } <nl> + <nl> + void setPassword ( const std : : string & password ) { <nl> + tlsPassword = password ; <nl> + } <nl> + <nl> + void clearVerifyPeers ( ) { <nl> + tlsVerifyPeers . clear ( ) ; <nl> + } <nl> + <nl> + void addVerifyPeers ( const std : : string & verifyPeers ) { <nl> + tlsVerifyPeers . push_back ( verifyPeers ) ; <nl> + } <nl> + <nl> + / / Load all specified certificates into memory , and return an object that <nl> + / / allows access to them . <nl> + / / If self has any certificates by path , they will be * synchronously * loaded from disk . <nl> + LoadedTLSConfig loadSync ( ) const ; <nl> + <nl> + / / Load all specified certificates into memory , and return an object that <nl> + / / allows access to them . <nl> + / / If self has any certificates by path , they will be * asynchronously * loaded from disk . <nl> + Future < LoadedTLSConfig > loadAsync ( ) const { <nl> + return loadAsync ( this ) ; <nl> + } <nl> + <nl> + / / Return the explicitly set path . <nl> + / / If one was not set , return the path from the environment . <nl> + / / ( Cert and Key only ) If neither exist , check for fdb . pem in cwd <nl> + / / ( Cert and Key only ) If fdb . pem doesn ' t exist , check for it in default config dir <nl> + / / Otherwise return the empty string . <nl> + / / Theoretically , fileExists ( ) can block , so these functions are labelled as synchronous <nl> + / / TODO : make an easy to use Future < bool > fileExists , and port lots of code over to it . <nl> + std : : string getCertificatePathSync ( ) const ; <nl> + std : : string getKeyPathSync ( ) const ; <nl> + std : : string getCAPathSync ( ) const ; <nl> + <nl> + PRIVATE_EXCEPT_FOR_TLSCONFIG_CPP : <nl> + ACTOR static Future < LoadedTLSConfig > loadAsync ( const TLSConfig * self ) ; <nl> + template < typename T > <nl> + friend class LoadAsyncActorState ; <nl> + <nl> + std : : string tlsCertPath , tlsKeyPath , tlsCAPath ; <nl> + std : : string tlsCertBytes , tlsKeyBytes , tlsCABytes ; <nl> + std : : string tlsPassword ; <nl> + std : : vector < std : : string > tlsVerifyPeers ; <nl> + TLSEndpointType endpointType = TLSEndpointType : : UNSET ; <nl> + } ; <nl> + <nl> + class TLSPolicy : ReferenceCounted < TLSPolicy > { <nl> + public : <nl> + <nl> + TLSPolicy ( TLSEndpointType client ) : is_client ( client = = TLSEndpointType : : CLIENT ) { } <nl> + virtual ~ TLSPolicy ( ) ; <nl> + <nl> + virtual void addref ( ) { ReferenceCounted < TLSPolicy > : : addref ( ) ; } <nl> + virtual void delref ( ) { ReferenceCounted < TLSPolicy > : : delref ( ) ; } <nl> + <nl> + # ifndef TLS_DISABLED <nl> + static std : : string ErrorString ( boost : : system : : error_code e ) ; <nl> + <nl> + void set_verify_peers ( std : : vector < std : : string > verify_peers ) ; <nl> + bool verify_peer ( bool preverified , X509_STORE_CTX * store_ctx ) ; <nl> + <nl> + std : : string toString ( ) const ; <nl> + <nl> + struct Rule { <nl> + explicit Rule ( std : : string input ) ; <nl> + <nl> + std : : string toString ( ) const ; <nl> + <nl> + std : : map < NID , Criteria > subject_criteria ; <nl> + std : : map < NID , Criteria > issuer_criteria ; <nl> + std : : map < NID , Criteria > root_criteria ; <nl> + <nl> + bool verify_cert = true ; <nl> + bool verify_time = true ; <nl> + } ; <nl> + <nl> + std : : vector < Rule > rules ; <nl> + # endif <nl> + bool is_client ; <nl> + } ; <nl> + <nl> + # define TLS_PLUGIN_FLAG " - - tls_plugin " <nl> + # define TLS_CERTIFICATE_FILE_FLAG " - - tls_certificate_file " <nl> + # define TLS_KEY_FILE_FLAG " - - tls_key_file " <nl> + # define TLS_VERIFY_PEERS_FLAG " - - tls_verify_peers " <nl> + # define TLS_CA_FILE_FLAG " - - tls_ca_file " <nl> + # define TLS_PASSWORD_FLAG " - - tls_password " <nl> + <nl> + # define TLS_OPTION_FLAGS \ <nl> + { TLSConfig : : OPT_TLS_PLUGIN , TLS_PLUGIN_FLAG , SO_REQ_SEP } , \ <nl> + { TLSConfig : : OPT_TLS_CERTIFICATES , TLS_CERTIFICATE_FILE_FLAG , SO_REQ_SEP } , \ <nl> + { TLSConfig : : OPT_TLS_KEY , TLS_KEY_FILE_FLAG , SO_REQ_SEP } , \ <nl> + { TLSConfig : : OPT_TLS_VERIFY_PEERS , TLS_VERIFY_PEERS_FLAG , SO_REQ_SEP } , \ <nl> + { TLSConfig : : OPT_TLS_PASSWORD , TLS_PASSWORD_FLAG , SO_REQ_SEP } , \ <nl> + { TLSConfig : : OPT_TLS_CA_FILE , TLS_CA_FILE_FLAG , SO_REQ_SEP } , <nl> + <nl> + # define TLS_HELP \ <nl> + " " TLS_CERTIFICATE_FILE_FLAG " CERTFILE \ n " \ <nl> + " The path of a file containing the TLS certificate and CA \ n " \ <nl> + " chain . \ n " \ <nl> + " " TLS_CA_FILE_FLAG " CERTAUTHFILE \ n " \ <nl> + " The path of a file containing the CA certificates chain . \ n " \ <nl> + " " TLS_KEY_FILE_FLAG " KEYFILE \ n " \ <nl> + " The path of a file containing the private key corresponding \ n " \ <nl> + " to the TLS certificate . \ n " \ <nl> + " " TLS_PASSWORD_FLAG " PASSCODE \ n " \ <nl> + " The passphrase of encrypted private key \ n " \ <nl> + " " TLS_VERIFY_PEERS_FLAG " CONSTRAINTS \ n " \ <nl> + " The constraints by which to validate TLS peers . The contents \ n " \ <nl> + " and format of CONSTRAINTS are plugin - specific . \ n " <nl> + <nl> + # include " flow / unactorcompiler . h " <nl> + # endif <nl> deleted file mode 100644 <nl> index 9a0ddfcfa9 . . 0000000000 <nl> mmm a / flow / TLSPolicy . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * TLSPolicy . h <nl> - * <nl> - * This source file is part of the FoundationDB open source project <nl> - * <nl> - * Copyright 2013 - 2020 Apple Inc . and the FoundationDB project authors <nl> - * <nl> - * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - * you may not use this file except in compliance with the License . <nl> - * You may obtain a copy of the License at <nl> - * <nl> - * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - * <nl> - * Unless required by applicable law or agreed to in writing , software <nl> - * distributed under the License is distributed on an " AS IS " BASIS , <nl> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - * See the License for the specific language governing permissions and <nl> - * limitations under the License . <nl> - * / <nl> - <nl> - # ifndef _FLOW_TLSPOLICY_H_ <nl> - # define _FLOW_TLSPOLICY_H_ <nl> - # pragma once <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < vector > <nl> - # include < boost / system / system_error . hpp > <nl> - # include " flow / FastRef . h " <nl> - <nl> - # ifndef TLS_DISABLED <nl> - <nl> - # include < openssl / x509 . h > <nl> - typedef int NID ; <nl> - <nl> - enum class MatchType { <nl> - EXACT , <nl> - PREFIX , <nl> - SUFFIX , <nl> - } ; <nl> - <nl> - enum class X509Location { <nl> - / / This NID is located within a X509_NAME <nl> - NAME , <nl> - / / This NID is an X509 extension , and should be parsed accordingly <nl> - EXTENSION , <nl> - } ; <nl> - <nl> - struct Criteria { <nl> - Criteria ( const std : : string & s ) <nl> - : criteria ( s ) , match_type ( MatchType : : EXACT ) , location ( X509Location : : NAME ) { } <nl> - Criteria ( const std : : string & s , MatchType mt ) <nl> - : criteria ( s ) , match_type ( mt ) , location ( X509Location : : NAME ) { } <nl> - Criteria ( const std : : string & s , X509Location loc ) <nl> - : criteria ( s ) , match_type ( MatchType : : EXACT ) , location ( loc ) { } <nl> - Criteria ( const std : : string & s , MatchType mt , X509Location loc ) <nl> - : criteria ( s ) , match_type ( mt ) , location ( loc ) { } <nl> - <nl> - std : : string criteria ; <nl> - MatchType match_type ; <nl> - X509Location location ; <nl> - <nl> - bool operator = = ( const Criteria & c ) const { <nl> - return criteria = = c . criteria & & match_type = = c . match_type & & location = = c . location ; <nl> - } <nl> - } ; <nl> - # endif <nl> - <nl> - struct TLSParams { <nl> - enum { OPT_TLS = 100000 , OPT_TLS_PLUGIN , OPT_TLS_CERTIFICATES , OPT_TLS_KEY , OPT_TLS_VERIFY_PEERS , OPT_TLS_CA_FILE , OPT_TLS_PASSWORD } ; <nl> - <nl> - std : : string tlsCertPath , tlsKeyPath , tlsCAPath , tlsPassword ; <nl> - std : : string tlsCertBytes , tlsKeyBytes , tlsCABytes ; <nl> - } ; <nl> - <nl> - class TLSPolicy : ReferenceCounted < TLSPolicy > { <nl> - public : <nl> - enum class Is { <nl> - CLIENT , <nl> - SERVER <nl> - } ; <nl> - <nl> - TLSPolicy ( Is client ) : is_client ( client = = Is : : CLIENT ) { } <nl> - virtual ~ TLSPolicy ( ) ; <nl> - <nl> - virtual void addref ( ) { ReferenceCounted < TLSPolicy > : : addref ( ) ; } <nl> - virtual void delref ( ) { ReferenceCounted < TLSPolicy > : : delref ( ) ; } <nl> - <nl> - # ifndef TLS_DISABLED <nl> - static std : : string ErrorString ( boost : : system : : error_code e ) ; <nl> - <nl> - void set_verify_peers ( std : : vector < std : : string > verify_peers ) ; <nl> - bool verify_peer ( bool preverified , X509_STORE_CTX * store_ctx ) ; <nl> - <nl> - std : : string toString ( ) const ; <nl> - <nl> - struct Rule { <nl> - explicit Rule ( std : : string input ) ; <nl> - <nl> - std : : string toString ( ) const ; <nl> - <nl> - std : : map < NID , Criteria > subject_criteria ; <nl> - std : : map < NID , Criteria > issuer_criteria ; <nl> - std : : map < NID , Criteria > root_criteria ; <nl> - <nl> - bool verify_cert = true ; <nl> - bool verify_time = true ; <nl> - } ; <nl> - <nl> - std : : vector < Rule > rules ; <nl> - # endif <nl> - bool is_client ; <nl> - } ; <nl> - <nl> - # define TLS_PLUGIN_FLAG " - - tls_plugin " <nl> - # define TLS_CERTIFICATE_FILE_FLAG " - - tls_certificate_file " <nl> - # define TLS_KEY_FILE_FLAG " - - tls_key_file " <nl> - # define TLS_VERIFY_PEERS_FLAG " - - tls_verify_peers " <nl> - # define TLS_CA_FILE_FLAG " - - tls_ca_file " <nl> - # define TLS_PASSWORD_FLAG " - - tls_password " <nl> - <nl> - # define TLS_OPTION_FLAGS \ <nl> - { TLSParams : : OPT_TLS_PLUGIN , TLS_PLUGIN_FLAG , SO_REQ_SEP } , \ <nl> - { TLSParams : : OPT_TLS_CERTIFICATES , TLS_CERTIFICATE_FILE_FLAG , SO_REQ_SEP } , \ <nl> - { TLSParams : : OPT_TLS_KEY , TLS_KEY_FILE_FLAG , SO_REQ_SEP } , \ <nl> - { TLSParams : : OPT_TLS_VERIFY_PEERS , TLS_VERIFY_PEERS_FLAG , SO_REQ_SEP } , \ <nl> - { TLSParams : : OPT_TLS_PASSWORD , TLS_PASSWORD_FLAG , SO_REQ_SEP } , \ <nl> - { TLSParams : : OPT_TLS_CA_FILE , TLS_CA_FILE_FLAG , SO_REQ_SEP } , <nl> - <nl> - # define TLS_HELP \ <nl> - " " TLS_CERTIFICATE_FILE_FLAG " CERTFILE \ n " \ <nl> - " The path of a file containing the TLS certificate and CA \ n " \ <nl> - " chain . \ n " \ <nl> - " " TLS_CA_FILE_FLAG " CERTAUTHFILE \ n " \ <nl> - " The path of a file containing the CA certificates chain . \ n " \ <nl> - " " TLS_KEY_FILE_FLAG " KEYFILE \ n " \ <nl> - " The path of a file containing the private key corresponding \ n " \ <nl> - " to the TLS certificate . \ n " \ <nl> - " " TLS_PASSWORD_FLAG " PASSCODE \ n " \ <nl> - " The passphrase of encrypted private key \ n " \ <nl> - " " TLS_VERIFY_PEERS_FLAG " CONSTRAINTS \ n " \ <nl> - " The constraints by which to validate TLS peers . The contents \ n " \ <nl> - " and format of CONSTRAINTS are plugin - specific . \ n " <nl> - <nl> - # endif <nl> mmm a / flow / flow . vcxproj <nl> ppp b / flow / flow . vcxproj <nl> <nl> < ClCompile Include = " version . cpp " / > <nl> < ClCompile Include = " SignalSafeUnwind . cpp " / > <nl> < ClCompile Include = " serialize . cpp " / > <nl> - < ClCompile Include = " TLSPolicy . cpp " / > <nl> + < ActorCompiler Include = " TLSConfig . actor . cpp " / > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " CompressedInt . h " / > <nl> <nl> < ClInclude Include = " Platform . h " / > <nl> < ClInclude Include = " ThreadSafeQueue . h " / > <nl> < ClInclude Include = " Trace . h " / > <nl> - < ClInclude Include = " TLSPolicy . h " / > <nl> + < ActorCompiler Include = " TLSConfig . actor . h " > <nl> + < EnableCompile > false < / EnableCompile > <nl> + < / ActorCompiler > <nl> < ClInclude Include = " SignalSafeUnwind . h " / > <nl> < ClInclude Include = " UnitTest . h " / > <nl> < ActorCompiler Include = " ThreadHelper . actor . h " > <nl> mmm a / flow / genericactors . actor . h <nl> ppp b / flow / genericactors . actor . h <nl> class ReferencedObject : NonCopyable , public ReferenceCounted < ReferencedObject < V <nl> public : <nl> ReferencedObject ( ) : value ( ) { } <nl> ReferencedObject ( V const & v ) : value ( v ) { } <nl> + ReferencedObject ( V & & v ) : value ( std : : move ( v ) ) { } <nl> ReferencedObject ( ReferencedObject & & r ) : value ( std : : move ( r . value ) ) { } <nl> - void operator = ( ReferencedObject & & r ) { <nl> + <nl> + void operator = ( ReferencedObject & & r ) { <nl> value = std : : move ( r . value ) ; <nl> } <nl> <nl> class ReferencedObject : NonCopyable , public ReferenceCounted < ReferencedObject < V <nl> return value ; <nl> } <nl> <nl> - V & mutate ( ) const { <nl> + V & mutate ( ) { <nl> return value ; <nl> } <nl> <nl> class ReferencedObject : NonCopyable , public ReferenceCounted < ReferencedObject < V <nl> value = v ; <nl> } <nl> <nl> + void set ( V & & v ) { <nl> + value = std : : move ( v ) ; <nl> + } <nl> + <nl> static Reference < ReferencedObject < V > > from ( V const & v ) { <nl> return Reference < ReferencedObject < V > > ( new ReferencedObject < V > ( v ) ) ; <nl> } <nl> - <nl> + <nl> + static Reference < ReferencedObject < V > > from ( V & & v ) { <nl> + return Reference < ReferencedObject < V > > ( new ReferencedObject < V > ( std : : move ( v ) ) ) ; <nl> + } <nl> + <nl> private : <nl> V value ; <nl> } ; <nl> mmm a / flow / network . h <nl> ppp b / flow / network . h <nl> <nl> # endif <nl> # include " flow / serialize . h " <nl> # include " flow / IRandom . h " <nl> - # include " flow / TLSPolicy . h " <nl> <nl> enum class TaskPriority { <nl> Max = 1000000 , <nl> typedef void * flowGlobalType ; <nl> typedef NetworkAddress ( * NetworkAddressFuncPtr ) ( ) ; <nl> typedef NetworkAddressList ( * NetworkAddressesFuncPtr ) ( ) ; <nl> <nl> + class TLSConfig ; <nl> class INetwork ; <nl> extern INetwork * g_network ; <nl> - extern INetwork * newNet2 ( bool useThreadPool = false , bool useMetrics = false , Reference < TLSPolicy > policy = Reference < TLSPolicy > ( ) , const TLSParams & tlsParams = TLSParams ( ) ) ; <nl> + extern INetwork * newNet2 ( const TLSConfig & tlsConfig , bool useThreadPool = false , bool useMetrics = false ) ; <nl> <nl> class INetwork { <nl> public : <nl> | Merge pull request from alexmiller - apple / certificate - refresh | apple/foundationdb | dbfc0cbcc0d495bf787bf5857da17fff6933fc93 | 2020-03-06T19:12:04Z |
mmm a / tools / file_packager . py <nl> ppp b / tools / file_packager . py <nl> def was_seen ( name ) : <nl> var that = this ; <nl> % s <nl> this . requests [ this . name ] = null ; <nl> - } , <nl> + } <nl> } ; <nl> % s <nl> ' ' ' % ( ' ' if not crunch else ' ' ' <nl> | Remove commas | emscripten-core/emscripten | cf66ff21cf5a4ced6f6b68205ead691060843500 | 2016-04-22T23:22:36Z |
mmm a / torch / __init__ . py <nl> ppp b / torch / __init__ . py <nl> <nl> <nl> r " " " <nl> - The Torch package contains data structures for multi - dimensional <nl> + The torch package contains data structures for multi - dimensional <nl> tensors and defines mathematical operations over these tensors . <nl> Additionally , it provides many utilities for efficient serializing of <nl> - Tensors and arbitrary types , with other useful utilities . <nl> + Tensors and arbitrary types , and other useful utilities . <nl> <nl> It has a CUDA counterpart , that enables you to run your tensor computations <nl> on an NVIDIA GPU with compute capability > = 3 . 0 . <nl> | Revert D24859919 : [ pytorch ] [ PR ] Grammatically updated the tech docs | pytorch/pytorch | 5647f0ca7c306002bf8edb73c3461af1778f19e0 | 2020-11-11T15:43:17Z |
mmm a / docs / en / query_language / functions / higher_order_functions . md <nl> ppp b / docs / en / query_language / functions / higher_order_functions . md <nl> A lambda function can ' t be omitted for the following functions : <nl> <nl> - [ arrayMap ] ( # higher_order_functions - array - map ) <nl> - [ arrayFilter ] ( # higher_order_functions - array - filter ) <nl> + - [ arrayFill ] ( # higher_order_functions - array - fill ) <nl> + - [ arrayReverseFill ] ( # higher_order_functions - array - reverse - fill ) <nl> + - [ arraySplit ] ( # higher_order_functions - array - split ) <nl> + - [ arrayReverseSplit ] ( # higher_order_functions - array - reverse - split ) <nl> - [ arrayFirst ] ( # higher_order_functions - array - first ) <nl> - [ arrayFirstIndex ] ( # higher_order_functions - array - first - index ) <nl> <nl> # # # arrayMap ( func , arr1 , . . . ) { # higher_order_functions - array - map } <nl> <nl> - Returns an array obtained from the original application of the ` func ` function to each element in the ` arr ` array . <nl> + Returns an array obtained from the original application of the ` func ` function to each element in the ` arr ` array . <nl> <nl> Examples : <nl> <nl> SELECT <nl> <nl> Note that the first argument ( lambda function ) can ' t be omitted in the ` arrayFilter ` function . <nl> <nl> + # # # arrayFill ( func , arr1 , . . . ) { # higher_order_functions - array - fill } <nl> + <nl> + Scan through ` arr1 ` from the first element to the last element and replace ` arr1 [ i ] ` by ` arr1 [ i - 1 ] ` if ` func ` returns 0 . The first element of ` arr1 ` will not be replaced . <nl> + <nl> + Examples : <nl> + <nl> + ` ` ` sql <nl> + SELECT arrayFill ( x - > not isNull ( x ) , [ 1 , null , 3 , 11 , 12 , null , null , 5 , 6 , 14 , null , null ] ) AS res <nl> + ` ` ` <nl> + <nl> + ` ` ` text <nl> + ┌ ─ res ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ <nl> + │ [ 1 , 1 , 3 , 11 , 12 , 12 , 12 , 5 , 6 , 14 , 14 , 14 ] │ <nl> + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> + ` ` ` <nl> + <nl> + Note that the first argument ( lambda function ) can ' t be omitted in the ` arrayFill ` function . <nl> + <nl> + # # # arrayReverseFill ( func , arr1 , . . . ) { # higher_order_functions - array - reverse - fill } <nl> + <nl> + Scan through ` arr1 ` from the last element to the first element and replace ` arr1 [ i ] ` by ` arr1 [ i + 1 ] ` if ` func ` returns 0 . The last element of ` arr1 ` will not be replaced . <nl> + <nl> + Examples : <nl> + <nl> + ` ` ` sql <nl> + SELECT arrayReverseFill ( x - > not isNull ( x ) , [ 1 , null , 3 , 11 , 12 , null , null , 5 , 6 , 14 , null , null ] ) AS res <nl> + ` ` ` <nl> + <nl> + ` ` ` text <nl> + ┌ ─ res ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ <nl> + │ [ 1 , 3 , 3 , 11 , 12 , 5 , 5 , 5 , 6 , 14 , NULL , NULL ] │ <nl> + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> + ` ` ` <nl> + <nl> + Note that the first argument ( lambda function ) can ' t be omitted in the ` arrayReverseFill ` function . <nl> + <nl> + # # # arraySplit ( func , arr1 , . . . ) { # higher_order_functions - array - split } <nl> + <nl> + Split ` arr1 ` into multiple arrays . When ` func ` returns something other than 0 , the array will be split on the left hand side of the element . The array will not be split before the first element . <nl> + <nl> + Examples : <nl> + <nl> + ` ` ` sql <nl> + SELECT arraySplit ( ( x , y ) - > y , [ 1 , 2 , 3 , 4 , 5 ] , [ 1 , 0 , 0 , 1 , 0 ] ) AS res <nl> + ` ` ` <nl> + <nl> + ` ` ` text <nl> + ┌ ─ res ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ <nl> + │ [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] │ <nl> + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> + ` ` ` <nl> + <nl> + Note that the first argument ( lambda function ) can ' t be omitted in the ` arraySplit ` function . <nl> + <nl> + # # # arrayReverseSplit ( func , arr1 , . . . ) { # higher_order_functions - array - reverse - split } <nl> + <nl> + Split ` arr1 ` into multiple arrays . When ` func ` returns something other than 0 , the array will be split on the right hand side of the element . The array will not be split after the last element . <nl> + <nl> + Examples : <nl> + <nl> + ` ` ` sql <nl> + SELECT arrayReverseSplit ( ( x , y ) - > y , [ 1 , 2 , 3 , 4 , 5 ] , [ 1 , 0 , 0 , 1 , 0 ] ) AS res <nl> + ` ` ` <nl> + <nl> + ` ` ` text <nl> + ┌ ─ res ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ <nl> + │ [ [ 1 ] , [ 2 , 3 , 4 ] , [ 5 ] ] │ <nl> + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> + ` ` ` <nl> + <nl> + Note that the first argument ( lambda function ) can ' t be omitted in the ` arraySplit ` function . <nl> + <nl> # # # arrayCount ( \ [ func , \ ] arr1 , . . . ) { # higher_order_functions - array - count } <nl> <nl> Returns the number of elements in the arr array for which func returns something other than 0 . If ' func ' is not specified , it returns the number of non - zero elements in the array . <nl> SELECT arrayCumSumNonNegative ( [ 1 , 1 , - 4 , 1 ] ) AS res <nl> <nl> # # # arraySort ( \ [ func , \ ] arr1 , . . . ) <nl> <nl> - Returns an array as result of sorting the elements of ` arr1 ` in ascending order . If the ` func ` function is specified , sorting order is determined by the result of the function ` func ` applied to the elements of array ( arrays ) <nl> + Returns an array as result of sorting the elements of ` arr1 ` in ascending order . If the ` func ` function is specified , sorting order is determined by the result of the function ` func ` applied to the elements of array ( arrays ) <nl> <nl> The [ Schwartzian transform ] ( https : / / en . wikipedia . org / wiki / Schwartzian_transform ) is used to improve sorting efficiency . <nl> <nl> | Add docs | ClickHouse/ClickHouse | 01d384e6bdf09acd1f1b4eda156339d576f7057d | 2019-10-26T13:38:05Z |
mmm a / build / build_osxbundle . sh <nl> ppp b / build / build_osxbundle . sh <nl> <nl> # ! / bin / sh <nl> QTPATH = / Users / admin / Qt / 5 . 3 / clang_64 / bin <nl> - <nl> export PATH = $ PATH : $ QTPATH <nl> <nl> + SOURCE_DIR = ` pwd ` <nl> + <nl> echo = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> TAG = $ 1 <nl> echo Version : $ TAG <nl> | Fix osx build script | uglide/RedisDesktopManager | 79c1c09323c61040d05fd7ea0c8e8044c436c2df | 2014-06-24T06:53:11Z |
mmm a / yarn . lock <nl> ppp b / yarn . lock <nl> forwarded @ ~ 0 . 1 . 2 : <nl> integrity sha1 - mMI9qxF1ZXuMBXPozszZGw / xjIQ = <nl> <nl> fp - ts @ ^ 2 . 5 . 0 : <nl> - version " 2 . 5 . 0 " <nl> - resolved " https : / / registry . yarnpkg . com / fp - ts / - / fp - ts - 2 . 5 . 0 . tgz # adca3b90452196274f7b074f12f9c02741624c1a " <nl> - integrity sha512 - xkC9ZKl / i2cU + 8FAsdyLcTvPRXphp42FcK5WmZpB47VXb4gggC3DHlVDKNLdbC + U8zz6yp1b0bj0mZg0axmZYQ = = <nl> + version " 2 . 5 . 1 " <nl> + resolved " https : / / registry . yarnpkg . com / fp - ts / - / fp - ts - 2 . 5 . 1 . tgz # 2edf15779ae60701ff2a45d6f31322d9413b4548 " <nl> + integrity sha512 - IjePHUJwegS9h7 + cRCywoL / Nfha3UnMd3VHVg4gycv69nAQPOJ3b / XnjtF5ggTBF4gjLZcNaHjZEYOsRcDeGaA = = <nl> <nl> fragment - cache @ ^ 0 . 2 . 1 : <nl> version " 0 . 2 . 1 " <nl> | Bump fp - ts from 2 . 5 . 0 to 2 . 5 . 1 ( ) | microsoft/react-native-windows | e7b9880f22dcdcdc357e547916095a899b7c49f7 | 2020-02-24T22:45:27Z |
mmm a / docker / build / dev . aarch64 . dockerfile <nl> ppp b / docker / build / dev . aarch64 . dockerfile <nl> ARG BASE_IMAGE_GPU = apolloauto / apollo : cyber - aarch64 - 18 . 04 - 20200826_1538 <nl> FROM $ { BASE_IMAGE_GPU } <nl> <nl> ARG GEOLOC <nl> - # ARG WORKHORSE <nl> ARG BUILD_STAGE <nl> ARG INSTALL_MODE <nl> <nl> COPY installers / tmp / installers <nl> <nl> RUN bash / tmp / installers / install_geo_adjustment . sh $ { GEOLOC } <nl> RUN bash / tmp / installers / install_modules_base . sh <nl> - <nl> RUN bash / tmp / installers / install_gpu_support . sh # $ { WORKHORSE } <nl> - # RUN bash / tmp / installers / install_common_modules . sh $ { INSTALL_MODE } <nl> - # RUN bash / tmp / installers / install_drivers_deps . sh $ { INSTALL_MODE } <nl> - # RUN bash / tmp / installers / install_perception_deps . sh $ { INSTALL_MODE } <nl> - # RUN bash / tmp / installers / install_dreamview_deps . sh $ { GEOLOC } <nl> + RUN bash / tmp / installers / install_ordinary_modules . sh <nl> + RUN bash / tmp / installers / install_drivers_deps . sh $ { INSTALL_MODE } <nl> + RUN bash / tmp / installers / install_perception_deps . sh <nl> + RUN bash / tmp / installers / install_dreamview_deps . sh $ { GEOLOC } <nl> <nl> - # RUN bash / tmp / installers / install_contrib_deps . sh $ { INSTALL_MODE } <nl> - # RUN bash / tmp / installers / install_3rdparty_pept_deps . sh $ { INSTALL_MODE } <nl> + RUN bash / tmp / installers / install_contrib_deps . sh <nl> + RUN bash / tmp / installers / install_3rdparty_pept_deps . sh <nl> <nl> - # RUN bash / tmp / installers / install_release_deps . sh <nl> + RUN bash / tmp / installers / install_release_deps . sh <nl> RUN bash / tmp / installers / post_install . sh $ { BUILD_STAGE } <nl> | Docker | Installer : updated dev . aarch64 dockerfile | ApolloAuto/apollo | 705081b81be77373553b4358333a28a7822d1b25 | 2020-08-31T03:37:49Z |
mmm a / src / mongo / db / s / migration_source_manager . cpp <nl> ppp b / src / mongo / db / s / migration_source_manager . cpp <nl> void MigrationSourceManager : : _cleanup ( ) { <nl> } <nl> <nl> if ( _useFCV44Protocol ) { <nl> - if ( _state < kCommittingOnConfig ) { <nl> + if ( _state > = kCloning & & _state < kCommittingOnConfig ) { <nl> + invariant ( _coordinator ) ; <nl> _coordinator - > setMigrationDecision ( <nl> migrationutil : : MigrationCoordinator : : Decision : : kAborted ) ; <nl> } <nl> | SERVER - 45625 MigrationSourceManager should only attempt to set a decision on its MigrationCoordinator if its MigrationCoordinator was initialized | mongodb/mongo | 46408bc0c2a433bb442ec7043e9090eae36b4eda | 2020-01-21T19:28:42Z |
mmm a / README . md <nl> ppp b / README . md <nl> As needed , the ` json_parse ` and ` build_parsed_json ` functions copy the input dat <nl> <nl> * * API and detailed documentation found [ here ] ( doc / JsonStream . md ) . * * <nl> <nl> - Here is a simple exemple , using single header simdjson : <nl> + Here is a simple example , using single header simdjson : <nl> ` ` ` cpp <nl> # include " simdjson . h " <nl> # include " simdjson . cpp " <nl> | Fix README typo ( ) | simdjson/simdjson | 6cefdc2f5cd7efdcd312d979d585ef1cd1ecca4a | 2019-12-23T16:08:55Z |
mmm a / php7_wrapper . h <nl> ppp b / php7_wrapper . h <nl> inline int sw_zend_hash_find ( HashTable * ht , char * k , int len , void * * v ) ; <nl> # define SW_ZEND_FETCH_RESOURCE_NO_RETURN ZEND_FETCH_RESOURCE_NO_RETURN <nl> # define SW_ZEND_FETCH_RESOURCE ZEND_FETCH_RESOURCE <nl> # define SW_ZEND_REGISTER_RESOURCE ZEND_REGISTER_RESOURCE <nl> - # define SW_MAKE_STD_ZVAL ( p ) MAKE_STD_ZVAL ( p ) <nl> + # define SW_MAKE_STD_ZVAL ( p ) MAKE_STD_ZVAL ( p ) <nl> # define SW_ZVAL_STRING ZVAL_STRING <nl> - # define SW_ALLOC_INIT_ZVAL ( p ) ALLOC_INIT_ZVAL ( p ) <nl> + # define SW_ALLOC_INIT_ZVAL ( p ) ALLOC_INIT_ZVAL ( p ) <nl> # define SW_RETVAL_STRINGL RETVAL_STRINGL <nl> # define sw_smart_str smart_str <nl> # define sw_php_var_unserialize php_var_unserialize <nl> typedef int zend_size_t ; <nl> continue ; \ <nl> } \ <nl> entry = * tmp ; <nl> + <nl> + # define SW_HASHTABLE_FOREACH_START2 ( ht , k , klen , ktype , entry ) \ <nl> + zval * * tmp = NULL ; \ <nl> + for ( zend_hash_internal_pointer_reset ( ht ) ; \ <nl> + ( ktype = zend_hash_get_current_key_ex ( ht , & k , & klen , & idx , 0 , NULL ) ) ! = HASH_KEY_NON_EXISTENT ; \ <nl> + zend_hash_move_forward ( ht ) \ <nl> + ) { \ <nl> + if ( zend_hash_get_current_data ( ht , ( void * * ) & tmp ) = = FAILURE ) { \ <nl> + continue ; \ <nl> + } \ <nl> + entry = * tmp ; \ <nl> + klen - - ; <nl> + <nl> # define SW_HASHTABLE_FOREACH_END ( ) } <nl> # define sw_zend_read_property zend_read_property <nl> - # define wrapper_zend_hash_get_current_key ( a , b , c , d ) zend_hash_get_current_key_ex ( a , b , c , d , 0 , NULL ) <nl> + # define sw_zend_hash_get_current_key ( a , b , c , d ) zend_hash_get_current_key_ex ( a , b , c , d , 0 , NULL ) <nl> # define sw_php_var_serialize ( a , b , c ) php_var_serialize ( a , & b , c ) <nl> # define IS_TRUE 1 <nl> inline int SW_Z_TYPE_P ( zval * z ) ; <nl> inline int Z_BVAL_P ( zval * v ) ; <nl> inline int sw_add_assoc_stringl_ex ( zval * arg , const char * key , size_t key_len , char * str , size_t length , int duplicate ) ; <nl> # define SW_Z_ARRVAL_P ( z ) Z_ARRVAL_P ( z ) - > ht <nl> <nl> - # define SW_HASHTABLE_FOREACH_START ( ht , entry ) ZEND_HASH_FOREACH_VAL ( ht , entry ) { <nl> - # define SW_HASHTABLE_FOREACH_END ( ) } ZEND_HASH_FOREACH_END ( ) ; <nl> + # define SW_HASHTABLE_FOREACH_START ( ht , _val ) ZEND_HASH_FOREACH_VAL ( ht , _val ) ; { <nl> + # define SW_HASHTABLE_FOREACH_START2 ( ht , k , klen , ktype , _val ) zend_string * _foreach_key ; \ <nl> + ZEND_HASH_FOREACH_STR_KEY_VAL ( ht , _foreach_key , _val ) ; k = _foreach_key - > val , klen = _foreach_key - > len ; { <nl> + <nl> + # define SW_HASHTABLE_FOREACH_END ( ) } ZEND_HASH_FOREACH_END ( ) ; <nl> <nl> # define Z_ARRVAL_PP ( s ) Z_ARRVAL_P ( * s ) <nl> # define SW_Z_TYPE_P Z_TYPE_P <nl> mmm a / swoole_client . c <nl> ppp b / swoole_client . c <nl> static int client_event_loop ( zval * sock_array , fd_set * fds TSRMLS_DC ) <nl> zend_hash_init ( new_hash , zend_hash_num_elements ( Z_ARRVAL_P ( sock_array ) ) , NULL , ZVAL_PTR_DTOR , 0 ) ; <nl> <nl> SW_HASHTABLE_FOREACH_START ( Z_ARRVAL_P ( sock_array ) , * element ) <nl> - ce = Z_OBJCE_P ( * element ) ; <nl> - zsock = sw_zend_read_property ( ce , * element , SW_STRL ( " sock " ) - 1 , 0 TSRMLS_CC ) ; <nl> - if ( zsock = = NULL | | ZVAL_IS_NULL ( zsock ) ) <nl> - { <nl> - php_error_docref ( NULL TSRMLS_CC , E_WARNING , " object is not swoole_client object . " ) ; <nl> - continue ; <nl> - } <nl> - if ( ( Z_LVAL ( * zsock ) < FD_SETSIZE ) & & FD_ISSET ( Z_LVAL ( * zsock ) , fds ) ) <nl> - { <nl> - switch ( sw_zend_hash_get_current_key ( Z_ARRVAL_P ( sock_array ) , & key , & key_len , & num_key ) ) <nl> + ce = Z_OBJCE_P ( * element ) ; <nl> + zsock = sw_zend_read_property ( ce , * element , SW_STRL ( " sock " ) - 1 , 0 TSRMLS_CC ) ; <nl> + if ( zsock = = NULL | | ZVAL_IS_NULL ( zsock ) ) <nl> { <nl> - case HASH_KEY_IS_STRING : <nl> - sw_zend_hash_add ( new_hash , key , key_len , ( void * ) element , sizeof ( zval * ) , ( void * * ) & dest_element ) ; <nl> - break ; <nl> - case HASH_KEY_IS_LONG : <nl> - sw_zend_hash_index_update ( new_hash , num_key , ( void * ) element , sizeof ( zval * ) , ( void * * ) & dest_element ) ; <nl> - break ; <nl> + php_error_docref ( NULL TSRMLS_CC , E_WARNING , " object is not swoole_client object . " ) ; <nl> + continue ; <nl> } <nl> - if ( dest_element ) <nl> + if ( ( Z_LVAL ( * zsock ) < FD_SETSIZE ) & & FD_ISSET ( Z_LVAL ( * zsock ) , fds ) ) <nl> { <nl> - sw_zval_add_ref ( dest_element ) ; <nl> + switch ( sw_zend_hash_get_current_key ( Z_ARRVAL_P ( sock_array ) , & key , & key_len , & num_key ) ) <nl> + { <nl> + case HASH_KEY_IS_STRING : <nl> + sw_zend_hash_add ( new_hash , key , key_len , ( void * ) element , sizeof ( zval * ) , ( void * * ) & dest_element ) ; <nl> + break ; <nl> + case HASH_KEY_IS_LONG : <nl> + sw_zend_hash_index_update ( new_hash , num_key , ( void * ) element , sizeof ( zval * ) , ( void * * ) & dest_element ) ; <nl> + break ; <nl> + } <nl> + if ( dest_element ) <nl> + { <nl> + sw_zval_add_ref ( dest_element ) ; <nl> + } <nl> } <nl> - } <nl> - num + + ; <nl> + num + + ; <nl> SW_HASHTABLE_FOREACH_END ( ) ; <nl> <nl> zend_hash_destroy ( Z_ARRVAL_P ( sock_array ) ) ; <nl> static int client_event_add ( zval * sock_array , fd_set * fds , int * max_fd TSRMLS_DC <nl> zval * zsock ; <nl> zend_class_entry * ce ; <nl> <nl> - int num = 0 ; <nl> if ( SW_Z_TYPE_P ( sock_array ) ! = IS_ARRAY ) <nl> { <nl> return 0 ; <nl> } <nl> - SW_HASHTABLE_FOREACH_START ( Z_ARRVAL_P ( sock_array ) , * element ) <nl> + <nl> + int num = 0 ; <nl> + SW_HASHTABLE_FOREACH_START ( Z_ARRVAL_P ( sock_array ) , * element ) <nl> ce = Z_OBJCE_P ( * element ) ; <nl> zsock = sw_zend_read_property ( ce , * element , SW_STRL ( " sock " ) - 1 , 0 TSRMLS_CC ) ; <nl> if ( zsock = = NULL | | ZVAL_IS_NULL ( zsock ) ) <nl> static int client_event_add ( zval * sock_array , fd_set * fds , int * max_fd TSRMLS_DC <nl> { <nl> * max_fd = Z_LVAL ( * zsock ) ; <nl> } <nl> - num + + ; <nl> + num + + ; <nl> SW_HASHTABLE_FOREACH_END ( ) ; <nl> return num ? 1 : 0 ; <nl> } <nl> mmm a / swoole_config . h <nl> ppp b / swoole_config . h <nl> <nl> # define SW_HTTP_HEADER_MAX_SIZE 8192 <nl> # define SW_HTTP_COMPRESS_GZIP <nl> # define SW_HTTP_UPLOAD_TMP_FILE " / tmp / swoole . upfile . XXXXXX " <nl> + # define SW_HTTP_DATE_FORMAT " D , d M Y H : i : s T " <nl> / / # define SW_HTTP_100_CONTINUE <nl> <nl> # define SW_WEBSOCKET_SERVER_SOFTWARE " swoole - websocket - server " <nl> mmm a / swoole_http . c <nl> ppp b / swoole_http . c <nl> static void http_build_header ( swoole_http_client * client , zval * object , swString <nl> ulong idx = 0 ; <nl> int type ; <nl> <nl> - SW_HASHTABLE_FOREACH_START ( ht , value ) <nl> + SW_HASHTABLE_FOREACH_START2 ( ht , key , keylen , type , value ) <nl> { <nl> - type = sw_zend_hash_get_current_key ( ht , & key , & keylen , & idx ) ; <nl> - if ( type ! = HASH_KEY_IS_STRING ) <nl> - { <nl> - continue ; <nl> - } <nl> if ( ! key ) <nl> { <nl> break ; <nl> static void http_build_header ( swoole_http_client * client , zval * object , swString <nl> body_length = swoole_zlib_buffer - > length ; <nl> } <nl> # endif <nl> - <nl> n = snprintf ( buf , sizeof ( buf ) , " Content - Length : % d \ r \ n " , body_length ) ; <nl> swString_append_ptr ( response , buf , n ) ; <nl> } <nl> } <nl> if ( ! ( flag & HTTP_RESPONSE_DATE ) ) <nl> { <nl> - date_str = sw_php_format_date ( ZEND_STRL ( " D , d - M - Y H : i : s T " ) , SwooleGS - > now , 0 TSRMLS_CC ) ; <nl> + date_str = sw_php_format_date ( ZEND_STRL ( SW_HTTP_DATE_FORMAT ) , SwooleGS - > now , 0 TSRMLS_CC ) ; <nl> n = snprintf ( buf , sizeof ( buf ) , " Date : % s \ r \ n " , date_str ) ; <nl> swString_append_ptr ( response , buf , n ) ; <nl> efree ( date_str ) ; <nl> static void http_build_header ( swoole_http_client * client , zval * object , swString <nl> swString_append_ptr ( response , ZEND_STRL ( " Connection : close \ r \ n " ) ) ; <nl> } <nl> <nl> - date_str = sw_php_format_date ( ZEND_STRL ( " D , d - M - Y H : i : s T " ) , SwooleGS - > now , 0 TSRMLS_CC ) ; <nl> + date_str = sw_php_format_date ( ZEND_STRL ( SW_HTTP_DATE_FORMAT ) , SwooleGS - > now , 0 TSRMLS_CC ) ; <nl> n = snprintf ( buf , sizeof ( buf ) , " Date : % s \ r \ n " , date_str ) ; <nl> efree ( date_str ) ; <nl> swString_append_ptr ( response , buf , n ) ; <nl> static PHP_METHOD ( swoole_http_response , header ) <nl> RETURN_FALSE ; <nl> } <nl> <nl> - zval * zheader ; <nl> - if ( ! client - > response . zheader ) <nl> + zval * zheader = client - > response . zheader ; <nl> + if ( ! zheader ) <nl> { <nl> http_alloc_zval ( client , response , zheader ) ; <nl> array_init ( zheader ) ; <nl> mmm a / swoole_phpng . c <nl> ppp b / swoole_phpng . c <nl> inline int sw_add_assoc_stringl_ex ( zval * arg , const char * key , size_t key_len , c <nl> return add_assoc_stringl_ex ( arg , key , key_len , str , length ) ; <nl> } <nl> <nl> - inline char * sw_php_format_date ( char * format , size_t format_len , time_t ts , int localtime ) { <nl> + inline char * sw_php_format_date ( char * format , size_t format_len , time_t ts , int localtime ) <nl> + { <nl> zend_string * time = php_format_date ( format , format_len , ts , localtime ) ; <nl> - <nl> - char * return_str = ( char * ) emalloc ( time - > len ) ; <nl> + char * return_str = ( char * ) emalloc ( time - > len + 1 ) ; <nl> memcpy ( return_str , time - > val , time - > len ) ; <nl> - zend_string_release ( time ) ; <nl> + return_str [ time - > len ] = 0 ; <nl> return return_str ; <nl> } <nl> <nl> inline int sw_zend_is_callable ( zval * cb , int a , char * * name ) { <nl> return ret ; <nl> } <nl> <nl> - inline int sw_zend_hash_del ( HashTable * ht , char * k , int len ) { <nl> + inline int sw_zend_hash_del ( HashTable * ht , char * k , int len ) <nl> + { <nl> zval key ; <nl> ZVAL_STRING ( & key , k ) ; <nl> <nl> inline int sw_zend_hash_del ( HashTable * ht , char * k , int len ) { <nl> <nl> } <nl> <nl> - inline int sw_zend_hash_add ( HashTable * ht , char * k , int len , void * pData , int datasize , void * * pDest ) { <nl> + inline int sw_zend_hash_add ( HashTable * ht , char * k , int len , void * pData , int datasize , void * * pDest ) <nl> + { <nl> zval key ; <nl> ZVAL_STRING ( & key , k ) ; <nl> zval * * real_p = pData ; <nl> inline int sw_zend_hash_add ( HashTable * ht , char * k , int len , void * pData , int da <nl> return zend_hash_add ( ht , Z_STR ( key ) , * real_p ) ? SUCCESS : FAILURE ; <nl> } <nl> <nl> - inline int sw_zend_hash_index_update ( HashTable * ht , int key , void * pData , int datasize , void * * pDest ) { <nl> + inline int sw_zend_hash_index_update ( HashTable * ht , int key , void * pData , int datasize , void * * pDest ) <nl> + { <nl> zval * * real_p = pData ; <nl> return zend_hash_index_update ( ht , key , * real_p ) ? SUCCESS : FAILURE ; <nl> } <nl> <nl> - inline int sw_zend_hash_update ( HashTable * ht , char * k , int len , void * val , int size , void * ptr ) { <nl> + inline int sw_zend_hash_update ( HashTable * ht , char * k , int len , void * val , int size , void * ptr ) <nl> + { <nl> zval key ; <nl> ZVAL_STRING ( & key , k ) ; <nl> <nl> inline int sw_zend_hash_update ( HashTable * ht , char * k , int len , void * val , int <nl> <nl> inline int sw_zend_hash_get_current_key ( HashTable * ht , char * * key , uint32_t * keylen , ulong * num ) <nl> { <nl> - zval str_key ; <nl> - int type = zend_hash_get_current_key ( ht , & Z_STR ( str_key ) , ( zend_ulong * ) num ) ; <nl> - * key = Z_STRVAL ( str_key ) ; <nl> - * keylen = Z_STRLEN ( str_key ) ; <nl> + zend_string * _key_ptr ; <nl> + int type = zend_hash_get_current_key ( ht , & _key_ptr , ( zend_ulong * ) num ) ; <nl> + * key = _key_ptr - > val ; <nl> + * keylen = _key_ptr - > len ; <nl> + printf ( " k = % s , klen = % d , num = % d \ n " , * key , * keylen , num ) ; <nl> return type ; <nl> } <nl> <nl> mmm a / swoole_table . c <nl> ppp b / swoole_table . c <nl> static void php_swoole_table_row2array ( swTable * table , swTableRow * row , zval * re <nl> { <nl> case SW_TABLE_INT8 : <nl> memcpy ( & lval , row - > data + col - > index , 1 ) ; <nl> + add_assoc_long_ex ( return_value , col - > name - > str , col - > name - > length + 1 , ( int8_t ) lval ) ; <nl> break ; <nl> case SW_TABLE_INT16 : <nl> memcpy ( & lval , row - > data + col - > index , 2 ) ; <nl> + add_assoc_long_ex ( return_value , col - > name - > str , col - > name - > length + 1 , ( int16_t ) lval ) ; <nl> break ; <nl> case SW_TABLE_INT32 : <nl> memcpy ( & lval , row - > data + col - > index , 4 ) ; <nl> + add_assoc_long_ex ( return_value , col - > name - > str , col - > name - > length + 1 , ( int32_t ) lval ) ; <nl> break ; <nl> default : <nl> memcpy ( & lval , row - > data + col - > index , 8 ) ; <nl> + add_assoc_long_ex ( return_value , col - > name - > str , col - > name - > length + 1 , lval ) ; <nl> break ; <nl> } <nl> - add_assoc_long_ex ( return_value , col - > name - > str , col - > name - > length + 1 , lval ) ; <nl> } <nl> } <nl> sw_spinlock_release ( & row - > lock ) ; <nl> static PHP_METHOD ( swoole_table , set ) <nl> zval * v ; <nl> char * k ; <nl> uint32_t klen ; <nl> - ulong knum ; <nl> + ulong idx = 0 ; <nl> + int ktype ; <nl> + HashTable * _ht = Z_ARRVAL_P ( array ) ; <nl> <nl> sw_atomic_t * lock = & row - > lock ; <nl> sw_spinlock ( lock ) ; <nl> <nl> - SW_HASHTABLE_FOREACH_START ( Z_ARRVAL_P ( array ) , v ) <nl> - sw_zend_hash_get_current_key ( Z_ARRVAL_P ( array ) , & k , & klen , & knum ) ; <nl> - col = swTableColumn_get ( table , k , klen - 1 ) ; <nl> - if ( col = = NULL ) <nl> + SW_HASHTABLE_FOREACH_START2 ( _ht , k , klen , ktype , v ) <nl> + { <nl> + / / printf ( " key = % s , klen = % d , ktype = % d \ n " , k , klen , ktype ) ; <nl> + col = swTableColumn_get ( table , k , klen ) ; <nl> + if ( k = = NULL | | col = = NULL ) <nl> { <nl> continue ; <nl> } <nl> else if ( col - > type = = SW_TABLE_STRING ) <nl> { <nl> - convert_to_string ( v ) ; <nl> - swTableRow_set_value ( row , col , Z_STRVAL_P ( v ) , Z_STRLEN_P ( v ) ) ; <nl> - } <nl> - else if ( col - > type = = SW_TABLE_FLOAT ) <nl> - { <nl> - convert_to_double ( v ) ; <nl> - swTableRow_set_value ( row , col , & Z_DVAL_P ( v ) , 0 ) ; <nl> - } <nl> - else <nl> - { <nl> - convert_to_long ( v ) ; <nl> - swTableRow_set_value ( row , col , & Z_LVAL_P ( v ) , 0 ) ; <nl> - } <nl> - SW_HASHTABLE_FOREACH_END ( ) ; <nl> - <nl> + convert_to_string ( v ) ; <nl> + swTableRow_set_value ( row , col , Z_STRVAL_P ( v ) , Z_STRLEN_P ( v ) ) ; <nl> + } <nl> + else if ( col - > type = = SW_TABLE_FLOAT ) <nl> + { <nl> + convert_to_double ( v ) ; <nl> + swTableRow_set_value ( row , col , & Z_DVAL_P ( v ) , 0 ) ; <nl> + } <nl> + else <nl> + { <nl> + convert_to_long ( v ) ; <nl> + swTableRow_set_value ( row , col , & Z_LVAL_P ( v ) , 0 ) ; <nl> + } <nl> + } <nl> + SW_HASHTABLE_FOREACH_END ( ) ; <nl> sw_spinlock_release ( lock ) ; <nl> - <nl> RETURN_TRUE ; <nl> } <nl> <nl> | Fixed core dump with php7 . | swoole/swoole-src | 8903b039a14b977d7206de9dab55fd630a480fd8 | 2015-06-23T11:08:26Z |
mmm a / tools / android / packaging / xbmc / src / org / xbmc / kodi / Main . java . in <nl> ppp b / tools / android / packaging / xbmc / src / org / xbmc / kodi / Main . java . in <nl> public class Main extends NativeActivity <nl> public void onCreate ( Bundle savedInstanceState ) <nl> { <nl> super . onCreate ( savedInstanceState ) ; <nl> - getWindow ( ) . setFormat ( PixelFormat . TRANSPARENT ) ; <nl> } <nl> <nl> @ Override <nl> public class Main extends NativeActivity <nl> } <nl> } <nl> <nl> + @ Override <nl> + public void onStart ( ) <nl> + { <nl> + super . onStart ( ) ; <nl> + getWindow ( ) . setFormat ( PixelFormat . TRANSPARENT ) ; <nl> + } <nl> + <nl> @ Override <nl> public void onResume ( ) <nl> { <nl> | Merge pull request from koying / fixupamlvideo | xbmc/xbmc | ece00bc666a60f48ede67df02a248bcb7cd807eb | 2014-11-27T20:44:56Z |
mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> CApplication : : CApplication ( void ) : m_itemCurrentFile ( new CFileItem ) , m_progressT <nl> m_strPlayListFile = " " ; <nl> m_nextPlaylistItem = - 1 ; <nl> m_bPlaybackStarting = false ; <nl> + m_skinReloading = false ; <nl> <nl> # ifdef HAS_GLX <nl> XInitThreads ( ) ; <nl> void CApplication : : StopServices ( ) <nl> <nl> void CApplication : : ReloadSkin ( ) <nl> { <nl> + m_skinReloading = false ; <nl> CGUIMessage msg ( GUI_MSG_LOAD_SKIN , - 1 , g_windowManager . GetActiveWindow ( ) ) ; <nl> g_windowManager . SendMessage ( msg ) ; <nl> / / Reload the skin , restoring the previously focused control . We need this as <nl> void CApplication : : ReloadSkin ( ) <nl> <nl> bool CApplication : : LoadSkin ( const CStdString & skinID ) <nl> { <nl> + if ( m_skinReloading ) <nl> + return false ; <nl> + <nl> AddonPtr addon ; <nl> if ( CAddonMgr : : Get ( ) . GetAddon ( skinID , addon , ADDON_SKIN ) ) <nl> { <nl> void CApplication : : LoadSkin ( const SkinPtr & skin ) <nl> vector < int > currentModelessWindows ; <nl> g_windowManager . GetActiveModelessWindows ( currentModelessWindows ) ; <nl> <nl> - CLog : : Log ( LOGINFO , " delete old skin . . . " ) ; <nl> UnloadSkin ( ) ; <nl> <nl> CLog : : Log ( LOGINFO , " load skin from : % s " , skin - > Path ( ) . c_str ( ) ) ; <nl> void CApplication : : LoadSkin ( const SkinPtr & skin ) <nl> } <nl> } <nl> <nl> - void CApplication : : UnloadSkin ( ) <nl> + void CApplication : : UnloadSkin ( bool forReload / * = false * / ) <nl> { <nl> + m_skinReloading = forReload ; <nl> + <nl> + CLog : : Log ( LOGINFO , " Unloading old skin % s . . . " , forReload ? " for reload " : " " ) ; <nl> + <nl> g_audioManager . Enable ( false ) ; <nl> <nl> g_windowManager . DeInitialize ( ) ; <nl> mmm a / xbmc / Application . h <nl> ppp b / xbmc / Application . h <nl> class CApplication : public CXBApplicationEx , public IPlayerCallback , public IMs <nl> bool IsCurrentThread ( ) const ; <nl> void Stop ( ) ; <nl> void RestartApp ( ) ; <nl> - void UnloadSkin ( ) ; <nl> + void UnloadSkin ( bool forReload = false ) ; <nl> bool LoadUserWindows ( ) ; <nl> void ReloadSkin ( ) ; <nl> const CStdString & CurrentFile ( ) ; <nl> class CApplication : public CXBApplicationEx , public IPlayerCallback , public IMs <nl> bool LoadSkin ( const CStdString & skinID ) ; <nl> void LoadSkin ( const boost : : shared_ptr < ADDON : : CSkinInfo > & skin ) ; <nl> <nl> + bool m_skinReloading ; / / if true we disallow LoadSkin until ReloadSkin is called <nl> + <nl> friend class CApplicationMessenger ; <nl> / / screensaver <nl> bool m_bScreenSave ; <nl> mmm a / xbmc / interfaces / Builtins . cpp <nl> ppp b / xbmc / interfaces / Builtins . cpp <nl> int CBuiltins : : Execute ( const CStdString & execString ) <nl> } <nl> else if ( execute . Equals ( " unloadskin " ) ) <nl> { <nl> - g_application . UnloadSkin ( ) ; <nl> + g_application . UnloadSkin ( true ) ; / / we ' re reloading the skin after this <nl> } <nl> else if ( execute . Equals ( " refreshrss " ) ) <nl> { <nl> | don ' t allow LoadSkin ( ) to run during an Unload / Reload cycle | xbmc/xbmc | 72eb44450754be1e6b2eb2d295a90769d0b03d11 | 2011-03-03T21:14:21Z |
mmm a / README . md <nl> ppp b / README . md <nl> <nl> # What is it ? <nl> <nl> - Google ' s common Java , C + + and JavaScript library for parsing , formatting , storing and validating international phone numbers . The Java version is optimized for running on smartphones , and is used by the Android framework since 4 . 0 ( Ice Cream Sandwich ) . <nl> + Google ' s common Java , C + + and JavaScript library for parsing , formatting , and validating international phone numbers . The Java version is optimized for running on smartphones , and is used by the Android framework since 4 . 0 ( Ice Cream Sandwich ) . <nl> <nl> # Want to report an issue ? <nl> If you want to report an issue , or to contribute to the project , please read the guidelines [ here ] ( https : / / github . com / googlei18n / libphonenumber / blob / master / CONTRIBUTING . md ) first . <nl> | remove " storing " from description of library , since it doesn ' t store any phone numbers | google/libphonenumber | b550e9a6bb9f6427da0ff7a30dcb804ddf8536b7 | 2016-01-07T13:58:33Z |
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> add_definitions ( <nl> - D $ { OSQUERY_BUILD_PLATFORM_DEFINE } _ $ { OSQUERY_BUILD_DISTRO_DEFINE } <nl> - DSTRIP_FLAG_HELP = 1 <nl> - DBOOST_NETWORK_ENABLE_HTTPS <nl> + - DNOMINMAX <nl> ) <nl> <nl> # Remove console output ( not handled by logged ) . <nl> mmm a / include / osquery / database . h <nl> ppp b / include / osquery / database . h <nl> <nl> # include < osquery / registry . h > <nl> # include < osquery / status . h > <nl> <nl> + # include " osquery / core / json . h " <nl> + <nl> namespace osquery { <nl> <nl> / * * <nl> using ColumnNames = std : : vector < std : : string > ; <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> Status serializeRow ( const Row & r , boost : : property_tree : : ptree & tree ) ; <nl> + Status serializeRowRJ ( const Row & r , rapidjson : : Document & d ) ; <nl> <nl> / * * <nl> * @ brief Serialize a Row object into a JSON string <nl> Status serializeRow ( const Row & r , boost : : property_tree : : ptree & tree ) ; <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> Status serializeRowJSON ( const Row & r , std : : string & json ) ; <nl> + Status serializeRowJSONRJ ( const Row & r , std : : string & json ) ; <nl> <nl> / * * <nl> * @ brief Deserialize a Row object from a property tree <nl> Status serializeRowJSON ( const Row & r , std : : string & json ) ; <nl> * / <nl> Status deserializeRow ( const boost : : property_tree : : ptree & tree , Row & r ) ; <nl> <nl> + Status deserializeRowRJ ( const rapidjson : : Value & v , Row & r ) ; <nl> + <nl> / * * <nl> * @ brief Deserialize a Row object from a JSON string <nl> * <nl> Status deserializeRow ( const boost : : property_tree : : ptree & tree , Row & r ) ; <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> Status deserializeRowJSON ( const std : : string & json , Row & r ) ; <nl> + Status deserializeRowJSONRJ ( const std : : string & json , Row & r ) ; <nl> <nl> / * * <nl> * @ brief The result set returned from a osquery SQL query <nl> using QueryData = std : : vector < Row > ; <nl> Status serializeQueryData ( const QueryData & q , <nl> boost : : property_tree : : ptree & tree ) ; <nl> <nl> + Status serializeQueryDataRJ ( const QueryData & q , rapidjson : : Document & d ) ; <nl> + <nl> / * * <nl> * @ brief Serialize a QueryData object into a property tree <nl> * <nl> Status serializeQueryData ( const QueryData & q , <nl> const ColumnNames & cols , <nl> boost : : property_tree : : ptree & tree ) ; <nl> <nl> + Status serializeQueryDataRJ ( const QueryData & q , <nl> + const ColumnNames & cols , <nl> + rapidjson : : Document & d ) ; <nl> + <nl> / * * <nl> * @ brief Serialize a QueryData object into a JSON string <nl> * <nl> Status serializeQueryData ( const QueryData & q , <nl> * / <nl> Status serializeQueryDataJSON ( const QueryData & q , std : : string & json ) ; <nl> <nl> + Status serializeQueryDataJSONRJ ( const QueryData & q , std : : string & json ) ; <nl> + <nl> / / / Inverse of serializeQueryData , convert property tree to QueryData . <nl> Status deserializeQueryData ( const boost : : property_tree : : ptree & tree , <nl> QueryData & qd ) ; <nl> <nl> + / / / Inverse of serializeQueryData , convert property tree to QueryData . <nl> + Status deserializeQueryDataRJ ( const rapidjson : : Value & v , QueryData & qd ) ; <nl> + <nl> / / / Inverse of serializeQueryDataJSON , convert a JSON string to QueryData . <nl> Status deserializeQueryDataJSON ( const std : : string & json , QueryData & qd ) ; <nl> <nl> mmm a / include / osquery / distributed . h <nl> ppp b / include / osquery / distributed . h <nl> struct DistributedQueryRequest { <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> Status serializeDistributedQueryRequest ( const DistributedQueryRequest & r , <nl> - boost : : property_tree : : ptree & tree ) ; <nl> + rapidjson : : Document & d ) ; <nl> <nl> / * * <nl> * @ brief Serialize a DistributedQueryRequest object into a JSON string <nl> Status serializeDistributedQueryRequestJSON ( const DistributedQueryRequest & r , <nl> * <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> - Status deserializeDistributedQueryRequest ( <nl> - const boost : : property_tree : : ptree & tree , DistributedQueryRequest & r ) ; <nl> + Status deserializeDistributedQueryRequest ( const rapidjson : : Value & d , <nl> + DistributedQueryRequest & r ) ; <nl> <nl> / * * <nl> * @ brief Deserialize a DistributedQueryRequest object from a JSON string <nl> struct DistributedQueryResult { <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> Status serializeDistributedQueryResult ( const DistributedQueryResult & r , <nl> - boost : : property_tree : : ptree & tree ) ; <nl> - <nl> + rapidjson : : Document & d ) ; <nl> / * * <nl> * @ brief Serialize a DistributedQueryResult object into a JSON string <nl> * <nl> Status serializeDistributedQueryResultJSON ( const DistributedQueryResult & r , <nl> * <nl> * @ return Status indicating the success or failure of the operation <nl> * / <nl> - Status deserializeDistributedQueryResult ( <nl> - const boost : : property_tree : : ptree & tree , DistributedQueryResult & r ) ; <nl> + Status deserializeDistributedQueryResult ( const rapidjson : : Document & d , <nl> + DistributedQueryResult & r ) ; <nl> <nl> / * * <nl> * @ brief Deserialize a DistributedQueryResult object from a JSON string <nl> mmm a / osquery / core / json . h <nl> ppp b / osquery / core / json . h <nl> <nl> <nl> # include < boost / property_tree / json_parser . hpp > <nl> <nl> + # include < rapidjson / document . h > <nl> + # include < rapidjson / error / en . h > <nl> + # include < rapidjson / stringbuffer . h > <nl> + # include < rapidjson / writer . h > <nl> + <nl> # ifdef WIN32 <nl> # pragma warning ( pop ) <nl> <nl> mmm a / osquery / database / benchmarks / database_benchmarks . cpp <nl> ppp b / osquery / database / benchmarks / database_benchmarks . cpp <nl> <nl> # include < osquery / database . h > <nl> # include < osquery / filesystem . h > <nl> <nl> - # include " osquery / tests / test_util . h " <nl> + # include " osquery / core / json . h " <nl> # include " osquery / database / query . h " <nl> + # include " osquery / tests / test_util . h " <nl> <nl> namespace osquery { <nl> <nl> static void DATABASE_serialize ( benchmark : : State & state ) { <nl> <nl> BENCHMARK ( DATABASE_serialize ) - > ArgPair ( 1 , 1 ) - > ArgPair ( 10 , 10 ) - > ArgPair ( 10 , 100 ) ; <nl> <nl> + static void DATABASE_serializeRJ ( benchmark : : State & state ) { <nl> + auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> + while ( state . KeepRunning ( ) ) { <nl> + rapidjson : : Document d ; <nl> + d . SetArray ( ) ; <nl> + serializeQueryDataRJ ( qd , d ) ; <nl> + } <nl> + } <nl> + <nl> + BENCHMARK ( DATABASE_serializeRJ ) <nl> + - > ArgPair ( 1 , 1 ) <nl> + - > ArgPair ( 10 , 10 ) <nl> + - > ArgPair ( 10 , 100 ) ; <nl> + <nl> static void DATABASE_serialize_column_order ( benchmark : : State & state ) { <nl> auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> auto cn = getExampleColumnNames ( state . range_x ( ) ) ; <nl> static void DATABASE_serialize_column_order ( benchmark : : State & state ) { <nl> BENCHMARK ( DATABASE_serialize_column_order ) <nl> - > ArgPair ( 1 , 1 ) <nl> - > ArgPair ( 10 , 10 ) <nl> - - > ArgPair ( 10 , 100 ) ; <nl> + - > ArgPair ( 10 , 100 ) <nl> + - > ArgPair ( 100 , 100 ) ; <nl> + <nl> + static void DATABASE_serializeRJ_column_order ( benchmark : : State & state ) { <nl> + auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> + auto cn = getExampleColumnNames ( state . range_x ( ) ) ; <nl> + while ( state . KeepRunning ( ) ) { <nl> + rapidjson : : Document d ; <nl> + d . SetArray ( ) ; <nl> + serializeQueryDataRJ ( qd , cn , d ) ; <nl> + } <nl> + } <nl> + <nl> + BENCHMARK ( DATABASE_serializeRJ_column_order ) <nl> + - > ArgPair ( 1 , 1 ) <nl> + - > ArgPair ( 10 , 10 ) <nl> + - > ArgPair ( 10 , 100 ) <nl> + - > ArgPair ( 100 , 100 ) ; <nl> <nl> static void DATABASE_serialize_json ( benchmark : : State & state ) { <nl> auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> BENCHMARK ( DATABASE_serialize_json ) <nl> - > ArgPair ( 10 , 10 ) <nl> - > ArgPair ( 10 , 100 ) ; <nl> <nl> + static void DATABASE_serializeRJ_json ( benchmark : : State & state ) { <nl> + auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> + while ( state . KeepRunning ( ) ) { <nl> + std : : string content ; <nl> + serializeQueryDataJSONRJ ( qd , content ) ; <nl> + } <nl> + } <nl> + <nl> + BENCHMARK ( DATABASE_serializeRJ_json ) <nl> + - > ArgPair ( 1 , 1 ) <nl> + - > ArgPair ( 10 , 10 ) <nl> + - > ArgPair ( 10 , 100 ) ; <nl> + <nl> static void DATABASE_diff ( benchmark : : State & state ) { <nl> auto qd = getExampleQueryData ( state . range_x ( ) , state . range_y ( ) ) ; <nl> while ( state . KeepRunning ( ) ) { <nl> static void DATABASE_store_large ( benchmark : : State & state ) { <nl> <nl> BENCHMARK ( DATABASE_store_large ) ; <nl> <nl> + static void DATABASE_store_largeRJ ( benchmark : : State & state ) { <nl> + / / Serialize the example result set into a string . <nl> + std : : string content ; <nl> + auto qd = getExampleQueryData ( 20 , 100 ) ; <nl> + serializeQueryDataJSONRJ ( qd , content ) ; <nl> + <nl> + while ( state . KeepRunning ( ) ) { <nl> + setDatabaseValue ( kPersistentSettings , " benchmark " , content ) ; <nl> + } <nl> + / / All benchmarks will share a single database handle . <nl> + deleteDatabaseValue ( kPersistentSettings , " benchmark " ) ; <nl> + } <nl> + <nl> + BENCHMARK ( DATABASE_store_largeRJ ) ; <nl> + <nl> static void DATABASE_store_append ( benchmark : : State & state ) { <nl> / / Serialize the example result set into a string . <nl> std : : string content ; <nl> static void DATABASE_store_append ( benchmark : : State & state ) { <nl> <nl> / / All benchmarks will share a single database handle . <nl> for ( size_t i = 0 ; i < k ; + + i ) { <nl> - / / deleteDatabaseValue ( kPersistentSettings , " key " + std : : to_string ( i ) ) ; <nl> + deleteDatabaseValue ( kPersistentSettings , " key " + std : : to_string ( i ) ) ; <nl> } <nl> } <nl> <nl> BENCHMARK ( DATABASE_store_append ) ; <nl> + <nl> + static void DATABASE_store_appendRJ ( benchmark : : State & state ) { <nl> + / / Serialize the example result set into a string . <nl> + std : : string content ; <nl> + auto qd = getExampleQueryData ( 20 , 100 ) ; <nl> + serializeQueryDataJSONRJ ( qd , content ) ; <nl> + <nl> + size_t k = 0 ; <nl> + while ( state . KeepRunning ( ) ) { <nl> + setDatabaseValue ( kPersistentSettings , " key " + std : : to_string ( k ) , content ) ; <nl> + deleteDatabaseValue ( kPersistentSettings , " key " + std : : to_string ( k ) ) ; <nl> + k + + ; <nl> + } <nl> + <nl> + / / All benchmarks will share a single database handle . <nl> + for ( size_t i = 0 ; i < k ; + + i ) { <nl> + deleteDatabaseValue ( kPersistentSettings , " key " + std : : to_string ( i ) ) ; <nl> + } <nl> + } <nl> + <nl> + BENCHMARK ( DATABASE_store_appendRJ ) ; <nl> } <nl> mmm a / osquery / database / database . cpp <nl> ppp b / osquery / database / database . cpp <nl> <nl> # include " osquery / core / json . h " <nl> <nl> namespace pt = boost : : property_tree ; <nl> + namespace rj = rapidjson ; <nl> <nl> namespace osquery { <nl> <nl> Status serializeRow ( const Row & r , pt : : ptree & tree ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status serializeRowRJ ( const Row & r , rj : : Document & d ) { <nl> + try { <nl> + for ( auto & i : r ) { <nl> + d . AddMember ( rj : : Value ( i . first . c_str ( ) , d . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( i . second . c_str ( ) , d . GetAllocator ( ) ) . Move ( ) , <nl> + d . GetAllocator ( ) ) ; <nl> + } <nl> + } catch ( const std : : exception & e ) { <nl> + return Status ( 1 , e . what ( ) ) ; <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status serializeRow ( const Row & r , const ColumnNames & cols , pt : : ptree & tree ) { <nl> try { <nl> for ( auto & c : cols ) { <nl> Status serializeRow ( const Row & r , const ColumnNames & cols , pt : : ptree & tree ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status serializeRowRJ ( const Row & r , const ColumnNames & cols , rj : : Document & d ) { <nl> + try { <nl> + for ( auto & c : cols ) { <nl> + d . AddMember ( rj : : Value ( c . c_str ( ) , d . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( r . at ( c ) . c_str ( ) , d . GetAllocator ( ) ) . Move ( ) , <nl> + d . GetAllocator ( ) ) ; <nl> + } <nl> + } catch ( const std : : exception & e ) { <nl> + return Status ( 1 , e . what ( ) ) ; <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status serializeRowJSON ( const Row & r , std : : string & json ) { <nl> pt : : ptree tree ; <nl> auto status = serializeRow ( r , tree ) ; <nl> Status serializeRowJSON ( const Row & r , std : : string & json ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status serializeRowJSONRJ ( const Row & r , std : : string & json ) { <nl> + rj : : Document d ( rj : : kObjectType ) ; <nl> + auto status = serializeRowRJ ( r , d ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + <nl> + rj : : StringBuffer sb ; <nl> + rj : : Writer < rj : : StringBuffer > writer ( sb ) ; <nl> + d . Accept ( writer ) ; <nl> + json = sb . GetString ( ) ; <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status deserializeRow ( const pt : : ptree & tree , Row & r ) { <nl> for ( const auto & i : tree ) { <nl> if ( i . first . length ( ) > 0 ) { <nl> Status deserializeRow ( const pt : : ptree & tree , Row & r ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status deserializeRowRJ ( const rj : : Value & v , Row & r ) { <nl> + if ( ! v . IsObject ( ) ) { <nl> + return Status ( 1 , " Row not an object " ) ; <nl> + } <nl> + for ( const auto & i : v . GetObject ( ) ) { <nl> + std : : string name ( i . name . GetString ( ) ) ; <nl> + std : : string value ( i . value . GetString ( ) ) ; <nl> + if ( name . length ( ) > 0 ) { <nl> + r [ name ] = value ; <nl> + } <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status deserializeRowJSON ( const std : : string & json , Row & r ) { <nl> pt : : ptree tree ; <nl> try { <nl> Status deserializeRowJSON ( const std : : string & json , Row & r ) { <nl> return deserializeRow ( tree , r ) ; <nl> } <nl> <nl> + Status deserializeRowJSONRJ ( const std : : string & json , Row & r ) { <nl> + rj : : Document d ; <nl> + if ( d . Parse ( json . c_str ( ) ) . HasParseError ( ) ) { <nl> + return Status ( 1 , " Error serializing JSON " ) ; <nl> + } <nl> + return deserializeRowRJ ( d , r ) ; <nl> + } <nl> + <nl> Status serializeQueryData ( const QueryData & q , pt : : ptree & tree ) { <nl> for ( const auto & r : q ) { <nl> pt : : ptree serialized ; <nl> - auto s = serializeRow ( r , serialized ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - return s ; <nl> + auto status = serializeRow ( r , serialized ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> } <nl> tree . push_back ( std : : make_pair ( " " , serialized ) ) ; <nl> } <nl> Status serializeQueryData ( const QueryData & q , <nl> pt : : ptree & tree ) { <nl> for ( const auto & r : q ) { <nl> pt : : ptree serialized ; <nl> - auto s = serializeRow ( r , cols , serialized ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - return s ; <nl> + auto status = serializeRow ( r , cols , serialized ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> } <nl> tree . push_back ( std : : make_pair ( " " , serialized ) ) ; <nl> } <nl> Status serializeQueryDataJSON ( const QueryData & q , std : : string & json ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status serializeQueryDataJSONRJ ( const QueryData & q , std : : string & json ) { <nl> + rj : : Document d ; <nl> + d . SetArray ( ) ; <nl> + auto status = serializeQueryDataRJ ( q , d ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + <nl> + rj : : StringBuffer sb ; <nl> + rj : : Writer < rj : : StringBuffer > writer ( sb ) ; <nl> + d . Accept ( writer ) ; <nl> + json = sb . GetString ( ) ; <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status deserializeQueryData ( const pt : : ptree & tree , QueryData & qd ) { <nl> for ( const auto & i : tree ) { <nl> Row r ; <nl> Status deserializeQueryData ( const pt : : ptree & tree , QueryData & qd ) { <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> + Status deserializeQueryDataRJ ( const rj : : Value & v , QueryData & qd ) { <nl> + if ( ! v . IsArray ( ) ) { <nl> + return Status ( 1 , " Not an array " ) ; <nl> + } <nl> + for ( const auto & i : v . GetArray ( ) ) { <nl> + Row r ; <nl> + auto status = deserializeRowRJ ( i , r ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + qd . push_back ( r ) ; <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> Status deserializeQueryDataJSON ( const std : : string & json , QueryData & qd ) { <nl> pt : : ptree tree ; <nl> try { <nl> void dumpDatabase ( ) { <nl> } <nl> } <nl> } <nl> + <nl> + Status serializeQueryDataRJ ( const QueryData & q , rj : : Document & d ) { <nl> + if ( ! d . IsArray ( ) ) { <nl> + return Status ( 1 , " Document is not an array " ) ; <nl> + } <nl> + for ( const auto & r : q ) { <nl> + rj : : Document serialized ; <nl> + serialized . SetObject ( ) ; <nl> + auto status = serializeRowRJ ( r , serialized ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + if ( serialized . GetObject ( ) . MemberCount ( ) ) { <nl> + d . PushBack ( rj : : Value ( serialized , d . GetAllocator ( ) ) . Move ( ) , <nl> + d . GetAllocator ( ) ) ; <nl> + } <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> + Status serializeQueryDataRJ ( const QueryData & q , <nl> + const ColumnNames & cols , <nl> + rj : : Document & d ) { <nl> + for ( const auto & r : q ) { <nl> + rj : : Document serialized ; <nl> + serialized . SetObject ( ) ; <nl> + auto status = serializeRowRJ ( r , cols , serialized ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + if ( serialized . GetObject ( ) . MemberCount ( ) ) { <nl> + d . PushBack ( rj : : Value ( serialized , d . GetAllocator ( ) ) . Move ( ) , <nl> + d . GetAllocator ( ) ) ; <nl> + } <nl> + } <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> + <nl> + Status serializeDiffResultsRJ ( const DiffResults & d , rj : : Document & doc ) { <nl> + / / Serialize and add " removed " first . <nl> + / / A property tree is somewhat ordered , this provides a loose contract to <nl> + / / the logger plugins and their aggregations , allowing them to parse chunked <nl> + / / lines . Note that the chunking is opaque to the database functions . <nl> + rj : : Document removed ; <nl> + auto status = serializeQueryDataRJ ( d . removed , removed ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + <nl> + doc . AddMember ( rj : : Value ( " removed " , doc . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( removed , doc . GetAllocator ( ) ) . Move ( ) , <nl> + doc . GetAllocator ( ) ) ; <nl> + <nl> + rj : : Document added ; <nl> + status = serializeQueryDataRJ ( d . added , added ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return status ; <nl> + } <nl> + doc . AddMember ( rj : : Value ( " added " , doc . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( added , doc . GetAllocator ( ) ) . Move ( ) , <nl> + doc . GetAllocator ( ) ) ; <nl> + return Status ( 0 , " OK " ) ; <nl> + } <nl> } <nl> mmm a / osquery / database / tests / results_tests . cpp <nl> ppp b / osquery / database / tests / results_tests . cpp <nl> TEST_F ( ResultsTests , test_serialize_row ) { <nl> EXPECT_EQ ( results . first , tree ) ; <nl> } <nl> <nl> + TEST_F ( ResultsTests , test_serializeRJ_row ) { <nl> + auto results = getSerializedRow ( ) ; <nl> + rapidjson : : Document d ( rapidjson : : kObjectType ) ; <nl> + auto s = serializeRowRJ ( results . second , d ) ; <nl> + EXPECT_TRUE ( s . ok ( ) ) ; <nl> + EXPECT_EQ ( s . toString ( ) , " OK " ) ; <nl> + EXPECT_EQ ( d [ " meaning_of_life " ] , " meaning_of_life_value " ) ; <nl> + EXPECT_EQ ( d [ " alphabetical " ] , " alphabetical_value " ) ; <nl> + } <nl> + <nl> TEST_F ( ResultsTests , test_deserialize_row_json ) { <nl> auto results = getSerializedRow ( ) ; <nl> std : : string input ; <nl> TEST_F ( ResultsTests , test_deserialize_row_json ) { <nl> EXPECT_EQ ( output , results . second ) ; <nl> } <nl> <nl> + TEST_F ( ResultsTests , test_deserialize_row_jsonRJ ) { <nl> + auto results = getSerializedRow ( ) ; <nl> + std : : string input ; <nl> + serializeRowJSONRJ ( results . second , input ) ; <nl> + <nl> + / / Pull the serialized JSON back into a Row output container . <nl> + Row output ; <nl> + auto s = deserializeRowJSONRJ ( input , output ) ; <nl> + EXPECT_TRUE ( s . ok ( ) ) ; <nl> + } <nl> + <nl> TEST_F ( ResultsTests , test_serialize_query_data ) { <nl> auto results = getSerializedQueryData ( ) ; <nl> pt : : ptree tree ; <nl> mmm a / osquery / distributed / distributed . cpp <nl> ppp b / osquery / distributed / distributed . cpp <nl> <nl> # include " osquery / core / conversions . h " <nl> # include " osquery / core / json . h " <nl> <nl> - namespace pt = boost : : property_tree ; <nl> + / / Windows defines the function GetObject globally meaning when compiling on <nl> + / / Windows , cl doesn ' t know what function to use . We need to undef this at the <nl> + / / beginning of all files that try to call the RapidJSON GetObject <nl> + # undef GetObject <nl> + <nl> + namespace rj = rapidjson ; <nl> <nl> namespace osquery { <nl> <nl> size_t Distributed : : getCompletedCount ( ) { <nl> } <nl> <nl> Status Distributed : : serializeResults ( std : : string & json ) { <nl> - pt : : ptree queries ; <nl> - pt : : ptree statuses ; <nl> + rj : : Document results ; <nl> + results . SetObject ( ) ; <nl> + rj : : Value queries ( rj : : kObjectType ) ; <nl> + rj : : Value statuses ( rj : : kObjectType ) ; <nl> for ( const auto & result : results_ ) { <nl> - pt : : ptree qd ; <nl> - auto s = serializeQueryData ( result . results , result . columns , qd ) ; <nl> + rj : : Document qd ; <nl> + qd . SetArray ( ) ; <nl> + auto s = serializeQueryDataRJ ( result . results , result . columns , qd ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> - queries . add_child ( result . request . id , qd ) ; <nl> - statuses . put ( result . request . id , result . status . getCode ( ) ) ; <nl> + / / This is a deep copy of qd which is not ideal , if we can make this a <nl> + / / move , that would be best <nl> + queries . AddMember ( <nl> + rj : : Value ( result . request . id . c_str ( ) , results . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( qd , results . GetAllocator ( ) ) , <nl> + results . GetAllocator ( ) ) ; <nl> + statuses . AddMember ( <nl> + rj : : Value ( result . request . id . c_str ( ) , results . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( result . status . getCode ( ) ) . Move ( ) , <nl> + results . GetAllocator ( ) ) ; <nl> } <nl> <nl> - pt : : ptree results ; <nl> - results . add_child ( " queries " , queries ) ; <nl> - results . add_child ( " statuses " , statuses ) ; <nl> - <nl> - std : : stringstream ss ; <nl> - try { <nl> - pt : : write_json ( ss , results , false ) ; <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error writing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> - } <nl> - json = ss . str ( ) ; <nl> + results . AddMember ( " queries " , queries , results . GetAllocator ( ) ) ; <nl> + results . AddMember ( " statuses " , statuses , results . GetAllocator ( ) ) ; <nl> <nl> + rj : : StringBuffer sb ; <nl> + rj : : Writer < rj : : StringBuffer > writer ( sb ) ; <nl> + results . Accept ( writer ) ; <nl> + json = sb . GetString ( ) ; <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> Status Distributed : : flushCompleted ( ) { <nl> } <nl> <nl> Status Distributed : : acceptWork ( const std : : string & work ) { <nl> - try { <nl> - pt : : ptree tree ; <nl> - { <nl> - std : : stringstream ss ( work ) ; <nl> - pt : : read_json ( ss , tree ) ; <nl> - } <nl> - std : : set < std : : string > queries_to_run ; <nl> - / / Check for and run discovery queries first <nl> - if ( tree . count ( " discovery " ) > 0 ) { <nl> - auto & queries = tree . get_child ( " discovery " ) ; <nl> - <nl> - for ( const auto & node : queries ) { <nl> - auto query = queries . get < std : : string > ( node . first , " " ) ; <nl> - if ( query . empty ( ) | | node . first . empty ( ) ) { <nl> - return Status ( <nl> - 1 , <nl> - " Distributed discovery query does not have complete attributes " ) ; <nl> - } <nl> - SQL sql ( query ) ; <nl> - if ( ! sql . getStatus ( ) . ok ( ) ) { <nl> - return Status ( 1 , " Distributed discovery query has an SQL error " ) ; <nl> - } <nl> - if ( sql . rows ( ) . size ( ) > 0 ) { <nl> - queries_to_run . insert ( node . first ) ; <nl> - } <nl> + rj : : Document d ; <nl> + rj : : ParseResult pr = d . Parse ( rj : : StringRef ( work . c_str ( ) ) ) ; <nl> + if ( ! pr ) { <nl> + return Status ( 1 , <nl> + " Error Parsing JSON : " + <nl> + std : : string ( GetParseError_En ( pr . Code ( ) ) , pr . Offset ( ) ) ) ; <nl> + } <nl> + std : : set < std : : string > queries_to_run ; <nl> + / / Check for and run discovery queries first <nl> + if ( d . HasMember ( " discovery " ) ) { <nl> + const rj : : Value & queries = d [ " discovery " ] ; <nl> + for ( const auto & query_entry : queries . GetObject ( ) ) { <nl> + auto name = std : : string ( query_entry . name . GetString ( ) ) ; <nl> + auto query = std : : string ( query_entry . value . GetString ( ) ) ; <nl> + <nl> + if ( query . empty ( ) | | name . empty ( ) ) { <nl> + return Status ( <nl> + 1 , " Distributed discovery query does not have complete attributes " ) ; <nl> + } <nl> + SQL sql ( query ) ; <nl> + if ( ! sql . getStatus ( ) . ok ( ) ) { <nl> + return Status ( 1 , " Distributed discovery query has an SQL error " ) ; <nl> + } <nl> + if ( sql . rows ( ) . size ( ) > 0 ) { <nl> + queries_to_run . insert ( name ) ; <nl> } <nl> } <nl> - <nl> - auto & queries = tree . get_child ( " queries " ) ; <nl> - for ( const auto & node : queries ) { <nl> - auto query = queries . get < std : : string > ( node . first , " " ) ; <nl> - if ( query . empty ( ) | | node . first . empty ( ) ) { <nl> + } <nl> + if ( d . HasMember ( " queries " ) ) { <nl> + const rj : : Value & queries = d [ " queries " ] ; <nl> + for ( const auto & query_entry : queries . GetObject ( ) ) { <nl> + auto name = std : : string ( query_entry . name . GetString ( ) ) ; <nl> + auto query = std : : string ( query_entry . value . GetString ( ) ) ; <nl> + if ( name . empty ( ) | | query . empty ( ) ) { <nl> return Status ( 1 , " Distributed query does not have complete attributes " ) ; <nl> } <nl> - if ( queries_to_run . empty ( ) | | queries_to_run . count ( node . first ) ) { <nl> - setDatabaseValue ( kQueries , kDistributedQueryPrefix + node . first , query ) ; <nl> + if ( queries_to_run . empty ( ) | | queries_to_run . count ( name ) ) { <nl> + setDatabaseValue ( kQueries , kDistributedQueryPrefix + name , query ) ; <nl> } <nl> } <nl> + } <nl> <nl> - if ( tree . count ( " accelerate " ) > 0 ) { <nl> - auto new_time = tree . get < std : : string > ( " accelerate " , " " ) ; <nl> - unsigned long duration ; <nl> - Status conversion = safeStrtoul ( new_time , 10 , duration ) ; <nl> - if ( conversion . ok ( ) ) { <nl> - LOG ( INFO ) < < " Accelerating distributed query checkins for " < < duration <nl> - < < " seconds " ; <nl> - setDatabaseValue ( kPersistentSettings , <nl> - " distributed_accelerate_checkins_expire " , <nl> - std : : to_string ( getUnixTime ( ) + duration ) ) ; <nl> - } else { <nl> - LOG ( WARNING ) < < " Failed to Accelerate : Timeframe is not an integer " ; <nl> - } <nl> + if ( d . HasMember ( " accelerate " ) ) { <nl> + auto new_time = std : : string ( d [ " accelerate " ] . GetString ( ) ) ; <nl> + unsigned long duration ; <nl> + Status conversion = safeStrtoul ( new_time , 10 , duration ) ; <nl> + if ( conversion . ok ( ) ) { <nl> + LOG ( INFO ) < < " Accelerating distributed query checkins for " < < duration <nl> + < < " seconds " ; <nl> + setDatabaseValue ( kPersistentSettings , <nl> + " distributed_accelerate_checkins_expire " , <nl> + std : : to_string ( getUnixTime ( ) + duration ) ) ; <nl> + } else { <nl> + LOG ( WARNING ) < < " Failed to Accelerate : Timeframe is not an integer " ; <nl> } <nl> - <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error parsing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> } <nl> - <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> void Distributed : : setCurrentRequestId ( const std : : string & cReqId ) { <nl> } <nl> <nl> Status serializeDistributedQueryRequest ( const DistributedQueryRequest & r , <nl> - pt : : ptree & tree ) { <nl> - tree . put ( " query " , r . query ) ; <nl> - tree . put ( " id " , r . id ) ; <nl> + rj : : Document & d ) { <nl> + d . AddMember ( rj : : Value ( " query " , d . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( r . query . c_str ( ) , d . GetAllocator ( ) ) , <nl> + d . GetAllocator ( ) ) ; <nl> + <nl> + d . AddMember ( rj : : Value ( " id " , d . GetAllocator ( ) ) . Move ( ) , <nl> + rj : : Value ( r . id . c_str ( ) , d . GetAllocator ( ) ) , <nl> + d . GetAllocator ( ) ) ; <nl> + <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> Status serializeDistributedQueryRequestJSON ( const DistributedQueryRequest & r , <nl> std : : string & json ) { <nl> - pt : : ptree tree ; <nl> - auto s = serializeDistributedQueryRequest ( r , tree ) ; <nl> + rj : : Document d ; <nl> + auto s = serializeDistributedQueryRequest ( r , d ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> <nl> - std : : stringstream ss ; <nl> - try { <nl> - pt : : write_json ( ss , tree , false ) ; <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error serializing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> - } <nl> - json = ss . str ( ) ; <nl> + rj : : StringBuffer sb ; <nl> + rj : : Writer < rj : : StringBuffer > writer ( sb ) ; <nl> + d . Accept ( writer ) ; <nl> + json = sb . GetString ( ) ; <nl> <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> - Status deserializeDistributedQueryRequest ( const pt : : ptree & tree , <nl> + Status deserializeDistributedQueryRequest ( const rj : : Value & d , <nl> DistributedQueryRequest & r ) { <nl> - r . query = tree . get < std : : string > ( " query " , " " ) ; <nl> - r . id = tree . get < std : : string > ( " id " , " " ) ; <nl> + if ( ! ( d . HasMember ( " query " ) & & d . HasMember ( " id " ) & & d [ " query " ] . IsString ( ) & & <nl> + d [ " id " ] . IsString ( ) ) ) { <nl> + return Status ( 1 , " Malformed distributed query request " ) ; <nl> + } <nl> + r . query = std : : string ( d [ " query " ] . GetString ( ) ) ; <nl> + r . id = std : : string ( d [ " id " ] . GetString ( ) ) ; <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> Status deserializeDistributedQueryRequestJSON ( const std : : string & json , <nl> DistributedQueryRequest & r ) { <nl> - std : : stringstream ss ( json ) ; <nl> - pt : : ptree tree ; <nl> - try { <nl> - pt : : read_json ( ss , tree ) ; <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error serializing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> + rj : : Document d ; <nl> + if ( d . Parse ( json . c_str ( ) ) . HasParseError ( ) ) { <nl> + return Status ( 1 , " Error serializing JSON " ) ; <nl> } <nl> - return deserializeDistributedQueryRequest ( tree , r ) ; <nl> + return deserializeDistributedQueryRequest ( d , r ) ; <nl> } <nl> <nl> Status serializeDistributedQueryResult ( const DistributedQueryResult & r , <nl> - pt : : ptree & tree ) { <nl> - pt : : ptree request ; <nl> + rj : : Document & d ) { <nl> + rj : : Document request ; <nl> + request . SetObject ( ) ; <nl> auto s = serializeDistributedQueryRequest ( r . request , request ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> <nl> - pt : : ptree results ; <nl> - s = serializeQueryData ( r . results , r . columns , results ) ; <nl> + rj : : Document results ; <nl> + results . SetArray ( ) ; <nl> + s = serializeQueryDataRJ ( r . results , r . columns , results ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> <nl> - tree . add_child ( " request " , request ) ; <nl> - tree . add_child ( " results " , results ) ; <nl> - <nl> + d . AddMember ( <nl> + " request " , rj : : Value ( request , d . GetAllocator ( ) ) . Move ( ) , d . GetAllocator ( ) ) ; <nl> + d . AddMember ( <nl> + " results " , rj : : Value ( results , d . GetAllocator ( ) ) . Move ( ) , d . GetAllocator ( ) ) ; <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> Status serializeDistributedQueryResultJSON ( const DistributedQueryResult & r , <nl> std : : string & json ) { <nl> - pt : : ptree tree ; <nl> - auto s = serializeDistributedQueryResult ( r , tree ) ; <nl> + rj : : Document d ; <nl> + auto s = serializeDistributedQueryResult ( r , d ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> <nl> - std : : stringstream ss ; <nl> - try { <nl> - pt : : write_json ( ss , tree , false ) ; <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error serializing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> - } <nl> - json = ss . str ( ) ; <nl> + rj : : StringBuffer sb ; <nl> + rj : : Writer < rj : : StringBuffer > writer ( sb ) ; <nl> + d . Accept ( writer ) ; <nl> + json = sb . GetString ( ) ; <nl> <nl> return Status ( 0 , " OK " ) ; <nl> } <nl> <nl> - Status deserializeDistributedQueryResult ( const pt : : ptree & tree , <nl> + Status deserializeDistributedQueryResult ( const rj : : Document & d , <nl> DistributedQueryResult & r ) { <nl> DistributedQueryRequest request ; <nl> - auto s = <nl> - deserializeDistributedQueryRequest ( tree . get_child ( " request " ) , request ) ; <nl> + auto s = deserializeDistributedQueryRequest ( d [ " request " ] , request ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> <nl> QueryData results ; <nl> - s = deserializeQueryData ( tree . get_child ( " results " ) , results ) ; <nl> + s = deserializeQueryDataRJ ( d [ " results " ] , results ) ; <nl> if ( ! s . ok ( ) ) { <nl> return s ; <nl> } <nl> Status deserializeDistributedQueryResult ( const pt : : ptree & tree , <nl> <nl> Status deserializeDistributedQueryResultJSON ( const std : : string & json , <nl> DistributedQueryResult & r ) { <nl> - pt : : ptree tree ; <nl> - try { <nl> - std : : stringstream ss ( json ) ; <nl> - pt : : read_json ( ss , tree ) ; <nl> - } catch ( const pt : : ptree_error & e ) { <nl> - return Status ( 1 , " Error serializing JSON : " + std : : string ( e . what ( ) ) ) ; <nl> + rj : : Document d ; <nl> + if ( d . Parse ( json . c_str ( ) ) . HasParseError ( ) ) { <nl> + return Status ( 1 , " Error serializing JSON " ) ; <nl> } <nl> - return deserializeDistributedQueryResult ( tree , r ) ; <nl> + return deserializeDistributedQueryResult ( d , r ) ; <nl> } <nl> } <nl> mmm a / osquery / distributed / tests / distributed_tests . cpp <nl> ppp b / osquery / distributed / tests / distributed_tests . cpp <nl> <nl> # include " osquery / tests / test_additional_util . h " <nl> # include " osquery / tests / test_util . h " <nl> <nl> + # include < rapidjson / prettywriter . h > <nl> + <nl> + / / distributed . cpp for why this is undefed <nl> + # undef GetObject <nl> + <nl> namespace pt = boost : : property_tree ; <nl> <nl> DECLARE_string ( distributed_tls_read_endpoint ) ; <nl> TEST_F ( DistributedTests , test_serialize_distributed_query_request ) { <nl> r . query = " foo " ; <nl> r . id = " bar " ; <nl> <nl> - pt : : ptree tree ; <nl> - auto s = serializeDistributedQueryRequest ( r , tree ) ; <nl> + rapidjson : : Document d ( rapidjson : : kObjectType ) ; <nl> + auto s = serializeDistributedQueryRequest ( r , d ) ; <nl> EXPECT_TRUE ( s . ok ( ) ) ; <nl> - EXPECT_EQ ( tree . get < std : : string > ( " query " ) , " foo " ) ; <nl> - EXPECT_EQ ( tree . get < std : : string > ( " id " ) , " bar " ) ; <nl> + EXPECT_TRUE ( d . HasMember ( " query " ) & & d [ " query " ] . IsString ( ) ) ; <nl> + EXPECT_TRUE ( d . HasMember ( " id " ) & & d [ " id " ] . IsString ( ) ) ; <nl> + if ( d . HasMember ( " query " ) ) { <nl> + EXPECT_EQ ( std : : string ( d [ " query " ] . GetString ( ) ) , " foo " ) ; <nl> + } <nl> + if ( d . HasMember ( " id " ) ) { <nl> + EXPECT_EQ ( std : : string ( d [ " id " ] . GetString ( ) ) , " bar " ) ; <nl> + } <nl> } <nl> <nl> TEST_F ( DistributedTests , test_deserialize_distributed_query_request ) { <nl> - pt : : ptree tree ; <nl> - tree . put < std : : string > ( " query " , " foo " ) ; <nl> - tree . put < std : : string > ( " id " , " bar " ) ; <nl> + rapidjson : : Document d ( rapidjson : : kObjectType ) ; <nl> + d . AddMember ( rapidjson : : Value ( " query " , d . GetAllocator ( ) ) . Move ( ) , <nl> + rapidjson : : Value ( " foo " , d . GetAllocator ( ) ) , <nl> + d . GetAllocator ( ) ) ; <nl> + <nl> + d . AddMember ( rapidjson : : Value ( " id " , d . GetAllocator ( ) ) . Move ( ) , <nl> + rapidjson : : Value ( " bar " , d . GetAllocator ( ) ) . Move ( ) , <nl> + d . GetAllocator ( ) ) ; <nl> <nl> DistributedQueryRequest r ; <nl> - auto s = deserializeDistributedQueryRequest ( tree , r ) ; <nl> + auto s = deserializeDistributedQueryRequest ( d , r ) ; <nl> EXPECT_TRUE ( s . ok ( ) ) ; <nl> EXPECT_EQ ( r . query , " foo " ) ; <nl> EXPECT_EQ ( r . id , " bar " ) ; <nl> TEST_F ( DistributedTests , test_serialize_distributed_query_result ) { <nl> Row r1 ; <nl> r1 [ " foo " ] = " bar " ; <nl> r . results = { r1 } ; <nl> - <nl> - pt : : ptree tree ; <nl> - auto s = serializeDistributedQueryResult ( r , tree ) ; <nl> + r . columns = { " foo " } ; <nl> + rapidjson : : Document d ( rapidjson : : kObjectType ) ; <nl> + auto s = serializeDistributedQueryResult ( r , d ) ; <nl> EXPECT_TRUE ( s . ok ( ) ) ; <nl> - EXPECT_EQ ( tree . get < std : : string > ( " request . query " ) , " foo " ) ; <nl> - EXPECT_EQ ( tree . get < std : : string > ( " request . id " ) , " bar " ) ; <nl> - auto & results = tree . get_child ( " results " ) ; <nl> - for ( const auto & q : results ) { <nl> - for ( const auto & row : q . second ) { <nl> - EXPECT_EQ ( row . first , " foo " ) ; <nl> - EXPECT_EQ ( q . second . get < std : : string > ( row . first ) , " bar " ) ; <nl> + EXPECT_TRUE ( d . IsObject ( ) ) ; <nl> + EXPECT_EQ ( d [ " request " ] [ " query " ] , " foo " ) ; <nl> + EXPECT_EQ ( d [ " request " ] [ " id " ] , " bar " ) ; <nl> + EXPECT_TRUE ( d [ " results " ] . IsArray ( ) ) ; <nl> + for ( const auto & q : d [ " results " ] . GetArray ( ) ) { <nl> + for ( const auto & row : q . GetObject ( ) ) { <nl> + EXPECT_EQ ( row . name , " foo " ) ; <nl> + EXPECT_EQ ( q [ row . name ] , " bar " ) ; <nl> } <nl> } <nl> } <nl> <nl> TEST_F ( DistributedTests , test_deserialize_distributed_query_result ) { <nl> - pt : : ptree request ; <nl> - request . put < std : : string > ( " id " , " foo " ) ; <nl> - request . put < std : : string > ( " query " , " bar " ) ; <nl> - <nl> - pt : : ptree row ; <nl> - row . put < std : : string > ( " foo " , " bar " ) ; <nl> - pt : : ptree results ; <nl> - results . push_back ( std : : make_pair ( " " , row ) ) ; <nl> - <nl> - pt : : ptree query_result ; <nl> - query_result . put_child ( " request " , request ) ; <nl> - query_result . put_child ( " results " , results ) ; <nl> + rapidjson : : Document query_result ( rapidjson : : kObjectType ) ; <nl> + rapidjson : : Document request ( rapidjson : : kObjectType ) ; <nl> + rapidjson : : Value row ( rapidjson : : kObjectType ) ; <nl> + rapidjson : : Document results ( rapidjson : : kArrayType ) ; <nl> + <nl> + request . AddMember ( <nl> + rapidjson : : Value ( " query " , query_result . GetAllocator ( ) ) . Move ( ) , <nl> + rapidjson : : Value ( " bar " , query_result . GetAllocator ( ) ) , <nl> + query_result . GetAllocator ( ) ) ; <nl> + <nl> + request . AddMember ( rapidjson : : Value ( " id " , query_result . GetAllocator ( ) ) . Move ( ) , <nl> + rapidjson : : Value ( " foo " , query_result . GetAllocator ( ) ) . Move ( ) , <nl> + query_result . GetAllocator ( ) ) ; <nl> + <nl> + row . AddMember ( rapidjson : : Value ( " foo " , query_result . GetAllocator ( ) ) . Move ( ) , <nl> + rapidjson : : Value ( " bar " , query_result . GetAllocator ( ) ) . Move ( ) , <nl> + query_result . GetAllocator ( ) ) ; <nl> + <nl> + results . PushBack ( rapidjson : : Value ( row , request . GetAllocator ( ) ) . Move ( ) , <nl> + request . GetAllocator ( ) ) ; <nl> + <nl> + query_result . AddMember ( " request " , <nl> + rapidjson : : Value ( request , query_result . GetAllocator ( ) ) , <nl> + query_result . GetAllocator ( ) ) ; <nl> + query_result . AddMember ( " results " , <nl> + rapidjson : : Value ( results , query_result . GetAllocator ( ) ) , <nl> + query_result . GetAllocator ( ) ) ; <nl> <nl> DistributedQueryResult r ; <nl> auto s = deserializeDistributedQueryResult ( query_result , r ) ; <nl> - EXPECT_TRUE ( s . ok ( ) ) ; <nl> EXPECT_EQ ( r . request . id , " foo " ) ; <nl> EXPECT_EQ ( r . request . query , " bar " ) ; <nl> EXPECT_EQ ( r . results [ 0 ] [ " foo " ] , " bar " ) ; <nl> mmm a / osquery / filesystem / fileops . h <nl> ppp b / osquery / filesystem / fileops . h <nl> <nl> # include < sys / types . h > <nl> <nl> # ifdef WIN32 <nl> - # define NOMINMAX <nl> # define WIN32_LEAN_AND_MEAN <nl> # include < windows . h > <nl> # else <nl> mmm a / osquery / filesystem / tests / fileops_tests . cpp <nl> ppp b / osquery / filesystem / tests / fileops_tests . cpp <nl> TEST_F ( FileOpsTests , test_large_read_write ) { <nl> <nl> const std : : string expected ( 20000000 , ' A ' ) ; <nl> const ssize_t expected_len = expected . size ( ) ; <nl> - ASSERT_EQ ( strlen ( expected . data ( ) ) , 20000000U ) ; <nl> + ASSERT_EQ ( strnlen ( expected . data ( ) , 20000001 ) , 20000000U ) ; <nl> <nl> { <nl> PlatformFile fd ( path , PF_CREATE_ALWAYS | PF_WRITE ) ; <nl> mmm a / osquery / filesystem / windows / fileops . cpp <nl> ppp b / osquery / filesystem / windows / fileops . cpp <nl> <nl> # include " osquery / core / process . h " <nl> # include " osquery / filesystem / fileops . h " <nl> <nl> + # define min ( a , b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) <nl> + # define max ( a , b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) <nl> + <nl> namespace fs = boost : : filesystem ; <nl> namespace errc = boost : : system : : errc ; <nl> <nl> mmm a / tools / provision . ps1 <nl> ppp b / tools / provision . ps1 <nl> function Install - ThirdParty { <nl> " snappy - msvc . 1 . 1 . 1 . 8 " , <nl> " thrift - dev . 0 . 10 . 0 - r4 " , <nl> " zlib . 1 . 2 . 8 " , <nl> + " libarchive . 3 . 3 . 1 - r1 " , <nl> + " rapidjson . 1 . 1 . 0 " <nl> " zstd . 1 . 2 . 0 - r3 " <nl> ) <nl> $ tmpDir = Join - Path $ env : TEMP ' osquery - packages ' <nl> mmm a / tools / provision . sh <nl> ppp b / tools / provision . sh <nl> function platform_darwin_main ( ) { <nl> function platform_posix_main ( ) { <nl> # libarchive for file carving <nl> brew_dependency osquery / osquery - local / libarchive <nl> + brew_dependency osquery / osquery - local / rapidjson <nl> brew_dependency osquery / osquery - local / zstd <nl> <nl> # List of LLVM - compiled dependencies . <nl> new file mode 100644 <nl> index 0000000000 . . fa5248c134 <nl> mmm / dev / null <nl> ppp b / tools / provision / chocolatey / rapidjson . ps1 <nl> <nl> + # Copyright ( c ) 2014 - present , 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 root 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> + # Update - able metadata <nl> + # <nl> + # $ version - The version of the software package to build <nl> + # $ chocoVersion - The chocolatey package version , used for incremental bumps <nl> + # without changing the version of the software package <nl> + $ version = ' 1 . 1 . 0 ' <nl> + $ chocoVersion = ' 1 . 1 . 0 ' <nl> + $ packageName = ' rapidjson ' <nl> + $ projectSource = ' https : / / github . com / miloyip / rapidjson / ' <nl> + $ packageSourceUrl = ' https : / / github . com / miloyip / rapidjson / ' <nl> + $ authors = ' Tencent ' <nl> + $ owners = ' Tencent ' <nl> + $ copyright = ' Copyright ( C ) 2015 THL A29 Limited , a Tencent company , ' + <nl> + ' and Milo Yip . All rights reserved . ' <nl> + $ license = ' https : / / raw . githubusercontent . com / miloyip / rapidjson / master / ' + <nl> + ' license . txt ' <nl> + $ url = " https : / / github . com / miloyip / rapidjson / archive / v $ version . zip " <nl> + <nl> + # Invoke our utilities file <nl> + . " $ ( Split - Path - Parent $ MyInvocation . MyCommand . Definition ) \ osquery_utils . ps1 " <nl> + <nl> + # Invoke the MSVC developer tools / env <nl> + Invoke - BatchFile " $ env : VS140COMNTOOLS \ . . \ . . \ vc \ vcvarsall . bat " amd64 <nl> + <nl> + # Time our execution <nl> + $ sw = [ System . Diagnostics . StopWatch ] : : startnew ( ) <nl> + <nl> + # Keep the location of build script , to bring with in the chocolatey package <nl> + $ buildScript = $ MyInvocation . MyCommand . Definition <nl> + <nl> + # Create the choco build dir if needed <nl> + $ buildPath = Get - OsqueryBuildPath <nl> + if ( $ buildPath - eq ' ' ) { <nl> + Write - Host ' [ - ] Failed to find source root ' - foregroundcolor red <nl> + exit <nl> + } <nl> + $ chocoBuildPath = " $ buildPath \ chocolatey \ $ packageName " <nl> + if ( - not ( Test - Path " $ chocoBuildPath " ) ) { <nl> + New - Item - Force - ItemType Directory - Path " $ chocoBuildPath " <nl> + } <nl> + Set - Location $ chocoBuildPath <nl> + <nl> + # Retreive the source <nl> + if ( - not ( Test - Path " $ packageName - $ version . zip " ) ) { <nl> + Invoke - WebRequest $ url - OutFile " $ packageName - $ version . zip " <nl> + } <nl> + <nl> + # Extract the source <nl> + $ sourceDir = Join - Path $ ( Get - Location ) " $ packageName - $ version " <nl> + if ( - not ( Test - Path $ sourceDir ) ) { <nl> + $ 7z = ( Get - Command ' 7z ' ) . Source <nl> + $ arg = " x $ packageName - $ version . zip " <nl> + Start - Process - FilePath $ 7z - ArgumentList $ arg - NoNewWindow - Wait <nl> + } <nl> + Set - Location $ sourceDir <nl> + <nl> + # If the build path exists , purge it for a clean packaging <nl> + $ chocoDir = Join - Path $ ( Get - Location ) ' osquery - choco ' <nl> + if ( Test - Path $ chocoDir ) { <nl> + Remove - Item - Force - Recurse $ chocoDir <nl> + } <nl> + <nl> + # Construct the Chocolatey Package <nl> + New - Item - ItemType Directory - Path $ chocoDir <nl> + Set - Location $ chocoDir <nl> + $ includeDir = New - Item - ItemType Directory - Path ' . \ local \ include ' <nl> + $ srcDir = New - Item - ItemType Directory - Path ' . \ local \ src ' <nl> + <nl> + Copy - Item - Recurse " $ sourceDir \ include \ rapidjson " $ includeDir <nl> + Copy - Item $ buildScript $ srcDir <nl> + <nl> + Write - NuSpec ` <nl> + $ packageName ` <nl> + $ chocoVersion ` <nl> + $ authors ` <nl> + $ owners ` <nl> + $ projectSource ` <nl> + $ packageSourceUrl ` <nl> + $ copyright ` <nl> + $ license <nl> + <nl> + choco pack <nl> + <nl> + Write - Host " [ * ] Build took $ ( $ sw . ElapsedMilliseconds ) ms " ` <nl> + - ForegroundColor DarkGreen <nl> + if ( Test - Path " $ packageName . $ chocoVersion . nupkg " ) { <nl> + Write - Host ` <nl> + " [ + ] Finished building $ packageName v $ chocoVersion . " ` <nl> + - ForegroundColor Green <nl> + } <nl> + else { <nl> + Write - Host ` <nl> + " [ - ] Failed to build $ packageName v $ chocoVersion . " ` <nl> + - ForegroundColor Red <nl> + } <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 0000000000 . . b95d4e1c5e <nl> mmm / dev / null <nl> ppp b / tools / provision / formula / rapidjson . rb <nl> <nl> + require File . expand_path ( " . . / Abstract / abstract - osquery - formula " , __FILE__ ) <nl> + <nl> + class Rapidjson < AbstractOsqueryFormula <nl> + desc " JSON parser / generator for C + + with SAX and DOM style APIs " <nl> + homepage " https : / / miloyip . github . io / rapidjson / " <nl> + url " https : / / github . com / miloyip / rapidjson / archive / v1 . 1 . 0 . tar . gz " <nl> + sha256 " bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e " <nl> + head " https : / / github . com / miloyip / rapidjson . git " <nl> + <nl> + option " without - docs " , " Don ' t build documentation " <nl> + <nl> + depends_on " cmake " = > : build <nl> + depends_on " doxygen " = > : build if build . with ? " docs " <nl> + <nl> + def install <nl> + args = std_cmake_args <nl> + args < < " - DRAPIDJSON_BUILD_DOC = OFF " if build . without ? " docs " <nl> + system " cmake " , " . " , * args <nl> + system " make " , " install " <nl> + end <nl> + <nl> + test do <nl> + system ENV . cxx , " # { share } / doc / RapidJSON / examples / capitalize / capitalize . cpp " , " - o " , " capitalize " <nl> + assert_equal ' { " A " : " B " } ' , pipe_output ( " . / capitalize " , ' { " a " : " b " } ' ) <nl> + end <nl> + end <nl> mmm a / tools / provision / freebsd . sh <nl> ppp b / tools / provision / freebsd . sh <nl> function distro_main ( ) { <nl> package asio <nl> package cpp - netlib <nl> package linenoise - ng <nl> + package rapidjson <nl> package zstd <nl> <nl> # Non - optional features . <nl> mmm a / tools / tests / test_http_server . py <nl> ppp b / tools / tests / test_http_server . py <nl> <nl> " node_invalid " : False , <nl> } <nl> <nl> + EXAMPLE_EMPTY_CONFIG = { <nl> + " schedule " : { <nl> + " tls_proc " : { " query " : " select * from processes " , " interval " : 1 } , <nl> + } , <nl> + " node_invalid " : False , <nl> + } <nl> + <nl> # A ' node ' variation of the TLS API uses a GET for config . <nl> EXAMPLE_NODE_CONFIG = EXAMPLE_CONFIG <nl> EXAMPLE_NODE_CONFIG [ " node " ] = True <nl> def log ( self , request ) : <nl> self . _reply ( { } ) <nl> <nl> def test_read_requests ( self ) : <nl> - # call made by unit tests to retrieve the entire history of requests <nl> + # call made by unit tests to retrieve the entire history of requests <nl> # made by code under test . Used by unit tests to verify that the code <nl> # under test made the expected calls to the TLS backend <nl> self . _reply ( RECEIVED_REQUESTS ) <nl> def _push_request ( self , command , request ) : <nl> # can retrieve it later for verification purposes <nl> request [ ' command ' ] = command <nl> RECEIVED_REQUESTS . append ( request ) <nl> - <nl> + <nl> def _reply ( self , response ) : <nl> debug ( " Replying : % s " % ( str ( response ) ) ) <nl> self . wfile . write ( json . dumps ( response ) ) <nl> <nl> <nl> def handler ( ) : <nl> - debug ( " Shutting down HTTP server via timeout ( % d ) seconds . " <nl> + debug ( " Shutting down HTTP server via timeout ( % d ) seconds . " <nl> % ( ARGS . timeout ) ) <nl> thread . interrupt_main ( ) <nl> <nl> | [ Distributed ] Moving to RapidJSON ( ) | osquery/osquery | 8a963e8d40e0c1d121f6c22f2ba6b434c341658f | 2017-08-07T23:34:44Z |
mmm a / ports / grpc / portfile . cmake <nl> ppp b / ports / grpc / portfile . cmake <nl> file ( RENAME $ { CURRENT_PACKAGES_DIR } / lib / cmake / gRPC / gRPCTargets - release . cmake $ { C <nl> file ( RENAME $ { CURRENT_PACKAGES_DIR } / debug / lib / cmake / gRPC / gRPCTargets - debug . cmake $ { CURRENT_PACKAGES_DIR } / share / grpc / gRPCTargets - debug . cmake ) <nl> <nl> file ( INSTALL $ { CURRENT_BUILDTREES_DIR } / src / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / grpc RENAME copyright ) <nl> + file ( MAKE_DIRECTORY $ { CURRENT_PACKAGES_DIR } / tools ) <nl> + file ( INSTALL $ { CURRENT_BUILDTREES_DIR } / $ { TARGET_TRIPLET } - rel / Release / grpc_cpp_plugin . exe DESTINATION $ { CURRENT_PACKAGES_DIR } / tools ) <nl> <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / bin ) <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> | Install grpc_cpp_plugin . exe into tools folder | microsoft/vcpkg | 9ee6208e02128f0d22859ffe91cb29ac49a13f17 | 2017-02-01T17:49:09Z |
mmm a / dbms / src / Columns / Collator . cpp <nl> ppp b / dbms / src / Columns / Collator . cpp <nl> const std : : string & Collator : : getLocale ( ) const <nl> { <nl> return locale ; <nl> } <nl> + <nl> + std : : vector < std : : string > Collator : : getAvailableCollations ( ) { <nl> + std : : vector < std : : string > result ; <nl> + # if USE_ICU <nl> + size_t available_locales_count = ucol_countAvailable ( ) ; <nl> + for ( size_t i = 0 ; i < available_locales_count ; + + i ) { <nl> + result . push_back ( ucol_getAvailable ( i ) ) ; <nl> + } <nl> + # endif <nl> + return result ; <nl> + } <nl> mmm a / dbms / src / Columns / Collator . h <nl> ppp b / dbms / src / Columns / Collator . h <nl> <nl> # pragma once <nl> <nl> # include < string > <nl> + # include < vector > <nl> # include < boost / noncopyable . hpp > <nl> <nl> struct UCollator ; <nl> class Collator : private boost : : noncopyable <nl> <nl> const std : : string & getLocale ( ) const ; <nl> <nl> + static std : : vector < std : : string > getAvailableCollations ( ) ; <nl> + <nl> private : <nl> std : : string locale ; <nl> UCollator * collator ; <nl> new file mode 100644 <nl> index 00000000000 . . b75a2e70298 <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / System / StorageSystemCollations . cpp <nl> <nl> + # include < Columns / Collator . h > <nl> + # include < Storages / System / StorageSystemCollations . h > <nl> + <nl> + namespace DB <nl> + { <nl> + void StorageSystemCollations : : fillData ( MutableColumns & res_columns ) const <nl> + { <nl> + for ( const auto & collation : Collator : : getAvailableCollations ( ) ) <nl> + { <nl> + res_columns [ 0 ] - > insert ( collation ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . a10b19bb954 <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / System / StorageSystemCollations . h <nl> <nl> + # pragma once <nl> + # include < Storages / System / IStorageSystemWithStringColumns . h > <nl> + # include < ext / shared_ptr_helper . h > <nl> + <nl> + namespace DB <nl> + { <nl> + class StorageSystemCollations : public ext : : shared_ptr_helper < StorageSystemCollations > , <nl> + public IStorageSystemWithStringColumns < StorageSystemCollations > <nl> + { <nl> + protected : <nl> + void fillData ( MutableColumns & res_columns ) const override ; <nl> + <nl> + public : <nl> + using IStorageSystemWithStringColumns : : IStorageSystemWithStringColumns ; <nl> + <nl> + std : : string getName ( ) const override <nl> + { <nl> + return " SystemTableCollations " ; <nl> + } <nl> + <nl> + static std : : vector < String > getColumnNames ( ) <nl> + { <nl> + return { " name " } ; <nl> + } <nl> + } ; <nl> + } <nl> mmm a / dbms / src / Storages / System / attachSystemTables . cpp <nl> ppp b / dbms / src / Storages / System / attachSystemTables . cpp <nl> <nl> # include < Storages / System / StorageSystemAggregateFunctionCombinators . h > <nl> # include < Storages / System / StorageSystemAsynchronousMetrics . h > <nl> # include < Storages / System / StorageSystemBuildOptions . h > <nl> + # include < Storages / System / StorageSystemCollations . h > <nl> # include < Storages / System / StorageSystemClusters . h > <nl> # include < Storages / System / StorageSystemColumns . h > <nl> # include < Storages / System / StorageSystemDatabases . h > <nl> void attachSystemTablesLocal ( IDatabase & system_database ) <nl> system_database . attachTable ( " table_functions " , StorageSystemTableFunctions : : create ( " table_functions " ) ) ; <nl> system_database . attachTable ( " aggregate_function_combinators " , StorageSystemAggregateFunctionCombinators : : create ( " aggregate_function_combinators " ) ) ; <nl> system_database . attachTable ( " data_type_families " , StorageSystemDataTypeFamilies : : create ( " data_type_families " ) ) ; <nl> + system_database . attachTable ( " collations " , StorageSystemCollations : : create ( " collations " ) ) ; <nl> } <nl> <nl> void attachSystemTablesServer ( IDatabase & system_database , bool has_zookeeper ) <nl> | CLICKHOUSE - 3791 : Add system table collations | ClickHouse/ClickHouse | fae9c33282e593151e14e0ca4df7b59eb213b3b0 | 2018-07-20T13:17:16Z |
mmm a / samples / Javascript / CocosPlayer / Classes / AppDelegate . cpp <nl> ppp b / samples / Javascript / CocosPlayer / Classes / AppDelegate . cpp <nl> <nl> # include " js_bindings_system_registration . h " <nl> # include " jsb_opengl_registration . h " <nl> <nl> - # ifdef JSLOG <nl> - # undef JSLOG <nl> - # endif <nl> - # define JSLOG CocosBuilder_log <nl> <nl> char * _js_log_buf_ccbuilder = NULL ; <nl> <nl> bool runMainScene ( ) { <nl> <nl> void handle_ccb_run ( ) { <nl> CCFileUtils : : sharedFileUtils ( ) - > purgeCachedEntries ( ) ; <nl> + CCFileUtils : : sharedFileUtils ( ) - > loadFilenameLookupDictionaryFromFile ( " fileLookup . plist " ) ; <nl> ScriptingCore : : getInstance ( ) - > runScript ( " main . js " ) ; <nl> } <nl> <nl> void handle_ccb_stop ( ) { <nl> runMainScene ( ) ; <nl> } <nl> <nl> + void sendLogMsg ( const char * msg ) ; <nl> + <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> + <nl> + void cocos2d : : CCLog ( const char * pszFormat , . . . ) <nl> + { <nl> + printf ( " Cocos2d : " ) ; <nl> + char szBuf [ kMaxLogLen + 1 ] = { 0 } ; <nl> + va_list ap ; <nl> + va_start ( ap , pszFormat ) ; <nl> + vsnprintf ( szBuf , kMaxLogLen , pszFormat , ap ) ; <nl> + va_end ( ap ) ; <nl> + printf ( " % s " , szBuf ) ; <nl> + printf ( " \ n " ) ; <nl> + sendLogMsg ( szBuf ) ; <nl> + } <nl> + # endif <nl> <nl> extern " C " { <nl> <nl> + <nl> const char * getCCBDirectoryPath ( ) ; <nl> <nl> bool AppDelegate : : applicationDidFinishLaunching ( ) <nl> bool AppDelegate : : applicationDidFinishLaunching ( ) <nl> if ( screenSize . height > 1024 ) <nl> { <nl> res = " iPad " ; <nl> - designSize = CCSizeMake ( 360 , 480 ) ; <nl> + designSize = CCSizeMake ( 768 , 1024 ) ; <nl> resourceSize = CCSizeMake ( 1536 , 2048 ) ; <nl> resDirOrders . push_back ( " resources - ipadhd " ) ; <nl> resDirOrders . push_back ( " resources - ipad " ) ; <nl> bool AppDelegate : : applicationDidFinishLaunching ( ) <nl> else if ( screenSize . height > 960 ) <nl> { <nl> res = " iPad " ; <nl> - designSize = CCSizeMake ( 360 , 480 ) ; <nl> + designSize = CCSizeMake ( 768 , 1024 ) ; <nl> resourceSize = CCSizeMake ( 768 , 1024 ) ; <nl> resDirOrders . push_back ( " resources - ipad " ) ; <nl> resDirOrders . push_back ( " resources - iphonehd " ) ; <nl> mmm a / samples / Javascript / CocosPlayer / Classes / Java_org_cocos2dx_cocosplayer_CocosPlayerSocket . cpp <nl> ppp b / samples / Javascript / CocosPlayer / Classes / Java_org_cocos2dx_cocosplayer_CocosPlayerSocket . cpp <nl> extern " C " { <nl> t . env - > DeleteLocalRef ( t . classID ) ; <nl> } <nl> } <nl> + <nl> + <nl> + void sendLogMsg ( const char * res ) { <nl> + JniMethodInfo t ; <nl> + if ( JniHelper : : getStaticMethodInfo ( t , SOCKET_CLASS_NAME , " sendLog " , " ( Ljava / lang / String ; ) V " ) ) { <nl> + jstring stringArg1 = t . env - > NewStringUTF ( res ) ; <nl> + t . env - > CallStaticVoidMethod ( t . classID , t . methodID , stringArg1 ) ; <nl> + t . env - > DeleteLocalRef ( stringArg1 ) ; <nl> + t . env - > DeleteLocalRef ( t . classID ) ; <nl> + } <nl> + } <nl> + <nl> const char * getCCBDirectoryPath ( ) { <nl> return " " ; <nl> } <nl> mmm a / samples / Javascript / CocosPlayer / Classes / Java_org_cocos2dx_cocosplayer_CocosPlayerSocket . h <nl> ppp b / samples / Javascript / CocosPlayer / Classes / Java_org_cocos2dx_cocosplayer_CocosPlayerSocket . h <nl> extern " C " { <nl> extern void updatePairing ( const char * code ) ; <nl> extern void cleanCacheDirJNI ( ) ; <nl> extern void setDeviceResolutionJNI ( const char * res ) ; <nl> + extern void sendLogMsg ( const char * log ) ; <nl> } <nl> <nl> # endif <nl> mmm a / samples / Javascript / CocosPlayer / proj . android / src / org / cocos2dx / cocosplayer / CCBStreamHandler . java <nl> ppp b / samples / Javascript / CocosPlayer / proj . android / src / org / cocos2dx / cocosplayer / CCBStreamHandler . java <nl> public static String getFileSystem ( ) { <nl> return null ; <nl> } <nl> <nl> + public static String getLogMsg ( String msg ) { <nl> + try { <nl> + NSDictionary root = new NSDictionary ( ) ; <nl> + root . put ( " cmd " , " log " ) ; <nl> + root . put ( " log " , msg ) ; <nl> + String payload = root . toXMLPropertyList ( ) ; <nl> + / / String data = new String ( header , 0 , header . length ) ; <nl> + return payload ; <nl> + } catch ( Exception e ) { <nl> + } <nl> + return null ; <nl> + } <nl> <nl> public static void setDeviceResolution ( String res ) { <nl> CocosPlayerSocket server = new CocosPlayerSocket ( ) ; <nl> mmm a / samples / Javascript / CocosPlayer / proj . android / src / org / cocos2dx / cocosplayer / CocosPlayerSocket . java <nl> ppp b / samples / Javascript / CocosPlayer / proj . android / src / org / cocos2dx / cocosplayer / CocosPlayerSocket . java <nl> <nl> private static ServerSocket server ; <nl> private static int mPairingCode = - 1 ; <nl> private static CocosPlayerPresence presence = null ; <nl> - <nl> + private static PrintWriter out = null ; <nl> + private static Socket client = null ; <nl> private void runCCB ( ) { <nl> Cocos2dxGLSurfaceView . getInstance ( ) . queueEvent ( new Runnable ( ) { <nl> @ Override <nl> protected Void doInBackground ( ServerSocket . . . args ) { <nl> ServerSocket server = args [ 0 ] ; <nl> while ( true ) { <nl> <nl> - Socket client = server . accept ( ) ; <nl> + client = server . accept ( ) ; <nl> <nl> Log . i ( TAG , " New connection from " + client . getInetAddress ( ) ) ; <nl> handleConnected ( ) ; <nl> protected Void doInBackground ( ServerSocket . . . args ) { <nl> try { <nl> <nl> / / Send deviceInfo and filelist <nl> - PrintWriter out = new PrintWriter ( client . getOutputStream ( ) , true ) ; <nl> + out = new PrintWriter ( client . getOutputStream ( ) , true ) ; <nl> CCBStreamHandler . sendString ( CCBStreamHandler . getDeviceInfo ( ) , client , out ) ; <nl> CCBStreamHandler . sendString ( CCBStreamHandler . getFileSystem ( ) , client , out ) ; <nl> / / out . close ( ) ; <nl> public static void setPairingCode ( int code ) { <nl> / / new PresenceStarter ( ) . execute ( server . getLocalPort ( ) , mPairingCode ) ; <nl> } <nl> <nl> + <nl> + public static void sendLog ( String log ) { <nl> + CCBStreamHandler . sendString ( CCBStreamHandler . getLogMsg ( log ) , client , out ) ; <nl> + } <nl> + <nl> public void createServer ( ) { <nl> <nl> Log . i ( TAG , " Creating server " + running ) ; <nl> mmm a / samples / Javascript / CocosPlayer / proj . ios / AppController . mm <nl> ppp b / samples / Javascript / CocosPlayer / proj . ios / AppController . mm <nl> void cleanCacheDirJNI ( ) { <nl> cleanCache ( ) ; <nl> } <nl> <nl> + void sendLogMsg ( const char * msg ) { <nl> + if ( server ! = NULL ) { <nl> + NSString * str = [ NSString stringWithCString : msg encoding : NSASCIIStringEncoding ] ; <nl> + [ server sendLog : [ str stringByAppendingString : @ " \ n " ] ] ; <nl> + } <nl> + } <nl> + <nl> + <nl> void updatePairing ( const char * pairing ) { <nl> NSString * code = [ NSString stringWithCString : pairing encoding : NSASCIIStringEncoding ] ; <nl> if ( [ code isEqual : @ " Auto " ] ) { <nl> | Adding log redirect over the network for iOS . Also fixing Stop command crash in Android | cocos2d/cocos2d-x | d8c30e0c5bcad2fcabe3ef2575b6bb72a59cee33 | 2013-04-26T01:39:51Z |
mmm a / docs / SIL . rst <nl> ppp b / docs / SIL . rst <nl> Checked Conversions <nl> <nl> Some user - level cast operations can fail and thus require runtime checking . <nl> <nl> - The ` unconditional_checked_cast_addr ` _ , ` unconditional_checked_cast_opaque ` _ and ` unconditional_checked_cast ` _ <nl> + The ` unconditional_checked_cast_addr ` _ , ` unconditional_checked_cast_value ` _ and ` unconditional_checked_cast ` _ <nl> instructions performs an unconditional checked cast ; it is a runtime failure <nl> if the cast fails . The ` checked_cast_addr_br ` _ , ` checked_cast_value_br ` _ and ` checked_cast_br ` _ <nl> terminator instruction performs a conditional checked cast ; it branches to one <nl> unconditional_checked_cast_addr <nl> Performs a checked indirect conversion , causing a runtime failure if the <nl> conversion fails . <nl> <nl> - unconditional_checked_cast_opaque <nl> - ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` <nl> + unconditional_checked_cast_value <nl> + ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` <nl> : : <nl> <nl> - sil - instruction : : = ' unconditional_checked_cast_opaque ' sil - operand ' to ' sil - type <nl> + sil - instruction : : = ' unconditional_checked_cast_value ' sil - operand ' to ' sil - type <nl> <nl> - % 1 = unconditional_checked_cast_opaque % 0 : $ A to $ B <nl> + % 1 = unconditional_checked_cast_value % 0 : $ A to $ B <nl> / / $ A must be not be an address <nl> / / $ B must be an opaque value <nl> / / % 1 will be of type $ B <nl> mmm a / include / swift / SIL / SILBuilder . h <nl> ppp b / include / swift / SIL / SILBuilder . h <nl> class SILBuilder { <nl> targetType ) ) ; <nl> } <nl> <nl> - UnconditionalCheckedCastOpaqueInst * <nl> - createUnconditionalCheckedCastOpaque ( SILLocation Loc , SILValue op , <nl> - SILType destTy ) { <nl> - return insert ( UnconditionalCheckedCastOpaqueInst : : create ( <nl> + UnconditionalCheckedCastValueInst * <nl> + createUnconditionalCheckedCastValue ( SILLocation Loc , SILValue op , <nl> + SILType destTy ) { <nl> + return insert ( UnconditionalCheckedCastValueInst : : create ( <nl> getSILDebugLocation ( Loc ) , op , destTy , F , OpenedArchetypes ) ) ; <nl> } <nl> <nl> mmm a / include / swift / SIL / SILCloner . h <nl> ppp b / include / swift / SIL / SILCloner . h <nl> SILCloner < ImplClass > : : visitUnconditionalCheckedCastAddrInst ( <nl> } <nl> <nl> template < typename ImplClass > <nl> - void SILCloner < ImplClass > : : visitUnconditionalCheckedCastOpaqueInst ( <nl> - UnconditionalCheckedCastOpaqueInst * Inst ) { <nl> + void SILCloner < ImplClass > : : visitUnconditionalCheckedCastValueInst ( <nl> + UnconditionalCheckedCastValueInst * Inst ) { <nl> SILLocation OpLoc = getOpLocation ( Inst - > getLoc ( ) ) ; <nl> SILValue OpValue = getOpValue ( Inst - > getOperand ( ) ) ; <nl> SILType OpType = getOpType ( Inst - > getType ( ) ) ; <nl> getBuilder ( ) . setCurrentDebugScope ( getOpScope ( Inst - > getDebugScope ( ) ) ) ; <nl> - doPostProcess ( Inst , getBuilder ( ) . createUnconditionalCheckedCastOpaque ( <nl> + doPostProcess ( Inst , getBuilder ( ) . createUnconditionalCheckedCastValue ( <nl> OpLoc , OpValue , OpType ) ) ; <nl> } <nl> <nl> mmm a / include / swift / SIL / SILInstruction . h <nl> ppp b / include / swift / SIL / SILInstruction . h <nl> class UnconditionalCheckedCastAddrInst : public SILInstruction <nl> <nl> / / / Perform an unconditional checked cast that aborts if the cast fails . <nl> / / / The result of the checked cast is left in the destination . <nl> - class UnconditionalCheckedCastOpaqueInst final <nl> + class UnconditionalCheckedCastValueInst final <nl> : public UnaryInstructionWithTypeDependentOperandsBase < <nl> - ValueKind : : UnconditionalCheckedCastOpaqueInst , <nl> - UnconditionalCheckedCastOpaqueInst , ConversionInst , true > { <nl> + ValueKind : : UnconditionalCheckedCastValueInst , <nl> + UnconditionalCheckedCastValueInst , ConversionInst , true > { <nl> friend SILBuilder ; <nl> <nl> - UnconditionalCheckedCastOpaqueInst ( SILDebugLocation DebugLoc , <nl> - SILValue Operand , <nl> - ArrayRef < SILValue > TypeDependentOperands , <nl> - SILType DestTy ) <nl> + UnconditionalCheckedCastValueInst ( SILDebugLocation DebugLoc , SILValue Operand , <nl> + ArrayRef < SILValue > TypeDependentOperands , <nl> + SILType DestTy ) <nl> : UnaryInstructionWithTypeDependentOperandsBase ( <nl> DebugLoc , Operand , TypeDependentOperands , DestTy ) { } <nl> <nl> - static UnconditionalCheckedCastOpaqueInst * <nl> + static UnconditionalCheckedCastValueInst * <nl> create ( SILDebugLocation DebugLoc , SILValue Operand , SILType DestTy , <nl> SILFunction & F , SILOpenedArchetypesState & OpenedArchetypes ) ; <nl> } ; <nl> mmm a / include / swift / SIL / SILNodes . def <nl> ppp b / include / swift / SIL / SILNodes . def <nl> ABSTRACT_VALUE ( SILInstruction , ValueBase ) <nl> INST ( ObjCMetatypeToObjectInst , ConversionInst , objc_metatype_to_object , None , DoesNotRelease ) <nl> INST ( ObjCExistentialMetatypeToObjectInst , ConversionInst , objc_existential_metatype_to_object , None , <nl> DoesNotRelease ) <nl> - INST ( UnconditionalCheckedCastOpaqueInst , ConversionInst , unconditional_checked_cast_opaque , None , DoesNotRelease ) <nl> + INST ( UnconditionalCheckedCastValueInst , ConversionInst , unconditional_checked_cast_value , None , DoesNotRelease ) <nl> INST ( UnconditionalCheckedCastInst , ConversionInst , unconditional_checked_cast , None , DoesNotRelease ) <nl> VALUE_RANGE ( ConversionInst , UpcastInst , UnconditionalCheckedCastInst ) <nl> INST ( IsNonnullInst , SILInstruction , is_nonnull , None , DoesNotRelease ) <nl> mmm a / lib / IRGen / IRGenSIL . cpp <nl> ppp b / lib / IRGen / IRGenSIL . cpp <nl> class IRGenSILFunction : <nl> void visitObjCToThickMetatypeInst ( ObjCToThickMetatypeInst * i ) ; <nl> void visitUnconditionalCheckedCastInst ( UnconditionalCheckedCastInst * i ) ; <nl> void visitUnconditionalCheckedCastAddrInst ( UnconditionalCheckedCastAddrInst * i ) ; <nl> - void visitUnconditionalCheckedCastOpaqueInst ( <nl> - UnconditionalCheckedCastOpaqueInst * i ) ; <nl> + void <nl> + visitUnconditionalCheckedCastValueInst ( UnconditionalCheckedCastValueInst * i ) ; <nl> void visitObjCMetatypeToObjectInst ( ObjCMetatypeToObjectInst * i ) ; <nl> void visitObjCExistentialMetatypeToObjectInst ( <nl> ObjCExistentialMetatypeToObjectInst * i ) ; <nl> void IRGenSILFunction : : visitUnconditionalCheckedCastAddrInst ( <nl> i - > getConsumptionKind ( ) , CheckedCastMode : : Unconditional ) ; <nl> } <nl> <nl> - void IRGenSILFunction : : visitUnconditionalCheckedCastOpaqueInst ( <nl> - swift : : UnconditionalCheckedCastOpaqueInst * i ) { <nl> + void IRGenSILFunction : : visitUnconditionalCheckedCastValueInst ( <nl> + swift : : UnconditionalCheckedCastValueInst * i ) { <nl> llvm_unreachable ( " unsupported instruction during IRGen " ) ; <nl> } <nl> <nl> mmm a / lib / Parse / ParseSIL . cpp <nl> ppp b / lib / Parse / ParseSIL . cpp <nl> bool SILParser : : parseSILInstruction ( SILBasicBlock * BB , SILBuilder & B ) { <nl> <nl> / / Checked Conversion instructions . <nl> case ValueKind : : UnconditionalCheckedCastInst : <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : <nl> case ValueKind : : CheckedCastValueBranchInst : <nl> case ValueKind : : CheckedCastBranchInst : { <nl> SILType ty ; <nl> bool SILParser : : parseSILInstruction ( SILBasicBlock * BB , SILBuilder & B ) { <nl> return true ; <nl> ResultVal = B . createUnconditionalCheckedCast ( InstLoc , Val , ty ) ; <nl> break ; <nl> - } else if ( Opcode = = ValueKind : : UnconditionalCheckedCastOpaqueInst ) { <nl> + } else if ( Opcode = = ValueKind : : UnconditionalCheckedCastValueInst ) { <nl> if ( parseSILDebugLocation ( InstLoc , B ) ) <nl> return true ; <nl> - ResultVal = B . createUnconditionalCheckedCastOpaque ( InstLoc , Val , ty ) ; <nl> + ResultVal = B . createUnconditionalCheckedCastValue ( InstLoc , Val , ty ) ; <nl> break ; <nl> } <nl> / / The conditional cast still needs its branch destinations . <nl> mmm a / lib / SIL / InstructionUtils . cpp <nl> ppp b / lib / SIL / InstructionUtils . cpp <nl> static bool isRCIdentityPreservingCast ( ValueKind Kind ) { <nl> case ValueKind : : UncheckedRefCastInst : <nl> case ValueKind : : UncheckedRefCastAddrInst : <nl> case ValueKind : : UnconditionalCheckedCastInst : <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : <nl> case ValueKind : : RefToBridgeObjectInst : <nl> case ValueKind : : BridgeObjectToRefInst : <nl> return true ; <nl> void ConformanceCollector : : collect ( swift : : SILInstruction * I ) { <nl> case ValueKind : : AllocRefDynamicInst : <nl> case ValueKind : : MetatypeInst : <nl> case ValueKind : : UnconditionalCheckedCastInst : <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : <nl> scanType ( I - > getType ( ) . getSwiftRValueType ( ) ) ; <nl> break ; <nl> case ValueKind : : AllocStackInst : { <nl> mmm a / lib / SIL / SILInstructions . cpp <nl> ppp b / lib / SIL / SILInstructions . cpp <nl> UnconditionalCheckedCastInst * UnconditionalCheckedCastInst : : create ( <nl> TypeDependentOperands , DestTy ) ; <nl> } <nl> <nl> - UnconditionalCheckedCastOpaqueInst * UnconditionalCheckedCastOpaqueInst : : create ( <nl> + UnconditionalCheckedCastValueInst * UnconditionalCheckedCastValueInst : : create ( <nl> SILDebugLocation DebugLoc , SILValue Operand , SILType DestTy , SILFunction & F , <nl> SILOpenedArchetypesState & OpenedArchetypes ) { <nl> SILModule & Mod = F . getModule ( ) ; <nl> UnconditionalCheckedCastOpaqueInst * UnconditionalCheckedCastOpaqueInst : : create ( <nl> unsigned size = <nl> totalSizeToAlloc < swift : : Operand > ( 1 + TypeDependentOperands . size ( ) ) ; <nl> void * Buffer = <nl> - Mod . allocateInst ( size , alignof ( UnconditionalCheckedCastOpaqueInst ) ) ; <nl> - return : : new ( Buffer ) UnconditionalCheckedCastOpaqueInst ( <nl> + Mod . allocateInst ( size , alignof ( UnconditionalCheckedCastValueInst ) ) ; <nl> + return : : new ( Buffer ) UnconditionalCheckedCastValueInst ( <nl> DebugLoc , Operand , TypeDependentOperands , DestTy ) ; <nl> } <nl> <nl> mmm a / lib / SIL / SILOwnershipVerifier . cpp <nl> ppp b / lib / SIL / SILOwnershipVerifier . cpp <nl> static bool isOwnershipForwardingValueKind ( ValueKind K ) { <nl> case ValueKind : : RefToBridgeObjectInst : <nl> case ValueKind : : BridgeObjectToRefInst : <nl> case ValueKind : : UnconditionalCheckedCastInst : <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : <nl> case ValueKind : : TupleExtractInst : <nl> case ValueKind : : StructExtractInst : <nl> case ValueKind : : UncheckedEnumDataInst : <nl> FORWARD_ANY_OWNERSHIP_INST ( ConvertFunction ) <nl> FORWARD_ANY_OWNERSHIP_INST ( RefToBridgeObject ) <nl> FORWARD_ANY_OWNERSHIP_INST ( BridgeObjectToRef ) <nl> FORWARD_ANY_OWNERSHIP_INST ( UnconditionalCheckedCast ) <nl> - FORWARD_ANY_OWNERSHIP_INST ( UnconditionalCheckedCastOpaque ) <nl> + FORWARD_ANY_OWNERSHIP_INST ( UnconditionalCheckedCastValue ) <nl> FORWARD_ANY_OWNERSHIP_INST ( MarkUninitialized ) <nl> FORWARD_ANY_OWNERSHIP_INST ( UncheckedEnumData ) <nl> # undef FORWARD_ANY_OWNERSHIP_INST <nl> mmm a / lib / SIL / SILPrinter . cpp <nl> ppp b / lib / SIL / SILPrinter . cpp <nl> class SILPrinter : public SILVisitor < SILPrinter > { <nl> < < getIDAndType ( CI - > getDest ( ) ) ; <nl> } <nl> <nl> - void visitUnconditionalCheckedCastOpaqueInst ( <nl> - UnconditionalCheckedCastOpaqueInst * CI ) { <nl> + void visitUnconditionalCheckedCastValueInst ( <nl> + UnconditionalCheckedCastValueInst * CI ) { <nl> * this < < getIDAndType ( CI - > getOperand ( ) ) < < " to " < < CI - > getType ( ) ; <nl> } <nl> <nl> mmm a / lib / SIL / SILValue . cpp <nl> ppp b / lib / SIL / SILValue . cpp <nl> CONSTANT_OWNERSHIP_INST ( Owned , PartialApply ) <nl> CONSTANT_OWNERSHIP_INST ( Owned , StrongPin ) <nl> CONSTANT_OWNERSHIP_INST ( Owned , ThinToThickFunction ) <nl> CONSTANT_OWNERSHIP_INST ( Owned , InitExistentialOpaque ) <nl> - CONSTANT_OWNERSHIP_INST ( Owned , UnconditionalCheckedCastOpaque ) <nl> + CONSTANT_OWNERSHIP_INST ( Owned , UnconditionalCheckedCastValue ) <nl> <nl> / / One would think that these / should / be unowned . In truth they are owned since <nl> / / objc metatypes do not go through the retain / release fast path . In their <nl> mmm a / lib / SIL / SILVerifier . cpp <nl> ppp b / lib / SIL / SILVerifier . cpp <nl> class SILVerifier : public SILVerifierBase < SILVerifier > { <nl> verifyOpenedArchetype ( CI , CI - > getType ( ) . getSwiftRValueType ( ) ) ; <nl> } <nl> <nl> - void checkUnconditionalCheckedCastOpaqueInst ( <nl> - UnconditionalCheckedCastOpaqueInst * CI ) { <nl> + void checkUnconditionalCheckedCastValueInst ( <nl> + UnconditionalCheckedCastValueInst * CI ) { <nl> verifyCheckedCast ( / * exact * / false , CI - > getOperand ( ) - > getType ( ) , <nl> CI - > getType ( ) , true ) ; <nl> verifyOpenedArchetype ( CI , CI - > getType ( ) . getSwiftRValueType ( ) ) ; <nl> mmm a / lib / SILGen / SILGenBuilder . cpp <nl> ppp b / lib / SILGen / SILGenBuilder . cpp <nl> ManagedValue SILGenBuilder : : createEnum ( SILLocation loc , ManagedValue payload , <nl> return gen . emitManagedRValueWithCleanup ( result ) ; <nl> } <nl> <nl> - ManagedValue SILGenBuilder : : createUnconditionalCheckedCastOpaque ( <nl> + ManagedValue SILGenBuilder : : createUnconditionalCheckedCastValue ( <nl> SILLocation loc , ManagedValue operand , SILType type ) { <nl> - SILValue result = SILBuilder : : createUnconditionalCheckedCastOpaque ( <nl> + SILValue result = SILBuilder : : createUnconditionalCheckedCastValue ( <nl> loc , operand . forward ( gen ) , type ) ; <nl> return gen . emitManagedRValueWithCleanup ( result ) ; <nl> } <nl> mmm a / lib / SILGen / SILGenBuilder . h <nl> ppp b / lib / SILGen / SILGenBuilder . h <nl> class SILGenBuilder : public SILBuilder { <nl> SILLocation loc , SILType ty , const TypeLowering & lowering , <nl> SGFContext context , std : : function < void ( SILValue ) > rvalueEmitter ) ; <nl> <nl> - using SILBuilder : : createUnconditionalCheckedCastOpaque ; <nl> - ManagedValue createUnconditionalCheckedCastOpaque ( SILLocation loc , <nl> - ManagedValue operand , <nl> - SILType type ) ; <nl> + using SILBuilder : : createUnconditionalCheckedCastValue ; <nl> + ManagedValue createUnconditionalCheckedCastValue ( SILLocation loc , <nl> + ManagedValue operand , <nl> + SILType type ) ; <nl> using SILBuilder : : createUnconditionalCheckedCast ; <nl> ManagedValue createUnconditionalCheckedCast ( SILLocation loc , <nl> ManagedValue operand , <nl> mmm a / lib / SILGen / SILGenDynamicCast . cpp <nl> ppp b / lib / SILGen / SILGenDynamicCast . cpp <nl> namespace { <nl> <nl> ManagedValue result ; <nl> if ( Strategy = = CastStrategy : : Address ) { <nl> - result = SGF . B . createUnconditionalCheckedCastOpaque ( <nl> + result = SGF . B . createUnconditionalCheckedCastValue ( <nl> Loc , operand , origTargetTL . getLoweredType ( ) ) ; <nl> } else { <nl> result = SGF . B . createUnconditionalCheckedCast ( <nl> namespace { <nl> <nl> SILValue resultScalar ; <nl> if ( Strategy = = CastStrategy : : Address ) { <nl> - resultScalar = SGF . B . createUnconditionalCheckedCastOpaque ( <nl> + resultScalar = SGF . B . createUnconditionalCheckedCastValue ( <nl> Loc , operand . forward ( SGF ) , origTargetTL . getLoweredType ( ) ) ; <nl> } else { <nl> resultScalar = SGF . B . createUnconditionalCheckedCast ( <nl> mmm a / lib / SILOptimizer / Utils / Local . cpp <nl> ppp b / lib / SILOptimizer / Utils / Local . cpp <nl> SILInstruction * CastOptimizer : : simplifyCheckedCastValueBranchInst ( <nl> } <nl> <nl> if ( ! CastedValue ) <nl> - CastedValue = Builder . createUnconditionalCheckedCastOpaque ( <nl> + CastedValue = Builder . createUnconditionalCheckedCastValue ( <nl> Loc , Op , LoweredTargetType ) ; <nl> } else { <nl> CastedValue = SILUndef : : get ( LoweredTargetType , Mod ) ; <nl> mmm a / lib / SILOptimizer / Utils / SILInliner . cpp <nl> ppp b / lib / SILOptimizer / Utils / SILInliner . cpp <nl> InlineCost swift : : instructionInlineCost ( SILInstruction & I ) { <nl> case ValueKind : : UncheckedTakeEnumDataAddrInst : <nl> case ValueKind : : UnconditionalCheckedCastInst : <nl> case ValueKind : : UnconditionalCheckedCastAddrInst : <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : <nl> case ValueKind : : UnmanagedToRefInst : <nl> case ValueKind : : UnownedReleaseInst : <nl> case ValueKind : : UnownedRetainInst : <nl> mmm a / lib / Serialization / DeserializeSIL . cpp <nl> ppp b / lib / Serialization / DeserializeSIL . cpp <nl> bool SILDeserializer : : readSILInstruction ( SILFunction * Fn , SILBasicBlock * BB , <nl> failureBB ) ; <nl> break ; <nl> } <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : { <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : { <nl> SILValue Val = getLocalValue ( <nl> ValID , getSILType ( MF - > getType ( TyID2 ) , ( SILValueCategory ) TyCategory2 ) ) ; <nl> SILType Ty = getSILType ( MF - > getType ( TyID ) , ( SILValueCategory ) TyCategory ) ; <nl> - ResultVal = Builder . createUnconditionalCheckedCastOpaque ( Loc , Val , Ty ) ; <nl> + ResultVal = Builder . createUnconditionalCheckedCastValue ( Loc , Val , Ty ) ; <nl> break ; <nl> } <nl> case ValueKind : : UnconditionalCheckedCastAddrInst : <nl> mmm a / lib / Serialization / SerializeSIL . cpp <nl> ppp b / lib / Serialization / SerializeSIL . cpp <nl> void SILSerializer : : writeSILInstruction ( const SILInstruction & SI ) { <nl> llvm : : makeArrayRef ( listOfValues ) ) ; <nl> break ; <nl> } <nl> - case ValueKind : : UnconditionalCheckedCastOpaqueInst : { <nl> - auto CI = cast < UnconditionalCheckedCastOpaqueInst > ( & SI ) ; <nl> + case ValueKind : : UnconditionalCheckedCastValueInst : { <nl> + auto CI = cast < UnconditionalCheckedCastValueInst > ( & SI ) ; <nl> SILInstCastLayout : : emitRecord ( <nl> Out , ScratchRecord , SILAbbrCodes [ SILInstCastLayout : : Code ] , <nl> ( unsigned ) SI . getKind ( ) , / * attr * / 0 , <nl> mmm a / test / SIL / Parser / opaque_values_parse . sil <nl> ppp b / test / SIL / Parser / opaque_values_parse . sil <nl> struct S : Foo { <nl> <nl> / / CHECK - LABEL : sil @ castOpaque : $ @ convention ( thin ) ( Int ) - > ( ) { <nl> / / CHECK : bb0 ( [ [ ARG : % . * ] ] : $ Int ) : <nl> - / / CHECK : unconditional_checked_cast_opaque [ [ ARG ] ] : $ Int to $ Foo <nl> + / / CHECK : unconditional_checked_cast_value [ [ ARG ] ] : $ Int to $ Foo <nl> / / CHECK - LABEL : } / / end sil function ' castOpaque ' <nl> sil @ castOpaque : $ @ convention ( thin ) ( Int ) - > ( ) { <nl> bb0 ( % 0 : $ Int ) : <nl> - % c = unconditional_checked_cast_opaque % 0 : $ Int to $ Foo <nl> + % c = unconditional_checked_cast_value % 0 : $ Int to $ Foo <nl> % t = tuple ( ) <nl> return % t : $ ( ) <nl> } <nl> mmm a / test / SIL / Serialization / opaque_values_serialize . sil <nl> ppp b / test / SIL / Serialization / opaque_values_serialize . sil <nl> struct S : Foo { <nl> <nl> / / CHECK - LABEL : sil @ castOpaque : $ @ convention ( thin ) ( Int ) - > ( ) { <nl> / / CHECK : bb0 ( [ [ ARG : % . * ] ] : $ Int ) : <nl> - / / CHECK : unconditional_checked_cast_opaque [ [ ARG ] ] : $ Int to $ Foo <nl> + / / CHECK : unconditional_checked_cast_value [ [ ARG ] ] : $ Int to $ Foo <nl> / / CHECK - LABEL : } / / end sil function ' castOpaque ' <nl> sil @ castOpaque : $ @ convention ( thin ) ( Int ) - > ( ) { <nl> bb0 ( % 0 : $ Int ) : <nl> - % c = unconditional_checked_cast_opaque % 0 : $ Int to $ Foo <nl> + % c = unconditional_checked_cast_value % 0 : $ Int to $ Foo <nl> % t = tuple ( ) <nl> return % t : $ ( ) <nl> } <nl> mmm a / test / SIL / ownership - verifier / opaque_use_verifier . sil <nl> ppp b / test / SIL / ownership - verifier / opaque_use_verifier . sil <nl> sil_stage canonical <nl> <nl> import Builtin <nl> <nl> - sil @ unconditional_checked_cast_opaque_test : $ @ convention ( thin ) < T > ( Builtin . Int32 ) - > @ out T { <nl> + sil @ unconditional_checked_cast_value_test : $ @ convention ( thin ) < T > ( Builtin . Int32 ) - > @ out T { <nl> bb0 ( % 0 : @ trivial $ Builtin . Int32 ) : <nl> - % 1 = unconditional_checked_cast_opaque % 0 : $ Builtin . Int32 to $ T <nl> + % 1 = unconditional_checked_cast_value % 0 : $ Builtin . Int32 to $ T <nl> return % 1 : $ T <nl> } <nl> mmm a / test / SILGen / opaque_values_silgen . swift <nl> ppp b / test / SILGen / opaque_values_silgen . swift <nl> func s160_______callAnyArg ( ) { <nl> / / CHECK : [ [ INT_TYPE : % . * ] ] = metatype $ @ thin Int . Type <nl> / / CHECK : [ [ INT_LIT : % . * ] ] = integer_literal $ Builtin . Int2048 , 42 <nl> / / CHECK : [ [ INT_ARG : % . * ] ] = apply % { { . * } } ( [ [ INT_LIT ] ] , [ [ INT_TYPE ] ] ) : $ @ convention ( method ) ( Builtin . Int2048 , @ thin Int . Type ) - > Int <nl> - / / CHECK : [ [ INT_CAST : % . * ] ] = unconditional_checked_cast_opaque [ [ INT_ARG ] ] : $ Int to $ T <nl> + / / CHECK : [ [ INT_CAST : % . * ] ] = unconditional_checked_cast_value [ [ INT_ARG ] ] : $ Int to $ T <nl> / / CHECK : [ [ CAST_BORROW : % . * ] ] = begin_borrow [ [ INT_CAST ] ] : $ T <nl> / / CHECK : [ [ RETURN_VAL : % . * ] ] = copy_value [ [ CAST_BORROW ] ] : $ T <nl> / / CHECK : end_borrow [ [ CAST_BORROW ] ] from [ [ INT_CAST ] ] : $ T , $ T <nl> func s170____force_convert < T > ( ) - > T { <nl> / / CHECK : bb0 : <nl> / / CHECK : [ [ INT_LIT : % . * ] ] = integer_literal $ Builtin . Int2048 , 42 <nl> / / CHECK : [ [ INT_ARG : % . * ] ] = apply % { { . * } } ( [ [ INT_LIT ] ] , [ [ INT_TYPE ] ] ) : $ @ convention ( method ) ( Builtin . Int2048 , @ thin Int . Type ) - > Int <nl> - / / CHECK : [ [ INT_CAST : % . * ] ] = unconditional_checked_cast_opaque [ [ INT_ARG ] ] : $ Int to $ Foo <nl> + / / CHECK : [ [ INT_CAST : % . * ] ] = unconditional_checked_cast_value [ [ INT_ARG ] ] : $ Int to $ Foo <nl> / / CHECK : return [ [ INT_CAST ] ] : $ Foo <nl> / / CHECK - LABEL : } / / end sil function ' _T020opaque_values_silgen21s180_______return_fooAA3Foo_pyF ' <nl> func s180_______return_foo ( ) - > Foo { <nl> mmm a / utils / sil - mode . el <nl> ppp b / utils / sil - mode . el <nl> <nl> <nl> ; ; Checked Conversions <nl> ` ( , ( regexp - opt ' ( " unconditional_checked_cast " " unconditional_checked_cast_addr " <nl> - " unconditional_checked_cast_opaque " ) <nl> + " unconditional_checked_cast_value " ) <nl> ' words ) . font - lock - keyword - face ) <nl> ; ; Runtime Failures <nl> ` ( , ( regexp - opt ' ( " cond_fail " ) <nl> mmm a / utils / vim / syntax / sil . vim <nl> ppp b / utils / vim / syntax / sil . vim <nl> syn keyword swiftKeyword init_existential_addr init_existential_opaque init_exis <nl> syn keyword swiftKeyword upcast address_to_pointer pointer_to_address pointer_to_thin_function unchecked_addr_cast unchecked_ref_cast unchecked_ref_cast_addr ref_to_raw_pointer ref_to_bridge_object ref_to_unmanaged unmanaged_to_ref raw_pointer_to_ref skipwhite <nl> syn keyword swiftKeyword convert_function thick_to_objc_metatype thin_function_to_pointer objc_to_thick_metatype thin_to_thick_function is_nonnull unchecked_ref_bit_cast unchecked_trivial_bit_cast bridge_object_to_ref bridge_object_to_word unchecked_bitwise_cast skipwhite <nl> syn keyword swiftKeyword objc_existential_metatype_to_object objc_metatype_to_object objc_protocol skipwhite <nl> - syn keyword swiftKeyword unconditional_checked_cast unconditional_checked_cast_addr unconditional_checked_cast_opaque skipwhite <nl> + syn keyword swiftKeyword unconditional_checked_cast unconditional_checked_cast_addr unconditional_checked_cast_value skipwhite <nl> syn keyword swiftKeyword cond_fail skipwhite <nl> syn keyword swiftKeyword unreachable return throw br cond_br switch_value select_enum select_enum_addr select_value switch_enum switch_enum_addr dynamic_method_br checked_cast_br checked_cast_value_br checked_cast_addr_br skipwhite <nl> syn keyword swiftKeyword project_box project_existential_box project_value_buffer project_block_storage init_block_storage_header copy_block mark_dependence skipwhite <nl> | Rename unconditional_checked_cast_opaque to unconditional_checked_cast_value | apple/swift | 33b0cf653fe2e725ef34ad347fc1569e92e5f3cf | 2017-03-08T02:53:52Z |
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> <nl> 4D76BE3B1A4AAF0A00102962 / * CCActionTimelineNode . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 4D76BE381A4AAF0A00102962 / * CCActionTimelineNode . cpp * / ; } ; <nl> 4D76BE3C1A4AAF0A00102962 / * CCActionTimelineNode . h in Headers * / = { isa = PBXBuildFile ; fileRef = 4D76BE391A4AAF0A00102962 / * CCActionTimelineNode . h * / ; } ; <nl> 4D76BE3D1A4AAF0A00102962 / * CCActionTimelineNode . h in Headers * / = { isa = PBXBuildFile ; fileRef = 4D76BE391A4AAF0A00102962 / * CCActionTimelineNode . h * / ; } ; <nl> + 5012168E1AC47380009A4BEA / * CCRenderState . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5012168C1AC47380009A4BEA / * CCRenderState . cpp * / ; } ; <nl> + 5012168F1AC47380009A4BEA / * CCRenderState . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5012168C1AC47380009A4BEA / * CCRenderState . cpp * / ; } ; <nl> + 501216901AC47380009A4BEA / * CCRenderState . h in Headers * / = { isa = PBXBuildFile ; fileRef = 5012168D1AC47380009A4BEA / * CCRenderState . h * / ; } ; <nl> + 501216911AC47380009A4BEA / * CCRenderState . h in Headers * / = { isa = PBXBuildFile ; fileRef = 5012168D1AC47380009A4BEA / * CCRenderState . h * / ; } ; <nl> + 501216941AC47393009A4BEA / * CCPass . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 501216921AC47393009A4BEA / * CCPass . cpp * / ; } ; <nl> + 501216951AC47393009A4BEA / * CCPass . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 501216921AC47393009A4BEA / * CCPass . cpp * / ; } ; <nl> + 501216961AC47393009A4BEA / * CCPass . h in Headers * / = { isa = PBXBuildFile ; fileRef = 501216931AC47393009A4BEA / * CCPass . h * / ; } ; <nl> + 501216971AC47393009A4BEA / * CCPass . h in Headers * / = { isa = PBXBuildFile ; fileRef = 501216931AC47393009A4BEA / * CCPass . h * / ; } ; <nl> + 5012169A1AC473A3009A4BEA / * CCTechnique . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 501216981AC473A3009A4BEA / * CCTechnique . cpp * / ; } ; <nl> + 5012169B1AC473A3009A4BEA / * CCTechnique . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 501216981AC473A3009A4BEA / * CCTechnique . cpp * / ; } ; <nl> + 5012169C1AC473A3009A4BEA / * CCTechnique . h in Headers * / = { isa = PBXBuildFile ; fileRef = 501216991AC473A3009A4BEA / * CCTechnique . h * / ; } ; <nl> + 5012169D1AC473A3009A4BEA / * CCTechnique . h in Headers * / = { isa = PBXBuildFile ; fileRef = 501216991AC473A3009A4BEA / * CCTechnique . h * / ; } ; <nl> + 501216A01AC473AD009A4BEA / * CCMaterial . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5012169E1AC473AD009A4BEA / * CCMaterial . cpp * / ; } ; <nl> + 501216A11AC473AD009A4BEA / * CCMaterial . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5012169E1AC473AD009A4BEA / * CCMaterial . cpp * / ; } ; <nl> + 501216A21AC473AD009A4BEA / * CCMaterial . h in Headers * / = { isa = PBXBuildFile ; fileRef = 5012169F1AC473AD009A4BEA / * CCMaterial . h * / ; } ; <nl> + 501216A31AC473AD009A4BEA / * CCMaterial . h in Headers * / = { isa = PBXBuildFile ; fileRef = 5012169F1AC473AD009A4BEA / * CCMaterial . h * / ; } ; <nl> 5027253A190BF1B900AAF4ED / * cocos2d . h in Headers * / = { isa = PBXBuildFile ; fileRef = 50272538190BF1B900AAF4ED / * cocos2d . h * / ; } ; <nl> 5027253B190BF1B900AAF4ED / * cocos2d . h in Headers * / = { isa = PBXBuildFile ; fileRef = 50272538190BF1B900AAF4ED / * cocos2d . h * / ; } ; <nl> 5027253C190BF1B900AAF4ED / * cocos2d . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 50272539190BF1B900AAF4ED / * cocos2d . cpp * / ; } ; <nl> <nl> 46C02E0618E91123004B7456 / * xxhash . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = xxhash . h ; sourceTree = " < group > " ; } ; <nl> 4D76BE381A4AAF0A00102962 / * CCActionTimelineNode . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCActionTimelineNode . cpp ; sourceTree = " < group > " ; } ; <nl> 4D76BE391A4AAF0A00102962 / * CCActionTimelineNode . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCActionTimelineNode . h ; sourceTree = " < group > " ; } ; <nl> + 5012168C1AC47380009A4BEA / * CCRenderState . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCRenderState . cpp ; sourceTree = " < group > " ; } ; <nl> + 5012168D1AC47380009A4BEA / * CCRenderState . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCRenderState . h ; sourceTree = " < group > " ; } ; <nl> + 501216921AC47393009A4BEA / * CCPass . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCPass . cpp ; sourceTree = " < group > " ; } ; <nl> + 501216931AC47393009A4BEA / * CCPass . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCPass . h ; sourceTree = " < group > " ; } ; <nl> + 501216981AC473A3009A4BEA / * CCTechnique . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCTechnique . cpp ; sourceTree = " < group > " ; } ; <nl> + 501216991AC473A3009A4BEA / * CCTechnique . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCTechnique . h ; sourceTree = " < group > " ; } ; <nl> + 5012169E1AC473AD009A4BEA / * CCMaterial . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCMaterial . cpp ; sourceTree = " < group > " ; } ; <nl> + 5012169F1AC473AD009A4BEA / * CCMaterial . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCMaterial . h ; sourceTree = " < group > " ; } ; <nl> 50272538190BF1B900AAF4ED / * cocos2d . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; name = cocos2d . h ; path = . . / cocos / cocos2d . h ; sourceTree = " < group > " ; } ; <nl> 50272539190BF1B900AAF4ED / * cocos2d . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; name = cocos2d . cpp ; path = . . / cocos / cocos2d . cpp ; sourceTree = " < group > " ; } ; <nl> 5034C9FB191D591000CE6051 / * ccShader_PositionTextureColorAlphaTest . frag * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . glsl ; path = ccShader_PositionTextureColorAlphaTest . frag ; sourceTree = " < group > " ; } ; <nl> <nl> B257B45E198A353E00D9A687 / * CCPrimitiveCommand . cpp * / , <nl> B257B45F198A353E00D9A687 / * CCPrimitiveCommand . h * / , <nl> 5034CA5D191D591900CE6051 / * shaders * / , <nl> + 5012168C1AC47380009A4BEA / * CCRenderState . cpp * / , <nl> + 5012168D1AC47380009A4BEA / * CCRenderState . h * / , <nl> + 501216921AC47393009A4BEA / * CCPass . cpp * / , <nl> + 501216931AC47393009A4BEA / * CCPass . h * / , <nl> + 501216981AC473A3009A4BEA / * CCTechnique . cpp * / , <nl> + 501216991AC473A3009A4BEA / * CCTechnique . h * / , <nl> + 5012169E1AC473AD009A4BEA / * CCMaterial . cpp * / , <nl> + 5012169F1AC473AD009A4BEA / * CCMaterial . h * / , <nl> ) ; <nl> name = renderer ; <nl> path = . . / cocos / renderer ; <nl> <nl> 1A570298180BCCAB0088DEC7 / * CCAnimationCache . h in Headers * / , <nl> B665E4181AA80A6600DDB1C5 / * CCPUTextureAnimatorTranslator . h in Headers * / , <nl> B665E2C81AA80A6500DDB1C5 / * CCPUGravityAffector . h in Headers * / , <nl> + 501216A21AC473AD009A4BEA / * CCMaterial . h in Headers * / , <nl> 50ABC05D1926664800A911A9 / * CCApplication - mac . h in Headers * / , <nl> 15AE190019AAD35000C27E9E / * CCComAudio . h in Headers * / , <nl> B665E3481AA80A6500DDB1C5 / * CCPUOnExpireObserverTranslator . h in Headers * / , <nl> <nl> 15AE181219AAD2F700C27E9E / * CCAnimation3D . h in Headers * / , <nl> 182C5CD81A98F30500C30D34 / * Sprite3DReader . h in Headers * / , <nl> 1A5702F0180BCE750088DEC7 / * CCTMXLayer . h in Headers * / , <nl> + 501216961AC47393009A4BEA / * CCPass . h in Headers * / , <nl> 50ABC01B1926664800A911A9 / * CCSAXParser . h in Headers * / , <nl> 50ABBED51925AB6F00A911A9 / * utlist . h in Headers * / , <nl> 1A5702F4180BCE750088DEC7 / * CCTMXObjectGroup . h in Headers * / , <nl> <nl> 15AE18F319AAD35000C27E9E / * CCArmatureDataManager . h in Headers * / , <nl> B665E2C01AA80A6500DDB1C5 / * CCPUGeometryRotator . h in Headers * / , <nl> 50ABBE471925AB6F00A911A9 / * CCEvent . h in Headers * / , <nl> + 5012169C1AC473A3009A4BEA / * CCTechnique . h in Headers * / , <nl> 15AE1B9E19AADFDF00C27E9E / * UIVBox . h in Headers * / , <nl> 15AE192319AAD35000C27E9E / * DictionaryHelper . h in Headers * / , <nl> B665E3D41AA80A6600DDB1C5 / * CCPUScriptLexer . h in Headers * / , <nl> <nl> 50ABBE971925AB6F00A911A9 / * CCProtocols . h in Headers * / , <nl> 50ABC0691926664800A911A9 / * CCStdC - mac . h in Headers * / , <nl> B665E34C1AA80A6500DDB1C5 / * CCPUOnPositionObserver . h in Headers * / , <nl> + 501216901AC47380009A4BEA / * CCRenderState . h in Headers * / , <nl> 15AE1A2B19AAD3D500C27E9E / * b2Distance . h in Headers * / , <nl> 15AE198919AAD36A00C27E9E / * ButtonReader . h in Headers * / , <nl> 15AE190219AAD35000C27E9E / * CCComController . h in Headers * / , <nl> <nl> 1A5701CE180BCB5A0088DEC7 / * CCLabelTTF . h in Headers * / , <nl> 15AE1AB119AAD40300C27E9E / * b2ChainAndPolygonContact . h in Headers * / , <nl> B665E4211AA80A6600DDB1C5 / * CCPUTextureRotatorTranslator . h in Headers * / , <nl> + 501216911AC47380009A4BEA / * CCRenderState . h in Headers * / , <nl> 1A5701E1180BCB8C0088DEC7 / * CCLayer . h in Headers * / , <nl> B665E3691AA80A6500DDB1C5 / * CCPUOnTimeObserverTranslator . h in Headers * / , <nl> 15AE1BEE19AAE01E00C27E9E / * CCControlExtensions . h in Headers * / , <nl> <nl> 292DB14219B4574100A80320 / * UIEditBoxImpl . h in Headers * / , <nl> 1A570303180BCE890088DEC7 / * CCParallaxNode . h in Headers * / , <nl> 50ABBE2A1925AB6F00A911A9 / * CCAutoreleasePool . h in Headers * / , <nl> + 501216971AC47393009A4BEA / * CCPass . h in Headers * / , <nl> 1A57030F180BCF190088DEC7 / * CCComponent . h in Headers * / , <nl> B665E22D1AA80A6500DDB1C5 / * CCPUBoxCollider . h in Headers * / , <nl> 15AE1AD519AAD40300C27E9E / * b2WeldJoint . h in Headers * / , <nl> <nl> 5034CA48191D591100CE6051 / * ccShader_Label_normal . frag in Headers * / , <nl> 15AE183F19AAD2F700C27E9E / * CCSkeleton3D . h in Headers * / , <nl> 50ABBD531925AB0000A911A9 / * Quaternion . h in Headers * / , <nl> + 5012169D1AC473A3009A4BEA / * CCTechnique . h in Headers * / , <nl> 15AE19B119AAD39700C27E9E / * ScrollViewReader . h in Headers * / , <nl> 503DD8E81926736A00CD74DD / * CCES2Renderer - ios . h in Headers * / , <nl> B665E41D1AA80A6600DDB1C5 / * CCPUTextureRotator . h in Headers * / , <nl> <nl> B665E3FD1AA80A6600DDB1C5 / * CCPUSphere . h in Headers * / , <nl> B68778FB1A8CA82E00643ABF / * CCParticle3DAffector . h in Headers * / , <nl> B665E3B51AA80A6500DDB1C5 / * CCPURendererTranslator . h in Headers * / , <nl> + 501216A31AC473AD009A4BEA / * CCMaterial . h in Headers * / , <nl> B665E20D1AA80A6500DDB1C5 / * CCPUBaseColliderTranslator . h in Headers * / , <nl> 1A01C68D18F57BE800EFE3A6 / * CCDeprecated . h in Headers * / , <nl> B665E2E91AA80A6500DDB1C5 / * CCPULinearForceAffector . h in Headers * / , <nl> <nl> B29A7DE119EE1B7700872B35 / * MeshAttachment . c in Sources * / , <nl> 15AE18F419AAD35000C27E9E / * CCArmatureDefine . cpp in Sources * / , <nl> 15AE186619AAD31D00C27E9E / * CDOpenALSupport . m in Sources * / , <nl> + 5012169A1AC473A3009A4BEA / * CCTechnique . cpp in Sources * / , <nl> 1A5701F7180BCBAD0088DEC7 / * CCMenu . cpp in Sources * / , <nl> B665E33E1AA80A6500DDB1C5 / * CCPUOnEventFlagObserverTranslator . cpp in Sources * / , <nl> 1A1645B2191B726C008C7C7F / * ConvertUTFWrapper . cpp in Sources * / , <nl> <nl> 1A570208180BCBDF0088DEC7 / * CCMotionStreak . cpp in Sources * / , <nl> 15FB20971AE7C57D00C31518 / * sweep . cc in Sources * / , <nl> 1A570210180BCBF40088DEC7 / * CCProgressTimer . cpp in Sources * / , <nl> + 501216941AC47393009A4BEA / * CCPass . cpp in Sources * / , <nl> 292DB15F19B461CA00A80320 / * ExtensionDeprecated . cpp in Sources * / , <nl> 292DB14D19B4574100A80320 / * UIEditBoxImpl - mac . mm in Sources * / , <nl> 50ABBDB51925AB4100A911A9 / * CCTexture2D . cpp in Sources * / , <nl> <nl> 15FB206A1AE7BE7400C31518 / * SpritePolygon . cpp in Sources * / , <nl> B29A7DDD19EE1B7700872B35 / * BoneData . c in Sources * / , <nl> 15AE188A19AAD33D00C27E9E / * CCControlLoader . cpp in Sources * / , <nl> + 5012168E1AC47380009A4BEA / * CCRenderState . cpp in Sources * / , <nl> B665E35A1AA80A6500DDB1C5 / * CCPUOnRandomObserver . cpp in Sources * / , <nl> B29A7DFB19EE1B7700872B35 / * spine - cocos2dx . cpp in Sources * / , <nl> 50ABC0011926664800A911A9 / * CCLock - apple . cpp in Sources * / , <nl> <nl> B665E39A1AA80A6500DDB1C5 / * CCPUPointEmitterTranslator . cpp in Sources * / , <nl> 50ABBD9B1925AB4100A911A9 / * ccGLStateCache . cpp in Sources * / , <nl> 15AE188119AAD33D00C27E9E / * CCBReader . cpp in Sources * / , <nl> + 501216A01AC473AD009A4BEA / * CCMaterial . cpp in Sources * / , <nl> 50ABBDB91925AB4100A911A9 / * CCTextureAtlas . cpp in Sources * / , <nl> 15AE1BE419AAE01E00C27E9E / * CCTableView . cpp in Sources * / , <nl> 15AE1A3219AAD3D500C27E9E / * b2CircleShape . cpp in Sources * / , <nl> <nl> 15AE18C519AAD33D00C27E9E / * CCLayerLoader . cpp in Sources * / , <nl> 15AE1BF719AAE01E00C27E9E / * CCControlStepper . cpp in Sources * / , <nl> 15AE1A3C19AAD3D500C27E9E / * b2CollideCircle . cpp in Sources * / , <nl> + 501216951AC47393009A4BEA / * CCPass . cpp in Sources * / , <nl> 50ABBE6E1925AB6F00A911A9 / * CCEventListenerKeyboard . cpp in Sources * / , <nl> B665E2CB1AA80A6500DDB1C5 / * CCPUGravityAffectorTranslator . cpp in Sources * / , <nl> 15AE18D719AAD33D00C27E9E / * CCScrollViewLoader . cpp in Sources * / , <nl> <nl> 50ABBD881925AB4100A911A9 / * CCCustomCommand . cpp in Sources * / , <nl> 15AE19B019AAD39700C27E9E / * ScrollViewReader . cpp in Sources * / , <nl> 50ABBE941925AB6F00A911A9 / * CCProfiling . cpp in Sources * / , <nl> + 5012169B1AC473A3009A4BEA / * CCTechnique . cpp in Sources * / , <nl> 15AE182D19AAD2F700C27E9E / * CCMeshVertexIndexData . cpp in Sources * / , <nl> 50ABBE5E1925AB6F00A911A9 / * CCEventListener . cpp in Sources * / , <nl> + 5012168F1AC47380009A4BEA / * CCRenderState . cpp in Sources * / , <nl> 15AE1BC719AAE00000C27E9E / * AssetsManager . cpp in Sources * / , <nl> 50ABBEA81925AB6F00A911A9 / * CCTouch . cpp in Sources * / , <nl> B29A7DEE19EE1B7700872B35 / * IkConstraint . c in Sources * / , <nl> <nl> B665E20F1AA80A6500DDB1C5 / * CCPUBaseForceAffector . cpp in Sources * / , <nl> 15AE1B7419AADA9A00C27E9E / * UILoadingBar . cpp in Sources * / , <nl> 50ABBEA41925AB6F00A911A9 / * CCScriptSupport . cpp in Sources * / , <nl> + 501216A11AC473AD009A4BEA / * CCMaterial . cpp in Sources * / , <nl> B665E3971AA80A6500DDB1C5 / * CCPUPointEmitter . cpp in Sources * / , <nl> B29A7DD219EE1B7700872B35 / * Skin . c in Sources * / , <nl> 3E6176761960F89B00DE83F5 / * CCEventListenerController . cpp in Sources * / , <nl> mmm a / build / cocos2d_tests . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_tests . xcodeproj / project . pbxproj <nl> <nl> 3EA0FB5E191B92F100B170C8 / * cocosvideo . mp4 in Resources * / = { isa = PBXBuildFile ; fileRef = 3EA0FB5D191B92F100B170C8 / * cocosvideo . mp4 * / ; } ; <nl> 3EA0FB66191B933000B170C8 / * MediaPlayer . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = 3EA0FB65191B933000B170C8 / * MediaPlayer . framework * / ; } ; <nl> 3EA0FB72191C844400B170C8 / * UIVideoPlayerTest . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 3EA0FB70191C844400B170C8 / * UIVideoPlayerTest . cpp * / ; } ; <nl> + 5046AB4A1AF2A8D80060550B / * MaterialSystemTest . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5046AB481AF2A8D80060550B / * MaterialSystemTest . cpp * / ; } ; <nl> + 5046AB4B1AF2A8D80060550B / * MaterialSystemTest . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 5046AB481AF2A8D80060550B / * MaterialSystemTest . cpp * / ; } ; <nl> + 5046AB5B1AF2C4180060550B / * Materials in Resources * / = { isa = PBXBuildFile ; fileRef = 5046AB5A1AF2C4180060550B / * Materials * / ; } ; <nl> + 5046AB5C1AF2C4180060550B / * Materials in Resources * / = { isa = PBXBuildFile ; fileRef = 5046AB5A1AF2C4180060550B / * Materials * / ; } ; <nl> 527B1F3019EF9819000A1F82 / * Default - 667h @ 2x . png in Resources * / = { isa = PBXBuildFile ; fileRef = 527B1F2E19EF9819000A1F82 / * Default - 667h @ 2x . png * / ; } ; <nl> 527B1F3119EF9819000A1F82 / * Default - 736h @ 3x . png in Resources * / = { isa = PBXBuildFile ; fileRef = 527B1F2F19EF9819000A1F82 / * Default - 736h @ 3x . png * / ; } ; <nl> 527B1F3419EF9CF8000A1F82 / * Default - 667h @ 2x . png in Resources * / = { isa = PBXBuildFile ; fileRef = 527B1F3219EF9CF8000A1F82 / * Default - 667h @ 2x . png * / ; } ; <nl> <nl> 3EA0FB70191C844400B170C8 / * UIVideoPlayerTest . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = UIVideoPlayerTest . cpp ; sourceTree = " < group > " ; } ; <nl> 3EA0FB71191C844400B170C8 / * UIVideoPlayerTest . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIVideoPlayerTest . h ; sourceTree = " < group > " ; } ; <nl> 46A15F9C1807A4F8005B8026 / * cocos2d_libs . xcodeproj * / = { isa = PBXFileReference ; lastKnownFileType = " wrapper . pb - project " ; path = cocos2d_libs . xcodeproj ; sourceTree = " < group > " ; } ; <nl> + 5046AB481AF2A8D80060550B / * MaterialSystemTest . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = MaterialSystemTest . cpp ; sourceTree = " < group > " ; } ; <nl> + 5046AB491AF2A8D80060550B / * MaterialSystemTest . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = MaterialSystemTest . h ; sourceTree = " < group > " ; } ; <nl> + 5046AB5A1AF2C4180060550B / * Materials * / = { isa = PBXFileReference ; lastKnownFileType = folder ; name = Materials ; path = " . . / tests / cpp - tests / Resources / Materials " ; sourceTree = " < group > " ; } ; <nl> 527B1F2E19EF9819000A1F82 / * Default - 667h @ 2x . png * / = { isa = PBXFileReference ; lastKnownFileType = image . png ; path = " Default - 667h @ 2x . png " ; sourceTree = " < group > " ; } ; <nl> 527B1F2F19EF9819000A1F82 / * Default - 736h @ 3x . png * / = { isa = PBXFileReference ; lastKnownFileType = image . png ; path = " Default - 736h @ 3x . png " ; sourceTree = " < group > " ; } ; <nl> 527B1F3219EF9CF8000A1F82 / * Default - 667h @ 2x . png * / = { isa = PBXFileReference ; lastKnownFileType = image . png ; path = " Default - 667h @ 2x . png " ; sourceTree = " < group > " ; } ; <nl> <nl> 1AC3592418CECF0A00F37B72 / * Classes * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> + 5046AB471AF2A8D80060550B / * MaterialSystemTest * / , <nl> 6886696E1AE8E8A000C2CFD9 / * SpritePolygonTest * / , <nl> B603F1AC1AC8EA2E00A9579C / * TerrainTest * / , <nl> 182C5CB71A95B28A00C30D34 / * CocosStudio3DTest * / , <nl> <nl> 1AC35CA818CED83500F37B72 / * Resources * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> + 5046AB5A1AF2C4180060550B / * Materials * / , <nl> B603F1B31AC8FBFB00A9579C / * TerrainTest * / , <nl> B63993301A49359F00B07923 / * Particle3D * / , <nl> 15B3709219EE5D1000ABE682 / * Manifests * / , <nl> <nl> name = Products ; <nl> sourceTree = " < group > " ; <nl> } ; <nl> + 5046AB471AF2A8D80060550B / * MaterialSystemTest * / = { <nl> + isa = PBXGroup ; <nl> + children = ( <nl> + 5046AB481AF2A8D80060550B / * MaterialSystemTest . cpp * / , <nl> + 5046AB491AF2A8D80060550B / * MaterialSystemTest . h * / , <nl> + ) ; <nl> + path = MaterialSystemTest ; <nl> + sourceTree = " < group > " ; <nl> + } ; <nl> 6886696E1AE8E8A000C2CFD9 / * SpritePolygonTest * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> <nl> 1AC35CE218CED84500F37B72 / * effect1 . raw in Resources * / , <nl> 1AC35CF218CED84500F37B72 / * Hello . png in Resources * / , <nl> 1AC35CA518CECF1E00F37B72 / * Icon . icns in Resources * / , <nl> + 5046AB5B1AF2C4180060550B / * Materials in Resources * / , <nl> B63993311A49359F00B07923 / * Particle3D in Resources * / , <nl> 1AC35CEC18CED84500F37B72 / * fonts in Resources * / , <nl> 1AC35CCA18CED84500F37B72 / * animations in Resources * / , <nl> <nl> 1AC35CE118CED84500F37B72 / * configs in Resources * / , <nl> 1AC35CE918CED84500F37B72 / * extensions in Resources * / , <nl> 3E2BDAD219BEA3E20055CDCD / * audio in Resources * / , <nl> + 5046AB5C1AF2C4180060550B / * Materials in Resources * / , <nl> C08689C318D370C90093E810 / * background . caf in Resources * / , <nl> 1AC35C9518CECF1400F37B72 / * Icon - 72 . png in Resources * / , <nl> 15B3709419EE5D1000ABE682 / * Manifests in Resources * / , <nl> <nl> 1AC35C2118CECF0C00F37B72 / * ParallaxTest . cpp in Sources * / , <nl> 1AC35C6B18CECF0C00F37B72 / * ZwoptexTest . cpp in Sources * / , <nl> 1AC35B7718CECF0C00F37B72 / * ComponentsTestScene . cpp in Sources * / , <nl> + 5046AB4A1AF2A8D80060550B / * MaterialSystemTest . cpp in Sources * / , <nl> B603F1AF1AC8EA4E00A9579C / * TerrainTest . cpp in Sources * / , <nl> 29080DC7191B595E0066F8DF / * UISceneManager . cpp in Sources * / , <nl> 1AC35C2F18CECF0C00F37B72 / * PerformanceParticleTest . cpp in Sources * / , <nl> <nl> 29080DB2191B595E0066F8DF / * UILayoutTest . cpp in Sources * / , <nl> 1AC35B6A18CECF0C00F37B72 / * ButtonTestLayer . cpp in Sources * / , <nl> 29080DB6191B595E0066F8DF / * UIListViewTest . cpp in Sources * / , <nl> + 5046AB4B1AF2A8D80060550B / * MaterialSystemTest . cpp in Sources * / , <nl> 1AC35B3018CECF0C00F37B72 / * Box2dView . cpp in Sources * / , <nl> 29080DAE191B595E0066F8DF / * UIImageViewTest . cpp in Sources * / , <nl> 1AC35C1018CECF0C00F37B72 / * LabelTest . cpp in Sources * / , <nl> mmm a / cocos / 2d / CCNode . cpp <nl> ppp b / cocos / 2d / CCNode . cpp <nl> THE SOFTWARE . <nl> # include " 2d / CCComponentContainer . h " <nl> # include " renderer / CCGLProgram . h " <nl> # include " renderer / CCGLProgramState . h " <nl> + # include " renderer / CCMaterial . h " <nl> # include " math / TransformUtils . h " <nl> <nl> # include " deprecated / CCString . h " <nl> Node : : Node ( void ) <nl> , _userData ( nullptr ) <nl> , _userObject ( nullptr ) <nl> , _glProgramState ( nullptr ) <nl> + , _material ( nullptr ) <nl> , _orderOfArrival ( 0 ) <nl> , _running ( false ) <nl> , _visible ( true ) <nl> void Node : : setUserObject ( Ref * userObject ) <nl> _userObject = userObject ; <nl> } <nl> <nl> + Material * Node : : getMaterial ( ) const <nl> + { <nl> + return _material ; <nl> + } <nl> + <nl> + void Node : : setMaterial ( Material * material ) <nl> + { <nl> + if ( _material ! = material ) <nl> + { <nl> + if ( _material ) <nl> + _material - > setTarget ( nullptr ) ; <nl> + CC_SAFE_RELEASE ( _material ) ; <nl> + <nl> + _material = material ; <nl> + CC_SAFE_RETAIN ( _material ) ; <nl> + _material - > setTarget ( this ) ; <nl> + } <nl> + } <nl> + <nl> GLProgramState * Node : : getGLProgramState ( ) const <nl> { <nl> return _glProgramState ; <nl> void Node : : setGLProgramState ( cocos2d : : GLProgramState * glProgramState ) <nl> } <nl> } <nl> <nl> + <nl> void Node : : setGLProgram ( GLProgram * glProgram ) <nl> { <nl> if ( _glProgramState = = nullptr | | ( _glProgramState & & _glProgramState - > getGLProgram ( ) ! = glProgram ) ) <nl> mmm a / cocos / 2d / CCNode . h <nl> ppp b / cocos / 2d / CCNode . h <nl> class Renderer ; <nl> class Director ; <nl> class GLProgram ; <nl> class GLProgramState ; <nl> + class Material ; <nl> # if CC_USE_PHYSICS <nl> class PhysicsBody ; <nl> class PhysicsWorld ; <nl> class CC_DLL Node : public Ref <nl> * @ param glProgramState The GLProgramState for this node . <nl> * / <nl> virtual void setGLProgramState ( GLProgramState * glProgramState ) ; <nl> + <nl> + / * * Returns the Material used for this Node * / <nl> + Material * getMaterial ( ) const ; <nl> + / * * Sets the Material used for this Node * / <nl> + void setMaterial ( Material * material ) ; <nl> <nl> / / / @ } end of Shader Program <nl> <nl> class CC_DLL Node : public Ref <nl> Ref * _userObject ; / / / < A user assigned Object <nl> <nl> GLProgramState * _glProgramState ; / / / < OpenGL Program State <nl> + Material * _material ; <nl> <nl> int _orderOfArrival ; / / / < used to preserve sequence while sorting children with the same localZOrder <nl> <nl> mmm a / cocos / 2d / CCSprite . cpp <nl> ppp b / cocos / 2d / CCSprite . cpp <nl> void Sprite : : draw ( Renderer * renderer , const Mat4 & transform , uint32_t flags ) <nl> if ( _insideBounds ) <nl> # endif <nl> { <nl> - _quadCommand . init ( _globalZOrder , _texture - > getName ( ) , getGLProgramState ( ) , _blendFunc , & _quad , 1 , transform , flags ) ; <nl> + if ( _material ) { <nl> + _quadCommand . init ( _globalZOrder , _material , & _quad , 1 , transform , flags ) ; <nl> + } else { <nl> + _quadCommand . init ( _globalZOrder , _texture - > getName ( ) , getGLProgramState ( ) , _blendFunc , & _quad , 1 , transform , flags ) ; <nl> + } <nl> renderer - > addCommand ( & _quadCommand ) ; <nl> <nl> # if CC_SPRITE_DEBUG_DRAW <nl> mmm a / cocos / 2d / libcocos2d . vcxproj <nl> ppp b / cocos / 2d / libcocos2d . vcxproj <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClCompile Include = " . . \ renderer \ CCGLProgramStateCache . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ ccGLStateCache . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCGroupCommand . cpp " / > <nl> + < ClCompile Include = " . . \ renderer \ CCMaterial . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCMeshCommand . cpp " / > <nl> + < ClCompile Include = " . . \ renderer \ CCPass . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCPrimitive . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCPrimitiveCommand . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCQuadCommand . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCRenderCommand . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCRenderer . cpp " / > <nl> + < ClCompile Include = " . . \ renderer \ CCRenderState . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ ccShaders . cpp " / > <nl> + < ClCompile Include = " . . \ renderer \ CCTechnique . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCTexture2D . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCTextureAtlas . cpp " / > <nl> < ClCompile Include = " . . \ renderer \ CCTextureCache . cpp " / > <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClInclude Include = " . . \ renderer \ CCGLProgramStateCache . h " / > <nl> < ClInclude Include = " . . \ renderer \ ccGLStateCache . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCGroupCommand . h " / > <nl> + < ClInclude Include = " . . \ renderer \ CCMaterial . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCMeshCommand . h " / > <nl> + < ClInclude Include = " . . \ renderer \ CCPass . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCPrimitive . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCPrimitiveCommand . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCQuadCommand . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCRenderCommand . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCRenderCommandPool . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCRenderer . h " / > <nl> + < ClInclude Include = " . . \ renderer \ CCRenderState . h " / > <nl> < ClInclude Include = " . . \ renderer \ ccShaders . h " / > <nl> + < ClInclude Include = " . . \ renderer \ CCTechnique . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCTexture2D . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCTextureAtlas . h " / > <nl> < ClInclude Include = " . . \ renderer \ CCTextureCache . h " / > <nl> mmm a / cocos / 2d / libcocos2d . vcxproj . filters <nl> ppp b / cocos / 2d / libcocos2d . vcxproj . filters <nl> <nl> < ClCompile Include = " SpritePolygonCache . cpp " > <nl> < Filter > 2d < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ renderer \ CCPass . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " . . \ renderer \ CCRenderState . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " . . \ renderer \ CCTechnique . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " . . \ renderer \ CCMaterial . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsBody . h " > <nl> <nl> < ClInclude Include = " SpritePolygonCache . h " > <nl> < Filter > 2d < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " . . \ renderer \ CCPass . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " . . \ renderer \ CCRenderState . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " . . \ renderer \ CCTechnique . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " . . \ renderer \ CCMaterial . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < None Include = " . . \ math \ Mat4 . inl " > <nl> mmm a / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems <nl> ppp b / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCGLProgramStateCache . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ ccGLStateCache . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCGroupCommand . h " / > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMaterial . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMeshCommand . h " / > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPass . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPrimitive . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPrimitiveCommand . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCQuadCommand . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderCommand . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderCommandPool . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderer . h " / > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderState . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ ccShaders . h " / > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTechnique . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTexture2D . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTextureAtlas . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTextureCache . h " / > <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCGLProgramStateCache . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ ccGLStateCache . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCGroupCommand . cpp " / > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMaterial . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMeshCommand . cpp " / > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPass . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPrimitive . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPrimitiveCommand . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCQuadCommand . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderCommand . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderer . cpp " / > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderState . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ ccShaders . cpp " / > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTechnique . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTexture2D . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTextureAtlas . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTextureCache . cpp " / > <nl> mmm a / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems . filters <nl> ppp b / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems . filters <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ SpritePolygonCache . h " > <nl> < Filter > 2d < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderState . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTechnique . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMaterial . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPass . h " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ cocos2d . cpp " / > <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ SpritePolygonCache . cpp " > <nl> < Filter > 2d < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCRenderState . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCTechnique . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCMaterial . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ renderer \ CCPass . cpp " > <nl> + < Filter > renderer < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Filter Include = " 2d " > <nl> mmm a / cocos / 3d / CCMesh . cpp <nl> ppp b / cocos / 3d / CCMesh . cpp <nl> <nl> # include " 3d / CCMeshSkin . h " <nl> # include " 3d / CCSkeleton3D . h " <nl> # include " 3d / CCMeshVertexIndexData . h " <nl> + # include " 2d / CCLight . h " <nl> + # include " 2d / CCScene . h " <nl> # include " base / CCEventDispatcher . h " <nl> # include " base / CCDirector . h " <nl> + # include " base / CCConfiguration . h " <nl> # include " renderer / CCTextureCache . h " <nl> # include " renderer / CCGLProgramState . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCPass . h " <nl> + # include " renderer / CCRenderer . h " <nl> + # include " math / Mat4 . h " <nl> + <nl> + # define USE_MATERIAL 1 <nl> <nl> using namespace std ; <nl> <nl> NS_CC_BEGIN <nl> <nl> + / / Helpers <nl> + <nl> + static const char * s_dirLightUniformColorName = " u_DirLightSourceColor " ; <nl> + static std : : vector < Vec3 > s_dirLightUniformColorValues ; <nl> + static const char * s_dirLightUniformDirName = " u_DirLightSourceDirection " ; <nl> + static std : : vector < Vec3 > s_dirLightUniformDirValues ; <nl> + <nl> + static const char * s_pointLightUniformColorName = " u_PointLightSourceColor " ; <nl> + static std : : vector < Vec3 > s_pointLightUniformColorValues ; <nl> + static const char * s_pointLightUniformPositionName = " u_PointLightSourcePosition " ; <nl> + static std : : vector < Vec3 > s_pointLightUniformPositionValues ; <nl> + static const char * s_pointLightUniformRangeInverseName = " u_PointLightSourceRangeInverse " ; <nl> + static std : : vector < float > s_pointLightUniformRangeInverseValues ; <nl> + <nl> + static const char * s_spotLightUniformColorName = " u_SpotLightSourceColor " ; <nl> + static std : : vector < Vec3 > s_spotLightUniformColorValues ; <nl> + static const char * s_spotLightUniformPositionName = " u_SpotLightSourcePosition " ; <nl> + static std : : vector < Vec3 > s_spotLightUniformPositionValues ; <nl> + static const char * s_spotLightUniformDirName = " u_SpotLightSourceDirection " ; <nl> + static std : : vector < Vec3 > s_spotLightUniformDirValues ; <nl> + static const char * s_spotLightUniformInnerAngleCosName = " u_SpotLightSourceInnerAngleCos " ; <nl> + static std : : vector < float > s_spotLightUniformInnerAngleCosValues ; <nl> + static const char * s_spotLightUniformOuterAngleCosName = " u_SpotLightSourceOuterAngleCos " ; <nl> + static std : : vector < float > s_spotLightUniformOuterAngleCosValues ; <nl> + static const char * s_spotLightUniformRangeInverseName = " u_SpotLightSourceRangeInverse " ; <nl> + static std : : vector < float > s_spotLightUniformRangeInverseValues ; <nl> + <nl> + static const char * s_ambientLightUniformColorName = " u_AmbientLightSourceColor " ; <nl> + <nl> + / / helpers <nl> + static void resetLightUniformValues ( ) <nl> + { <nl> + const auto & conf = Configuration : : getInstance ( ) ; <nl> + int maxDirLight = conf - > getMaxSupportDirLightInShader ( ) ; <nl> + int maxPointLight = conf - > getMaxSupportPointLightInShader ( ) ; <nl> + int maxSpotLight = conf - > getMaxSupportSpotLightInShader ( ) ; <nl> + <nl> + s_dirLightUniformColorValues . assign ( maxDirLight , Vec3 : : ZERO ) ; <nl> + s_dirLightUniformDirValues . assign ( maxDirLight , Vec3 : : ZERO ) ; <nl> + <nl> + s_pointLightUniformColorValues . assign ( maxPointLight , Vec3 : : ZERO ) ; <nl> + s_pointLightUniformPositionValues . assign ( maxPointLight , Vec3 : : ZERO ) ; <nl> + s_pointLightUniformRangeInverseValues . assign ( maxPointLight , 0 . 0f ) ; <nl> + <nl> + s_spotLightUniformColorValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> + s_spotLightUniformPositionValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> + s_spotLightUniformDirValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> + s_spotLightUniformInnerAngleCosValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> + s_spotLightUniformOuterAngleCosValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> + s_spotLightUniformRangeInverseValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> + } <nl> + <nl> + / / Generate a dummy texture when the texture file is missing <nl> + static Texture2D * getDummyTexture ( ) <nl> + { <nl> + auto texture = Director : : getInstance ( ) - > getTextureCache ( ) - > getTextureForKey ( " / dummyTexture " ) ; <nl> + if ( ! texture ) <nl> + { <nl> + # ifdef NDEBUG <nl> + unsigned char data [ ] = { 0 , 0 , 0 , 0 } ; / / 1 * 1 transparent picture <nl> + # else <nl> + unsigned char data [ ] = { 255 , 0 , 0 , 255 } ; / / 1 * 1 red picture <nl> + # endif <nl> + Image * image = new ( std : : nothrow ) Image ( ) ; <nl> + image - > initWithRawData ( data , sizeof ( data ) , 1 , 1 , sizeof ( unsigned char ) ) ; <nl> + texture = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( image , " / dummyTexture " ) ; <nl> + image - > release ( ) ; <nl> + } <nl> + return texture ; <nl> + } <nl> + <nl> + <nl> Mesh : : Mesh ( ) <nl> : _texture ( nullptr ) <nl> , _skin ( nullptr ) <nl> , _visible ( true ) <nl> , _isTransparent ( false ) <nl> , _meshIndexData ( nullptr ) <nl> + , _material ( nullptr ) <nl> , _glProgramState ( nullptr ) <nl> , _blend ( BlendFunc : : ALPHA_NON_PREMULTIPLIED ) <nl> , _visibleChanged ( nullptr ) <nl> + , _blendDirty ( true ) <nl> { <nl> <nl> } <nl> Mesh : : ~ Mesh ( ) <nl> CC_SAFE_RELEASE ( _texture ) ; <nl> CC_SAFE_RELEASE ( _skin ) ; <nl> CC_SAFE_RELEASE ( _meshIndexData ) ; <nl> + CC_SAFE_RELEASE ( _material ) ; <nl> CC_SAFE_RELEASE ( _glProgramState ) ; <nl> } <nl> <nl> void Mesh : : setVisible ( bool visible ) <nl> } <nl> } <nl> <nl> + bool Mesh : : isVisible ( ) const <nl> + { <nl> + return _visible ; <nl> + } <nl> + <nl> void Mesh : : setTexture ( const std : : string & texPath ) <nl> { <nl> auto tex = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( texPath ) ; <nl> void Mesh : : setTexture ( const std : : string & texPath ) <nl> <nl> void Mesh : : setTexture ( Texture2D * tex ) <nl> { <nl> + # if USE_MATERIAL <nl> + <nl> + / / Texture must be saved for future use <nl> + / / it doesn ' t matter if the material is already set or not <nl> + / / This functionality is added for compatibility issues <nl> + if ( tex ! = _texture ) <nl> + { <nl> + CC_SAFE_RETAIN ( tex ) ; <nl> + CC_SAFE_RELEASE ( _texture ) ; <nl> + _texture = tex ; <nl> + } <nl> + <nl> + if ( _material ) { <nl> + auto technique = _material - > _currentTechnique ; <nl> + for ( auto & pass : technique - > _passes ) <nl> + { <nl> + pass - > setTexture ( tex ) ; <nl> + } <nl> + } <nl> + <nl> + bindMeshCommand ( ) ; <nl> + # else <nl> if ( tex ! = _texture ) <nl> { <nl> CC_SAFE_RETAIN ( tex ) ; <nl> void Mesh : : setTexture ( Texture2D * tex ) <nl> _texture = tex ; <nl> bindMeshCommand ( ) ; <nl> } <nl> + # endif <nl> + } <nl> + <nl> + Texture2D * Mesh : : getTexture ( ) const <nl> + { <nl> + return _texture ; <nl> + } <nl> + <nl> + void Mesh : : setMaterial ( Material * material ) <nl> + { <nl> + if ( _material ! = material ) { <nl> + CC_SAFE_RELEASE ( _material ) ; <nl> + _material = material ; <nl> + CC_SAFE_RETAIN ( _material ) ; <nl> + } <nl> + } <nl> + <nl> + Material * Mesh : : getMaterial ( ) const <nl> + { <nl> + return _material ; <nl> + } <nl> + <nl> + void Mesh : : draw ( Renderer * renderer , float globalZOrder , const Mat4 & transform , uint32_t flags , unsigned int lightMask , const Vec4 & color , bool forceDepthWrite ) <nl> + { <nl> + if ( ! isVisible ( ) ) <nl> + return ; <nl> + <nl> + bool isTransparent = ( _isTransparent | | color . w < 1 . f ) ; <nl> + float globalZ = isTransparent ? 0 : globalZOrder ; <nl> + if ( isTransparent ) <nl> + flags | = Node : : FLAGS_RENDER_AS_3D ; <nl> + <nl> + <nl> + # if USE_MATERIAL <nl> + _meshCommand . init ( globalZ , <nl> + _material , <nl> + getVertexBuffer ( ) , <nl> + getIndexBuffer ( ) , <nl> + getPrimitiveType ( ) , <nl> + getIndexFormat ( ) , <nl> + getIndexCount ( ) , <nl> + transform , <nl> + flags ) ; <nl> + <nl> + <nl> + if ( isTransparent & & ! forceDepthWrite ) <nl> + _material - > getStateBlock ( ) - > setDepthWrite ( false ) ; <nl> + else <nl> + _material - > getStateBlock ( ) - > setDepthWrite ( true ) ; <nl> + <nl> + <nl> + _meshCommand . setSkipBatching ( isTransparent ) ; <nl> + <nl> + / / set default uniforms for Mesh <nl> + / / ' u_color ' and others <nl> + const auto & scene = Director : : getInstance ( ) - > getRunningScene ( ) ; <nl> + auto technique = _material - > _currentTechnique ; <nl> + for ( auto & pass : technique - > _passes ) <nl> + { <nl> + auto programState = pass - > getGLProgramState ( ) ; <nl> + programState - > setUniformVec4 ( " u_color " , color ) ; <nl> + <nl> + if ( _skin ) <nl> + programState - > setUniformVec4v ( " u_matrixPalette " , _skin - > getMatrixPalette ( ) , ( GLsizei ) _skin - > getMatrixPaletteSize ( ) ) ; <nl> + <nl> + if ( scene & & scene - > getLights ( ) . size ( ) > 0 ) <nl> + setLightUniforms ( programState , scene , color , lightMask ) ; <nl> + } <nl> + # else <nl> + <nl> + if ( ! _texture ) <nl> + { <nl> + / / let the mesh use a dummy texture instead of the missing or crashing texture file <nl> + setTexture ( getDummyTexture ( ) ) ; <nl> + } <nl> + GLuint textureID = _texture - > getName ( ) ; <nl> + <nl> + <nl> + _meshCommand . init ( globalZ , <nl> + textureID , <nl> + _glProgramState , <nl> + _blend , <nl> + getVertexBuffer ( ) , <nl> + getIndexBuffer ( ) , <nl> + getPrimitiveType ( ) , <nl> + getIndexFormat ( ) , <nl> + getIndexCount ( ) , <nl> + transform , <nl> + flags ) ; <nl> + <nl> + if ( forceDepthWrite ) <nl> + { <nl> + _meshCommand . setDepthWriteEnabled ( true ) ; <nl> + } <nl> + _meshCommand . setTransparent ( isTransparent ) ; <nl> + <nl> + / / support tint and fade <nl> + _meshCommand . setDisplayColor ( color ) ; <nl> + <nl> + if ( _skin ) <nl> + { <nl> + _meshCommand . setMatrixPaletteSize ( ( int ) _skin - > getMatrixPaletteSize ( ) ) ; <nl> + _meshCommand . setMatrixPalette ( _skin - > getMatrixPalette ( ) ) ; <nl> + } <nl> + <nl> + _meshCommand . setLightMask ( lightMask ) ; <nl> + <nl> + # endif / / ! MATERIAL <nl> + <nl> + <nl> + <nl> + renderer - > addCommand ( & _meshCommand ) ; <nl> } <nl> <nl> void Mesh : : setSkin ( MeshSkin * skin ) <nl> void Mesh : : setMeshIndexData ( MeshIndexData * subMesh ) <nl> <nl> void Mesh : : setGLProgramState ( GLProgramState * glProgramState ) <nl> { <nl> + / / XXX create dummy texture <nl> + # if USE_MATERIAL <nl> + auto material = Material : : createWithGLStateProgram ( glProgramState ) ; <nl> + setMaterial ( material ) ; <nl> + <nl> + / / Was the texture set before teh GLProgramState ? Set it <nl> + if ( _texture ) <nl> + setTexture ( _texture ) ; <nl> + <nl> + if ( _blendDirty ) <nl> + setBlendFunc ( _blend ) ; <nl> + <nl> + bindMeshCommand ( ) ; <nl> + # else <nl> if ( _glProgramState ! = glProgramState ) <nl> { <nl> CC_SAFE_RETAIN ( glProgramState ) ; <nl> void Mesh : : setGLProgramState ( GLProgramState * glProgramState ) <nl> _glProgramState = glProgramState ; <nl> bindMeshCommand ( ) ; <nl> } <nl> + # endif <nl> + } <nl> + <nl> + GLProgramState * Mesh : : getGLProgramState ( ) const <nl> + { <nl> + # if USE_MATERIAL <nl> + return _material ? _material - > _currentTechnique - > _passes . at ( 0 ) - > getGLProgramState ( ) <nl> + : nullptr ; <nl> + # else <nl> + return _glProgramState ; <nl> + # endif <nl> } <nl> <nl> void Mesh : : calculateAABB ( ) <nl> void Mesh : : calculateAABB ( ) <nl> <nl> void Mesh : : bindMeshCommand ( ) <nl> { <nl> + # if USE_MATERIAL <nl> + if ( _material & & _meshIndexData ) <nl> + { <nl> + auto pass = _material - > _currentTechnique - > _passes . at ( 0 ) ; <nl> + auto glprogramstate = pass - > getGLProgramState ( ) ; <nl> + auto texture = pass - > getTexture ( ) ; <nl> + auto textureid = texture ? texture - > getName ( ) : 0 ; <nl> + / / XXX <nl> + / / auto blend = pass - > getStateBlock ( ) - > getBlendFunc ( ) ; <nl> + auto blend = BlendFunc : : ALPHA_PREMULTIPLIED ; <nl> + <nl> + _meshCommand . genMaterialID ( textureid , glprogramstate , _meshIndexData - > getVertexBuffer ( ) - > getVBO ( ) , _meshIndexData - > getIndexBuffer ( ) - > getVBO ( ) , blend ) ; <nl> + _material - > getStateBlock ( ) - > setCullFace ( true ) ; <nl> + _material - > getStateBlock ( ) - > setDepthTest ( true ) ; <nl> + } <nl> + # else <nl> if ( _glProgramState & & _meshIndexData & & _texture ) <nl> { <nl> GLuint texID = _texture ? _texture - > getName ( ) : 0 ; <nl> void Mesh : : bindMeshCommand ( ) <nl> _meshCommand . setCullFaceEnabled ( true ) ; <nl> _meshCommand . setDepthTestEnabled ( true ) ; <nl> } <nl> + # endif <nl> + } <nl> + <nl> + void Mesh : : setLightUniforms ( GLProgramState * glProgramState , Scene * scene , const Vec4 & color , unsigned int lightmask ) <nl> + { <nl> + CCASSERT ( glProgramState , " Invalid glProgramstate " ) ; <nl> + CCASSERT ( scene , " Invalid scene " ) ; <nl> + <nl> + const auto & conf = Configuration : : getInstance ( ) ; <nl> + int maxDirLight = conf - > getMaxSupportDirLightInShader ( ) ; <nl> + int maxPointLight = conf - > getMaxSupportPointLightInShader ( ) ; <nl> + int maxSpotLight = conf - > getMaxSupportSpotLightInShader ( ) ; <nl> + auto & lights = scene - > getLights ( ) ; <nl> + <nl> + <nl> + if ( glProgramState - > getVertexAttribsFlags ( ) & ( 1 < < GLProgram : : VERTEX_ATTRIB_NORMAL ) ) <nl> + { <nl> + resetLightUniformValues ( ) ; <nl> + <nl> + GLint enabledDirLightNum = 0 ; <nl> + GLint enabledPointLightNum = 0 ; <nl> + GLint enabledSpotLightNum = 0 ; <nl> + Vec3 ambientColor ; <nl> + for ( const auto & light : lights ) <nl> + { <nl> + bool useLight = light - > isEnabled ( ) & & ( ( unsigned int ) light - > getLightFlag ( ) & lightmask ) ; <nl> + if ( useLight ) <nl> + { <nl> + float intensity = light - > getIntensity ( ) ; <nl> + switch ( light - > getLightType ( ) ) <nl> + { <nl> + case LightType : : DIRECTIONAL : <nl> + { <nl> + if ( enabledDirLightNum < maxDirLight ) <nl> + { <nl> + auto dirLight = static_cast < DirectionLight * > ( light ) ; <nl> + Vec3 dir = dirLight - > getDirectionInWorld ( ) ; <nl> + dir . normalize ( ) ; <nl> + const Color3B & col = dirLight - > getDisplayedColor ( ) ; <nl> + s_dirLightUniformColorValues [ enabledDirLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> + s_dirLightUniformDirValues [ enabledDirLightNum ] = dir ; <nl> + + + enabledDirLightNum ; <nl> + } <nl> + <nl> + } <nl> + break ; <nl> + case LightType : : POINT : <nl> + { <nl> + if ( enabledPointLightNum < maxPointLight ) <nl> + { <nl> + auto pointLight = static_cast < PointLight * > ( light ) ; <nl> + Mat4 mat = pointLight - > getNodeToWorldTransform ( ) ; <nl> + const Color3B & col = pointLight - > getDisplayedColor ( ) ; <nl> + s_pointLightUniformColorValues [ enabledPointLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> + s_pointLightUniformPositionValues [ enabledPointLightNum ] . set ( mat . m [ 12 ] , mat . m [ 13 ] , mat . m [ 14 ] ) ; <nl> + s_pointLightUniformRangeInverseValues [ enabledPointLightNum ] = 1 . 0f / pointLight - > getRange ( ) ; <nl> + + + enabledPointLightNum ; <nl> + } <nl> + } <nl> + break ; <nl> + case LightType : : SPOT : <nl> + { <nl> + if ( enabledSpotLightNum < maxSpotLight ) <nl> + { <nl> + auto spotLight = static_cast < SpotLight * > ( light ) ; <nl> + Vec3 dir = spotLight - > getDirectionInWorld ( ) ; <nl> + dir . normalize ( ) ; <nl> + Mat4 mat = light - > getNodeToWorldTransform ( ) ; <nl> + const Color3B & col = spotLight - > getDisplayedColor ( ) ; <nl> + s_spotLightUniformColorValues [ enabledSpotLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> + s_spotLightUniformPositionValues [ enabledSpotLightNum ] . set ( mat . m [ 12 ] , mat . m [ 13 ] , mat . m [ 14 ] ) ; <nl> + s_spotLightUniformDirValues [ enabledSpotLightNum ] = dir ; <nl> + s_spotLightUniformInnerAngleCosValues [ enabledSpotLightNum ] = spotLight - > getCosInnerAngle ( ) ; <nl> + s_spotLightUniformOuterAngleCosValues [ enabledSpotLightNum ] = spotLight - > getCosOuterAngle ( ) ; <nl> + s_spotLightUniformRangeInverseValues [ enabledSpotLightNum ] = 1 . 0f / spotLight - > getRange ( ) ; <nl> + + + enabledSpotLightNum ; <nl> + } <nl> + } <nl> + break ; <nl> + case LightType : : AMBIENT : <nl> + { <nl> + auto ambLight = static_cast < AmbientLight * > ( light ) ; <nl> + const Color3B & col = ambLight - > getDisplayedColor ( ) ; <nl> + ambientColor . add ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( 0 < maxDirLight ) <nl> + { <nl> + glProgramState - > setUniformVec3v ( s_dirLightUniformColorName , & s_dirLightUniformColorValues [ 0 ] , s_dirLightUniformColorValues . size ( ) ) ; <nl> + glProgramState - > setUniformVec3v ( s_dirLightUniformDirName , & s_dirLightUniformDirValues [ 0 ] , s_dirLightUniformDirValues . size ( ) ) ; <nl> + } <nl> + <nl> + if ( 0 < maxPointLight ) <nl> + { <nl> + glProgramState - > setUniformVec3v ( s_pointLightUniformColorName , & s_pointLightUniformColorValues [ 0 ] , s_pointLightUniformColorValues . size ( ) ) ; <nl> + glProgramState - > setUniformVec3v ( s_pointLightUniformPositionName , & s_pointLightUniformPositionValues [ 0 ] , s_pointLightUniformPositionValues . size ( ) ) ; <nl> + glProgramState - > setUniformFloatv ( s_pointLightUniformRangeInverseName , & s_pointLightUniformRangeInverseValues [ 0 ] , s_pointLightUniformRangeInverseValues . size ( ) ) ; <nl> + } <nl> + <nl> + if ( 0 < maxSpotLight ) <nl> + { <nl> + glProgramState - > setUniformVec3v ( s_spotLightUniformColorName , & s_spotLightUniformColorValues [ 0 ] , s_spotLightUniformColorValues . size ( ) ) ; <nl> + glProgramState - > setUniformVec3v ( s_spotLightUniformPositionName , & s_spotLightUniformPositionValues [ 0 ] , s_spotLightUniformPositionValues . size ( ) ) ; <nl> + glProgramState - > setUniformVec3v ( s_spotLightUniformDirName , & s_spotLightUniformDirValues [ 0 ] , s_spotLightUniformDirValues . size ( ) ) ; <nl> + glProgramState - > setUniformFloatv ( s_spotLightUniformInnerAngleCosName , & s_spotLightUniformInnerAngleCosValues [ 0 ] , s_spotLightUniformInnerAngleCosValues . size ( ) ) ; <nl> + glProgramState - > setUniformFloatv ( s_spotLightUniformOuterAngleCosName , & s_spotLightUniformOuterAngleCosValues [ 0 ] , s_spotLightUniformOuterAngleCosValues . size ( ) ) ; <nl> + glProgramState - > setUniformFloatv ( s_spotLightUniformRangeInverseName , & s_spotLightUniformRangeInverseValues [ 0 ] , s_spotLightUniformRangeInverseValues . size ( ) ) ; <nl> + } <nl> + <nl> + glProgramState - > setUniformVec3 ( s_ambientLightUniformColorName , Vec3 ( ambientColor . x , ambientColor . y , ambientColor . z ) ) ; <nl> + } <nl> + else / / normal does not exist <nl> + { <nl> + Vec3 ambient ( 0 . 0f , 0 . 0f , 0 . 0f ) ; <nl> + bool hasAmbient = false ; <nl> + for ( const auto & light : lights ) <nl> + { <nl> + if ( light - > getLightType ( ) = = LightType : : AMBIENT ) <nl> + { <nl> + bool useLight = light - > isEnabled ( ) & & ( ( unsigned int ) light - > getLightFlag ( ) & lightmask ) ; <nl> + if ( useLight ) <nl> + { <nl> + hasAmbient = true ; <nl> + const Color3B & col = light - > getDisplayedColor ( ) ; <nl> + ambient . x + = col . r * light - > getIntensity ( ) ; <nl> + ambient . y + = col . g * light - > getIntensity ( ) ; <nl> + ambient . z + = col . b * light - > getIntensity ( ) ; <nl> + } <nl> + } <nl> + } <nl> + if ( hasAmbient ) <nl> + { <nl> + ambient . x / = 255 . f ; ambient . y / = 255 . f ; ambient . z / = 255 . f ; <nl> + } <nl> + glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( color . x * ambient . x , color . y * ambient . y , color . z * ambient . z , color . w ) ) ; <nl> + } <nl> } <nl> <nl> void Mesh : : setBlendFunc ( const BlendFunc & blendFunc ) <nl> { <nl> + # if USE_MATERIAL <nl> + / / Blend must be saved for future use <nl> + / / it doesn ' t matter if the material is already set or not <nl> + / / This functionality is added for compatibility issues <nl> + if ( _blend ! = blendFunc ) <nl> + { <nl> + _blendDirty = true ; <nl> + _blend = blendFunc ; <nl> + } <nl> + <nl> + if ( _material ) { <nl> + _material - > getStateBlock ( ) - > setBlendFunc ( blendFunc ) ; <nl> + bindMeshCommand ( ) ; <nl> + } <nl> + # else <nl> if ( _blend . src ! = blendFunc . src | | _blend . dst ! = blendFunc . dst ) <nl> { <nl> _blend = blendFunc ; <nl> bindMeshCommand ( ) ; <nl> } <nl> + # endif <nl> } <nl> - const BlendFunc & Mesh : : getBlendFunc ( ) const <nl> + const BlendFunc & Mesh : : getBlendFunc ( ) const <nl> { <nl> + # if USE_MATERIAL <nl> + / / return _material - > _currentTechnique - > _passes . at ( 0 ) - > getBlendFunc ( ) ; <nl> return _blend ; <nl> + # else <nl> + return _blend ; <nl> + # endif <nl> } <nl> <nl> GLenum Mesh : : getPrimitiveType ( ) const <nl> GLuint Mesh : : getIndexBuffer ( ) const <nl> { <nl> return _meshIndexData - > getIndexBuffer ( ) - > getVBO ( ) ; <nl> } <nl> - <nl> NS_CC_END <nl> mmm a / cocos / 3d / CCMesh . h <nl> ppp b / cocos / 3d / CCMesh . h <nl> class MeshSkin ; <nl> class MeshIndexData ; <nl> class GLProgramState ; <nl> class GLProgram ; <nl> + class Material ; <nl> + class Renderer ; <nl> + class Scene ; <nl> + <nl> / * * <nl> * @ brief Mesh : contains ref to index buffer , GLProgramState , texture , skin , blend function , aabb and so on <nl> * / <nl> class CC_DLL Mesh : public Ref <nl> / * * texture getter and setter * / <nl> void setTexture ( const std : : string & texPath ) ; <nl> void setTexture ( Texture2D * tex ) ; <nl> - Texture2D * getTexture ( ) const { return _texture ; } <nl> + Texture2D * getTexture ( ) const ; <nl> <nl> / * * visible getter and setter * / <nl> void setVisible ( bool visible ) ; <nl> - bool isVisible ( ) const { return _visible ; } <nl> + bool isVisible ( ) const ; <nl> <nl> / * * <nl> * skin getter <nl> class CC_DLL Mesh : public Ref <nl> * <nl> * @ lua NA <nl> * / <nl> - GLProgramState * getGLProgramState ( ) const { return _glProgramState ; } <nl> + GLProgramState * getGLProgramState ( ) const ; <nl> <nl> / * * name getter * / <nl> const std : : string & getName ( ) const { return _name ; } <nl> class CC_DLL Mesh : public Ref <nl> / * * get AABB * / <nl> const AABB & getAABB ( ) const { return _aabb ; } <nl> <nl> - CC_CONSTRUCTOR_ACCESS : <nl> - <nl> - Mesh ( ) ; <nl> - virtual ~ Mesh ( ) ; <nl> - <nl> - / * * <nl> - * Get the default GL program . <nl> - * / <nl> - GLProgram * getDefaultGLProgram ( bool textured ) ; <nl> - <nl> - / * * <nl> - * Set the default GL program . <nl> + / * * Sets a new GLProgramState for the Mesh <nl> + * A new Material will be created for it <nl> * / <nl> void setGLProgramState ( GLProgramState * glProgramState ) ; <nl> - <nl> + <nl> + / * * Sets a new Material to the Mesh * / <nl> + void setMaterial ( Material * material ) ; <nl> + <nl> + / * * Returns the Material being used by the Mesh * / <nl> + Material * getMaterial ( ) const ; <nl> + <nl> + void draw ( Renderer * renderer , float globalZ , const Mat4 & transform , uint32_t flags , unsigned int lightMask , const Vec4 & color , bool forceDepthWrite ) ; <nl> + <nl> / * * <nl> * Get the MeshCommand . <nl> * / <nl> class CC_DLL Mesh : public Ref <nl> * / <nl> void calculateAABB ( ) ; <nl> <nl> - / * * <nl> - * Bind to the MeshCommand <nl> - * / <nl> - void bindMeshCommand ( ) ; <nl> + <nl> + CC_CONSTRUCTOR_ACCESS : <nl> + <nl> + Mesh ( ) ; <nl> + virtual ~ Mesh ( ) ; <nl> + <nl> protected : <nl> - Texture2D * _texture ; / / texture that submesh is using <nl> - MeshSkin * _skin ; / / skin <nl> - bool _visible ; / / is the submesh visible <nl> - bool _isTransparent ; / / is this mesh transparent , it is a property of material in fact <nl> - <nl> - std : : string _name ; <nl> - MeshIndexData * _meshIndexData ; <nl> - GLProgramState * _glProgramState ; <nl> - MeshCommand _meshCommand ; <nl> - BlendFunc _blend ; <nl> - AABB _aabb ; <nl> + void setLightUniforms ( GLProgramState * glProgramState , Scene * scene , const Vec4 & color , unsigned int lightmask ) ; <nl> + void bindMeshCommand ( ) ; <nl> + <nl> + Texture2D * _texture ; / / texture that submesh is using <nl> + MeshSkin * _skin ; / / skin <nl> + bool _visible ; / / is the submesh visible <nl> + bool _isTransparent ; / / is this mesh transparent , it is a property of material in fact <nl> + <nl> + std : : string _name ; <nl> + MeshCommand _meshCommand ; <nl> + MeshIndexData * _meshIndexData ; <nl> + GLProgramState * _glProgramState ; <nl> + BlendFunc _blend ; <nl> + bool _blendDirty ; <nl> + Material * _material ; <nl> + AABB _aabb ; <nl> std : : function < void ( ) > _visibleChanged ; <nl> } ; <nl> <nl> mmm a / cocos / 3d / CCSprite3D . cpp <nl> ppp b / cocos / 3d / CCSprite3D . cpp <nl> <nl> # include " renderer / CCRenderer . h " <nl> # include " renderer / CCGLProgramState . h " <nl> # include " renderer / CCGLProgramCache . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCPass . h " <nl> <nl> # include " deprecated / CCString . h " / / For StringUtils : : format <nl> <nl> Sprite3D * Sprite3D : : create ( ) <nl> <nl> Sprite3D * Sprite3D : : create ( const std : : string & modelPath ) <nl> { <nl> - if ( modelPath . length ( ) < 4 ) <nl> - CCASSERT ( false , " invalid filename for Sprite3D " ) ; <nl> + CCASSERT ( modelPath . length ( ) > = 4 , " invalid filename for Sprite3D " ) ; <nl> <nl> auto sprite = new ( std : : nothrow ) Sprite3D ( ) ; <nl> if ( sprite & & sprite - > initWithFile ( modelPath ) ) <nl> bool Sprite3D : : loadFromCache ( const std : : string & path ) <nl> } <nl> <nl> for ( ssize_t i = 0 ; i < _meshes . size ( ) ; i + + ) { <nl> - _meshes . at ( i ) - > setGLProgramState ( spritedata - > glProgramStates . at ( i ) ) ; <nl> + / / cloning is needed in order to have one state per sprite <nl> + auto glstate = spritedata - > glProgramStates . at ( i ) ; <nl> + _meshes . at ( i ) - > setGLProgramState ( glstate - > clone ( ) ) ; <nl> } <nl> return true ; <nl> } <nl> bool Sprite3D : : initWithFile ( const std : : string & path ) <nl> <nl> MeshDatas * meshdatas = new ( std : : nothrow ) MeshDatas ( ) ; <nl> MaterialDatas * materialdatas = new ( std : : nothrow ) MaterialDatas ( ) ; <nl> - NodeDatas * nodeDatas = new ( std : : nothrow ) NodeDatas ( ) ; <nl> + NodeDatas * nodeDatas = new ( std : : nothrow ) NodeDatas ( ) ; <nl> if ( loadFromFile ( path , nodeDatas , meshdatas , materialdatas ) ) <nl> { <nl> if ( initFrom ( * nodeDatas , * meshdatas , * materialdatas ) ) <nl> bool Sprite3D : : initFrom ( const NodeDatas & nodeDatas , const MeshDatas & meshdatas , <nl> <nl> return true ; <nl> } <nl> - Sprite3D * Sprite3D : : createSprite3DNode ( NodeData * nodedata , ModelData * modeldata , const MaterialDatas & matrialdatas ) <nl> + Sprite3D * Sprite3D : : createSprite3DNode ( NodeData * nodedata , ModelData * modeldata , const MaterialDatas & materialdatas ) <nl> { <nl> auto sprite = new ( std : : nothrow ) Sprite3D ( ) ; <nl> if ( sprite ) <nl> { <nl> sprite - > setName ( nodedata - > id ) ; <nl> auto mesh = Mesh : : create ( nodedata - > id , getMeshIndexData ( modeldata - > subMeshId ) ) ; <nl> - if ( modeldata - > matrialId = = " " & & matrialdatas . materials . size ( ) ) <nl> + if ( modeldata - > matrialId = = " " & & materialdatas . materials . size ( ) ) <nl> { <nl> - const NTextureData * textureData = matrialdatas . materials [ 0 ] . getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> + const NTextureData * textureData = materialdatas . materials [ 0 ] . getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> if ( ! textureData - > filename . empty ( ) ) <nl> mesh - > setTexture ( textureData - > filename ) ; <nl> } <nl> else <nl> { <nl> - const NMaterialData * materialData = matrialdatas . getMaterialData ( modeldata - > matrialId ) ; <nl> + const NMaterialData * materialData = materialdatas . getMaterialData ( modeldata - > matrialId ) ; <nl> if ( materialData ) <nl> { <nl> const NTextureData * textureData = materialData - > getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> Sprite3D * Sprite3D : : createSprite3DNode ( NodeData * nodedata , ModelData * modeldata , c <nl> } <nl> return sprite ; <nl> } <nl> - void Sprite3D : : createAttachSprite3DNode ( NodeData * nodedata , const MaterialDatas & matrialdatas ) <nl> + void Sprite3D : : createAttachSprite3DNode ( NodeData * nodedata , const MaterialDatas & materialdatas ) <nl> { <nl> for ( const auto & it : nodedata - > modelNodeDatas ) <nl> { <nl> if ( it & & getAttachNode ( nodedata - > id ) ) <nl> { <nl> - auto sprite = createSprite3DNode ( nodedata , it , matrialdatas ) ; <nl> + auto sprite = createSprite3DNode ( nodedata , it , materialdatas ) ; <nl> if ( sprite ) <nl> { <nl> getAttachNode ( nodedata - > id ) - > addChild ( sprite ) ; <nl> void Sprite3D : : createAttachSprite3DNode ( NodeData * nodedata , const MaterialDatas & <nl> } <nl> for ( const auto & it : nodedata - > children ) <nl> { <nl> - createAttachSprite3DNode ( it , matrialdatas ) ; <nl> + createAttachSprite3DNode ( it , materialdatas ) ; <nl> } <nl> } <nl> + <nl> + void Sprite3D : : setMaterial ( Material * material ) <nl> + { <nl> + setMaterial ( material , - 1 ) ; <nl> + } <nl> + <nl> + void Sprite3D : : setMaterial ( Material * material , int meshIndex ) <nl> + { <nl> + CCASSERT ( material , " Invalid Material " ) ; <nl> + CCASSERT ( meshIndex = = - 1 | | ( meshIndex > = 0 & & meshIndex < _meshes . size ( ) ) , " Invalid meshIndex " ) ; <nl> + <nl> + if ( meshIndex = = - 1 ) <nl> + { <nl> + for ( auto & mesh : _meshes ) <nl> + { <nl> + mesh - > setMaterial ( material ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + _meshes . at ( meshIndex ) - > setMaterial ( material ) ; <nl> + } <nl> + } <nl> + <nl> void Sprite3D : : genGLProgramState ( bool useLight ) <nl> { <nl> _shaderUsingLight = useLight ; <nl> <nl> std : : unordered_map < const MeshVertexData * , GLProgramState * > glProgramestates ; <nl> - for ( auto & mesh : _meshVertexDatas ) <nl> + for ( auto & meshVertexData : _meshVertexDatas ) <nl> { <nl> - bool textured = mesh - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_TEX_COORD ) ; <nl> - bool hasSkin = mesh - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_BLEND_INDEX ) <nl> - & & mesh - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_BLEND_WEIGHT ) ; <nl> - bool hasNormal = mesh - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_NORMAL ) ; <nl> - <nl> - GLProgram * glProgram = nullptr ; <nl> + bool textured = meshVertexData - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_TEX_COORD ) ; <nl> + bool hasSkin = meshVertexData - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_BLEND_INDEX ) <nl> + & & meshVertexData - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_BLEND_WEIGHT ) ; <nl> + bool hasNormal = meshVertexData - > hasVertexAttrib ( GLProgram : : VERTEX_ATTRIB_NORMAL ) ; <nl> + <nl> const char * shader = nullptr ; <nl> if ( textured ) <nl> { <nl> void Sprite3D : : genGLProgramState ( bool useLight ) <nl> { <nl> shader = GLProgram : : SHADER_3D_POSITION ; <nl> } <nl> - if ( shader ) <nl> - glProgram = GLProgramCache : : getInstance ( ) - > getGLProgram ( shader ) ; <nl> - <nl> - auto programstate = GLProgramState : : create ( glProgram ) ; <nl> + <nl> + CCASSERT ( shader , " Couldn ' t find shader for sprite " ) ; <nl> + <nl> + auto glProgram = GLProgramCache : : getInstance ( ) - > getGLProgram ( shader ) ; <nl> + auto glprogramstate = GLProgramState : : create ( glProgram ) ; <nl> + <nl> long offset = 0 ; <nl> - auto attributeCount = mesh - > getMeshVertexAttribCount ( ) ; <nl> + auto attributeCount = meshVertexData - > getMeshVertexAttribCount ( ) ; <nl> for ( auto k = 0 ; k < attributeCount ; k + + ) { <nl> - auto meshattribute = mesh - > getMeshVertexAttrib ( k ) ; <nl> - programstate - > setVertexAttribPointer ( s_attributeNames [ meshattribute . vertexAttrib ] , <nl> + auto meshattribute = meshVertexData - > getMeshVertexAttrib ( k ) ; <nl> + glprogramstate - > setVertexAttribPointer ( s_attributeNames [ meshattribute . vertexAttrib ] , <nl> meshattribute . size , <nl> meshattribute . type , <nl> GL_FALSE , <nl> - mesh - > getVertexBuffer ( ) - > getSizePerVertex ( ) , <nl> + meshVertexData - > getVertexBuffer ( ) - > getSizePerVertex ( ) , <nl> ( GLvoid * ) offset ) ; <nl> offset + = meshattribute . attribSizeBytes ; <nl> } <nl> <nl> - glProgramestates [ mesh ] = programstate ; <nl> + glProgramestates [ meshVertexData ] = glprogramstate ; <nl> } <nl> <nl> - for ( auto & it : _meshes ) { <nl> - auto glProgramState = glProgramestates [ it - > getMeshIndexData ( ) - > getMeshVertexData ( ) ] ; <nl> - it - > setGLProgramState ( glProgramState ) ; <nl> + for ( auto & mesh : _meshes ) { <nl> + auto glProgramState = glProgramestates [ mesh - > getMeshIndexData ( ) - > getMeshVertexData ( ) ] ; <nl> + <nl> + / / hack to prevent cloning the very first time <nl> + if ( glProgramState - > getReferenceCount ( ) = = 1 ) <nl> + mesh - > setGLProgramState ( glProgramState ) ; <nl> + else <nl> + mesh - > setGLProgramState ( glProgramState - > clone ( ) ) ; <nl> } <nl> } <nl> <nl> - void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & matrialdatas , bool singleSprite ) <nl> + void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & materialdatas , bool singleSprite ) <nl> { <nl> Node * node = nullptr ; <nl> for ( const auto & it : nodedata - > modelNodeDatas ) <nl> void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & m <nl> } <nl> mesh - > _visibleChanged = std : : bind ( & Sprite3D : : onAABBDirty , this ) ; <nl> <nl> - if ( it - > matrialId = = " " & & matrialdatas . materials . size ( ) ) <nl> + if ( it - > matrialId = = " " & & materialdatas . materials . size ( ) ) <nl> { <nl> - const NTextureData * textureData = matrialdatas . materials [ 0 ] . getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> + const NTextureData * textureData = materialdatas . materials [ 0 ] . getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> mesh - > setTexture ( textureData - > filename ) ; <nl> } <nl> else <nl> { <nl> - const NMaterialData * materialData = matrialdatas . getMaterialData ( it - > matrialId ) ; <nl> + const NMaterialData * materialData = materialdatas . getMaterialData ( it - > matrialId ) ; <nl> if ( materialData ) <nl> { <nl> const NTextureData * textureData = materialData - > getTextureData ( NTextureData : : Usage : : Diffuse ) ; <nl> void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & m <nl> auto tex = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( textureData - > filename ) ; <nl> if ( tex ) <nl> { <nl> - Texture2D : : TexParams texParams ; <nl> + Texture2D : : TexParams texParams ; <nl> texParams . minFilter = GL_LINEAR ; <nl> texParams . magFilter = GL_LINEAR ; <nl> texParams . wrapS = textureData - > wrapS ; <nl> void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & m <nl> } <nl> else <nl> { <nl> - auto sprite = createSprite3DNode ( nodedata , it , matrialdatas ) ; <nl> + auto sprite = createSprite3DNode ( nodedata , it , materialdatas ) ; <nl> if ( sprite ) <nl> { <nl> if ( root ) <nl> void Sprite3D : : createNode ( NodeData * nodedata , Node * root , const MaterialDatas & m <nl> } <nl> for ( const auto & it : nodedata - > children ) <nl> { <nl> - createNode ( it , node , matrialdatas , nodedata - > children . size ( ) = = 1 ) ; <nl> + createNode ( it , node , materialdatas , nodedata - > children . size ( ) = = 1 ) ; <nl> } <nl> } <nl> <nl> void Sprite3D : : removeAllAttachNode ( ) <nl> _attachments . clear ( ) ; <nl> } <nl> <nl> - / / Generate a dummy texture when the texture file is missing <nl> - static Texture2D * getDummyTexture ( ) <nl> - { <nl> - auto texture = Director : : getInstance ( ) - > getTextureCache ( ) - > getTextureForKey ( " / dummyTexture " ) ; <nl> - if ( ! texture ) <nl> - { <nl> - # ifdef NDEBUG <nl> - unsigned char data [ ] = { 0 , 0 , 0 , 0 } ; / / 1 * 1 transparent picture <nl> - # else <nl> - unsigned char data [ ] = { 255 , 0 , 0 , 255 } ; / / 1 * 1 red picture <nl> - # endif <nl> - Image * image = new ( std : : nothrow ) Image ( ) ; <nl> - image - > initWithRawData ( data , sizeof ( data ) , 1 , 1 , sizeof ( unsigned char ) ) ; <nl> - texture = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( image , " / dummyTexture " ) ; <nl> - image - > release ( ) ; <nl> - } <nl> - return texture ; <nl> - } <nl> - <nl> void Sprite3D : : visit ( cocos2d : : Renderer * renderer , const cocos2d : : Mat4 & parentTransform , uint32_t parentFlags ) <nl> { <nl> / / quick return if not visible . children won ' t be drawn . <nl> void Sprite3D : : draw ( Renderer * renderer , const Mat4 & transform , uint32_t flags ) <nl> genGLProgramState ( usingLight ) ; <nl> } <nl> <nl> - int i = 0 ; <nl> - for ( auto & mesh : _meshes ) { <nl> - if ( ! mesh - > isVisible ( ) ) <nl> - { <nl> - i + + ; <nl> - continue ; <nl> - } <nl> - auto programstate = mesh - > getGLProgramState ( ) ; <nl> - auto & meshCommand = mesh - > getMeshCommand ( ) ; <nl> - <nl> - GLuint textureID = 0 ; <nl> - if ( mesh - > getTexture ( ) ) <nl> - { <nl> - textureID = mesh - > getTexture ( ) - > getName ( ) ; <nl> - } else <nl> - { / / let the mesh use a dummy texture instead of the missing or crashing texture file <nl> - auto texture = getDummyTexture ( ) ; <nl> - mesh - > setTexture ( texture ) ; <nl> - textureID = texture - > getName ( ) ; <nl> - } <nl> - <nl> - bool isTransparent = ( mesh - > _isTransparent | | color . a < 1 . f ) ; <nl> - float globalZ = isTransparent ? 0 : _globalZOrder ; <nl> - if ( isTransparent ) <nl> - flags | = Node : : FLAGS_RENDER_AS_3D ; <nl> - <nl> - meshCommand . init ( globalZ , textureID , programstate , _blend , mesh - > getVertexBuffer ( ) , mesh - > getIndexBuffer ( ) , mesh - > getPrimitiveType ( ) , mesh - > getIndexFormat ( ) , mesh - > getIndexCount ( ) , transform , flags ) ; <nl> - <nl> - meshCommand . setLightMask ( _lightMask ) ; <nl> + for ( auto & mesh : _meshes ) <nl> + { <nl> + mesh - > draw ( renderer , <nl> + _globalZOrder , <nl> + transform , <nl> + flags , <nl> + _lightMask , <nl> + Vec4 ( color . r , color . g , color . b , color . a ) , <nl> + _forceDepthWrite ) ; <nl> <nl> - auto skin = mesh - > getSkin ( ) ; <nl> - if ( skin ) <nl> - { <nl> - meshCommand . setMatrixPaletteSize ( ( int ) skin - > getMatrixPaletteSize ( ) ) ; <nl> - meshCommand . setMatrixPalette ( skin - > getMatrixPalette ( ) ) ; <nl> - } <nl> - / / support tint and fade <nl> - meshCommand . setDisplayColor ( Vec4 ( color . r , color . g , color . b , color . a ) ) ; <nl> - if ( _forceDepthWrite ) <nl> - { <nl> - meshCommand . setDepthWriteEnabled ( true ) ; <nl> - } <nl> - meshCommand . setTransparent ( isTransparent ) ; <nl> - renderer - > addCommand ( & meshCommand ) ; <nl> } <nl> } <nl> <nl> void Sprite3D : : setBlendFunc ( const BlendFunc & blendFunc ) <nl> if ( _blend . src ! = blendFunc . src | | _blend . dst ! = blendFunc . dst ) <nl> { <nl> _blend = blendFunc ; <nl> - for ( auto & state : _meshes ) <nl> + for ( auto & mesh : _meshes ) <nl> { <nl> - state - > setBlendFunc ( blendFunc ) ; <nl> + mesh - > setBlendFunc ( blendFunc ) ; <nl> } <nl> } <nl> } <nl> Rect Sprite3D : : getBoundingBox ( ) const <nl> void Sprite3D : : setCullFace ( GLenum cullFace ) <nl> { <nl> for ( auto & it : _meshes ) { <nl> - it - > getMeshCommand ( ) . setCullFace ( cullFace ) ; <nl> + it - > getMaterial ( ) - > getStateBlock ( ) - > setCullFaceSide ( ( RenderState : : CullFaceSide ) cullFace ) ; <nl> + / / it - > getMeshCommand ( ) . setCullFace ( cullFace ) ; <nl> } <nl> } <nl> <nl> void Sprite3D : : setCullFaceEnabled ( bool enable ) <nl> { <nl> for ( auto & it : _meshes ) { <nl> - it - > getMeshCommand ( ) . setCullFaceEnabled ( enable ) ; <nl> + it - > getMaterial ( ) - > getStateBlock ( ) - > setCullFace ( enable ) ; <nl> + / / it - > getMeshCommand ( ) . setCullFaceEnabled ( enable ) ; <nl> } <nl> } <nl> <nl> mmm a / cocos / 3d / CCSprite3D . h <nl> ppp b / cocos / 3d / CCSprite3D . h <nl> class CC_DLL Sprite3D : public Node , public BlendProtocol <nl> / * * draw * / <nl> virtual void draw ( Renderer * renderer , const Mat4 & transform , uint32_t flags ) override ; <nl> <nl> + / * * Adds a new material to the sprite . <nl> + The Material will be applied to all the meshes that belong to the sprite . <nl> + Internally it will call ` setMaterial ( material , - 1 ) ` <nl> + * / <nl> + void setMaterial ( Material * material ) ; <nl> + <nl> + / * * Adds a new material to a particular mesh of the sprite . <nl> + meshIndex is the mesh that will be applied to . <nl> + if meshIndex = = - 1 , then it will be applied to all the meshes that belong to the sprite . <nl> + * / <nl> + void setMaterial ( Material * material , int meshIndex ) ; <nl> + <nl> CC_CONSTRUCTOR_ACCESS : <nl> <nl> Sprite3D ( ) ; <nl> class CC_DLL Sprite3D : public Node , public BlendProtocol <nl> / * * get MeshIndexData by Id * / <nl> MeshIndexData * getMeshIndexData ( const std : : string & indexId ) const ; <nl> <nl> - void addMesh ( Mesh * mesh ) ; <nl> + void addMesh ( Mesh * mesh ) ; <nl> <nl> void onAABBDirty ( ) { _aabbDirty = true ; } <nl> <nl> mmm a / cocos / 3d / CMakeLists . txt <nl> ppp b / cocos / 3d / CMakeLists . txt <nl> set ( COCOS_3D_SRC <nl> 3d / CCAnimate3D . cpp <nl> 3d / CCAnimation3D . cpp <nl> 3d / CCAttachNode . cpp <nl> + 3d / CCBillBoard . cpp <nl> 3d / CCBundle3D . cpp <nl> 3d / CCBundleReader . cpp <nl> 3d / CCFrustum . cpp <nl> set ( COCOS_3D_SRC <nl> 3d / CCPlane . cpp <nl> 3d / CCRay . cpp <nl> 3d / CCSkeleton3D . cpp <nl> + 3d / CCSkybox . cpp <nl> 3d / CCSprite3D . cpp <nl> 3d / CCSprite3DMaterial . cpp <nl> - 3d / CCBillBoard . cpp <nl> - 3d / CCSkybox . cpp <nl> - 3d / CCTextureCube . cpp <nl> 3d / CCTerrain . cpp <nl> + 3d / CCTextureCube . cpp <nl> <nl> ) <nl> mmm a / cocos / Android . mk <nl> ppp b / cocos / Android . mk <nl> cocos2d . cpp \ <nl> 2d / CCComponentContainer . cpp \ <nl> 2d / CCDrawNode . cpp \ <nl> 2d / CCDrawingPrimitives . cpp \ <nl> + 2d / CCFastTMXLayer . cpp \ <nl> + 2d / CCFastTMXTiledMap . cpp \ <nl> 2d / CCFont . cpp \ <nl> 2d / CCFontAtlas . cpp \ <nl> 2d / CCFontAtlasCache . cpp \ <nl> cocos2d . cpp \ <nl> 2d / CCSpriteBatchNode . cpp \ <nl> 2d / CCSpriteFrame . cpp \ <nl> 2d / CCSpriteFrameCache . cpp \ <nl> - 2d / MarchingSquare . cpp \ <nl> - 2d / SpritePolygon . cpp \ <nl> - 2d / SpritePolygonCache . cpp \ <nl> 2d / CCTMXLayer . cpp \ <nl> - 2d / CCFastTMXLayer . cpp \ <nl> 2d / CCTMXObjectGroup . cpp \ <nl> 2d / CCTMXTiledMap . cpp \ <nl> - 2d / CCFastTMXTiledMap . cpp \ <nl> 2d / CCTMXXMLParser . cpp \ <nl> 2d / CCTextFieldTTF . cpp \ <nl> 2d / CCTileMapAtlas . cpp \ <nl> cocos2d . cpp \ <nl> 2d / CCTransitionPageTurn . cpp \ <nl> 2d / CCTransitionProgress . cpp \ <nl> 2d / CCTweenFunction . cpp \ <nl> + 2d / MarchingSquare . cpp \ <nl> + 2d / SpritePolygon . cpp \ <nl> + 2d / SpritePolygonCache . cpp \ <nl> 3d / CCFrustum . cpp \ <nl> 3d / CCPlane . cpp \ <nl> - platform / CCGLView . cpp \ <nl> platform / CCFileUtils . cpp \ <nl> + platform / CCGLView . cpp \ <nl> + platform / CCImage . cpp \ <nl> platform / CCSAXParser . cpp \ <nl> platform / CCThread . cpp \ <nl> - platform / CCImage . cpp \ <nl> + $ ( MATHNEONFILE ) \ <nl> math / CCAffineTransform . cpp \ <nl> math / CCGeometry . cpp \ <nl> math / CCVertex . cpp \ <nl> - $ ( MATHNEONFILE ) \ <nl> math / Mat4 . cpp \ <nl> math / Quaternion . cpp \ <nl> math / TransformUtils . cpp \ <nl> base / CCAsyncTaskPool . cpp \ <nl> base / CCAutoreleasePool . cpp \ <nl> base / CCConfiguration . cpp \ <nl> base / CCConsole . cpp \ <nl> + base / CCController - android . cpp \ <nl> + base / CCController . cpp \ <nl> base / CCData . cpp \ <nl> base / CCDataVisitor . cpp \ <nl> base / CCDirector . cpp \ <nl> base / CCEvent . cpp \ <nl> base / CCEventAcceleration . cpp \ <nl> + base / CCEventController . cpp \ <nl> base / CCEventCustom . cpp \ <nl> base / CCEventDispatcher . cpp \ <nl> base / CCEventFocus . cpp \ <nl> base / CCEventKeyboard . cpp \ <nl> - base / CCEventController . cpp \ <nl> base / CCEventListener . cpp \ <nl> - base / CCEventListenerController . cpp \ <nl> base / CCEventListenerAcceleration . cpp \ <nl> + base / CCEventListenerController . cpp \ <nl> base / CCEventListenerCustom . cpp \ <nl> base / CCEventListenerFocus . cpp \ <nl> base / CCEventListenerKeyboard . cpp \ <nl> base / CCEventTouch . cpp \ <nl> base / CCIMEDispatcher . cpp \ <nl> base / CCNS . cpp \ <nl> base / CCProfiling . cpp \ <nl> - base / ccRandom . cpp \ <nl> base / CCRef . cpp \ <nl> base / CCScheduler . cpp \ <nl> base / CCScriptSupport . cpp \ <nl> base / CCTouch . cpp \ <nl> - base / CCUserDefault . cpp \ <nl> base / CCUserDefault - android . cpp \ <nl> + base / CCUserDefault . cpp \ <nl> base / CCValue . cpp \ <nl> + base / ObjectFactory . cpp \ <nl> base / TGAlib . cpp \ <nl> base / ZipUtils . cpp \ <nl> + base / allocator / CCAllocatorDiagnostics . cpp \ <nl> + base / allocator / CCAllocatorGlobal . cpp \ <nl> + base / allocator / CCAllocatorGlobalNewDelete . cpp \ <nl> base / atitc . cpp \ <nl> base / base64 . cpp \ <nl> base / ccCArray . cpp \ <nl> base / ccFPSImages . c \ <nl> + base / ccRandom . cpp \ <nl> base / ccTypes . cpp \ <nl> base / ccUTF8 . cpp \ <nl> base / ccUtils . cpp \ <nl> base / etc1 . cpp \ <nl> base / pvr . cpp \ <nl> base / s3tc . cpp \ <nl> - base / CCController . cpp \ <nl> - base / CCController - android . cpp \ <nl> - base / allocator / CCAllocatorDiagnostics . cpp \ <nl> - base / allocator / CCAllocatorGlobal . cpp \ <nl> - base / allocator / CCAllocatorGlobalNewDelete . cpp \ <nl> - base / ObjectFactory . cpp \ <nl> renderer / CCBatchCommand . cpp \ <nl> renderer / CCCustomCommand . cpp \ <nl> renderer / CCGLProgram . cpp \ <nl> renderer / CCGLProgramCache . cpp \ <nl> renderer / CCGLProgramState . cpp \ <nl> renderer / CCGLProgramStateCache . cpp \ <nl> renderer / CCGroupCommand . cpp \ <nl> - renderer / CCQuadCommand . cpp \ <nl> + renderer / CCMaterial . cpp \ <nl> renderer / CCMeshCommand . cpp \ <nl> + renderer / CCPass . cpp \ <nl> + renderer / CCPrimitive . cpp \ <nl> + renderer / CCPrimitiveCommand . cpp \ <nl> + renderer / CCQuadCommand . cpp \ <nl> renderer / CCRenderCommand . cpp \ <nl> + renderer / CCRenderState . cpp \ <nl> renderer / CCRenderer . cpp \ <nl> + renderer / CCTechnique . cpp \ <nl> renderer / CCTexture2D . cpp \ <nl> renderer / CCTextureAtlas . cpp \ <nl> renderer / CCTextureCache . cpp \ <nl> - renderer / ccGLStateCache . cpp \ <nl> - renderer / ccShaders . cpp \ <nl> + renderer / CCTrianglesCommand . cpp \ <nl> renderer / CCVertexIndexBuffer . cpp \ <nl> renderer / CCVertexIndexData . cpp \ <nl> - renderer / CCPrimitive . cpp \ <nl> - renderer / CCPrimitiveCommand . cpp \ <nl> - renderer / CCTrianglesCommand . cpp \ <nl> + renderer / ccGLStateCache . cpp \ <nl> + renderer / ccShaders . cpp \ <nl> deprecated / CCArray . cpp \ <nl> - deprecated / CCSet . cpp \ <nl> - deprecated / CCString . cpp \ <nl> - deprecated / CCDictionary . cpp \ <nl> deprecated / CCDeprecated . cpp \ <nl> + deprecated / CCDictionary . cpp \ <nl> deprecated / CCNotificationCenter . cpp \ <nl> + deprecated / CCSet . cpp \ <nl> + deprecated / CCString . cpp \ <nl> physics / CCPhysicsBody . cpp \ <nl> physics / CCPhysicsContact . cpp \ <nl> physics / CCPhysicsJoint . cpp \ <nl> mmm a / cocos / base / CCDirector . cpp <nl> ppp b / cocos / base / CCDirector . cpp <nl> THE SOFTWARE . <nl> # include " renderer / CCTextureCache . h " <nl> # include " renderer / ccGLStateCache . h " <nl> # include " renderer / CCRenderer . h " <nl> + # include " renderer / CCRenderState . h " <nl> # include " 2d / CCCamera . h " <nl> # include " base / CCUserDefault . h " <nl> # include " base / ccFPSImages . h " <nl> bool Director : : init ( void ) <nl> initMatrixStack ( ) ; <nl> <nl> _renderer = new ( std : : nothrow ) Renderer ; <nl> + RenderState : : initialize ( ) ; <nl> <nl> return true ; <nl> } <nl> void Director : : reset ( ) <nl> UserDefault : : destroyInstance ( ) ; <nl> <nl> GL : : invalidateStateCache ( ) ; <nl> + <nl> + RenderState : : finalize ( ) ; <nl> <nl> destroyTextureCache ( ) ; <nl> } <nl> mmm a / cocos / renderer / CCGLProgram . cpp <nl> ppp b / cocos / renderer / CCGLProgram . cpp <nl> THE SOFTWARE . <nl> # include " CCPrecompiledShaders . h " <nl> # endif <nl> <nl> + <nl> + / / helper functions <nl> + <nl> + static void replaceDefines ( const std : : string & compileTimeDefines , std : : string & out ) <nl> + { <nl> + / / Replace semicolons with ' # define . . . \ n ' <nl> + if ( compileTimeDefines . size ( ) > 0 ) <nl> + { <nl> + size_t pos ; <nl> + out = compileTimeDefines ; <nl> + out . insert ( 0 , " # define " ) ; <nl> + while ( ( pos = out . find ( ' ; ' ) ) ! = std : : string : : npos ) <nl> + { <nl> + out . replace ( pos , 1 , " \ n # define " ) ; <nl> + } <nl> + out + = " \ n " ; <nl> + } <nl> + } <nl> + <nl> + <nl> NS_CC_BEGIN <nl> <nl> const char * GLProgram : : SHADER_NAME_POSITION_TEXTURE_COLOR = " ShaderPositionTextureColor " ; <nl> const char * GLProgram : : ATTRIBUTE_NAME_NORMAL = " a_normal " ; <nl> const char * GLProgram : : ATTRIBUTE_NAME_BLEND_WEIGHT = " a_blendWeight " ; <nl> const char * GLProgram : : ATTRIBUTE_NAME_BLEND_INDEX = " a_blendIndex " ; <nl> <nl> + static const char * COCOS2D_SHADER_UNIFORMS = <nl> + " uniform mat4 CC_PMatrix ; \ n " <nl> + " uniform mat4 CC_MVMatrix ; \ n " <nl> + " uniform mat4 CC_MVPMatrix ; \ n " <nl> + " uniform mat3 CC_NormalMatrix ; \ n " <nl> + " uniform vec4 CC_Time ; \ n " <nl> + " uniform vec4 CC_SinTime ; \ n " <nl> + " uniform vec4 CC_CosTime ; \ n " <nl> + " uniform vec4 CC_Random01 ; \ n " <nl> + " uniform sampler2D CC_Texture0 ; \ n " <nl> + " uniform sampler2D CC_Texture1 ; \ n " <nl> + " uniform sampler2D CC_Texture2 ; \ n " <nl> + " uniform sampler2D CC_Texture3 ; \ n " <nl> + " / / CC INCLUDES END \ n \ n " ; <nl> + <nl> + static const std : : string EMPTY_DEFINE ; <nl> + <nl> GLProgram * GLProgram : : createWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray ) <nl> + { <nl> + return createWithByteArrays ( vShaderByteArray , fShaderByteArray , EMPTY_DEFINE ) ; <nl> + } <nl> + <nl> + GLProgram * GLProgram : : createWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray , const std : : string & compileTimeDefines ) <nl> { <nl> auto ret = new ( std : : nothrow ) GLProgram ( ) ; <nl> - if ( ret & & ret - > initWithByteArrays ( vShaderByteArray , fShaderByteArray ) ) { <nl> + if ( ret & & ret - > initWithByteArrays ( vShaderByteArray , fShaderByteArray , compileTimeDefines ) ) { <nl> ret - > link ( ) ; <nl> ret - > updateUniforms ( ) ; <nl> ret - > autorelease ( ) ; <nl> GLProgram * GLProgram : : createWithByteArrays ( const GLchar * vShaderByteArray , const <nl> return nullptr ; <nl> } <nl> <nl> + <nl> GLProgram * GLProgram : : createWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename ) <nl> + { <nl> + return createWithFilenames ( vShaderFilename , fShaderFilename , EMPTY_DEFINE ) ; <nl> + } <nl> + <nl> + GLProgram * GLProgram : : createWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename , const std : : string & compileTimeDefines ) <nl> { <nl> auto ret = new ( std : : nothrow ) GLProgram ( ) ; <nl> - if ( ret & & ret - > initWithFilenames ( vShaderFilename , fShaderFilename ) ) { <nl> + if ( ret & & ret - > initWithFilenames ( vShaderFilename , fShaderFilename , compileTimeDefines ) ) { <nl> ret - > link ( ) ; <nl> ret - > updateUniforms ( ) ; <nl> ret - > autorelease ( ) ; <nl> GLProgram * GLProgram : : createWithFilenames ( const std : : string & vShaderFilename , co <nl> return nullptr ; <nl> } <nl> <nl> + <nl> GLProgram : : GLProgram ( ) <nl> : _program ( 0 ) <nl> , _vertShader ( 0 ) <nl> GLProgram : : ~ GLProgram ( ) <nl> } <nl> <nl> bool GLProgram : : initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray ) <nl> + { <nl> + return initWithByteArrays ( vShaderByteArray , fShaderByteArray , EMPTY_DEFINE ) ; <nl> + } <nl> + <nl> + bool GLProgram : : initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray , const std : : string & compileTimeDefines ) <nl> { <nl> <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 ) <nl> bool GLProgram : : initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * <nl> _program = glCreateProgram ( ) ; <nl> CHECK_GL_ERROR_DEBUG ( ) ; <nl> <nl> + / / convert defines here . If we do it in " compileShader " we will do it it twice . <nl> + / / a cache for the defines could be useful , but seems like overkill at this point <nl> + std : : string replacedDefines = " " ; <nl> + replaceDefines ( compileTimeDefines , replacedDefines ) ; <nl> + <nl> _vertShader = _fragShader = 0 ; <nl> <nl> if ( vShaderByteArray ) <nl> { <nl> - if ( ! compileShader ( & _vertShader , GL_VERTEX_SHADER , vShaderByteArray ) ) <nl> + if ( ! compileShader ( & _vertShader , GL_VERTEX_SHADER , vShaderByteArray , replacedDefines ) ) <nl> { <nl> CCLOG ( " cocos2d : ERROR : Failed to compile vertex shader " ) ; <nl> return false ; <nl> bool GLProgram : : initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * <nl> / / Create and compile fragment shader <nl> if ( fShaderByteArray ) <nl> { <nl> - if ( ! compileShader ( & _fragShader , GL_FRAGMENT_SHADER , fShaderByteArray ) ) <nl> + if ( ! compileShader ( & _fragShader , GL_FRAGMENT_SHADER , fShaderByteArray , replacedDefines ) ) <nl> { <nl> CCLOG ( " cocos2d : ERROR : Failed to compile fragment shader " ) ; <nl> return false ; <nl> bool GLProgram : : initWithPrecompiledProgramByteArray ( const GLchar * vShaderByteArr <nl> } <nl> # endif <nl> <nl> - bool GLProgram : : initWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename ) <nl> + bool GLProgram : : initWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename ) <nl> + { <nl> + return initWithFilenames ( vShaderFilename , fShaderFilename , EMPTY_DEFINE ) ; <nl> + } <nl> + <nl> + bool GLProgram : : initWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename , const std : : string & compileTimeDefines ) <nl> { <nl> auto fileUtils = FileUtils : : getInstance ( ) ; <nl> std : : string vertexSource = fileUtils - > getStringFromFile ( FileUtils : : getInstance ( ) - > fullPathForFilename ( vShaderFilename ) ) ; <nl> std : : string fragmentSource = fileUtils - > getStringFromFile ( FileUtils : : getInstance ( ) - > fullPathForFilename ( fShaderFilename ) ) ; <nl> <nl> - return initWithByteArrays ( vertexSource . c_str ( ) , fragmentSource . c_str ( ) ) ; <nl> + return initWithByteArrays ( vertexSource . c_str ( ) , fragmentSource . c_str ( ) , compileTimeDefines ) ; <nl> } <nl> <nl> void GLProgram : : bindPredefinedVertexAttribs ( ) <nl> std : : string GLProgram : : getDescription ( ) const <nl> } <nl> <nl> bool GLProgram : : compileShader ( GLuint * shader , GLenum type , const GLchar * source ) <nl> + { <nl> + return compileShader ( shader , type , source , " " ) ; <nl> + } <nl> + <nl> + bool GLProgram : : compileShader ( GLuint * shader , GLenum type , const GLchar * source , const std : : string & convertedDefines ) <nl> { <nl> GLint status ; <nl> <nl> bool GLProgram : : compileShader ( GLuint * shader , GLenum type , const GLchar * source <nl> # elif ( CC_TARGET_PLATFORM ! = CC_PLATFORM_WIN32 & & CC_TARGET_PLATFORM ! = CC_PLATFORM_LINUX & & CC_TARGET_PLATFORM ! = CC_PLATFORM_MAC ) <nl> ( type = = GL_VERTEX_SHADER ? " precision highp float ; \ n precision highp int ; \ n " : " precision mediump float ; \ n precision mediump int ; \ n " ) , <nl> # endif <nl> - " uniform mat4 CC_PMatrix ; \ n " <nl> - " uniform mat4 CC_MVMatrix ; \ n " <nl> - " uniform mat4 CC_MVPMatrix ; \ n " <nl> - " uniform mat3 CC_NormalMatrix ; \ n " <nl> - " uniform vec4 CC_Time ; \ n " <nl> - " uniform vec4 CC_SinTime ; \ n " <nl> - " uniform vec4 CC_CosTime ; \ n " <nl> - " uniform vec4 CC_Random01 ; \ n " <nl> - " uniform sampler2D CC_Texture0 ; \ n " <nl> - " uniform sampler2D CC_Texture1 ; \ n " <nl> - " uniform sampler2D CC_Texture2 ; \ n " <nl> - " uniform sampler2D CC_Texture3 ; \ n " <nl> - " / / CC INCLUDES END \ n \ n " , <nl> - source , <nl> - } ; <nl> + COCOS2D_SHADER_UNIFORMS , <nl> + convertedDefines . c_str ( ) , <nl> + source } ; <nl> <nl> * shader = glCreateShader ( type ) ; <nl> glShaderSource ( * shader , sizeof ( sources ) / sizeof ( * sources ) , sources , nullptr ) ; <nl> void GLProgram : : setUniformLocationWith1i ( GLint location , GLint i1 ) <nl> { <nl> bool updated = updateUniformLocation ( location , & i1 , sizeof ( i1 ) * 1 ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform1i ( ( GLint ) location , i1 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith2i ( GLint location , GLint i1 , GLint i2 ) <nl> GLint ints [ 2 ] = { i1 , i2 } ; <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform2i ( ( GLint ) location , i1 , i2 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith3i ( GLint location , GLint i1 , GLint i2 , GLi <nl> GLint ints [ 3 ] = { i1 , i2 , i3 } ; <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform3i ( ( GLint ) location , i1 , i2 , i3 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith4i ( GLint location , GLint i1 , GLint i2 , GLi <nl> GLint ints [ 4 ] = { i1 , i2 , i3 , i4 } ; <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform4i ( ( GLint ) location , i1 , i2 , i3 , i4 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith2iv ( GLint location , GLint * ints , unsigned <nl> { <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 2 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform2iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith3iv ( GLint location , GLint * ints , unsigned <nl> { <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 3 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform3iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith4iv ( GLint location , GLint * ints , unsigned <nl> { <nl> bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 4 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform4iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith1f ( GLint location , GLfloat f1 ) <nl> { <nl> bool updated = updateUniformLocation ( location , & f1 , sizeof ( f1 ) * 1 ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform1f ( ( GLint ) location , f1 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith2f ( GLint location , GLfloat f1 , GLfloat f2 ) <nl> GLfloat floats [ 2 ] = { f1 , f2 } ; <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( floats ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform2f ( ( GLint ) location , f1 , f2 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith3f ( GLint location , GLfloat f1 , GLfloat f2 , <nl> GLfloat floats [ 3 ] = { f1 , f2 , f3 } ; <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( floats ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform3f ( ( GLint ) location , f1 , f2 , f3 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith4f ( GLint location , GLfloat f1 , GLfloat f2 , <nl> GLfloat floats [ 4 ] = { f1 , f2 , f3 , f4 } ; <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( floats ) ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform4f ( ( GLint ) location , f1 , f2 , f3 , f4 ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith1fv ( GLint location , const GLfloat * floats <nl> { <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( float ) * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform1fv ( ( GLint ) location , ( GLsizei ) numberOfArrays , floats ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith2fv ( GLint location , const GLfloat * floats , <nl> { <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( float ) * 2 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform2fv ( ( GLint ) location , ( GLsizei ) numberOfArrays , floats ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith3fv ( GLint location , const GLfloat * floats , <nl> { <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( float ) * 3 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform3fv ( ( GLint ) location , ( GLsizei ) numberOfArrays , floats ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith4fv ( GLint location , const GLfloat * floats , <nl> { <nl> bool updated = updateUniformLocation ( location , floats , sizeof ( float ) * 4 * numberOfArrays ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniform4fv ( ( GLint ) location , ( GLsizei ) numberOfArrays , floats ) ; <nl> } <nl> void GLProgram : : setUniformLocationWith4fv ( GLint location , const GLfloat * floats , <nl> void GLProgram : : setUniformLocationWithMatrix2fv ( GLint location , const GLfloat * matrixArray , unsigned int numberOfMatrices ) { <nl> bool updated = updateUniformLocation ( location , matrixArray , sizeof ( float ) * 4 * numberOfMatrices ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniformMatrix2fv ( ( GLint ) location , ( GLsizei ) numberOfMatrices , GL_FALSE , matrixArray ) ; <nl> } <nl> void GLProgram : : setUniformLocationWithMatrix2fv ( GLint location , const GLfloat * m <nl> void GLProgram : : setUniformLocationWithMatrix3fv ( GLint location , const GLfloat * matrixArray , unsigned int numberOfMatrices ) { <nl> bool updated = updateUniformLocation ( location , matrixArray , sizeof ( float ) * 9 * numberOfMatrices ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniformMatrix3fv ( ( GLint ) location , ( GLsizei ) numberOfMatrices , GL_FALSE , matrixArray ) ; <nl> } <nl> void GLProgram : : setUniformLocationWithMatrix4fv ( GLint location , const GLfloat * m <nl> { <nl> bool updated = updateUniformLocation ( location , matrixArray , sizeof ( float ) * 16 * numberOfMatrices ) ; <nl> <nl> - if ( updated ) <nl> + if ( updated ) <nl> { <nl> glUniformMatrix4fv ( ( GLint ) location , ( GLsizei ) numberOfMatrices , GL_FALSE , matrixArray ) ; <nl> } <nl> void GLProgram : : setUniformsForBuiltins ( const Mat4 & matrixMV ) <nl> { <nl> auto & matrixP = _director - > getMatrix ( MATRIX_STACK_TYPE : : MATRIX_STACK_PROJECTION ) ; <nl> <nl> - if ( _flags . usesP ) <nl> + if ( _flags . usesP ) <nl> setUniformLocationWithMatrix4fv ( _builtInUniforms [ UNIFORM_P_MATRIX ] , matrixP . m , 1 ) ; <nl> <nl> - if ( _flags . usesMV ) <nl> + if ( _flags . usesMV ) <nl> setUniformLocationWithMatrix4fv ( _builtInUniforms [ UNIFORM_MV_MATRIX ] , matrixMV . m , 1 ) ; <nl> <nl> - if ( _flags . usesMVP ) { <nl> + if ( _flags . usesMVP ) { <nl> Mat4 matrixMVP = matrixP * matrixMV ; <nl> setUniformLocationWithMatrix4fv ( _builtInUniforms [ UNIFORM_MVP_MATRIX ] , matrixMVP . m , 1 ) ; <nl> } <nl> void GLProgram : : setUniformsForBuiltins ( const Mat4 & matrixMV ) <nl> setUniformLocationWithMatrix3fv ( _builtInUniforms [ UNIFORM_NORMAL_MATRIX ] , normalMat , 1 ) ; <nl> } <nl> <nl> - if ( _flags . usesTime ) { <nl> + if ( _flags . usesTime ) { <nl> / / This doesn ' t give the most accurate global time value . <nl> / / Cocos2D doesn ' t store a high precision time value , so this will have to do . <nl> / / Getting Mach time per frame per shader using time could be extremely expensive . <nl> void GLProgram : : setUniformsForBuiltins ( const Mat4 & matrixMV ) <nl> setUniformLocationWith4f ( _builtInUniforms [ GLProgram : : UNIFORM_COS_TIME ] , time / 8 . 0 , time / 4 . 0 , time / 2 . 0 , cosf ( time ) ) ; <nl> } <nl> <nl> - if ( _flags . usesRandom ) <nl> + if ( _flags . usesRandom ) <nl> setUniformLocationWith4f ( _builtInUniforms [ GLProgram : : UNIFORM_RANDOM01 ] , CCRANDOM_0_1 ( ) , CCRANDOM_0_1 ( ) , CCRANDOM_0_1 ( ) , CCRANDOM_0_1 ( ) ) ; <nl> } <nl> <nl> void GLProgram : : reset ( ) <nl> } <nl> <nl> NS_CC_END <nl> + <nl> mmm a / cocos / renderer / CCGLProgram . h <nl> ppp b / cocos / renderer / CCGLProgram . h <nl> THE SOFTWARE . <nl> # define __CCGLPROGRAM_H__ <nl> <nl> # include < unordered_map > <nl> + # include < string > <nl> <nl> # include " base / ccMacros . h " <nl> # include " base / CCRef . h " <nl> class CC_DLL GLProgram : public Ref <nl> * / <nl> static GLProgram * createWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray ) ; <nl> bool initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray ) ; <nl> + static GLProgram * createWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray , const std : : string & compileTimeDefines ) ; <nl> + bool initWithByteArrays ( const GLchar * vShaderByteArray , const GLchar * fShaderByteArray , const std : : string & compileTimeDefines ) ; <nl> + <nl> / * * <nl> @ } <nl> * / <nl> class CC_DLL GLProgram : public Ref <nl> * / <nl> static GLProgram * createWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename ) ; <nl> bool initWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename ) ; <nl> + <nl> + static GLProgram * createWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename , const std : : string & compileTimeDefines ) ; <nl> + bool initWithFilenames ( const std : : string & vShaderFilename , const std : : string & fShaderFilename , const std : : string & compileTimeDefines ) ; <nl> / * * <nl> @ } <nl> * / <nl> class CC_DLL GLProgram : public Ref <nl> / * * Parse user defined uniform automatically . * / <nl> void parseUniforms ( ) ; <nl> / * * Compile the shader sources . * / <nl> + bool compileShader ( GLuint * shader , GLenum type , const GLchar * source , const std : : string & convertedDefines ) ; <nl> bool compileShader ( GLuint * shader , GLenum type , const GLchar * source ) ; <nl> <nl> / * * OpenGL handle for program . * / <nl> mmm a / cocos / renderer / CCGLProgramState . cpp <nl> ppp b / cocos / renderer / CCGLProgramState . cpp <nl> NS_CC_BEGIN <nl> UniformValue : : UniformValue ( ) <nl> : _uniform ( nullptr ) <nl> , _glprogram ( nullptr ) <nl> - , _useCallback ( false ) <nl> + , _type ( Type : : VALUE ) <nl> { <nl> } <nl> <nl> UniformValue : : UniformValue ( Uniform * uniform , GLProgram * glprogram ) <nl> : _uniform ( uniform ) <nl> , _glprogram ( glprogram ) <nl> - , _useCallback ( false ) <nl> + , _type ( Type : : VALUE ) <nl> { <nl> } <nl> <nl> UniformValue : : ~ UniformValue ( ) <nl> { <nl> - if ( _useCallback ) <nl> + if ( _type = = Type : : CALLBACK_FN ) <nl> delete _value . callback ; <nl> } <nl> <nl> void UniformValue : : apply ( ) <nl> { <nl> - if ( _useCallback ) { <nl> + if ( _type = = Type : : CALLBACK_FN ) <nl> + { <nl> ( * _value . callback ) ( _glprogram , _uniform ) ; <nl> } <nl> - else <nl> + else if ( _type = = Type : : POINTER ) <nl> + { <nl> + switch ( _uniform - > type ) { <nl> + case GL_FLOAT : <nl> + _glprogram - > setUniformLocationWith1fv ( _uniform - > location , _value . floatv . pointer , _value . floatv . size ) ; <nl> + break ; <nl> + <nl> + case GL_FLOAT_VEC2 : <nl> + _glprogram - > setUniformLocationWith2fv ( _uniform - > location , _value . v2f . pointer , _value . v2f . size ) ; <nl> + break ; <nl> + <nl> + case GL_FLOAT_VEC3 : <nl> + _glprogram - > setUniformLocationWith3fv ( _uniform - > location , _value . v3f . pointer , _value . v3f . size ) ; <nl> + break ; <nl> + <nl> + case GL_FLOAT_VEC4 : <nl> + _glprogram - > setUniformLocationWith4fv ( _uniform - > location , _value . v4f . pointer , _value . v4f . size ) ; <nl> + break ; <nl> + <nl> + default : <nl> + CCASSERT ( false , " Unsupported type " ) ; <nl> + break ; <nl> + } <nl> + } <nl> + else / * _type = = VALUE * / <nl> { <nl> switch ( _uniform - > type ) { <nl> case GL_SAMPLER_2D : <nl> void UniformValue : : setCallback ( const std : : function < void ( GLProgram * , Uniform * ) > & <nl> / / TODO : memory will leak if the user does : <nl> / / value - > setCallback ( ) ; <nl> / / value - > setFloat ( ) ; <nl> - if ( _useCallback ) <nl> + if ( _type = = Type : : CALLBACK_FN ) <nl> delete _value . callback ; <nl> <nl> _value . callback = new std : : function < void ( GLProgram * , Uniform * ) > ( ) ; <nl> * _value . callback = callback ; <nl> <nl> - _useCallback = true ; <nl> - } <nl> - <nl> - void UniformValue : : setFloat ( float value ) <nl> - { <nl> - CCASSERT ( _uniform - > type = = GL_FLOAT , " " ) ; <nl> - _value . floatValue = value ; <nl> - _useCallback = false ; <nl> + _type = Type : : CALLBACK_FN ; <nl> } <nl> <nl> void UniformValue : : setTexture ( GLuint textureId , GLuint textureUnit ) <nl> void UniformValue : : setTexture ( GLuint textureId , GLuint textureUnit ) <nl> / / CCASSERT ( _uniform - > type = = GL_SAMPLER_2D , " Wrong type . expecting GL_SAMPLER_2D " ) ; <nl> _value . tex . textureId = textureId ; <nl> _value . tex . textureUnit = textureUnit ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> } <nl> void UniformValue : : setInt ( int value ) <nl> { <nl> CCASSERT ( _uniform - > type = = GL_INT , " Wrong type : expecting GL_INT " ) ; <nl> _value . intValue = value ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> + } <nl> + <nl> + void UniformValue : : setFloat ( float value ) <nl> + { <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT , " Wrong type : expecting GL_FLOAT " ) ; <nl> + _value . floatValue = value ; <nl> + _type = Type : : VALUE ; <nl> + } <nl> + <nl> + void UniformValue : : setFloatv ( const float * pointer , ssize_t size ) <nl> + { <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT , " Wrong type : expecting GL_FLOAT " ) ; <nl> + _value . floatv . pointer = ( const float * ) pointer ; <nl> + _value . floatv . size = ( GLsizei ) size ; <nl> + _type = Type : : POINTER ; <nl> } <nl> <nl> void UniformValue : : setVec2 ( const Vec2 & value ) <nl> { <nl> - CCASSERT ( _uniform - > type = = GL_FLOAT_VEC2 , " " ) ; <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC2 , " Wrong type : expecting GL_FLOAT_VEC2 " ) ; <nl> memcpy ( _value . v2Value , & value , sizeof ( _value . v2Value ) ) ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> + } <nl> + <nl> + void UniformValue : : setVec2v ( const Vec2 * pointer , ssize_t size ) <nl> + { <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC2 , " Wrong type : expecting GL_FLOAT_VEC2 " ) ; <nl> + _value . v2f . pointer = ( const float * ) pointer ; <nl> + _value . v2f . size = ( GLsizei ) size ; <nl> + _type = Type : : POINTER ; <nl> } <nl> <nl> void UniformValue : : setVec3 ( const Vec3 & value ) <nl> { <nl> - CCASSERT ( _uniform - > type = = GL_FLOAT_VEC3 , " " ) ; <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC3 , " Wrong type : expecting GL_FLOAT_VEC3 " ) ; <nl> memcpy ( _value . v3Value , & value , sizeof ( _value . v3Value ) ) ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> + <nl> + } <nl> + <nl> + void UniformValue : : setVec3v ( const Vec3 * pointer , ssize_t size ) <nl> + { <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC3 , " Wrong type : expecting GL_FLOAT_VEC3 " ) ; <nl> + _value . v3f . pointer = ( const float * ) pointer ; <nl> + _value . v3f . size = ( GLsizei ) size ; <nl> + _type = Type : : POINTER ; <nl> + <nl> } <nl> <nl> void UniformValue : : setVec4 ( const Vec4 & value ) <nl> { <nl> - CCASSERT ( _uniform - > type = = GL_FLOAT_VEC4 , " " ) ; <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC4 , " Wrong type : expecting GL_FLOAT_VEC4 " ) ; <nl> memcpy ( _value . v4Value , & value , sizeof ( _value . v4Value ) ) ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> + } <nl> + <nl> + void UniformValue : : setVec4v ( const Vec4 * pointer , ssize_t size ) <nl> + { <nl> + CCASSERT ( _uniform - > type = = GL_FLOAT_VEC4 , " Wrong type : expecting GL_FLOAT_VEC4 " ) ; <nl> + _value . v4f . pointer = ( const float * ) pointer ; <nl> + _value . v4f . size = ( GLsizei ) size ; <nl> + _type = Type : : POINTER ; <nl> } <nl> <nl> void UniformValue : : setMat4 ( const Mat4 & value ) <nl> { <nl> CCASSERT ( _uniform - > type = = GL_FLOAT_MAT4 , " " ) ; <nl> memcpy ( _value . matrixValue , & value , sizeof ( _value . matrixValue ) ) ; <nl> - _useCallback = false ; <nl> + _type = Type : : VALUE ; <nl> } <nl> <nl> / / <nl> GLProgramState * GLProgramState : : getOrCreateWithGLProgram ( GLProgram * glprogram ) <nl> return ret ; <nl> } <nl> <nl> + GLProgramState * GLProgramState : : getOrCreateWithShaders ( const std : : string & vertexShader , const std : : string & fragShader , const std : : string & compileTimeDefines ) <nl> + { <nl> + auto glprogramcache = GLProgramCache : : getInstance ( ) ; <nl> + const std : : string key = vertexShader + " + " + fragShader + " + " + compileTimeDefines ; <nl> + auto glprogram = glprogramcache - > getGLProgram ( key ) ; <nl> + <nl> + if ( ! glprogram ) { <nl> + glprogram = GLProgram : : createWithFilenames ( vertexShader , fragShader , compileTimeDefines ) ; <nl> + glprogramcache - > addGLProgram ( glprogram , key ) ; <nl> + } <nl> + <nl> + return create ( glprogram ) ; <nl> + } <nl> + <nl> + <nl> GLProgramState : : GLProgramState ( ) <nl> : _uniformAttributeValueDirty ( true ) <nl> , _textureUnitIndex ( 1 ) <nl> GLProgramState : : ~ GLProgramState ( ) <nl> CC_SAFE_RELEASE ( _glprogram ) ; <nl> } <nl> <nl> + GLProgramState * GLProgramState : : clone ( ) const <nl> + { <nl> + auto glprogramstate = new ( std : : nothrow ) GLProgramState ( ) ; <nl> + <nl> + / / copy everything manually , instead of calling init since this is faster <nl> + <nl> + glprogramstate - > _glprogram = this - > _glprogram ; <nl> + CC_SAFE_RETAIN ( glprogramstate - > _glprogram ) ; <nl> + <nl> + glprogramstate - > _attributes = this - > _attributes ; <nl> + glprogramstate - > _vertexAttribsFlags = this - > _vertexAttribsFlags ; <nl> + <nl> + / / copy uniforms <nl> + glprogramstate - > _uniformsByName = this - > _uniformsByName ; <nl> + glprogramstate - > _uniforms = this - > _uniforms ; <nl> + glprogramstate - > _uniformAttributeValueDirty = this - > _uniformAttributeValueDirty ; <nl> + <nl> + / / copy textures <nl> + glprogramstate - > _textureUnitIndex = this - > _textureUnitIndex ; <nl> + glprogramstate - > _boundTextureUnits = this - > _boundTextureUnits ; <nl> + <nl> + glprogramstate - > autorelease ( ) ; <nl> + return glprogramstate ; <nl> + } <nl> + <nl> bool GLProgramState : : init ( GLProgram * glprogram ) <nl> { <nl> CCASSERT ( glprogram , " invalid shader " ) ; <nl> void GLProgramState : : applyGLProgram ( const Mat4 & modelView ) <nl> _glprogram - > use ( ) ; <nl> _glprogram - > setUniformsForBuiltins ( modelView ) ; <nl> } <nl> + <nl> void GLProgramState : : applyAttributes ( bool applyAttribFlags ) <nl> { <nl> / / Don ' t set attributes if they weren ' t set <nl> void GLProgramState : : setGLProgram ( GLProgram * glprogram ) <nl> } <nl> } <nl> <nl> + uint32_t GLProgramState : : getVertexAttribsFlags ( ) const <nl> + { <nl> + return _vertexAttribsFlags ; <nl> + } <nl> + <nl> + ssize_t GLProgramState : : getVertexAttribCount ( ) const <nl> + { <nl> + return _attributes . size ( ) ; <nl> + } <nl> + <nl> UniformValue * GLProgramState : : getUniformValue ( GLint uniformLocation ) <nl> { <nl> updateUniformsAndAttributes ( ) ; <nl> void GLProgramState : : setUniformInt ( GLint uniformLocation , int value ) <nl> <nl> } <nl> <nl> + void GLProgramState : : setUniformFloatv ( const std : : string & uniformName , const float * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformName ) ; <nl> + if ( v ) <nl> + v - > setFloatv ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform not found : % s " , uniformName . c_str ( ) ) ; <nl> + } <nl> + <nl> + void GLProgramState : : setUniformFloatv ( GLint uniformLocation , const float * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformLocation ) ; <nl> + if ( v ) <nl> + v - > setFloatv ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> + } <nl> + <nl> void GLProgramState : : setUniformVec2 ( const std : : string & uniformName , const Vec2 & value ) <nl> { <nl> auto v = getUniformValue ( uniformName ) ; <nl> void GLProgramState : : setUniformVec2 ( GLint uniformLocation , const Vec2 & value ) <nl> CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> } <nl> <nl> + void GLProgramState : : setUniformVec2v ( const std : : string & uniformName , const Vec2 * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformName ) ; <nl> + if ( v ) <nl> + v - > setVec2v ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform not found : % s " , uniformName . c_str ( ) ) ; <nl> + } <nl> + <nl> + void GLProgramState : : setUniformVec2v ( GLint uniformLocation , const Vec2 * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformLocation ) ; <nl> + if ( v ) <nl> + v - > setVec2v ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> + } <nl> + <nl> void GLProgramState : : setUniformVec3 ( const std : : string & uniformName , const Vec3 & value ) <nl> { <nl> auto v = getUniformValue ( uniformName ) ; <nl> void GLProgramState : : setUniformVec3 ( GLint uniformLocation , const Vec3 & value ) <nl> CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> } <nl> <nl> + void GLProgramState : : setUniformVec3v ( const std : : string & uniformName , const Vec3 * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformName ) ; <nl> + if ( v ) <nl> + v - > setVec3v ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform not found : % s " , uniformName . c_str ( ) ) ; <nl> + } <nl> + <nl> + void GLProgramState : : setUniformVec3v ( GLint uniformLocation , const Vec3 * pointer , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformLocation ) ; <nl> + if ( v ) <nl> + v - > setVec3v ( pointer , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> + } <nl> + <nl> void GLProgramState : : setUniformVec4 ( const std : : string & uniformName , const Vec4 & value ) <nl> { <nl> auto v = getUniformValue ( uniformName ) ; <nl> void GLProgramState : : setUniformVec4 ( GLint uniformLocation , const Vec4 & value ) <nl> CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> } <nl> <nl> + void GLProgramState : : setUniformVec4v ( const std : : string & uniformName , const Vec4 * value , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformName ) ; <nl> + if ( v ) <nl> + v - > setVec4v ( value , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform not found : % s " , uniformName . c_str ( ) ) ; <nl> + } <nl> + <nl> + void GLProgramState : : setUniformVec4v ( GLint uniformLocation , const Vec4 * value , ssize_t size ) <nl> + { <nl> + auto v = getUniformValue ( uniformLocation ) ; <nl> + if ( v ) <nl> + v - > setVec4v ( value , size ) ; <nl> + else <nl> + CCLOG ( " cocos2d : warning : Uniform at location not found : % i " , uniformLocation ) ; <nl> + } <nl> + <nl> + <nl> void GLProgramState : : setUniformMat4 ( const std : : string & uniformName , const Mat4 & value ) <nl> { <nl> auto v = getUniformValue ( uniformName ) ; <nl> mmm a / cocos / renderer / CCGLProgramState . h <nl> ppp b / cocos / renderer / CCGLProgramState . h <nl> class CC_DLL UniformValue <nl> * / <nl> void setFloat ( float value ) ; <nl> void setInt ( int value ) ; <nl> + void setFloatv ( const float * pointer , ssize_t size ) ; <nl> void setVec2 ( const Vec2 & value ) ; <nl> + void setVec2v ( const Vec2 * pointer , ssize_t size ) ; <nl> void setVec3 ( const Vec3 & value ) ; <nl> + void setVec3v ( const Vec3 * pointer , ssize_t size ) ; <nl> void setVec4 ( const Vec4 & value ) ; <nl> + void setVec4v ( const Vec4 * pointer , ssize_t size ) ; <nl> void setMat4 ( const Mat4 & value ) ; <nl> / * * <nl> @ } <nl> class CC_DLL UniformValue <nl> void apply ( ) ; <nl> <nl> protected : <nl> + <nl> + enum class Type { <nl> + VALUE , <nl> + POINTER , <nl> + CALLBACK_FN / / CALLBACK is already defined in windows , can ' t use it . <nl> + } ; <nl> + <nl> / * * Weak reference to Uniform . * / <nl> Uniform * _uniform ; <nl> / * * Weak reference to GLprogram . * / <nl> GLProgram * _glprogram ; <nl> - / * * Whether or not callback is used . * / <nl> - bool _useCallback ; <nl> + / * * What kind of type is the Uniform * / <nl> + Type _type ; <nl> + <nl> / * * <nl> @ name Uniform Value Uniform <nl> @ { <nl> class CC_DLL UniformValue <nl> GLuint textureId ; <nl> GLuint textureUnit ; <nl> } tex ; <nl> + struct { <nl> + const float * pointer ; <nl> + GLsizei size ; <nl> + } floatv ; <nl> + struct { <nl> + const float * pointer ; <nl> + GLsizei size ; <nl> + } v2f ; <nl> + struct { <nl> + const float * pointer ; <nl> + GLsizei size ; <nl> + } v3f ; <nl> + struct { <nl> + const float * pointer ; <nl> + GLsizei size ; <nl> + } v4f ; <nl> std : : function < void ( GLProgram * , Uniform * ) > * callback ; <nl> <nl> U ( ) { memset ( this , 0 , sizeof ( * this ) ) ; } <nl> class CC_DLL VertexAttribValue <nl> A GLProgram can be used by thousands of Nodes , but if different uniform values <nl> are going to be used , then each node will need its own GLProgramState <nl> * / <nl> - class CC_DLL GLProgramState : public Ref <nl> + class CC_DLL GLProgramState : public Ref , public Clonable <nl> { <nl> friend class GLProgramStateCache ; <nl> public : <nl> class CC_DLL GLProgramState : public Ref <nl> / * * gets - or - creates an instance of GLProgramState for a given GLProgramName * / <nl> static GLProgramState * getOrCreateWithGLProgramName ( const std : : string & glProgramName ) ; <nl> <nl> + / * * gets - or - creates an instance of GLProgramState for given shaders * / <nl> + static GLProgramState * getOrCreateWithShaders ( const std : : string & vertexShader , const std : : string & fragShader , const std : : string & compileTimeDefines ) ; <nl> + <nl> + / * * Returns a new copy of the GLProgramState . The GLProgram is reused * / <nl> + GLProgramState * clone ( ) const ; <nl> + <nl> / * * <nl> Apply GLProgram , attributes and uniforms . <nl> @ param modelView The applied modelView matrix to shader . <nl> class CC_DLL GLProgramState : public Ref <nl> / * * @ } * / <nl> <nl> / * * Get the flag of vertex attribs used by OR operation . * / <nl> - uint32_t getVertexAttribsFlags ( ) const { return _vertexAttribsFlags ; } <nl> + uint32_t getVertexAttribsFlags ( ) const ; <nl> / * * Get the number of vertex attributes . * / <nl> - ssize_t getVertexAttribCount ( ) const { return _attributes . size ( ) ; } <nl> + ssize_t getVertexAttribCount ( ) const ; <nl> / * * @ { <nl> Set the vertex attribute value . <nl> * / <nl> class CC_DLL GLProgramState : public Ref <nl> * / <nl> void setUniformInt ( const std : : string & uniformName , int value ) ; <nl> void setUniformFloat ( const std : : string & uniformName , float value ) ; <nl> + void setUniformFloatv ( const std : : string & uniformName , const float * pointer , ssize_t size ) ; <nl> void setUniformVec2 ( const std : : string & uniformName , const Vec2 & value ) ; <nl> + void setUniformVec2v ( const std : : string & uniformName , const Vec2 * pointer , ssize_t size ) ; <nl> void setUniformVec3 ( const std : : string & uniformName , const Vec3 & value ) ; <nl> + void setUniformVec3v ( const std : : string & uniformName , const Vec3 * pointer , ssize_t size ) ; <nl> void setUniformVec4 ( const std : : string & uniformName , const Vec4 & value ) ; <nl> + void setUniformVec4v ( const std : : string & uniformName , const Vec4 * pointer , ssize_t size ) ; <nl> void setUniformMat4 ( const std : : string & uniformName , const Mat4 & value ) ; <nl> void setUniformCallback ( const std : : string & uniformName , const std : : function < void ( GLProgram * , Uniform * ) > & callback ) ; <nl> void setUniformTexture ( const std : : string & uniformName , Texture2D * texture ) ; <nl> class CC_DLL GLProgramState : public Ref <nl> * / <nl> void setUniformInt ( GLint uniformLocation , int value ) ; <nl> void setUniformFloat ( GLint uniformLocation , float value ) ; <nl> + void setUniformFloatv ( GLint uniformLocation , const float * pointer , ssize_t size ) ; <nl> void setUniformVec2 ( GLint uniformLocation , const Vec2 & value ) ; <nl> + void setUniformVec2v ( GLint uniformLocation , const Vec2 * pointer , ssize_t size ) ; <nl> void setUniformVec3 ( GLint uniformLocation , const Vec3 & value ) ; <nl> + void setUniformVec3v ( GLint uniformLocation , const Vec3 * pointer , ssize_t size ) ; <nl> void setUniformVec4 ( GLint uniformLocation , const Vec4 & value ) ; <nl> + void setUniformVec4v ( GLint uniformLocation , const Vec4 * pointer , ssize_t size ) ; <nl> void setUniformMat4 ( GLint uniformLocation , const Mat4 & value ) ; <nl> void setUniformCallback ( GLint uniformLocation , const std : : function < void ( GLProgram * , Uniform * ) > & callback ) ; <nl> void setUniformTexture ( GLint uniformLocation , Texture2D * texture ) ; <nl> new file mode 100644 <nl> index 000000000000 . . 0474e74f2bb5 <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCMaterial . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCPass . h " <nl> + # include " renderer / CCTextureCache . h " <nl> + # include " renderer / CCTexture2D . h " <nl> + # include " renderer / CCGLProgram . h " <nl> + # include " renderer / CCGLProgramState . h " <nl> + <nl> + # include " base / CCDirector . h " <nl> + # include " platform / CCFileUtils . h " <nl> + <nl> + # include " json / document . h " <nl> + <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT ) <nl> + # define strcasecmp _stricmp <nl> + # endif <nl> + <nl> + static const float MATERIAL_FORMAT_VERSION = 1 . 0 ; <nl> + static const char * MATERIAL_TYPE = " material " ; <nl> + <nl> + / / Helpers declaration <nl> + static const char * getOptionalString ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & json , const char * key , const char * defaultValue ) ; <nl> + static bool isValidUniform ( const char * name ) ; <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + Material * Material : : createWithFilename ( const std : : string & filepath ) <nl> + { <nl> + auto validfilename = FileUtils : : getInstance ( ) - > fullPathForFilename ( filepath ) ; <nl> + if ( validfilename . size ( ) > 0 ) { <nl> + auto mat = new ( std : : nothrow ) Material ( ) ; <nl> + if ( mat & & mat - > initWithFile ( validfilename ) ) <nl> + { <nl> + mat - > autorelease ( ) ; <nl> + return mat ; <nl> + } <nl> + } <nl> + <nl> + return nullptr ; <nl> + } <nl> + <nl> + Material * Material : : createWithGLStateProgram ( GLProgramState * programState ) <nl> + { <nl> + CCASSERT ( programState , " Invalid GL Program State " ) ; <nl> + <nl> + auto mat = new ( std : : nothrow ) Material ( ) ; <nl> + if ( mat & & mat - > initWithGLProgramState ( programState ) ) <nl> + { <nl> + mat - > autorelease ( ) ; <nl> + return mat ; <nl> + <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + bool Material : : initWithGLProgramState ( cocos2d : : GLProgramState * state ) <nl> + { <nl> + auto technique = Technique : : createWithGLProgramState ( this , state ) ; <nl> + if ( technique ) { <nl> + _techniques . pushBack ( technique ) ; <nl> + <nl> + / / weak pointer <nl> + _currentTechnique = technique ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + bool Material : : initWithFile ( const std : : string & validfilename ) <nl> + { <nl> + Data data = FileUtils : : getInstance ( ) - > getDataFromFile ( validfilename ) ; <nl> + char * bytes = ( char * ) data . getBytes ( ) ; <nl> + bytes [ data . getSize ( ) - 1 ] = ' \ 0 ' ; <nl> + <nl> + rapidjson : : Document document ; <nl> + document . ParseInsitu < 0 > ( bytes ) ; <nl> + <nl> + if ( document . HasParseError ( ) ) <nl> + { <nl> + CCLOG ( " GetParseError % s \ n " , document . GetParseError ( ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + CCASSERT ( document . IsObject ( ) , " Invalid JSON file " ) ; <nl> + <nl> + if ( ! parseMetadata ( document ) ) { <nl> + CCLOG ( " Error parsing Material metadata " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + parseProperties ( document ) ; <nl> + return true ; <nl> + } <nl> + <nl> + void Material : : setTarget ( cocos2d : : Node * target ) <nl> + { <nl> + _target = target ; <nl> + } <nl> + <nl> + bool Material : : parseMetadata ( const rapidjson : : Document & jsonDocument ) <nl> + { <nl> + bool broken = false ; <nl> + <nl> + const auto & metadata = jsonDocument [ " metadata " ] ; <nl> + if ( metadata . IsObject ( ) ) <nl> + { <nl> + auto version = metadata [ " version " ] . GetDouble ( ) ; <nl> + broken | = std : : floor ( version ) ! = std : : floor ( MATERIAL_FORMAT_VERSION ) ; <nl> + <nl> + auto type = metadata [ " type " ] . GetString ( ) ; <nl> + broken | = strcmp ( type , MATERIAL_TYPE ) ! = 0 ; <nl> + } <nl> + <nl> + return ! broken ; <nl> + } <nl> + <nl> + bool Material : : parseProperties ( const rapidjson : : Document & jsonDocument ) <nl> + { <nl> + auto name = jsonDocument [ " name " ] . GetString ( ) ; <nl> + setName ( name ) ; <nl> + <nl> + auto & techniquesJSON = jsonDocument [ " techniques " ] ; <nl> + CCASSERT ( techniquesJSON . IsArray ( ) , " Invalid Techniques " ) ; <nl> + <nl> + for ( rapidjson : : SizeType i = 0 ; i < techniquesJSON . Size ( ) ; i + + ) { <nl> + auto & techniqueJSON = techniquesJSON [ i ] ; <nl> + parseTechnique ( techniqueJSON ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Material : : parseTechnique ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & techniqueJSON ) <nl> + { <nl> + CCASSERT ( techniqueJSON . IsObject ( ) , " Invalid type for Technique . It must be an object " ) ; <nl> + <nl> + auto technique = Technique : : create ( this ) ; <nl> + _techniques . pushBack ( technique ) ; <nl> + <nl> + / / first one is the default one <nl> + if ( ! _currentTechnique ) <nl> + _currentTechnique = technique ; <nl> + <nl> + / / name <nl> + if ( techniqueJSON . HasMember ( " name " ) ) <nl> + technique - > setName ( techniqueJSON [ " name " ] . GetString ( ) ) ; <nl> + <nl> + / / passes <nl> + auto & passesJSON = techniqueJSON [ " passes " ] ; <nl> + CCASSERT ( passesJSON . IsArray ( ) , " Invalid type for ' passes ' " ) ; <nl> + <nl> + for ( rapidjson : : SizeType i = 0 ; i < passesJSON . Size ( ) ; i + + ) { <nl> + auto & passJSON = passesJSON [ i ] ; <nl> + parsePass ( technique , passJSON ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Material : : parsePass ( Technique * technique , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & passJSON ) <nl> + { <nl> + auto pass = Pass : : create ( technique ) ; <nl> + technique - > addPass ( pass ) ; <nl> + <nl> + / / Textures <nl> + if ( passJSON . HasMember ( " textures " ) ) { <nl> + auto & texturesJSON = passJSON [ " textures " ] ; <nl> + CCASSERT ( texturesJSON . IsArray ( ) , " Invalid type for ' textures ' " ) ; <nl> + <nl> + for ( rapidjson : : SizeType i = 0 ; i < texturesJSON . Size ( ) ; i + + ) { <nl> + auto & textureJSON = texturesJSON [ i ] ; <nl> + parseTexture ( pass , textureJSON ) ; <nl> + } <nl> + } <nl> + <nl> + / / Render State <nl> + if ( passJSON . HasMember ( " renderState " ) ) { <nl> + parseRenderState ( pass , passJSON [ " renderState " ] ) ; <nl> + } <nl> + <nl> + / / Shaders <nl> + if ( passJSON . HasMember ( " shader " ) ) { <nl> + parseShader ( pass , passJSON [ " shader " ] ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Material : : parseTexture ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & textureJSON ) <nl> + { <nl> + CCASSERT ( textureJSON . IsObject ( ) , " Invalid type for Texture . It must be an object " ) ; <nl> + <nl> + / / required <nl> + auto filename = textureJSON [ " path " ] . GetString ( ) ; <nl> + <nl> + auto texture = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( filename ) ; <nl> + if ( ! texture ) { <nl> + CCLOG ( " Invalid filepath " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / / optionals <nl> + <nl> + { <nl> + Texture2D : : TexParams texParams ; <nl> + <nl> + / / mipmap <nl> + bool usemipmap = false ; <nl> + const char * mipmap = getOptionalString ( textureJSON , " mipmap " , " false " ) ; <nl> + if ( mipmap & & strcasecmp ( mipmap , " true " ) = = 0 ) { <nl> + texture - > generateMipmap ( ) ; <nl> + usemipmap = true ; <nl> + } <nl> + <nl> + / / valid options : REPEAT , CLAMP <nl> + const char * wrapS = getOptionalString ( textureJSON , " wrapS " , " CLAMP_TO_EDGE " ) ; <nl> + if ( strcasecmp ( wrapS , " REPEAT " ) = = 0 ) <nl> + texParams . wrapS = GL_REPEAT ; <nl> + else if ( strcasecmp ( wrapS , " CLAMP_TO_EDGE " ) = = 0 ) <nl> + texParams . wrapS = GL_CLAMP_TO_EDGE ; <nl> + else <nl> + CCLOG ( " Invalid wrapS : % s " , wrapS ) ; <nl> + <nl> + <nl> + / / valid options : REPEAT , CLAMP <nl> + const char * wrapT = getOptionalString ( textureJSON , " wrapT " , " CLAMP_TO_EDGE " ) ; <nl> + if ( strcasecmp ( wrapT , " REPEAT " ) = = 0 ) <nl> + texParams . wrapT = GL_REPEAT ; <nl> + else if ( strcasecmp ( wrapT , " CLAMP_TO_EDGE " ) = = 0 ) <nl> + texParams . wrapT = GL_CLAMP_TO_EDGE ; <nl> + else <nl> + CCLOG ( " Invalid wrapT : % s " , wrapT ) ; <nl> + <nl> + <nl> + / / valid options : NEAREST , LINEAR , NEAREST_MIPMAP_NEAREST , LINEAR_MIPMAP_NEAREST , NEAREST_MIPMAP_LINEAR , LINEAR_MIPMAP_LINEAR <nl> + const char * minFilter = getOptionalString ( textureJSON , " minFilter " , mipmap ? " LINEAR_MIPMAP_NEAREST " : " LINEAR " ) ; <nl> + if ( strcasecmp ( minFilter , " NEAREST " ) = = 0 ) <nl> + texParams . minFilter = GL_NEAREST ; <nl> + else if ( strcasecmp ( minFilter , " LINEAR " ) = = 0 ) <nl> + texParams . minFilter = GL_LINEAR ; <nl> + else if ( strcasecmp ( minFilter , " NEAREST_MIPMAP_NEAREST " ) = = 0 ) <nl> + texParams . minFilter = GL_NEAREST_MIPMAP_NEAREST ; <nl> + else if ( strcasecmp ( minFilter , " LINEAR_MIPMAP_NEAREST " ) = = 0 ) <nl> + texParams . minFilter = GL_LINEAR_MIPMAP_NEAREST ; <nl> + else if ( strcasecmp ( minFilter , " NEAREST_MIPMAP_LINEAR " ) = = 0 ) <nl> + texParams . minFilter = GL_NEAREST_MIPMAP_LINEAR ; <nl> + else if ( strcasecmp ( minFilter , " LINEAR_MIPMAP_LINEAR " ) = = 0 ) <nl> + texParams . minFilter = GL_LINEAR_MIPMAP_LINEAR ; <nl> + else <nl> + CCLOG ( " Invalid minFilter : % s " , minFilter ) ; <nl> + <nl> + / / valid options : NEAREST , LINEAR <nl> + const char * magFilter = getOptionalString ( textureJSON , " magFilter " , " LINEAR " ) ; <nl> + if ( strcasecmp ( magFilter , " NEAREST " ) = = 0 ) <nl> + texParams . magFilter = GL_NEAREST ; <nl> + else if ( strcasecmp ( magFilter , " LINEAR " ) = = 0 ) <nl> + texParams . magFilter = GL_LINEAR ; <nl> + else <nl> + CCLOG ( " Invalid magFilter : % s " , magFilter ) ; <nl> + <nl> + texture - > setTexParameters ( texParams ) ; <nl> + } <nl> + <nl> + pass - > _textures . pushBack ( texture ) ; <nl> + return true ; <nl> + } <nl> + <nl> + bool Material : : parseShader ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & shaderJSON ) <nl> + { <nl> + <nl> + CCASSERT ( shaderJSON . IsObject ( ) , " Invalid type for ' shader ' . It must be an object " ) ; <nl> + <nl> + / / vertexShader <nl> + const char * vertShader = getOptionalString ( shaderJSON , " vertexShader " , nullptr ) ; <nl> + <nl> + / / fragmentShader <nl> + const char * fragShader = getOptionalString ( shaderJSON , " fragmentShader " , nullptr ) ; <nl> + <nl> + / / compileTimeDefines <nl> + const char * compileTimeDefines = getOptionalString ( shaderJSON , " defines " , " " ) ; <nl> + <nl> + if ( vertShader & & fragShader ) <nl> + { <nl> + auto glProgramState = GLProgramState : : getOrCreateWithShaders ( vertShader , fragShader , compileTimeDefines ) ; <nl> + pass - > setGLProgramState ( glProgramState ) ; <nl> + <nl> + / / Parse uniforms only if the GLProgramState was created <nl> + for ( auto it = shaderJSON . MemberonBegin ( ) ; it ! = shaderJSON . MemberonEnd ( ) ; it + + ) <nl> + { <nl> + / / skip " defines " , " vertexShader " , " fragmentShader " <nl> + if ( isValidUniform ( it - > name . GetString ( ) ) ) <nl> + parseUniform ( glProgramState , it ) ; <nl> + } <nl> + <nl> + / / glProgramState - > updateUniformsAndAttributes ( ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Material : : parseUniform ( GLProgramState * programState , const rapidjson : : Value : : ConstMemberIterator & iterator ) <nl> + { <nl> + const char * key = iterator - > name . GetString ( ) ; <nl> + auto & value = iterator - > value ; <nl> + <nl> + if ( value . IsNumber ( ) ) { <nl> + float v = value . GetDouble ( ) ; <nl> + programState - > setUniformFloat ( key , v ) ; <nl> + } <nl> + else if ( value . IsArray ( ) ) { <nl> + <nl> + int size = value . Size ( ) ; <nl> + switch ( size ) { <nl> + case 1 : <nl> + { <nl> + rapidjson : : SizeType idx = 0 ; <nl> + float v = value [ idx ] . GetDouble ( ) ; <nl> + programState - > setUniformFloat ( key , v ) ; <nl> + break ; <nl> + } <nl> + case 2 : <nl> + { <nl> + Vec2 vect = parseUniformVec2 ( value ) ; <nl> + programState - > setUniformVec2 ( key , vect ) ; <nl> + break ; <nl> + } <nl> + case 3 : <nl> + { <nl> + Vec3 vect = parseUniformVec3 ( value ) ; <nl> + programState - > setUniformVec3 ( key , vect ) ; <nl> + break ; <nl> + } <nl> + case 4 : <nl> + { <nl> + Vec4 vect = parseUniformVec4 ( value ) ; <nl> + programState - > setUniformVec4 ( key , vect ) ; <nl> + break ; <nl> + } <nl> + case 16 : <nl> + { <nl> + Mat4 mat = parseUniformMat4 ( value ) ; <nl> + programState - > setUniformMat4 ( key , mat ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + Vec2 Material : : parseUniformVec2 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & value ) <nl> + { <nl> + Vec2 ret ; <nl> + rapidjson : : SizeType idx = 0 ; <nl> + ret . x = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . y = value [ idx + + ] . GetDouble ( ) ; <nl> + return ret ; <nl> + } <nl> + <nl> + Vec3 Material : : parseUniformVec3 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & value ) <nl> + { <nl> + Vec3 ret ; <nl> + rapidjson : : SizeType idx = 0 ; <nl> + ret . x = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . y = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . z = value [ idx + + ] . GetDouble ( ) ; <nl> + return ret ; <nl> + } <nl> + <nl> + Vec4 Material : : parseUniformVec4 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & value ) <nl> + { <nl> + Vec4 ret ; <nl> + rapidjson : : SizeType idx = 0 ; <nl> + ret . x = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . y = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . z = value [ idx + + ] . GetDouble ( ) ; <nl> + ret . w = value [ idx + + ] . GetDouble ( ) ; <nl> + return ret ; <nl> + } <nl> + <nl> + Mat4 Material : : parseUniformMat4 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & value ) <nl> + { <nl> + Mat4 ret ; <nl> + <nl> + for ( rapidjson : : SizeType i = 0 ; i < 16 ; i + + ) <nl> + ret . m [ i ] = value [ i ] . GetDouble ( ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + <nl> + bool Material : : parseRenderState ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & renderState ) <nl> + { <nl> + auto state = pass - > getStateBlock ( ) ; <nl> + <nl> + / / Parse uniforms only if the GLProgramState was created <nl> + for ( auto it = renderState . MemberonBegin ( ) ; it ! = renderState . MemberonEnd ( ) ; it + + ) <nl> + { <nl> + / / Render state only can have " strings " or numbers as values . No objects or lists <nl> + state - > setState ( it - > name . GetString ( ) , it - > value . GetString ( ) ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void Material : : setName ( const std : : string & name ) <nl> + { <nl> + _name = name ; <nl> + } <nl> + <nl> + std : : string Material : : getName ( ) const <nl> + { <nl> + return _name ; <nl> + } <nl> + <nl> + Material : : Material ( ) <nl> + : _name ( " " ) <nl> + , _target ( nullptr ) <nl> + , _currentTechnique ( nullptr ) <nl> + { <nl> + } <nl> + <nl> + Material : : ~ Material ( ) <nl> + { <nl> + } <nl> + <nl> + Technique * Material : : getTechnique ( ) const <nl> + { <nl> + return _currentTechnique ; <nl> + } <nl> + Technique * Material : : getTechniqueByName ( const std : : string & name ) <nl> + { <nl> + for ( const auto & technique : _techniques ) { <nl> + CCLOG ( " technique name : % s " , technique - > getName ( ) . c_str ( ) ) ; <nl> + if ( technique - > getName ( ) . compare ( name ) = = 0 ) <nl> + return technique ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + Technique * Material : : getTechniqueByIndex ( ssize_t index ) <nl> + { <nl> + CC_ASSERT ( index > = 0 & & index < _techniques . size ( ) & & " Invalid size " ) ; <nl> + <nl> + return _techniques . at ( index ) ; <nl> + } <nl> + <nl> + void Material : : addTechnique ( Technique * technique ) <nl> + { <nl> + _techniques . pushBack ( technique ) ; <nl> + } <nl> + <nl> + void Material : : setTechnique ( const std : : string & techniqueName ) <nl> + { <nl> + auto technique = getTechniqueByName ( techniqueName ) ; <nl> + if ( technique ) <nl> + _currentTechnique = technique ; <nl> + } <nl> + <nl> + ssize_t Material : : getTechniqueCount ( ) const <nl> + { <nl> + return _techniques . size ( ) ; <nl> + } <nl> + <nl> + NS_CC_END <nl> + <nl> + / / Helpers implementation <nl> + static bool isValidUniform ( const char * name ) <nl> + { <nl> + return ! ( strcmp ( name , " defines " ) = = 0 | | <nl> + strcmp ( name , " vertexShader " ) = = 0 | | <nl> + strcmp ( name , " fragmentShader " ) = = 0 ) ; <nl> + } <nl> + <nl> + static const char * getOptionalString ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & json , const char * key , const char * defaultValue ) <nl> + { <nl> + if ( json . HasMember ( key ) ) { <nl> + return json [ key ] . GetString ( ) ; <nl> + } <nl> + return defaultValue ; <nl> + } <nl> + <nl> new file mode 100644 <nl> index 000000000000 . . c02987890846 <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCMaterial . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __cocos2d_libs__CCMaterial__ <nl> + # define __cocos2d_libs__CCMaterial__ <nl> + <nl> + # include < string > <nl> + # include " json / document . h " <nl> + <nl> + # include " renderer / CCRenderState . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " base / CCRef . h " <nl> + # include " base / CCVector . h " <nl> + # include " math / Vec2 . h " <nl> + # include " math / Vec3 . h " <nl> + # include " math / Vec4 . h " <nl> + # include " math / Mat4 . h " <nl> + # include " platform / CCPlatformMacros . h " <nl> + <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + class Technique ; <nl> + class Pass ; <nl> + class GLProgramState ; <nl> + class Node ; <nl> + <nl> + / / / Material <nl> + class CC_DLL Material : public RenderState <nl> + { <nl> + friend class Node ; <nl> + friend class Technique ; <nl> + friend class Pass ; <nl> + friend class MeshCommand ; <nl> + friend class Renderer ; <nl> + friend class Mesh ; <nl> + <nl> + public : <nl> + / * * Creates a Material with a JSON file containing the definition of the material . <nl> + * / <nl> + static Material * createWithFilename ( const std : : string & path ) ; <nl> + <nl> + / * * Creates a Material with a GLProgramState . <nl> + It will only contain one Technique and one Pass . <nl> + Added in order to support legacy code . <nl> + * / <nl> + static Material * createWithGLStateProgram ( GLProgramState * programState ) ; <nl> + <nl> + / / / returns the material name <nl> + std : : string getName ( ) const ; <nl> + / / / sets the material name <nl> + void setName ( const std : : string & name ) ; <nl> + <nl> + / * * Returns a Technique by its name . <nl> + returns ` nullptr ` if the Technique can ' t be found . <nl> + * / <nl> + Technique * getTechniqueByName ( const std : : string & name ) ; <nl> + <nl> + / * * Returns a Technique by index . <nl> + returns ` nullptr ` if the index is invalid . <nl> + * / <nl> + Technique * getTechniqueByIndex ( ssize_t index ) ; <nl> + <nl> + / * * Adds a Technique into the Material * / <nl> + void addTechnique ( Technique * technique ) ; <nl> + <nl> + / * * Sets the current technique * / <nl> + void setTechnique ( const std : : string & techniqueName ) ; <nl> + <nl> + / * * Returns the number of Techniques in the Material . * / <nl> + ssize_t getTechniqueCount ( ) const ; <nl> + <nl> + / * * Returns the Technique used by the Material * / <nl> + Technique * getTechnique ( ) const ; <nl> + <nl> + protected : <nl> + Material ( ) ; <nl> + ~ Material ( ) ; <nl> + bool initWithGLProgramState ( GLProgramState * state ) ; <nl> + bool initWithFile ( const std : : string & file ) ; <nl> + <nl> + void setTarget ( Node * target ) ; <nl> + <nl> + bool parseMetadata ( const rapidjson : : Document & json ) ; <nl> + bool parseProperties ( const rapidjson : : Document & json ) ; <nl> + bool parseTechnique ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & techniqueJSON ) ; <nl> + bool parsePass ( Technique * technique , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & passJSON ) ; <nl> + bool parseTexture ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & textureJSON ) ; <nl> + bool parseShader ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & shaderJSON ) ; <nl> + bool parseUniform ( GLProgramState * programState , const rapidjson : : Value : : ConstMemberIterator & iterator ) ; <nl> + Vec2 parseUniformVec2 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & uniformJSON ) ; <nl> + Vec3 parseUniformVec3 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & uniformJSON ) ; <nl> + Vec4 parseUniformVec4 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & uniformJSON ) ; <nl> + Mat4 parseUniformMat4 ( const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & uniformJSON ) ; <nl> + bool parseRenderState ( Pass * pass , const rapidjson : : GenericValue < rapidjson : : UTF8 < > > & renderState ) ; <nl> + <nl> + <nl> + / / material name <nl> + std : : string _name ; <nl> + <nl> + / / array of techniques <nl> + Vector < Technique * > _techniques ; <nl> + <nl> + / / weak pointer since it is being help by _techniques <nl> + Technique * _currentTechnique ; <nl> + <nl> + / / weak reference <nl> + Node * _target ; <nl> + } ; <nl> + <nl> + NS_CC_END <nl> + <nl> + <nl> + # endif / * defined ( __cocos2d_libs__CCMaterial__ ) * / <nl> mmm a / cocos / renderer / CCMeshCommand . cpp <nl> ppp b / cocos / renderer / CCMeshCommand . cpp <nl> <nl> # include " renderer / CCTextureAtlas . h " <nl> # include " renderer / CCTexture2D . h " <nl> # include " renderer / ccGLStateCache . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCPass . h " <nl> # include " xxhash . h " <nl> <nl> NS_CC_BEGIN <nl> <nl> - static const char * s_dirLightUniformColorName = " u_DirLightSourceColor " ; <nl> - static std : : vector < Vec3 > s_dirLightUniformColorValues ; <nl> - static const char * s_dirLightUniformDirName = " u_DirLightSourceDirection " ; <nl> - static std : : vector < Vec3 > s_dirLightUniformDirValues ; <nl> - <nl> - static const char * s_pointLightUniformColorName = " u_PointLightSourceColor " ; <nl> - static std : : vector < Vec3 > s_pointLightUniformColorValues ; <nl> - static const char * s_pointLightUniformPositionName = " u_PointLightSourcePosition " ; <nl> - static std : : vector < Vec3 > s_pointLightUniformPositionValues ; <nl> - static const char * s_pointLightUniformRangeInverseName = " u_PointLightSourceRangeInverse " ; <nl> - static std : : vector < float > s_pointLightUniformRangeInverseValues ; <nl> - <nl> - static const char * s_spotLightUniformColorName = " u_SpotLightSourceColor " ; <nl> - static std : : vector < Vec3 > s_spotLightUniformColorValues ; <nl> - static const char * s_spotLightUniformPositionName = " u_SpotLightSourcePosition " ; <nl> - static std : : vector < Vec3 > s_spotLightUniformPositionValues ; <nl> - static const char * s_spotLightUniformDirName = " u_SpotLightSourceDirection " ; <nl> - static std : : vector < Vec3 > s_spotLightUniformDirValues ; <nl> - static const char * s_spotLightUniformInnerAngleCosName = " u_SpotLightSourceInnerAngleCos " ; <nl> - static std : : vector < float > s_spotLightUniformInnerAngleCosValues ; <nl> - static const char * s_spotLightUniformOuterAngleCosName = " u_SpotLightSourceOuterAngleCos " ; <nl> - static std : : vector < float > s_spotLightUniformOuterAngleCosValues ; <nl> - static const char * s_spotLightUniformRangeInverseName = " u_SpotLightSourceRangeInverse " ; <nl> - static std : : vector < float > s_spotLightUniformRangeInverseValues ; <nl> - <nl> - static const char * s_ambientLightUniformColorName = " u_AmbientLightSourceColor " ; <nl> - <nl> <nl> MeshCommand : : MeshCommand ( ) <nl> : _textureID ( 0 ) <nl> MeshCommand : : MeshCommand ( ) <nl> , _renderStateCullFaceEnabled ( false ) <nl> , _renderStateDepthTest ( false ) <nl> , _renderStateDepthWrite ( GL_FALSE ) <nl> - , _lightMask ( - 1 ) <nl> + , _material ( nullptr ) <nl> { <nl> _type = RenderCommand : : Type : : MESH_COMMAND ; <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 | | CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT ) <nl> MeshCommand : : MeshCommand ( ) <nl> } <nl> <nl> void MeshCommand : : init ( float globalZOrder , <nl> - GLuint textureID , <nl> - cocos2d : : GLProgramState * glProgramState , <nl> - cocos2d : : BlendFunc blendType , <nl> + Material * material , <nl> GLuint vertexBuffer , <nl> GLuint indexBuffer , <nl> GLenum primitive , <nl> void MeshCommand : : init ( float globalZOrder , <nl> const cocos2d : : Mat4 & mv , <nl> uint32_t flags ) <nl> { <nl> - CCASSERT ( glProgramState , " GLProgramState cannot be nill " ) ; <nl> - <nl> + CCASSERT ( material , " material cannot be nill " ) ; <nl> + <nl> RenderCommand : : init ( globalZOrder , mv , flags ) ; <nl> - <nl> + <nl> _globalOrder = globalZOrder ; <nl> - _textureID = textureID ; <nl> - _blendType = blendType ; <nl> - _glProgramState = glProgramState ; <nl> + _material = material ; <nl> <nl> _vertexBuffer = vertexBuffer ; <nl> _indexBuffer = indexBuffer ; <nl> void MeshCommand : : init ( float globalZOrder , <nl> _indexFormat = indexFormat ; <nl> _indexCount = indexCount ; <nl> _mv . set ( mv ) ; <nl> - <nl> + <nl> _is3D = true ; <nl> } <nl> <nl> void MeshCommand : : init ( float globalOrder , <nl> init ( globalOrder , textureID , glProgramState , blendType , vertexBuffer , indexBuffer , primitive , indexFormat , indexCount , mv , 0 ) ; <nl> } <nl> <nl> + void MeshCommand : : init ( float globalZOrder , <nl> + GLuint textureID , <nl> + cocos2d : : GLProgramState * glProgramState , <nl> + cocos2d : : BlendFunc blendType , <nl> + GLuint vertexBuffer , <nl> + GLuint indexBuffer , <nl> + GLenum primitive , <nl> + GLenum indexFormat , <nl> + ssize_t indexCount , <nl> + const cocos2d : : Mat4 & mv , <nl> + uint32_t flags ) <nl> + { <nl> + CCASSERT ( glProgramState , " GLProgramState cannot be nill " ) ; <nl> + <nl> + RenderCommand : : init ( globalZOrder , mv , flags ) ; <nl> + <nl> + _globalOrder = globalZOrder ; <nl> + _textureID = textureID ; <nl> + _blendType = blendType ; <nl> + _glProgramState = glProgramState ; <nl> + <nl> + _vertexBuffer = vertexBuffer ; <nl> + _indexBuffer = indexBuffer ; <nl> + _primitive = primitive ; <nl> + _indexFormat = indexFormat ; <nl> + _indexCount = indexCount ; <nl> + _mv . set ( mv ) ; <nl> + <nl> + _is3D = true ; <nl> + } <nl> + <nl> void MeshCommand : : setCullFaceEnabled ( bool enable ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you should call material - > setCullFace ( ) " ) ; <nl> + <nl> _cullFaceEnabled = enable ; <nl> } <nl> <nl> void MeshCommand : : setCullFace ( GLenum cullFace ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you should call material - > setCullFaceSide ( ) " ) ; <nl> + <nl> _cullFace = cullFace ; <nl> } <nl> <nl> void MeshCommand : : setDepthTestEnabled ( bool enable ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you should call material - > setDepthTest ( ) " ) ; <nl> + <nl> _depthTestEnabled = enable ; <nl> } <nl> <nl> void MeshCommand : : setDepthWriteEnabled ( bool enable ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you should call material - > setDepthWrite ( ) " ) ; <nl> + <nl> _forceDepthWrite = enable ; <nl> _depthWriteEnabled = enable ; <nl> } <nl> <nl> void MeshCommand : : setDisplayColor ( const Vec4 & color ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you should set the color as a uniform : use u_color " ) ; <nl> + <nl> _displayColor = color ; <nl> } <nl> <nl> + void MeshCommand : : setMatrixPalette ( const Vec4 * matrixPalette ) <nl> + { <nl> + CCASSERT ( ! _material , " If using material , you should set the color as a uniform : use u_matrixPalette " ) ; <nl> + <nl> + _matrixPalette = matrixPalette ; <nl> + } <nl> + <nl> + void MeshCommand : : setMatrixPaletteSize ( int size ) <nl> + { <nl> + CCASSERT ( ! _material , " If using material , you should set the color as a uniform : use u_matrixPalette with its size " ) ; <nl> + <nl> + _matrixPaletteSize = size ; <nl> + } <nl> + <nl> void MeshCommand : : setTransparent ( bool value ) <nl> { <nl> + CCASSERT ( ! _material , " If using material , you shouldn ' t call setTransparent . " ) ; <nl> + <nl> _isTransparent = value ; <nl> / / Skip batching for transparent mesh <nl> _skipBatching = value ; <nl> MeshCommand : : ~ MeshCommand ( ) <nl> <nl> void MeshCommand : : applyRenderState ( ) <nl> { <nl> + CCASSERT ( ! _material , " Must not be called when using materials " ) ; <nl> + <nl> + / / blend and texture <nl> + GL : : bindTexture2D ( _textureID ) ; <nl> + GL : : blendFunc ( _blendType . src , _blendType . dst ) ; <nl> + <nl> + / / cull face <nl> _renderStateCullFaceEnabled = glIsEnabled ( GL_CULL_FACE ) ! = GL_FALSE ; <nl> - _renderStateDepthTest = glIsEnabled ( GL_DEPTH_TEST ) ! = GL_FALSE ; <nl> - glGetBooleanv ( GL_DEPTH_WRITEMASK , & _renderStateDepthWrite ) ; <nl> GLint cullface ; <nl> glGetIntegerv ( GL_CULL_FACE_MODE , & cullface ) ; <nl> _renderStateCullFace = ( GLenum ) cullface ; <nl> void MeshCommand : : applyRenderState ( ) <nl> { <nl> glCullFace ( _cullFace ) ; <nl> } <nl> - <nl> + <nl> + / / depth <nl> + _renderStateDepthTest = ( glIsEnabled ( GL_DEPTH_TEST ) ! = GL_FALSE ) ; <nl> + glGetBooleanv ( GL_DEPTH_WRITEMASK , & _renderStateDepthWrite ) ; <nl> + <nl> if ( _depthTestEnabled ! = _renderStateDepthTest ) <nl> { <nl> _depthTestEnabled ? glEnable ( GL_DEPTH_TEST ) : glDisable ( GL_DEPTH_TEST ) ; <nl> } <nl> - <nl> + <nl> if ( _depthWriteEnabled ! = _renderStateDepthWrite ) <nl> { <nl> glDepthMask ( _depthWriteEnabled ) ; <nl> void MeshCommand : : applyRenderState ( ) <nl> <nl> void MeshCommand : : restoreRenderState ( ) <nl> { <nl> + CCASSERT ( ! _material , " Must not be called when using Material " ) ; <nl> + <nl> + / / cull <nl> if ( _cullFaceEnabled ! = _renderStateCullFaceEnabled ) <nl> { <nl> _renderStateCullFaceEnabled ? glEnable ( GL_CULL_FACE ) : glDisable ( GL_CULL_FACE ) ; <nl> } <nl> - <nl> + <nl> if ( _cullFace ! = _renderStateCullFace ) <nl> { <nl> glCullFace ( _renderStateCullFace ) ; <nl> } <nl> - <nl> + <nl> + / / depth <nl> if ( _depthTestEnabled ! = _renderStateDepthTest ) <nl> { <nl> _renderStateDepthTest ? glEnable ( GL_DEPTH_TEST ) : glDisable ( GL_DEPTH_TEST ) ; <nl> } <nl> - <nl> + <nl> if ( _depthWriteEnabled ! = _renderStateDepthWrite ) <nl> { <nl> glDepthMask ( _renderStateDepthWrite ) ; <nl> } <nl> } <nl> <nl> - void MeshCommand : : genMaterialID ( GLuint texID , void * glProgramState , GLuint vertexBuffer , GLuint indexBuffer , const BlendFunc & blend ) <nl> + void MeshCommand : : genMaterialID ( GLuint texID , void * glProgramState , GLuint vertexBuffer , GLuint indexBuffer , BlendFunc blend ) <nl> { <nl> int intArray [ 7 ] = { 0 } ; <nl> intArray [ 0 ] = ( int ) texID ; <nl> void MeshCommand : : genMaterialID ( GLuint texID , void * glProgramState , GLuint verte <nl> _materialID = XXH32 ( ( const void * ) intArray , sizeof ( intArray ) , 0 ) ; <nl> } <nl> <nl> - void MeshCommand : : MatrixPalleteCallBack ( GLProgram * glProgram , Uniform * uniform ) <nl> + uint32_t MeshCommand : : getMaterialID ( ) const <nl> { <nl> - glUniform4fv ( uniform - > location , ( GLsizei ) _matrixPaletteSize , ( const float * ) _matrixPalette ) ; <nl> + return _materialID ; <nl> } <nl> <nl> void MeshCommand : : preBatchDraw ( ) <nl> { <nl> - / / Set material <nl> - GL : : bindTexture2D ( _textureID ) ; <nl> - GL : : blendFunc ( _blendType . src , _blendType . dst ) ; <nl> - <nl> if ( Configuration : : getInstance ( ) - > supportsShareableVAO ( ) & & _vao = = 0 ) <nl> buildVAO ( ) ; <nl> if ( _vao ) <nl> void MeshCommand : : preBatchDraw ( ) <nl> else <nl> { <nl> glBindBuffer ( GL_ARRAY_BUFFER , _vertexBuffer ) ; <nl> - _glProgramState - > applyAttributes ( ) ; <nl> + <nl> + / / FIXME : Assumes that all the passes in the Material share the same Vertex Attribs <nl> + GLProgramState * programState = _material <nl> + ? _material - > _currentTechnique - > _passes . at ( 0 ) - > getGLProgramState ( ) <nl> + : _glProgramState ; <nl> + programState - > applyAttributes ( ) ; <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _indexBuffer ) ; <nl> } <nl> } <nl> + <nl> void MeshCommand : : batchDraw ( ) <nl> { <nl> - / / set render state <nl> - applyRenderState ( ) ; <nl> - <nl> - _glProgramState - > setUniformVec4 ( " u_color " , _displayColor ) ; <nl> - <nl> - if ( _matrixPaletteSize & & _matrixPalette ) <nl> + if ( _material ) <nl> { <nl> - _glProgramState - > setUniformCallback ( " u_matrixPalette " , CC_CALLBACK_2 ( MeshCommand : : MatrixPalleteCallBack , this ) ) ; <nl> - <nl> + for ( const auto & pass : _material - > _currentTechnique - > _passes ) <nl> + { <nl> + / / don ' t bind attributes , since they were <nl> + / / already bound in preBatchDraw <nl> + pass - > bind ( _mv , false ) ; <nl> + <nl> + glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> + <nl> + pass - > unbind ( ) ; <nl> + } <nl> } <nl> - <nl> - _glProgramState - > applyGLProgram ( _mv ) ; <nl> - _glProgramState - > applyUniforms ( ) ; <nl> + else <nl> + { <nl> + _glProgramState - > applyGLProgram ( _mv ) ; <nl> <nl> - const auto & scene = Director : : getInstance ( ) - > getRunningScene ( ) ; <nl> - if ( scene & & scene - > getLights ( ) . size ( ) > 0 ) <nl> - setLightUniforms ( ) ; <nl> - <nl> - / / Draw <nl> - glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> - <nl> - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> + / / set render state <nl> + applyRenderState ( ) ; <nl> + <nl> + / / Draw <nl> + glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> + <nl> + / / restore render state <nl> + restoreRenderState ( ) ; <nl> + } <nl> } <nl> void MeshCommand : : postBatchDraw ( ) <nl> { <nl> - / / restore render state <nl> - restoreRenderState ( ) ; <nl> if ( _vao ) <nl> { <nl> GL : : bindVAO ( 0 ) ; <nl> void MeshCommand : : postBatchDraw ( ) <nl> <nl> void MeshCommand : : execute ( ) <nl> { <nl> - / / set render state <nl> - applyRenderState ( ) ; <nl> - / / Set material <nl> - GL : : bindTexture2D ( _textureID ) ; <nl> - GL : : blendFunc ( _blendType . src , _blendType . dst ) ; <nl> - <nl> + / / Draw without VAO <nl> glBindBuffer ( GL_ARRAY_BUFFER , _vertexBuffer ) ; <nl> - _glProgramState - > setUniformVec4 ( " u_color " , _displayColor ) ; <nl> - <nl> - if ( _matrixPaletteSize & & _matrixPalette ) <nl> + glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _indexBuffer ) ; <nl> + <nl> + if ( _material ) <nl> { <nl> - _glProgramState - > setUniformCallback ( " u_matrixPalette " , CC_CALLBACK_2 ( MeshCommand : : MatrixPalleteCallBack , this ) ) ; <nl> + for ( const auto & pass : _material - > _currentTechnique - > _passes ) <nl> + { <nl> + / / don ' t bind attributes , since they were <nl> + / / already bound in preBatchDraw <nl> + pass - > bind ( _mv , true ) ; <nl> + <nl> + glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> + <nl> + pass - > unbind ( ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + / / set render state <nl> + _glProgramState - > apply ( _mv ) ; <nl> + <nl> + applyRenderState ( ) ; <nl> + <nl> + / / Draw <nl> + glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> <nl> + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> + <nl> + / / restore render state <nl> + restoreRenderState ( ) ; <nl> } <nl> - <nl> - _glProgramState - > apply ( _mv ) ; <nl> <nl> - const auto & scene = Director : : getInstance ( ) - > getRunningScene ( ) ; <nl> - if ( scene & & scene - > getLights ( ) . size ( ) > 0 ) <nl> - setLightUniforms ( ) ; <nl> - <nl> - glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _indexBuffer ) ; <nl> - <nl> - / / Draw <nl> - glDrawElements ( _primitive , ( GLsizei ) _indexCount , _indexFormat , 0 ) ; <nl> - <nl> - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES ( 1 , _indexCount ) ; <nl> - <nl> - / / restore render state <nl> - restoreRenderState ( ) ; <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) ; <nl> glBindBuffer ( GL_ARRAY_BUFFER , 0 ) ; <nl> } <nl> <nl> void MeshCommand : : buildVAO ( ) <nl> { <nl> + / / FIXME : Assumes that all the passes in the Material share the same Vertex Attribs <nl> + GLProgramState * programState = ( _material ! = nullptr ) <nl> + ? _material - > _currentTechnique - > _passes . at ( 0 ) - > getGLProgramState ( ) <nl> + : _glProgramState ; <nl> + <nl> releaseVAO ( ) ; <nl> glGenVertexArrays ( 1 , & _vao ) ; <nl> GL : : bindVAO ( _vao ) ; <nl> glBindBuffer ( GL_ARRAY_BUFFER , _vertexBuffer ) ; <nl> - auto flags = _glProgramState - > getVertexAttribsFlags ( ) ; <nl> + auto flags = programState - > getVertexAttribsFlags ( ) ; <nl> for ( int i = 0 ; flags > 0 ; i + + ) { <nl> int flag = 1 < < i ; <nl> if ( flag & flags ) <nl> glEnableVertexAttribArray ( i ) ; <nl> flags & = ~ flag ; <nl> } <nl> - _glProgramState - > applyAttributes ( false ) ; <nl> + programState - > applyAttributes ( false ) ; <nl> <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _indexBuffer ) ; <nl> <nl> void MeshCommand : : releaseVAO ( ) <nl> } <nl> } <nl> <nl> - <nl> - void MeshCommand : : setLightUniforms ( ) <nl> - { <nl> - Director * director = Director : : getInstance ( ) ; <nl> - auto scene = director - > getRunningScene ( ) ; <nl> - const auto & conf = Configuration : : getInstance ( ) ; <nl> - int maxDirLight = conf - > getMaxSupportDirLightInShader ( ) ; <nl> - int maxPointLight = conf - > getMaxSupportPointLightInShader ( ) ; <nl> - int maxSpotLight = conf - > getMaxSupportSpotLightInShader ( ) ; <nl> - auto & lights = scene - > getLights ( ) ; <nl> - auto glProgram = _glProgramState - > getGLProgram ( ) ; <nl> - if ( _glProgramState - > getVertexAttribsFlags ( ) & ( 1 < < GLProgram : : VERTEX_ATTRIB_NORMAL ) ) <nl> - { <nl> - resetLightUniformValues ( ) ; <nl> - <nl> - GLint enabledDirLightNum = 0 ; <nl> - GLint enabledPointLightNum = 0 ; <nl> - GLint enabledSpotLightNum = 0 ; <nl> - Vec3 ambientColor ; <nl> - for ( const auto & light : lights ) <nl> - { <nl> - bool useLight = light - > isEnabled ( ) & & ( ( unsigned int ) light - > getLightFlag ( ) & _lightMask ) ; <nl> - if ( useLight ) <nl> - { <nl> - float intensity = light - > getIntensity ( ) ; <nl> - switch ( light - > getLightType ( ) ) <nl> - { <nl> - case LightType : : DIRECTIONAL : <nl> - { <nl> - if ( enabledDirLightNum < maxDirLight ) <nl> - { <nl> - auto dirLight = static_cast < DirectionLight * > ( light ) ; <nl> - Vec3 dir = dirLight - > getDirectionInWorld ( ) ; <nl> - dir . normalize ( ) ; <nl> - const Color3B & col = dirLight - > getDisplayedColor ( ) ; <nl> - s_dirLightUniformColorValues [ enabledDirLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> - s_dirLightUniformDirValues [ enabledDirLightNum ] = dir ; <nl> - + + enabledDirLightNum ; <nl> - } <nl> - <nl> - } <nl> - break ; <nl> - case LightType : : POINT : <nl> - { <nl> - if ( enabledPointLightNum < maxPointLight ) <nl> - { <nl> - auto pointLight = static_cast < PointLight * > ( light ) ; <nl> - Mat4 mat = pointLight - > getNodeToWorldTransform ( ) ; <nl> - const Color3B & col = pointLight - > getDisplayedColor ( ) ; <nl> - s_pointLightUniformColorValues [ enabledPointLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> - s_pointLightUniformPositionValues [ enabledPointLightNum ] . set ( mat . m [ 12 ] , mat . m [ 13 ] , mat . m [ 14 ] ) ; <nl> - s_pointLightUniformRangeInverseValues [ enabledPointLightNum ] = 1 . 0f / pointLight - > getRange ( ) ; <nl> - + + enabledPointLightNum ; <nl> - } <nl> - } <nl> - break ; <nl> - case LightType : : SPOT : <nl> - { <nl> - if ( enabledSpotLightNum < maxSpotLight ) <nl> - { <nl> - auto spotLight = static_cast < SpotLight * > ( light ) ; <nl> - Vec3 dir = spotLight - > getDirectionInWorld ( ) ; <nl> - dir . normalize ( ) ; <nl> - Mat4 mat = light - > getNodeToWorldTransform ( ) ; <nl> - const Color3B & col = spotLight - > getDisplayedColor ( ) ; <nl> - s_spotLightUniformColorValues [ enabledSpotLightNum ] . set ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> - s_spotLightUniformPositionValues [ enabledSpotLightNum ] . set ( mat . m [ 12 ] , mat . m [ 13 ] , mat . m [ 14 ] ) ; <nl> - s_spotLightUniformDirValues [ enabledSpotLightNum ] = dir ; <nl> - s_spotLightUniformInnerAngleCosValues [ enabledSpotLightNum ] = spotLight - > getCosInnerAngle ( ) ; <nl> - s_spotLightUniformOuterAngleCosValues [ enabledSpotLightNum ] = spotLight - > getCosOuterAngle ( ) ; <nl> - s_spotLightUniformRangeInverseValues [ enabledSpotLightNum ] = 1 . 0f / spotLight - > getRange ( ) ; <nl> - + + enabledSpotLightNum ; <nl> - } <nl> - } <nl> - break ; <nl> - case LightType : : AMBIENT : <nl> - { <nl> - auto ambLight = static_cast < AmbientLight * > ( light ) ; <nl> - const Color3B & col = ambLight - > getDisplayedColor ( ) ; <nl> - ambientColor . add ( col . r / 255 . 0f * intensity , col . g / 255 . 0f * intensity , col . b / 255 . 0f * intensity ) ; <nl> - } <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( 0 < maxDirLight ) <nl> - { <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_dirLightUniformColorName ) , ( GLfloat * ) ( & s_dirLightUniformColorValues [ 0 ] ) , ( unsigned int ) s_dirLightUniformColorValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_dirLightUniformDirName ) , ( GLfloat * ) ( & s_dirLightUniformDirValues [ 0 ] ) , ( unsigned int ) s_dirLightUniformDirValues . size ( ) ) ; <nl> - } <nl> - <nl> - if ( 0 < maxPointLight ) <nl> - { <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_pointLightUniformColorName ) , ( GLfloat * ) ( & s_pointLightUniformColorValues [ 0 ] ) , ( unsigned int ) s_pointLightUniformColorValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_pointLightUniformPositionName ) , ( GLfloat * ) ( & s_pointLightUniformPositionValues [ 0 ] ) , ( unsigned int ) s_pointLightUniformPositionValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith1fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_pointLightUniformRangeInverseName ) , ( GLfloat * ) ( & s_pointLightUniformRangeInverseValues [ 0 ] ) , ( unsigned int ) s_pointLightUniformRangeInverseValues . size ( ) ) ; <nl> - } <nl> - <nl> - if ( 0 < maxSpotLight ) <nl> - { <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformColorName ) , ( GLfloat * ) ( & s_spotLightUniformColorValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformColorValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformPositionName ) , ( GLfloat * ) ( & s_spotLightUniformPositionValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformPositionValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith3fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformDirName ) , ( GLfloat * ) ( & s_spotLightUniformDirValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformDirValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith1fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformInnerAngleCosName ) , ( GLfloat * ) ( & s_spotLightUniformInnerAngleCosValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformInnerAngleCosValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith1fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformOuterAngleCosName ) , ( GLfloat * ) ( & s_spotLightUniformOuterAngleCosValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformOuterAngleCosValues . size ( ) ) ; <nl> - glProgram - > setUniformLocationWith1fv ( ( GLint ) glProgram - > getUniformLocationForName ( s_spotLightUniformRangeInverseName ) , ( GLfloat * ) ( & s_spotLightUniformRangeInverseValues [ 0 ] ) , ( unsigned int ) s_spotLightUniformRangeInverseValues . size ( ) ) ; <nl> - } <nl> - <nl> - glProgram - > setUniformLocationWith3f ( glProgram - > getUniformLocationForName ( s_ambientLightUniformColorName ) , ambientColor . x , ambientColor . y , ambientColor . z ) ; <nl> - } <nl> - else / / normal does not exist <nl> - { <nl> - Vec3 ambient ( 0 . 0f , 0 . 0f , 0 . 0f ) ; <nl> - bool hasAmbient = false ; <nl> - for ( const auto & light : lights ) <nl> - { <nl> - if ( light - > getLightType ( ) = = LightType : : AMBIENT ) <nl> - { <nl> - bool useLight = light - > isEnabled ( ) & & ( ( unsigned int ) light - > getLightFlag ( ) & _lightMask ) ; <nl> - if ( useLight ) <nl> - { <nl> - hasAmbient = true ; <nl> - const Color3B & col = light - > getDisplayedColor ( ) ; <nl> - ambient . x + = col . r * light - > getIntensity ( ) ; <nl> - ambient . y + = col . g * light - > getIntensity ( ) ; <nl> - ambient . z + = col . b * light - > getIntensity ( ) ; <nl> - } <nl> - } <nl> - } <nl> - if ( hasAmbient ) <nl> - { <nl> - ambient . x / = 255 . f ; ambient . y / = 255 . f ; ambient . z / = 255 . f ; <nl> - } <nl> - glProgram - > setUniformLocationWith4f ( glProgram - > getUniformLocationForName ( " u_color " ) , _displayColor . x * ambient . x , _displayColor . y * ambient . y , _displayColor . z * ambient . z , _displayColor . w ) ; <nl> - } <nl> - } <nl> - <nl> - void MeshCommand : : resetLightUniformValues ( ) <nl> - { <nl> - const auto & conf = Configuration : : getInstance ( ) ; <nl> - int maxDirLight = conf - > getMaxSupportDirLightInShader ( ) ; <nl> - int maxPointLight = conf - > getMaxSupportPointLightInShader ( ) ; <nl> - int maxSpotLight = conf - > getMaxSupportSpotLightInShader ( ) ; <nl> - <nl> - s_dirLightUniformColorValues . assign ( maxDirLight , Vec3 : : ZERO ) ; <nl> - s_dirLightUniformDirValues . assign ( maxDirLight , Vec3 : : ZERO ) ; <nl> - <nl> - s_pointLightUniformColorValues . assign ( maxPointLight , Vec3 : : ZERO ) ; <nl> - s_pointLightUniformPositionValues . assign ( maxPointLight , Vec3 : : ZERO ) ; <nl> - s_pointLightUniformRangeInverseValues . assign ( maxPointLight , 0 . 0f ) ; <nl> - <nl> - s_spotLightUniformColorValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> - s_spotLightUniformPositionValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> - s_spotLightUniformDirValues . assign ( maxSpotLight , Vec3 : : ZERO ) ; <nl> - s_spotLightUniformInnerAngleCosValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> - s_spotLightUniformOuterAngleCosValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> - s_spotLightUniformRangeInverseValues . assign ( maxSpotLight , 0 . 0f ) ; <nl> - } <nl> - <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 | | CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT ) <nl> void MeshCommand : : listenRendererRecreated ( EventCustom * event ) <nl> { <nl> mmm a / cocos / renderer / CCMeshCommand . h <nl> ppp b / cocos / renderer / CCMeshCommand . h <nl> class GLProgram ; <nl> struct Uniform ; <nl> class EventListenerCustom ; <nl> class EventCustom ; <nl> + class Material ; <nl> <nl> / / it is a common mesh <nl> class CC_DLL MeshCommand : public RenderCommand <nl> class CC_DLL MeshCommand : public RenderCommand <nl> <nl> MeshCommand ( ) ; <nl> ~ MeshCommand ( ) ; <nl> - <nl> + <nl> + void init ( float globalZOrder , Material * material , GLuint vertexBuffer , GLuint indexBuffer , GLenum primitive , GLenum indexFormat , ssize_t indexCount , const Mat4 & mv , uint32_t flags ) ; <nl> + <nl> void init ( float globalZOrder , GLuint textureID , GLProgramState * glProgramState , BlendFunc blendType , GLuint vertexBuffer , GLuint indexBuffer , GLenum primitive , GLenum indexFormat , ssize_t indexCount , const Mat4 & mv , uint32_t flags ) ; <nl> <nl> CC_DEPRECATED_ATTRIBUTE void init ( float globalZOrder , GLuint textureID , GLProgramState * glProgramState , BlendFunc blendType , GLuint vertexBuffer , GLuint indexBuffer , GLenum primitive , GLenum indexType , ssize_t indexCount , const Mat4 & mv ) ; <nl> class CC_DLL MeshCommand : public RenderCommand <nl> <nl> void setDisplayColor ( const Vec4 & color ) ; <nl> <nl> - void setMatrixPalette ( const Vec4 * matrixPalette ) { _matrixPalette = matrixPalette ; } <nl> + void setMatrixPalette ( const Vec4 * matrixPalette ) ; <nl> <nl> - void setMatrixPaletteSize ( int size ) { _matrixPaletteSize = size ; } <nl> + void setMatrixPaletteSize ( int size ) ; <nl> <nl> - void setLightMask ( unsigned int lightmask ) { _lightMask = lightmask ; } <nl> + void setLightMask ( unsigned int lightmask ) ; <nl> <nl> void setTransparent ( bool value ) ; <nl> <nl> class CC_DLL MeshCommand : public RenderCommand <nl> void batchDraw ( ) ; <nl> void postBatchDraw ( ) ; <nl> <nl> - void genMaterialID ( GLuint texID , void * glProgramState , GLuint vertexBuffer , GLuint indexBuffer , const BlendFunc & blend ) ; <nl> + void genMaterialID ( GLuint texID , void * glProgramState , GLuint vertexBuffer , GLuint indexBuffer , BlendFunc blend ) ; <nl> <nl> - uint32_t getMaterialID ( ) const { return _materialID ; } <nl> + uint32_t getMaterialID ( ) const ; <nl> <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 | | CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT ) <nl> void listenRendererRecreated ( EventCustom * event ) ; <nl> class CC_DLL MeshCommand : public RenderCommand <nl> void buildVAO ( ) ; <nl> void releaseVAO ( ) ; <nl> <nl> - / / apply renderstate <nl> + / / apply renderstate , not used when using material <nl> void applyRenderState ( ) ; <nl> - <nl> - void setLightUniforms ( ) ; <nl> - <nl> - / / restore to all false <nl> void restoreRenderState ( ) ; <nl> - <nl> - void MatrixPalleteCallBack ( GLProgram * glProgram , Uniform * uniform ) ; <nl> - <nl> - void resetLightUniformValues ( ) ; <nl> <nl> GLuint _textureID ; <nl> GLProgramState * _glProgramState ; <nl> BlendFunc _blendType ; <nl> - <nl> - GLuint _textrueID ; <nl> <nl> Vec4 _displayColor ; / / in order to support tint and fade in fade out <nl> <nl> class CC_DLL MeshCommand : public RenderCommand <nl> / / ModelView transform <nl> Mat4 _mv ; <nl> <nl> - unsigned int _lightMask ; <nl> + / / weak ref <nl> + Material * _material ; <nl> <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_WP8 | | CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT ) <nl> EventListenerCustom * _rendererRecreatedListener ; <nl> new file mode 100644 <nl> index 000000000000 . . 7e8aa626d48b <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCPass . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # include " CCPass . h " <nl> + # include " renderer / CCGLProgramState . h " <nl> + # include " renderer / CCGLProgram . h " <nl> + # include " renderer / CCTexture2D . h " <nl> + # include " renderer / ccGLStateCache . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCMaterial . h " <nl> + <nl> + # include " base / ccTypes . h " <nl> + # include " 2d / CCNode . h " <nl> + <nl> + # include < xxhash . h > <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + <nl> + Pass * Pass : : create ( Technique * technique ) <nl> + { <nl> + auto pass = new ( std : : nothrow ) Pass ( ) ; <nl> + if ( pass & & pass - > init ( technique ) ) <nl> + { <nl> + pass - > autorelease ( ) ; <nl> + return pass ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + Pass * Pass : : createWithGLProgramState ( Technique * technique , GLProgramState * programState ) <nl> + { <nl> + auto pass = new ( std : : nothrow ) Pass ( ) ; <nl> + if ( pass & & pass - > initWithGLProgramState ( technique , programState ) ) <nl> + { <nl> + pass - > autorelease ( ) ; <nl> + return pass ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + bool Pass : : init ( Technique * technique ) <nl> + { <nl> + _parent = technique ; <nl> + return true ; <nl> + } <nl> + <nl> + bool Pass : : initWithGLProgramState ( Technique * technique , GLProgramState * glProgramState ) <nl> + { <nl> + _parent = technique ; <nl> + _glProgramState = glProgramState ; <nl> + CC_SAFE_RETAIN ( _glProgramState ) ; <nl> + return true ; <nl> + } <nl> + <nl> + Pass : : Pass ( ) <nl> + : _glProgramState ( nullptr ) <nl> + { <nl> + } <nl> + <nl> + Pass : : ~ Pass ( ) <nl> + { <nl> + CC_SAFE_RELEASE ( _glProgramState ) ; <nl> + } <nl> + <nl> + GLProgramState * Pass : : getGLProgramState ( ) const <nl> + { <nl> + return _glProgramState ; <nl> + } <nl> + <nl> + void Pass : : setGLProgramState ( GLProgramState * glProgramState ) <nl> + { <nl> + if ( _glProgramState ! = glProgramState ) { <nl> + CC_SAFE_RELEASE ( _glProgramState ) ; <nl> + _glProgramState = glProgramState ; <nl> + CC_SAFE_RETAIN ( _glProgramState ) ; <nl> + <nl> + _hashDirty = true ; <nl> + } <nl> + } <nl> + <nl> + uint32_t Pass : : getHash ( ) const <nl> + { <nl> + if ( _hashDirty | | _state - > isDirty ( ) ) { <nl> + uint32_t glProgram = ( uint32_t ) _glProgramState - > getGLProgram ( ) - > getProgram ( ) ; <nl> + uint32_t textureid = ( uint32_t ) _textures . at ( 0 ) - > getName ( ) ; <nl> + uint32_t stateblockid = _state - > getHash ( ) ; <nl> + <nl> + _hash = glProgram ^ textureid ^ stateblockid ; <nl> + <nl> + / / _hash = XXH32 ( ( const void * ) intArray , sizeof ( intArray ) , 0 ) ; <nl> + _hashDirty = false ; <nl> + } <nl> + <nl> + return _hash ; <nl> + } <nl> + <nl> + void Pass : : bind ( const Mat4 & modelView ) <nl> + { <nl> + bind ( modelView , true ) ; <nl> + } <nl> + <nl> + void Pass : : bind ( const Mat4 & modelView , bool bindAttributes ) <nl> + { <nl> + auto glprogramstate = _glProgramState ? _glProgramState : getTarget ( ) - > getGLProgramState ( ) ; <nl> + <nl> + glprogramstate - > applyGLProgram ( modelView ) ; <nl> + if ( bindAttributes ) <nl> + glprogramstate - > applyAttributes ( ) ; <nl> + glprogramstate - > applyUniforms ( ) ; <nl> + <nl> + / / set render state <nl> + RenderState : : bind ( this ) ; <nl> + } <nl> + <nl> + Node * Pass : : getTarget ( ) const <nl> + { <nl> + CCASSERT ( _parent & & _parent - > _parent , " Pass must have a Technique and Material " ) ; <nl> + <nl> + Material * material = static_cast < Material * > ( _parent - > _parent ) ; <nl> + return material - > _target ; <nl> + } <nl> + <nl> + void Pass : : unbind ( ) <nl> + { <nl> + RenderState : : StateBlock : : restore ( 0 ) ; <nl> + } <nl> + <nl> + NS_CC_END <nl> new file mode 100644 <nl> index 000000000000 . . f41116c85219 <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCPass . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __cocos2d_libs__CCPass__ <nl> + # define __cocos2d_libs__CCPass__ <nl> + <nl> + # include < stdio . h > <nl> + <nl> + # include " platform / CCPlatformMacros . h " <nl> + # include " renderer / CCRenderState . h " <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + class GLProgramState ; <nl> + class Technique ; <nl> + class Node ; <nl> + <nl> + class CC_DLL Pass : public RenderState <nl> + { <nl> + friend class Material ; <nl> + <nl> + public : <nl> + / * * Creates a Pass with a GLProgramState . <nl> + * / <nl> + static Pass * createWithGLProgramState ( Technique * parent , GLProgramState * programState ) ; <nl> + <nl> + static Pass * create ( Technique * parent ) ; <nl> + <nl> + / * * Returns the GLProgramState * / <nl> + GLProgramState * getGLProgramState ( ) const ; <nl> + <nl> + / * * Binds the GLProgramState and the RenderState . <nl> + This method must be called before call the actuall draw call . <nl> + * / <nl> + void bind ( const Mat4 & modelView ) ; <nl> + void bind ( const Mat4 & modelView , bool bindAttributes ) ; <nl> + <nl> + / * * Unbinds the Pass . <nl> + This method must be called AFTER calling the actuall draw call <nl> + * / <nl> + void unbind ( ) ; <nl> + <nl> + uint32_t getHash ( ) const ; <nl> + <nl> + protected : <nl> + Pass ( ) ; <nl> + ~ Pass ( ) ; <nl> + bool init ( Technique * parent ) ; <nl> + bool initWithGLProgramState ( Technique * parent , GLProgramState * glProgramState ) ; <nl> + <nl> + void setGLProgramState ( GLProgramState * glProgramState ) ; <nl> + Node * getTarget ( ) const ; <nl> + <nl> + GLProgramState * _glProgramState ; <nl> + } ; <nl> + <nl> + NS_CC_END <nl> + <nl> + <nl> + <nl> + # endif / * defined ( __cocos2d_libs__CCPass__ ) * / <nl> mmm a / cocos / renderer / CCQuadCommand . cpp <nl> ppp b / cocos / renderer / CCQuadCommand . cpp <nl> <nl> <nl> # include " renderer / ccGLStateCache . h " <nl> # include " renderer / CCGLProgram . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCRenderer . h " <nl> + # include " renderer / CCPass . h " <nl> + <nl> # include " xxhash . h " <nl> - # include " CCRenderer . h " <nl> <nl> NS_CC_BEGIN <nl> <nl> QuadCommand : : QuadCommand ( ) <nl> , _blendType ( BlendFunc : : DISABLE ) <nl> , _quads ( nullptr ) <nl> , _quadsCount ( 0 ) <nl> + , _material ( nullptr ) <nl> + , _multiplePass ( false ) <nl> { <nl> _type = RenderCommand : : Type : : QUAD_COMMAND ; <nl> } <nl> void QuadCommand : : init ( float globalOrder , GLuint textureID , GLProgramState * shad <nl> } <nl> } <nl> <nl> + void QuadCommand : : init ( float globalOrder , Material * material , V3F_C4B_T2F_Quad * quads , ssize_t quadCount , const Mat4 & mv , uint32_t flags ) <nl> + { <nl> + CCASSERT ( material , " Invalid Material " ) ; <nl> + <nl> + RenderCommand : : init ( globalOrder , mv , flags ) ; <nl> + <nl> + _quadsCount = quadCount ; <nl> + _quads = quads ; <nl> + <nl> + _mv = mv ; <nl> + <nl> + if ( _material ! = material ) { <nl> + _material = material ; <nl> + <nl> + generateMaterialID ( ) ; <nl> + } <nl> + } <nl> + <nl> void QuadCommand : : init ( float globalOrder , GLuint textureID , GLProgramState * shader , const BlendFunc & blendType , V3F_C4B_T2F_Quad * quads , ssize_t quadCount , const Mat4 & mv ) <nl> { <nl> init ( globalOrder , textureID , shader , blendType , quads , quadCount , mv , 0 ) ; <nl> void QuadCommand : : init ( float globalOrder , GLuint textureID , GLProgramState * shad <nl> <nl> QuadCommand : : ~ QuadCommand ( ) <nl> { <nl> + CC_SAFE_RELEASE ( _material ) ; <nl> } <nl> <nl> void QuadCommand : : generateMaterialID ( ) <nl> { <nl> + _skipBatching = false ; <nl> + _multiplePass = false ; <nl> <nl> - if ( _glProgramState - > getUniformCount ( ) > 0 ) <nl> + if ( _material ) <nl> { <nl> - _materialID = Renderer : : MATERIAL_ID_DO_NOT_BATCH ; <nl> + auto technique = _material - > getTechnique ( ) ; <nl> + auto count = technique - > getPassCount ( ) ; <nl> + <nl> + / / multiple pass : no batching <nl> + if ( count > 1 ) { <nl> + _materialID = Renderer : : MATERIAL_ID_DO_NOT_BATCH ; <nl> + _skipBatching = true ; <nl> + _multiplePass = true ; <nl> + } <nl> + / / count = = 1 . Ok for batching <nl> + else if ( technique - > getPassByIndex ( 0 ) - > getGLProgramState ( ) - > getUniformCount ( ) = = 0 ) <nl> + { <nl> + _materialID = technique - > getPassByIndex ( 0 ) - > getHash ( ) ; <nl> + } <nl> + / / count = = 1 + custom uniforms . No batching <nl> + else <nl> + { <nl> + _materialID = Renderer : : MATERIAL_ID_DO_NOT_BATCH ; <nl> + _skipBatching = true ; <nl> + } <nl> } <nl> else <nl> { <nl> - int glProgram = ( int ) _glProgramState - > getGLProgram ( ) - > getProgram ( ) ; <nl> - int intArray [ 4 ] = { glProgram , ( int ) _textureID , ( int ) _blendType . src , ( int ) _blendType . dst } ; <nl> - <nl> - _materialID = XXH32 ( ( const void * ) intArray , sizeof ( intArray ) , 0 ) ; <nl> + if ( _glProgramState - > getUniformCount ( ) = = 0 ) <nl> + { <nl> + int glProgram = ( int ) _glProgramState - > getGLProgram ( ) - > getProgram ( ) ; <nl> + int intArray [ 4 ] = { glProgram , ( int ) _textureID , ( int ) _blendType . src , ( int ) _blendType . dst } ; <nl> + <nl> + _materialID = XXH32 ( ( const void * ) intArray , sizeof ( intArray ) , 0 ) ; <nl> + } <nl> + else <nl> + { <nl> + _materialID = Renderer : : MATERIAL_ID_DO_NOT_BATCH ; <nl> + _skipBatching = true ; <nl> + } <nl> } <nl> } <nl> <nl> void QuadCommand : : useMaterial ( ) const <nl> { <nl> - / / Set texture <nl> - GL : : bindTexture2D ( _textureID ) ; <nl> - <nl> - / / set blend mode <nl> - GL : : blendFunc ( _blendType . src , _blendType . dst ) ; <nl> - <nl> - _glProgramState - > apply ( _mv ) ; <nl> + CCASSERT ( ! _multiplePass , " Material with multiple passes cannot be bound " ) ; <nl> + <nl> + if ( ! _material ) { <nl> + / / Set texture <nl> + GL : : bindTexture2D ( _textureID ) ; <nl> + <nl> + / / set blend mode <nl> + GL : : blendFunc ( _blendType . src , _blendType . dst ) ; <nl> + <nl> + _glProgramState - > applyGLProgram ( _mv ) ; <nl> + _glProgramState - > applyUniforms ( ) ; <nl> + } else { <nl> + _material - > getTechnique ( ) - > getPassByIndex ( 0 ) - > bind ( _mv ) ; <nl> + } <nl> } <nl> <nl> NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / renderer / CCQuadCommand . h <nl> ppp b / cocos / renderer / CCQuadCommand . h <nl> <nl> <nl> NS_CC_BEGIN <nl> <nl> + class Material ; <nl> + <nl> / * * <nl> Command used to render one or more Quads , similar to TrianglesCommand . <nl> Every QuadCommand will have generate material ID by give textureID , glProgramState , Blend function <nl> class CC_DLL QuadCommand : public RenderCommand <nl> * / <nl> void init ( float globalOrder , GLuint textureID , GLProgramState * shader , const BlendFunc & blendType , V3F_C4B_T2F_Quad * quads , ssize_t quadCount , <nl> const Mat4 & mv , uint32_t flags ) ; <nl> + <nl> + void init ( float globalOrder , Material * material , V3F_C4B_T2F_Quad * quads , ssize_t quadCount , const Mat4 & mv , uint32_t flags ) ; <nl> + <nl> / * * Deprecated function , the params is similar as the upper init function , with flags equals 0 . * / <nl> CC_DEPRECATED_ATTRIBUTE void init ( float globalOrder , GLuint textureID , GLProgramState * shader , const BlendFunc & blendType , V3F_C4B_T2F_Quad * quads , ssize_t quadCount , <nl> const Mat4 & mv ) ; <nl> class CC_DLL QuadCommand : public RenderCommand <nl> inline BlendFunc getBlendType ( ) const { return _blendType ; } <nl> / * * Get the model view matrix . * / <nl> inline const Mat4 & getModelView ( ) const { return _mv ; } <nl> + <nl> + Material * getMaterial ( ) const { return _material ; } <nl> + bool isMultiplePass ( ) const { return _multiplePass ; } <nl> <nl> protected : <nl> / * * Generate the material ID by textureID , glProgramState , and blend function . * / <nl> class CC_DLL QuadCommand : public RenderCommand <nl> ssize_t _quadsCount ; <nl> / * * Model view matrix when rendering the triangles . * / <nl> Mat4 _mv ; <nl> + <nl> + / / weak ref <nl> + Material * _material ; <nl> + bool _multiplePass ; <nl> } ; <nl> <nl> NS_CC_END <nl> new file mode 100644 <nl> index 000000000000 . . 530b3fd8e5cb <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCRenderState . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + Copyright ( c ) 2014 GamePlay3D team <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <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> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # include " CCRenderState . h " <nl> + <nl> + # include < string > <nl> + <nl> + # include " renderer / CCTexture2D . h " <nl> + # include " renderer / CCPass . h " <nl> + # include " renderer / ccGLStateCache . h " <nl> + <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + RenderState : : StateBlock * RenderState : : StateBlock : : _defaultState = nullptr ; <nl> + <nl> + / / Render state override bits <nl> + enum <nl> + { <nl> + RS_BLEND = ( 1 < < 0 ) , <nl> + RS_BLEND_FUNC = ( 1 < < 1 ) , <nl> + RS_CULL_FACE = ( 1 < < 2 ) , <nl> + RS_DEPTH_TEST = ( 1 < < 3 ) , <nl> + RS_DEPTH_WRITE = ( 1 < < 4 ) , <nl> + RS_DEPTH_FUNC = ( 1 < < 5 ) , <nl> + RS_CULL_FACE_SIDE = ( 1 < < 6 ) , <nl> + RS_STENCIL_TEST = ( 1 < < 7 ) , <nl> + RS_STENCIL_WRITE = ( 1 < < 8 ) , <nl> + RS_STENCIL_FUNC = ( 1 < < 9 ) , <nl> + RS_STENCIL_OP = ( 1 < < 10 ) , <nl> + RS_FRONT_FACE = ( 1 < < 11 ) , <nl> + <nl> + RS_ALL_ONES = 0xFFFFFFFF , <nl> + } ; <nl> + <nl> + <nl> + RenderState : : RenderState ( ) <nl> + : _textures ( ) <nl> + , _hash ( 0 ) <nl> + , _hashDirty ( true ) <nl> + , _parent ( nullptr ) <nl> + { <nl> + _state = StateBlock : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _state ) ; <nl> + } <nl> + <nl> + RenderState : : ~ RenderState ( ) <nl> + { <nl> + CC_SAFE_RELEASE ( _state ) ; <nl> + } <nl> + <nl> + void RenderState : : initialize ( ) <nl> + { <nl> + if ( StateBlock : : _defaultState = = NULL ) <nl> + { <nl> + StateBlock : : _defaultState = StateBlock : : create ( ) ; <nl> + CC_SAFE_RETAIN ( StateBlock : : _defaultState ) ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : finalize ( ) <nl> + { <nl> + CC_SAFE_RELEASE ( StateBlock : : _defaultState ) ; <nl> + } <nl> + <nl> + bool RenderState : : init ( RenderState * parent ) <nl> + { <nl> + CCASSERT ( ! _parent , " Cannot reinitialize Render State " ) ; <nl> + CCASSERT ( parent , " parent must be non - null " ) ; <nl> + <nl> + / / Weak reference <nl> + _parent = parent ; <nl> + return true ; <nl> + } <nl> + <nl> + std : : string RenderState : : getName ( ) const <nl> + { <nl> + return _name ; <nl> + } <nl> + <nl> + <nl> + const Vector < Texture2D * > & RenderState : : getTextures ( ) const <nl> + { <nl> + return _textures ; <nl> + } <nl> + <nl> + void RenderState : : setTexture ( Texture2D * texture ) <nl> + { <nl> + if ( _textures . size ( ) > 0 ) <nl> + _textures . replace ( 0 , texture ) ; <nl> + else <nl> + _textures . pushBack ( texture ) ; <nl> + } <nl> + <nl> + Texture2D * RenderState : : getTexture ( ) const <nl> + { <nl> + if ( _textures . size ( ) > 0 ) <nl> + return _textures . at ( 0 ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + void RenderState : : bind ( Pass * pass ) <nl> + { <nl> + CC_ASSERT ( pass ) ; <nl> + <nl> + if ( _textures . size ( ) > 0 ) <nl> + GL : : bindTexture2D ( _textures . at ( 0 ) - > getName ( ) ) ; <nl> + <nl> + / / Get the combined modified state bits for our RenderState hierarchy . <nl> + long stateOverrideBits = _state ? _state - > _bits : 0 ; <nl> + RenderState * rs = _parent ; <nl> + while ( rs ) <nl> + { <nl> + if ( rs - > _state ) <nl> + { <nl> + stateOverrideBits | = rs - > _state - > _bits ; <nl> + } <nl> + rs = rs - > _parent ; <nl> + } <nl> + <nl> + / / Restore renderer state to its default , except for explicitly specified states <nl> + StateBlock : : restore ( stateOverrideBits ) ; <nl> + <nl> + / / Apply renderer state for the entire hierarchy , top - down . <nl> + rs = NULL ; <nl> + while ( ( rs = getTopmost ( rs ) ) ) <nl> + { <nl> + if ( rs - > _state ) <nl> + { <nl> + rs - > _state - > bindNoRestore ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + RenderState * RenderState : : getTopmost ( RenderState * below ) <nl> + { <nl> + RenderState * rs = this ; <nl> + if ( rs = = below ) <nl> + { <nl> + / / Nothing below ourself . <nl> + return NULL ; <nl> + } <nl> + <nl> + while ( rs ) <nl> + { <nl> + if ( rs - > _parent = = below | | rs - > _parent = = NULL ) <nl> + { <nl> + / / Stop traversing up here . <nl> + return rs ; <nl> + } <nl> + rs = rs - > _parent ; <nl> + } <nl> + <nl> + return NULL ; <nl> + } <nl> + <nl> + RenderState : : StateBlock * RenderState : : getStateBlock ( ) const <nl> + { <nl> + return _state ; <nl> + } <nl> + <nl> + / / <nl> + / / StateBlock <nl> + / / <nl> + RenderState : : StateBlock * RenderState : : StateBlock : : create ( ) <nl> + { <nl> + auto state = new ( std : : nothrow ) RenderState : : StateBlock ( ) ; <nl> + if ( state ) <nl> + { <nl> + state - > autorelease ( ) ; <nl> + } <nl> + <nl> + return state ; <nl> + } <nl> + <nl> + / / <nl> + / / The defaults are based on GamePlay3D defaults , with the following chagnes <nl> + / / _depthWriteEnabled is FALSE <nl> + / / _depthTestEnabled is TRUE <nl> + / / _blendEnabled is TRUE <nl> + RenderState : : StateBlock : : StateBlock ( ) <nl> + : _cullFaceEnabled ( false ) <nl> + , _depthTestEnabled ( true ) , _depthWriteEnabled ( false ) , _depthFunction ( RenderState : : DEPTH_LESS ) <nl> + , _blendEnabled ( true ) , _blendSrc ( RenderState : : BLEND_ONE ) , _blendDst ( RenderState : : BLEND_ZERO ) <nl> + , _cullFaceSide ( CULL_FACE_SIDE_BACK ) , _frontFace ( FRONT_FACE_CCW ) <nl> + , _stencilTestEnabled ( false ) , _stencilWrite ( RS_ALL_ONES ) <nl> + , _stencilFunction ( RenderState : : STENCIL_ALWAYS ) , _stencilFunctionRef ( 0 ) , _stencilFunctionMask ( RS_ALL_ONES ) <nl> + , _stencilOpSfail ( RenderState : : STENCIL_OP_KEEP ) , _stencilOpDpfail ( RenderState : : STENCIL_OP_KEEP ) , _stencilOpDppass ( RenderState : : STENCIL_OP_KEEP ) <nl> + , _bits ( 0L ) <nl> + { <nl> + } <nl> + <nl> + RenderState : : StateBlock : : ~ StateBlock ( ) <nl> + { <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : bind ( ) <nl> + { <nl> + / / When the public bind ( ) is called with no RenderState object passed in , <nl> + / / we assume we are being called to bind the state of a single StateBlock , <nl> + / / irrespective of whether it belongs to a hierarchy of RenderStates . <nl> + / / Therefore , we call restore ( ) here with only this StateBlock ' s override <nl> + / / bits to restore state before applying the new state . <nl> + StateBlock : : restore ( _bits ) ; <nl> + <nl> + bindNoRestore ( ) ; <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : bindNoRestore ( ) <nl> + { <nl> + CC_ASSERT ( _defaultState ) ; <nl> + <nl> + / / Update any state that differs from _defaultState and flip _defaultState bits <nl> + if ( ( _bits & RS_BLEND ) & & ( _blendEnabled ! = _defaultState - > _blendEnabled ) ) <nl> + { <nl> + if ( _blendEnabled ) <nl> + glEnable ( GL_BLEND ) ; <nl> + else <nl> + glDisable ( GL_BLEND ) ; <nl> + _defaultState - > _blendEnabled = _blendEnabled ; <nl> + } <nl> + if ( ( _bits & RS_BLEND_FUNC ) & & ( _blendSrc ! = _defaultState - > _blendSrc | | _blendDst ! = _defaultState - > _blendDst ) ) <nl> + { <nl> + GL : : blendFunc ( ( GLenum ) _blendSrc , ( GLenum ) _blendDst ) ; <nl> + _defaultState - > _blendSrc = _blendSrc ; <nl> + _defaultState - > _blendDst = _blendDst ; <nl> + } <nl> + if ( ( _bits & RS_CULL_FACE ) & & ( _cullFaceEnabled ! = _defaultState - > _cullFaceEnabled ) ) <nl> + { <nl> + if ( _cullFaceEnabled ) <nl> + glEnable ( GL_CULL_FACE ) ; <nl> + else <nl> + glDisable ( GL_CULL_FACE ) ; <nl> + _defaultState - > _cullFaceEnabled = _cullFaceEnabled ; <nl> + } <nl> + if ( ( _bits & RS_CULL_FACE_SIDE ) & & ( _cullFaceSide ! = _defaultState - > _cullFaceSide ) ) <nl> + { <nl> + glCullFace ( ( GLenum ) _cullFaceSide ) ; <nl> + _defaultState - > _cullFaceSide = _cullFaceSide ; <nl> + } <nl> + if ( ( _bits & RS_FRONT_FACE ) & & ( _frontFace ! = _defaultState - > _frontFace ) ) <nl> + { <nl> + glFrontFace ( ( GLenum ) _frontFace ) ; <nl> + _defaultState - > _frontFace = _frontFace ; <nl> + } <nl> + if ( ( _bits & RS_DEPTH_TEST ) & & ( _depthTestEnabled ! = _defaultState - > _depthTestEnabled ) ) <nl> + { <nl> + if ( _depthTestEnabled ) <nl> + glEnable ( GL_DEPTH_TEST ) ; <nl> + else <nl> + glDisable ( GL_DEPTH_TEST ) ; <nl> + _defaultState - > _depthTestEnabled = _depthTestEnabled ; <nl> + } <nl> + if ( ( _bits & RS_DEPTH_WRITE ) & & ( _depthWriteEnabled ! = _defaultState - > _depthWriteEnabled ) ) <nl> + { <nl> + glDepthMask ( _depthWriteEnabled ? GL_TRUE : GL_FALSE ) ; <nl> + _defaultState - > _depthWriteEnabled = _depthWriteEnabled ; <nl> + } <nl> + if ( ( _bits & RS_DEPTH_FUNC ) & & ( _depthFunction ! = _defaultState - > _depthFunction ) ) <nl> + { <nl> + glDepthFunc ( ( GLenum ) _depthFunction ) ; <nl> + _defaultState - > _depthFunction = _depthFunction ; <nl> + } <nl> + if ( ( _bits & RS_STENCIL_TEST ) & & ( _stencilTestEnabled ! = _defaultState - > _stencilTestEnabled ) ) <nl> + { <nl> + if ( _stencilTestEnabled ) <nl> + glEnable ( GL_STENCIL_TEST ) ; <nl> + else <nl> + glDisable ( GL_STENCIL_TEST ) ; <nl> + _defaultState - > _stencilTestEnabled = _stencilTestEnabled ; <nl> + } <nl> + if ( ( _bits & RS_STENCIL_WRITE ) & & ( _stencilWrite ! = _defaultState - > _stencilWrite ) ) <nl> + { <nl> + glStencilMask ( _stencilWrite ) ; <nl> + _defaultState - > _stencilWrite = _stencilWrite ; <nl> + } <nl> + if ( ( _bits & RS_STENCIL_FUNC ) & & ( _stencilFunction ! = _defaultState - > _stencilFunction | | <nl> + _stencilFunctionRef ! = _defaultState - > _stencilFunctionRef | | <nl> + _stencilFunctionMask ! = _defaultState - > _stencilFunctionMask ) ) <nl> + { <nl> + glStencilFunc ( ( GLenum ) _stencilFunction , _stencilFunctionRef , _stencilFunctionMask ) ; <nl> + _defaultState - > _stencilFunction = _stencilFunction ; <nl> + _defaultState - > _stencilFunctionRef = _stencilFunctionRef ; <nl> + _defaultState - > _stencilFunctionMask = _stencilFunctionMask ; <nl> + } <nl> + if ( ( _bits & RS_STENCIL_OP ) & & ( _stencilOpSfail ! = _defaultState - > _stencilOpSfail | | <nl> + _stencilOpDpfail ! = _defaultState - > _stencilOpDpfail | | <nl> + _stencilOpDppass ! = _defaultState - > _stencilOpDppass ) ) <nl> + { <nl> + glStencilOp ( ( GLenum ) _stencilOpSfail , ( GLenum ) _stencilOpDpfail , ( GLenum ) _stencilOpDppass ) ; <nl> + _defaultState - > _stencilOpSfail = _stencilOpSfail ; <nl> + _defaultState - > _stencilOpDpfail = _stencilOpDpfail ; <nl> + _defaultState - > _stencilOpDppass = _stencilOpDppass ; <nl> + } <nl> + <nl> + _defaultState - > _bits | = _bits ; <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : restore ( long stateOverrideBits ) <nl> + { <nl> + CC_ASSERT ( _defaultState ) ; <nl> + <nl> + / / If there is no state to restore ( i . e . no non - default state ) , do nothing . <nl> + if ( _defaultState - > _bits = = 0 ) <nl> + { <nl> + return ; <nl> + } <nl> + <nl> + / / Restore any state that is not overridden and is not default <nl> + if ( ! ( stateOverrideBits & RS_BLEND ) & & ( _defaultState - > _bits & RS_BLEND ) ) <nl> + { <nl> + glEnable ( GL_BLEND ) ; <nl> + _defaultState - > _bits & = ~ RS_BLEND ; <nl> + _defaultState - > _blendEnabled = true ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_BLEND_FUNC ) & & ( _defaultState - > _bits & RS_BLEND_FUNC ) ) <nl> + { <nl> + GL : : blendFunc ( GL_ONE , GL_ZERO ) ; <nl> + _defaultState - > _bits & = ~ RS_BLEND_FUNC ; <nl> + _defaultState - > _blendSrc = RenderState : : BLEND_ONE ; <nl> + _defaultState - > _blendDst = RenderState : : BLEND_ZERO ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_CULL_FACE ) & & ( _defaultState - > _bits & RS_CULL_FACE ) ) <nl> + { <nl> + glDisable ( GL_CULL_FACE ) ; <nl> + _defaultState - > _bits & = ~ RS_CULL_FACE ; <nl> + _defaultState - > _cullFaceEnabled = false ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_CULL_FACE_SIDE ) & & ( _defaultState - > _bits & RS_CULL_FACE_SIDE ) ) <nl> + { <nl> + glCullFace ( ( GLenum ) GL_BACK ) ; <nl> + _defaultState - > _bits & = ~ RS_CULL_FACE_SIDE ; <nl> + _defaultState - > _cullFaceSide = RenderState : : CULL_FACE_SIDE_BACK ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_FRONT_FACE ) & & ( _defaultState - > _bits & RS_FRONT_FACE ) ) <nl> + { <nl> + glFrontFace ( ( GLenum ) GL_CCW ) ; <nl> + _defaultState - > _bits & = ~ RS_FRONT_FACE ; <nl> + _defaultState - > _frontFace = RenderState : : FRONT_FACE_CCW ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_DEPTH_TEST ) & & ( _defaultState - > _bits & RS_DEPTH_TEST ) ) <nl> + { <nl> + glEnable ( GL_DEPTH_TEST ) ; <nl> + _defaultState - > _bits & = ~ RS_DEPTH_TEST ; <nl> + _defaultState - > _depthTestEnabled = true ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_DEPTH_WRITE ) & & ( _defaultState - > _bits & RS_DEPTH_WRITE ) ) <nl> + { <nl> + glDepthMask ( GL_FALSE ) ; <nl> + _defaultState - > _bits & = ~ RS_DEPTH_WRITE ; <nl> + _defaultState - > _depthWriteEnabled = false ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_DEPTH_FUNC ) & & ( _defaultState - > _bits & RS_DEPTH_FUNC ) ) <nl> + { <nl> + glDepthFunc ( ( GLenum ) GL_LESS ) ; <nl> + _defaultState - > _bits & = ~ RS_DEPTH_FUNC ; <nl> + _defaultState - > _depthFunction = RenderState : : DEPTH_LESS ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_STENCIL_TEST ) & & ( _defaultState - > _bits & RS_STENCIL_TEST ) ) <nl> + { <nl> + glDisable ( GL_STENCIL_TEST ) ; <nl> + _defaultState - > _bits & = ~ RS_STENCIL_TEST ; <nl> + _defaultState - > _stencilTestEnabled = false ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_STENCIL_WRITE ) & & ( _defaultState - > _bits & RS_STENCIL_WRITE ) ) <nl> + { <nl> + glStencilMask ( RS_ALL_ONES ) ; <nl> + _defaultState - > _bits & = ~ RS_STENCIL_WRITE ; <nl> + _defaultState - > _stencilWrite = RS_ALL_ONES ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_STENCIL_FUNC ) & & ( _defaultState - > _bits & RS_STENCIL_FUNC ) ) <nl> + { <nl> + glStencilFunc ( ( GLenum ) RenderState : : STENCIL_ALWAYS , 0 , RS_ALL_ONES ) ; <nl> + _defaultState - > _bits & = ~ RS_STENCIL_FUNC ; <nl> + _defaultState - > _stencilFunction = RenderState : : STENCIL_ALWAYS ; <nl> + _defaultState - > _stencilFunctionRef = 0 ; <nl> + _defaultState - > _stencilFunctionMask = RS_ALL_ONES ; <nl> + } <nl> + if ( ! ( stateOverrideBits & RS_STENCIL_OP ) & & ( _defaultState - > _bits & RS_STENCIL_OP ) ) <nl> + { <nl> + glStencilOp ( ( GLenum ) RenderState : : STENCIL_OP_KEEP , ( GLenum ) RenderState : : STENCIL_OP_KEEP , ( GLenum ) RenderState : : STENCIL_OP_KEEP ) ; <nl> + _defaultState - > _bits & = ~ RS_STENCIL_OP ; <nl> + _defaultState - > _stencilOpSfail = RenderState : : STENCIL_OP_KEEP ; <nl> + _defaultState - > _stencilOpDpfail = RenderState : : STENCIL_OP_KEEP ; <nl> + _defaultState - > _stencilOpDppass = RenderState : : STENCIL_OP_KEEP ; <nl> + } <nl> + } <nl> + <nl> + static bool parseBoolean ( const std : : string & value ) <nl> + { <nl> + return ( value . compare ( " true " ) = = 0 ) ; <nl> + } <nl> + <nl> + static int parseInt ( const std : : string & value ) <nl> + { <nl> + / / Android NDK 10 doesn ' t support std : : stoi a / std : : stoul <nl> + # if CC_TARGET_PLATFORM ! = CC_PLATFORM_ANDROID <nl> + return std : : stoi ( value ) ; <nl> + # else <nl> + return atoi ( value . c_str ( ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + static unsigned int parseUInt ( const std : : string & value ) <nl> + { <nl> + / / Android NDK 10 doesn ' t support std : : stoi a / std : : stoul <nl> + # if CC_TARGET_PLATFORM ! = CC_PLATFORM_ANDROID <nl> + return ( unsigned int ) std : : stoul ( value ) ; <nl> + # else <nl> + return ( unsigned int ) atoi ( value . c_str ( ) ) ; <nl> + # endif <nl> + <nl> + } <nl> + <nl> + static RenderState : : Blend parseBlend ( const std : : string & value ) <nl> + { <nl> + / / Convert the string to uppercase for comparison . <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " ZERO " ) <nl> + return RenderState : : BLEND_ZERO ; <nl> + else if ( upper = = " ONE " ) <nl> + return RenderState : : BLEND_ONE ; <nl> + else if ( upper = = " SRC_COLOR " ) <nl> + return RenderState : : BLEND_SRC_COLOR ; <nl> + else if ( upper = = " ONE_MINUS_SRC_COLOR " ) <nl> + return RenderState : : BLEND_ONE_MINUS_SRC_COLOR ; <nl> + else if ( upper = = " DST_COLOR " ) <nl> + return RenderState : : BLEND_DST_COLOR ; <nl> + else if ( upper = = " ONE_MINUS_DST_COLOR " ) <nl> + return RenderState : : BLEND_ONE_MINUS_DST_COLOR ; <nl> + else if ( upper = = " SRC_ALPHA " ) <nl> + return RenderState : : BLEND_SRC_ALPHA ; <nl> + else if ( upper = = " ONE_MINUS_SRC_ALPHA " ) <nl> + return RenderState : : BLEND_ONE_MINUS_SRC_ALPHA ; <nl> + else if ( upper = = " DST_ALPHA " ) <nl> + return RenderState : : BLEND_DST_ALPHA ; <nl> + else if ( upper = = " ONE_MINUS_DST_ALPHA " ) <nl> + return RenderState : : BLEND_ONE_MINUS_DST_ALPHA ; <nl> + else if ( upper = = " CONSTANT_ALPHA " ) <nl> + return RenderState : : BLEND_CONSTANT_ALPHA ; <nl> + else if ( upper = = " ONE_MINUS_CONSTANT_ALPHA " ) <nl> + return RenderState : : BLEND_ONE_MINUS_CONSTANT_ALPHA ; <nl> + else if ( upper = = " SRC_ALPHA_SATURATE " ) <nl> + return RenderState : : BLEND_SRC_ALPHA_SATURATE ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported blend value ( % s ) . ( Will default to BLEND_ONE if errors are treated as warnings ) " , value . c_str ( ) ) ; <nl> + return RenderState : : BLEND_ONE ; <nl> + } <nl> + } <nl> + <nl> + static RenderState : : DepthFunction parseDepthFunc ( const std : : string & value ) <nl> + { <nl> + / / Convert string to uppercase for comparison <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " NEVER " ) <nl> + return RenderState : : DEPTH_NEVER ; <nl> + else if ( upper = = " LESS " ) <nl> + return RenderState : : DEPTH_LESS ; <nl> + else if ( upper = = " EQUAL " ) <nl> + return RenderState : : DEPTH_EQUAL ; <nl> + else if ( upper = = " LEQUAL " ) <nl> + return RenderState : : DEPTH_LEQUAL ; <nl> + else if ( upper = = " GREATER " ) <nl> + return RenderState : : DEPTH_GREATER ; <nl> + else if ( upper = = " NOTEQUAL " ) <nl> + return RenderState : : DEPTH_NOTEQUAL ; <nl> + else if ( upper = = " GEQUAL " ) <nl> + return RenderState : : DEPTH_GEQUAL ; <nl> + else if ( upper = = " ALWAYS " ) <nl> + return RenderState : : DEPTH_ALWAYS ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported depth function value ( % s ) . Will default to DEPTH_LESS if errors are treated as warnings ) " , value . c_str ( ) ) ; <nl> + return RenderState : : DEPTH_LESS ; <nl> + } <nl> + } <nl> + <nl> + static RenderState : : CullFaceSide parseCullFaceSide ( const std : : string & value ) <nl> + { <nl> + / / Convert string to uppercase for comparison <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " BACK " ) <nl> + return RenderState : : CULL_FACE_SIDE_BACK ; <nl> + else if ( upper = = " FRONT " ) <nl> + return RenderState : : CULL_FACE_SIDE_FRONT ; <nl> + else if ( upper = = " FRONT_AND_BACK " ) <nl> + return RenderState : : CULL_FACE_SIDE_FRONT_AND_BACK ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported cull face side value ( % s ) . Will default to BACK if errors are treated as warnings . " , value . c_str ( ) ) ; <nl> + return RenderState : : CULL_FACE_SIDE_BACK ; <nl> + } <nl> + } <nl> + <nl> + static RenderState : : FrontFace parseFrontFace ( const std : : string & value ) <nl> + { <nl> + / / Convert string to uppercase for comparison <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " CCW " ) <nl> + return RenderState : : FRONT_FACE_CCW ; <nl> + else if ( upper = = " CW " ) <nl> + return RenderState : : FRONT_FACE_CW ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported front face side value ( % s ) . Will default to CCW if errors are treated as warnings . " , value . c_str ( ) ) ; <nl> + return RenderState : : FRONT_FACE_CCW ; <nl> + } <nl> + } <nl> + <nl> + static RenderState : : StencilFunction parseStencilFunc ( const std : : string & value ) <nl> + { <nl> + / / Convert string to uppercase for comparison <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " NEVER " ) <nl> + return RenderState : : STENCIL_NEVER ; <nl> + else if ( upper = = " LESS " ) <nl> + return RenderState : : STENCIL_LESS ; <nl> + else if ( upper = = " EQUAL " ) <nl> + return RenderState : : STENCIL_EQUAL ; <nl> + else if ( upper = = " LEQUAL " ) <nl> + return RenderState : : STENCIL_LEQUAL ; <nl> + else if ( upper = = " GREATER " ) <nl> + return RenderState : : STENCIL_GREATER ; <nl> + else if ( upper = = " NOTEQUAL " ) <nl> + return RenderState : : STENCIL_NOTEQUAL ; <nl> + else if ( upper = = " GEQUAL " ) <nl> + return RenderState : : STENCIL_GEQUAL ; <nl> + else if ( upper = = " ALWAYS " ) <nl> + return RenderState : : STENCIL_ALWAYS ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported stencil function value ( % s ) . Will default to STENCIL_ALWAYS if errors are treated as warnings ) " , value . c_str ( ) ) ; <nl> + return RenderState : : STENCIL_ALWAYS ; <nl> + } <nl> + } <nl> + <nl> + static RenderState : : StencilOperation parseStencilOp ( const std : : string & value ) <nl> + { <nl> + / / Convert string to uppercase for comparison <nl> + std : : string upper ( value ) ; <nl> + std : : transform ( upper . begin ( ) , upper . end ( ) , upper . begin ( ) , ( int ( * ) ( int ) ) toupper ) ; <nl> + if ( upper = = " KEEP " ) <nl> + return RenderState : : STENCIL_OP_KEEP ; <nl> + else if ( upper = = " ZERO " ) <nl> + return RenderState : : STENCIL_OP_ZERO ; <nl> + else if ( upper = = " REPLACE " ) <nl> + return RenderState : : STENCIL_OP_REPLACE ; <nl> + else if ( upper = = " INCR " ) <nl> + return RenderState : : STENCIL_OP_INCR ; <nl> + else if ( upper = = " DECR " ) <nl> + return RenderState : : STENCIL_OP_DECR ; <nl> + else if ( upper = = " INVERT " ) <nl> + return RenderState : : STENCIL_OP_INVERT ; <nl> + else if ( upper = = " INCR_WRAP " ) <nl> + return RenderState : : STENCIL_OP_INCR_WRAP ; <nl> + else if ( upper = = " DECR_WRAP " ) <nl> + return RenderState : : STENCIL_OP_DECR_WRAP ; <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported stencil operation value ( % s ) . Will default to STENCIL_OP_KEEP if errors are treated as warnings ) " , value . c_str ( ) ) ; <nl> + return RenderState : : STENCIL_OP_KEEP ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setState ( const std : : string & name , const std : : string & value ) <nl> + { <nl> + if ( name . compare ( " blend " ) = = 0 ) <nl> + { <nl> + setBlend ( parseBoolean ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " blendSrc " ) = = 0 ) <nl> + { <nl> + setBlendSrc ( parseBlend ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " blendDst " ) = = 0 ) <nl> + { <nl> + setBlendDst ( parseBlend ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " cullFace " ) = = 0 ) <nl> + { <nl> + setCullFace ( parseBoolean ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " cullFaceSide " ) = = 0 ) <nl> + { <nl> + setCullFaceSide ( parseCullFaceSide ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " frontFace " ) = = 0 ) <nl> + { <nl> + setFrontFace ( parseFrontFace ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " depthTest " ) = = 0 ) <nl> + { <nl> + setDepthTest ( parseBoolean ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " depthWrite " ) = = 0 ) <nl> + { <nl> + setDepthWrite ( parseBoolean ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " depthFunc " ) = = 0 ) <nl> + { <nl> + setDepthFunction ( parseDepthFunc ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " stencilTest " ) = = 0 ) <nl> + { <nl> + setStencilTest ( parseBoolean ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " stencilWrite " ) = = 0 ) <nl> + { <nl> + setStencilWrite ( parseUInt ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " stencilFunc " ) = = 0 ) <nl> + { <nl> + setStencilFunction ( parseStencilFunc ( value ) , _stencilFunctionRef , _stencilFunctionMask ) ; <nl> + } <nl> + else if ( name . compare ( " stencilFuncRef " ) = = 0 ) <nl> + { <nl> + setStencilFunction ( _stencilFunction , parseInt ( value ) , _stencilFunctionMask ) ; <nl> + } <nl> + else if ( name . compare ( " stencilFuncMask " ) = = 0 ) <nl> + { <nl> + setStencilFunction ( _stencilFunction , _stencilFunctionRef , parseUInt ( value ) ) ; <nl> + } <nl> + else if ( name . compare ( " stencilOpSfail " ) = = 0 ) <nl> + { <nl> + setStencilOperation ( parseStencilOp ( value ) , _stencilOpDpfail , _stencilOpDppass ) ; <nl> + } <nl> + else if ( name . compare ( " stencilOpDpfail " ) = = 0 ) <nl> + { <nl> + setStencilOperation ( _stencilOpSfail , parseStencilOp ( value ) , _stencilOpDppass ) ; <nl> + } <nl> + else if ( name . compare ( " stencilOpDppass " ) = = 0 ) <nl> + { <nl> + setStencilOperation ( _stencilOpSfail , _stencilOpDpfail , parseStencilOp ( value ) ) ; <nl> + } <nl> + else <nl> + { <nl> + CCLOG ( " Unsupported render state string ' % s ' . " , name . c_str ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + bool RenderState : : StateBlock : : isDirty ( ) const <nl> + { <nl> + / / XXX <nl> + return true ; <nl> + } <nl> + <nl> + uint32_t RenderState : : StateBlock : : getHash ( ) const <nl> + { <nl> + / / XXX <nl> + return 0x12345678 ; <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setBlend ( bool enabled ) <nl> + { <nl> + _blendEnabled = enabled ; <nl> + if ( enabled ) <nl> + { <nl> + _bits & = ~ RS_BLEND ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_BLEND ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setBlendFunc ( const BlendFunc & blendFunc ) <nl> + { <nl> + if ( blendFunc = = BlendFunc : : DISABLE ) <nl> + { <nl> + setBlendSrc ( BLEND_ONE ) ; <nl> + setBlendDst ( BLEND_ZERO ) ; <nl> + } <nl> + else if ( blendFunc = = BlendFunc : : ALPHA_PREMULTIPLIED ) <nl> + { <nl> + setBlendSrc ( BLEND_ONE ) ; <nl> + setBlendDst ( BLEND_ONE_MINUS_SRC_ALPHA ) ; <nl> + } <nl> + else if ( blendFunc = = BlendFunc : : ALPHA_NON_PREMULTIPLIED ) <nl> + { <nl> + setBlendSrc ( BLEND_SRC_ALPHA ) ; <nl> + setBlendDst ( BLEND_ONE_MINUS_SRC_ALPHA ) ; <nl> + } <nl> + else if ( blendFunc = = BlendFunc : : ADDITIVE ) <nl> + { <nl> + setBlendSrc ( BLEND_SRC_ALPHA ) ; <nl> + setBlendDst ( BLEND_ONE ) ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setBlendSrc ( Blend blend ) <nl> + { <nl> + _blendSrc = blend ; <nl> + if ( _blendSrc = = BLEND_ONE & & _blendDst = = BLEND_ZERO ) <nl> + { <nl> + / / Default blend func <nl> + _bits & = ~ RS_BLEND_FUNC ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_BLEND_FUNC ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setBlendDst ( Blend blend ) <nl> + { <nl> + _blendDst = blend ; <nl> + if ( _blendSrc = = BLEND_ONE & & _blendDst = = BLEND_ZERO ) <nl> + { <nl> + / / Default blend func <nl> + _bits & = ~ RS_BLEND_FUNC ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_BLEND_FUNC ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setCullFace ( bool enabled ) <nl> + { <nl> + _cullFaceEnabled = enabled ; <nl> + if ( ! enabled ) <nl> + { <nl> + _bits & = ~ RS_CULL_FACE ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_CULL_FACE ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setCullFaceSide ( CullFaceSide side ) <nl> + { <nl> + _cullFaceSide = side ; <nl> + if ( _cullFaceSide = = CULL_FACE_SIDE_BACK ) <nl> + { <nl> + / / Default cull side <nl> + _bits & = ~ RS_CULL_FACE_SIDE ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_CULL_FACE_SIDE ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setFrontFace ( FrontFace winding ) <nl> + { <nl> + _frontFace = winding ; <nl> + if ( _frontFace = = FRONT_FACE_CCW ) <nl> + { <nl> + / / Default front face <nl> + _bits & = ~ RS_FRONT_FACE ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_FRONT_FACE ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setDepthTest ( bool enabled ) <nl> + { <nl> + _depthTestEnabled = enabled ; <nl> + if ( enabled ) <nl> + { <nl> + _bits & = ~ RS_DEPTH_TEST ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_DEPTH_TEST ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setDepthWrite ( bool enabled ) <nl> + { <nl> + _depthWriteEnabled = enabled ; <nl> + if ( ! enabled ) <nl> + { <nl> + _bits & = ~ RS_DEPTH_WRITE ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_DEPTH_WRITE ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setDepthFunction ( DepthFunction func ) <nl> + { <nl> + _depthFunction = func ; <nl> + if ( _depthFunction = = DEPTH_LESS ) <nl> + { <nl> + / / Default depth function <nl> + _bits & = ~ RS_DEPTH_FUNC ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_DEPTH_FUNC ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setStencilTest ( bool enabled ) <nl> + { <nl> + _stencilTestEnabled = enabled ; <nl> + if ( ! enabled ) <nl> + { <nl> + _bits & = ~ RS_STENCIL_TEST ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_STENCIL_TEST ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setStencilWrite ( unsigned int mask ) <nl> + { <nl> + _stencilWrite = mask ; <nl> + if ( mask = = RS_ALL_ONES ) <nl> + { <nl> + / / Default stencil write <nl> + _bits & = ~ RS_STENCIL_WRITE ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_STENCIL_WRITE ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setStencilFunction ( StencilFunction func , int ref , unsigned int mask ) <nl> + { <nl> + _stencilFunction = func ; <nl> + _stencilFunctionRef = ref ; <nl> + _stencilFunctionMask = mask ; <nl> + if ( func = = STENCIL_ALWAYS & & ref = = 0 & & mask = = RS_ALL_ONES ) <nl> + { <nl> + / / Default stencil function <nl> + _bits & = ~ RS_STENCIL_FUNC ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_STENCIL_FUNC ; <nl> + } <nl> + } <nl> + <nl> + void RenderState : : StateBlock : : setStencilOperation ( StencilOperation sfail , StencilOperation dpfail , StencilOperation dppass ) <nl> + { <nl> + _stencilOpSfail = sfail ; <nl> + _stencilOpDpfail = dpfail ; <nl> + _stencilOpDppass = dppass ; <nl> + if ( sfail = = STENCIL_OP_KEEP & & dpfail = = STENCIL_OP_KEEP & & dppass = = STENCIL_OP_KEEP ) <nl> + { <nl> + / / Default stencil operation <nl> + _bits & = ~ RS_STENCIL_OP ; <nl> + } <nl> + else <nl> + { <nl> + _bits | = RS_STENCIL_OP ; <nl> + } <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 48f768059141 <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCRenderState . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + Copyright ( c ) 2014 GamePlay3D team <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <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> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __cocos2d_libs__CCRenderState__ <nl> + # define __cocos2d_libs__CCRenderState__ <nl> + <nl> + # include < string > <nl> + # include < functional > <nl> + # include < cstdint > <nl> + <nl> + # include " renderer / CCTexture2D . h " <nl> + # include " platform / CCPlatformMacros . h " <nl> + # include " base / CCRef . h " <nl> + # include " base / ccTypes . h " <nl> + # include " base / CCVector . h " <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + class Texture2D ; <nl> + class Pass ; <nl> + <nl> + / * * <nl> + * Defines the rendering state of the graphics device . <nl> + * / <nl> + class CC_DLL RenderState : public Ref <nl> + { <nl> + friend class Material ; <nl> + friend class Technique ; <nl> + friend class Pass ; <nl> + <nl> + public : <nl> + / * * <nl> + * Static initializer that is called during game startup . <nl> + * / <nl> + static void initialize ( ) ; <nl> + <nl> + / * * <nl> + * Static finalizer that is called during game shutdown . <nl> + * / <nl> + static void finalize ( ) ; <nl> + <nl> + std : : string getName ( ) const ; <nl> + <nl> + <nl> + const Vector < Texture2D * > & getTextures ( ) const ; <nl> + <nl> + / * * Replaces the texture that is at the front of _textures array . <nl> + Added to be backwards compatible . <nl> + * / <nl> + void setTexture ( Texture2D * texture ) ; <nl> + <nl> + / * * Returns the texture that is at the front of the _textures array . <nl> + Added to be backwards compatible . <nl> + * / <nl> + Texture2D * getTexture ( ) const ; <nl> + <nl> + / * * <nl> + * Binds the render state for this RenderState and any of its parents , top - down , <nl> + * for the given pass . <nl> + * / <nl> + void bind ( Pass * pass ) ; <nl> + <nl> + / * * <nl> + * Returns the topmost RenderState in the hierarchy below the given RenderState . <nl> + * / <nl> + RenderState * getTopmost ( RenderState * below ) ; <nl> + <nl> + enum Blend <nl> + { <nl> + BLEND_ZERO = GL_ZERO , <nl> + BLEND_ONE = GL_ONE , <nl> + BLEND_SRC_COLOR = GL_SRC_COLOR , <nl> + BLEND_ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR , <nl> + BLEND_DST_COLOR = GL_DST_COLOR , <nl> + BLEND_ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR , <nl> + BLEND_SRC_ALPHA = GL_SRC_ALPHA , <nl> + BLEND_ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA , <nl> + BLEND_DST_ALPHA = GL_DST_ALPHA , <nl> + BLEND_ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA , <nl> + BLEND_CONSTANT_ALPHA = GL_CONSTANT_ALPHA , <nl> + BLEND_ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA , <nl> + BLEND_SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines the supported depth compare functions . <nl> + * <nl> + * Depth compare functions specify the comparison that takes place between the <nl> + * incoming pixel ' s depth value and the depth value already in the depth buffer . <nl> + * If the compare function passes , the new pixel will be drawn . <nl> + * <nl> + * The intial depth compare function is DEPTH_LESS . <nl> + * / <nl> + enum DepthFunction <nl> + { <nl> + DEPTH_NEVER = GL_NEVER , <nl> + DEPTH_LESS = GL_LESS , <nl> + DEPTH_EQUAL = GL_EQUAL , <nl> + DEPTH_LEQUAL = GL_LEQUAL , <nl> + DEPTH_GREATER = GL_GREATER , <nl> + DEPTH_NOTEQUAL = GL_NOTEQUAL , <nl> + DEPTH_GEQUAL = GL_GEQUAL , <nl> + DEPTH_ALWAYS = GL_ALWAYS <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines culling criteria for front - facing , back - facing and both - side <nl> + * facets . <nl> + * / <nl> + enum CullFaceSide <nl> + { <nl> + CULL_FACE_SIDE_BACK = GL_BACK , <nl> + CULL_FACE_SIDE_FRONT = GL_FRONT , <nl> + CULL_FACE_SIDE_FRONT_AND_BACK = GL_FRONT_AND_BACK <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines the winding of vertices in faces that are considered front facing . <nl> + * <nl> + * The initial front face mode is set to FRONT_FACE_CCW . <nl> + * / <nl> + enum FrontFace <nl> + { <nl> + FRONT_FACE_CW = GL_CW , <nl> + FRONT_FACE_CCW = GL_CCW <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines the supported stencil compare functions . <nl> + * <nl> + * Stencil compare functions determine if a new pixel will be drawn . <nl> + * <nl> + * The initial stencil compare function is STENCIL_ALWAYS . <nl> + * / <nl> + enum StencilFunction <nl> + { <nl> + STENCIL_NEVER = GL_NEVER , <nl> + STENCIL_ALWAYS = GL_ALWAYS , <nl> + STENCIL_LESS = GL_LESS , <nl> + STENCIL_LEQUAL = GL_LEQUAL , <nl> + STENCIL_EQUAL = GL_EQUAL , <nl> + STENCIL_GREATER = GL_GREATER , <nl> + STENCIL_GEQUAL = GL_GEQUAL , <nl> + STENCIL_NOTEQUAL = GL_NOTEQUAL <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines the supported stencil operations to perform . <nl> + * <nl> + * Stencil operations determine what should happen to the pixel if the <nl> + * stencil test fails , passes , or passes but fails the depth test . <nl> + * <nl> + * The initial stencil operation is STENCIL_OP_KEEP . <nl> + * / <nl> + enum StencilOperation <nl> + { <nl> + STENCIL_OP_KEEP = GL_KEEP , <nl> + STENCIL_OP_ZERO = GL_ZERO , <nl> + STENCIL_OP_REPLACE = GL_REPLACE , <nl> + STENCIL_OP_INCR = GL_INCR , <nl> + STENCIL_OP_DECR = GL_DECR , <nl> + STENCIL_OP_INVERT = GL_INVERT , <nl> + STENCIL_OP_INCR_WRAP = GL_INCR_WRAP , <nl> + STENCIL_OP_DECR_WRAP = GL_DECR_WRAP <nl> + } ; <nl> + <nl> + / * * <nl> + * Defines a block of fixed - function render states that can be applied to a <nl> + * RenderState object . <nl> + * / <nl> + class StateBlock : public Ref <nl> + { <nl> + friend class RenderState ; <nl> + friend class Pass ; <nl> + friend class RenderQueue ; <nl> + friend class Renderer ; <nl> + <nl> + public : <nl> + / * * <nl> + * Creates a new StateBlock with default render state settings . <nl> + * / <nl> + static StateBlock * create ( ) ; <nl> + <nl> + / * * <nl> + * Binds the state in this StateBlock to the renderer . <nl> + * <nl> + * This method handles both setting and restoring of render states to ensure that <nl> + * only the state explicitly defined by this StateBlock is applied to the renderer . <nl> + * / <nl> + void bind ( ) ; <nl> + <nl> + / * * <nl> + * Explicitly sets the source and destination used in the blend function for this render state . <nl> + * <nl> + * Note that the blend function is only applied when blending is enabled . <nl> + * <nl> + * @ param blendFunc Specifies how the blending factors are computed . <nl> + * / <nl> + void setBlendFunc ( const BlendFunc & blendFunc ) ; <nl> + <nl> + / * * <nl> + * Toggles blending . <nl> + * <nl> + * @ param enabled true to enable , false to disable . <nl> + * / <nl> + void setBlend ( bool enabled ) ; <nl> + <nl> + / * * <nl> + * Explicitly sets the source used in the blend function for this render state . <nl> + * <nl> + * Note that the blend function is only applied when blending is enabled . <nl> + * <nl> + * @ param blend Specifies how the source blending factors are computed . <nl> + * / <nl> + void setBlendSrc ( Blend blend ) ; <nl> + <nl> + / * * <nl> + * Explicitly sets the source used in the blend function for this render state . <nl> + * <nl> + * Note that the blend function is only applied when blending is enabled . <nl> + * <nl> + * @ param blend Specifies how the destination blending factors are computed . <nl> + * / <nl> + void setBlendDst ( Blend blend ) ; <nl> + <nl> + / * * <nl> + * Explicitly enables or disables backface culling . <nl> + * <nl> + * @ param enabled true to enable , false to disable . <nl> + * / <nl> + void setCullFace ( bool enabled ) ; <nl> + <nl> + / * * <nl> + * Sets the side of the facets to cull . <nl> + * <nl> + * When not explicitly set , the default is to cull back - facing facets . <nl> + * <nl> + * @ param side The side to cull . <nl> + * / <nl> + void setCullFaceSide ( CullFaceSide side ) ; <nl> + <nl> + / * * <nl> + * Sets the winding for front facing polygons . <nl> + * <nl> + * By default , counter - clockwise wound polygons are considered front facing . <nl> + * <nl> + * @ param winding The winding for front facing polygons . <nl> + * / <nl> + void setFrontFace ( FrontFace winding ) ; <nl> + <nl> + / * * <nl> + * Toggles depth testing . <nl> + * <nl> + * By default , depth testing is disabled . <nl> + * <nl> + * @ param enabled true to enable , false to disable . <nl> + * / <nl> + void setDepthTest ( bool enabled ) ; <nl> + <nl> + / * * <nl> + * Toggles depth writing . <nl> + * <nl> + * @ param enabled true to enable , false to disable . <nl> + * / <nl> + void setDepthWrite ( bool enabled ) ; <nl> + <nl> + / * * <nl> + * Sets the depth function to use when depth testing is enabled . <nl> + * <nl> + * When not explicitly set and when depth testing is enabled , the default <nl> + * depth function is DEPTH_LESS . <nl> + * <nl> + * @ param func The depth function . <nl> + * / <nl> + void setDepthFunction ( DepthFunction func ) ; <nl> + <nl> + / * * <nl> + * Toggles stencil testing . <nl> + * <nl> + * By default , stencil testing is disabled . <nl> + * <nl> + * @ param enabled true to enable , false to disable . <nl> + * / <nl> + void setStencilTest ( bool enabled ) ; <nl> + <nl> + / * * <nl> + * Sets the stencil writing mask . <nl> + * <nl> + * By default , the stencil writing mask is all 1 ' s . <nl> + * <nl> + * @ param mask Bit mask controlling writing to individual stencil planes . <nl> + * / <nl> + void setStencilWrite ( unsigned int mask ) ; <nl> + <nl> + / * * <nl> + * Sets the stencil function . <nl> + * <nl> + * By default , the function is set to STENCIL_ALWAYS , the reference value is 0 , and the mask is all 1 ' s . <nl> + * <nl> + * @ param func The stencil function . <nl> + * @ param ref The stencil reference value . <nl> + * @ param mask The stencil mask . <nl> + * / <nl> + void setStencilFunction ( StencilFunction func , int ref , unsigned int mask ) ; <nl> + <nl> + / * * <nl> + * Sets the stencil operation . <nl> + * <nl> + * By default , stencil fail , stencil pass / depth fail , and stencil and depth pass are set to STENCIL_OP_KEEP . <nl> + * <nl> + * @ param sfail The stencil operation if the stencil test fails . <nl> + * @ param dpfail The stencil operation if the stencil test passes , but the depth test fails . <nl> + * @ param dppass The stencil operation if both the stencil test and depth test pass . <nl> + * / <nl> + void setStencilOperation ( StencilOperation sfail , StencilOperation dpfail , StencilOperation dppass ) ; <nl> + <nl> + / * * <nl> + * Sets a render state from the given name and value strings . <nl> + * <nl> + * This method attempts to interpret the passed in strings as render state <nl> + * name and value . This is normally used when loading render states from <nl> + * material files . <nl> + * <nl> + * @ param name Name of the render state to set . <nl> + * @ param value Value of the specified render state . <nl> + * / <nl> + void setState ( const std : : string & name , const std : : string & value ) ; <nl> + <nl> + uint32_t getHash ( ) const ; <nl> + bool isDirty ( ) const ; <nl> + <nl> + protected : <nl> + StateBlock ( ) ; <nl> + ~ StateBlock ( ) ; <nl> + <nl> + void bindNoRestore ( ) ; <nl> + static void restore ( long stateOverrideBits ) ; <nl> + static void enableDepthWrite ( ) ; <nl> + <nl> + bool _cullFaceEnabled ; <nl> + bool _depthTestEnabled ; <nl> + bool _depthWriteEnabled ; <nl> + DepthFunction _depthFunction ; <nl> + bool _blendEnabled ; <nl> + Blend _blendSrc ; <nl> + Blend _blendDst ; <nl> + CullFaceSide _cullFaceSide ; <nl> + FrontFace _frontFace ; <nl> + bool _stencilTestEnabled ; <nl> + unsigned int _stencilWrite ; <nl> + StencilFunction _stencilFunction ; <nl> + int _stencilFunctionRef ; <nl> + unsigned int _stencilFunctionMask ; <nl> + StencilOperation _stencilOpSfail ; <nl> + StencilOperation _stencilOpDpfail ; <nl> + StencilOperation _stencilOpDppass ; <nl> + <nl> + long _bits ; <nl> + <nl> + static StateBlock * _defaultState ; <nl> + <nl> + mutable uint32_t _hash ; <nl> + mutable bool _hashDirty ; <nl> + } ; <nl> + <nl> + void setStateBlock ( StateBlock * state ) ; <nl> + StateBlock * getStateBlock ( ) const ; <nl> + <nl> + protected : <nl> + RenderState ( ) ; <nl> + ~ RenderState ( ) ; <nl> + bool init ( RenderState * parent ) ; <nl> + <nl> + mutable uint32_t _hash ; <nl> + mutable bool _hashDirty ; <nl> + <nl> + / * * <nl> + * The StateBlock of fixed - function render states that can be applied to the RenderState . <nl> + * / <nl> + mutable StateBlock * _state ; <nl> + <nl> + / * * <nl> + * The RenderState ' s parent . Weak Reference <nl> + * / <nl> + RenderState * _parent ; <nl> + <nl> + / / name , for filtering <nl> + std : : string _name ; <nl> + <nl> + Vector < Texture2D * > _textures ; <nl> + } ; <nl> + <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __cocos2d_libs__CCRenderState__ ) * / <nl> mmm a / cocos / renderer / CCRenderer . cpp <nl> ppp b / cocos / renderer / CCRenderer . cpp <nl> <nl> # include " renderer / CCCustomCommand . h " <nl> # include " renderer / CCGroupCommand . h " <nl> # include " renderer / CCPrimitiveCommand . h " <nl> + # include " renderer / CCMeshCommand . h " <nl> # include " renderer / CCGLProgramCache . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCPass . h " <nl> + # include " renderer / CCRenderState . h " <nl> # include " renderer / ccGLStateCache . h " <nl> - # include " renderer / CCMeshCommand . h " <nl> + <nl> # include " base / CCConfiguration . h " <nl> # include " base / CCDirector . h " <nl> # include " base / CCEventDispatcher . h " <nl> void RenderQueue : : restoreRenderState ( ) <nl> if ( _isCullEnabled ) <nl> { <nl> glEnable ( GL_CULL_FACE ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setCullFace ( true ) ; <nl> } <nl> else <nl> { <nl> glDisable ( GL_CULL_FACE ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setCullFace ( false ) ; <nl> } <nl> <nl> <nl> if ( _isDepthEnabled ) <nl> { <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> } <nl> else <nl> { <nl> glDisable ( GL_DEPTH_TEST ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( false ) ; <nl> } <nl> <nl> glDepthMask ( _isDepthWrite ) ; <nl> - <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( _isDepthEnabled ) ; <nl> + <nl> CHECK_GL_ERROR_DEBUG ( ) ; <nl> } <nl> <nl> void Renderer : : visitRenderQueue ( RenderQueue & queue ) <nl> { <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> glDepthMask ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( true ) ; <nl> } <nl> else <nl> { <nl> glDisable ( GL_DEPTH_TEST ) ; <nl> glDepthMask ( false ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( false ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( false ) ; <nl> } <nl> for ( auto it = zNegQueue . cbegin ( ) ; it ! = zNegQueue . cend ( ) ; + + it ) <nl> { <nl> void Renderer : : visitRenderQueue ( RenderQueue & queue ) <nl> if ( opaqueQueue . size ( ) > 0 ) <nl> { <nl> / / Clear depth to achieve layered rendering <nl> - glDepthMask ( true ) ; <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> - <nl> + glDepthMask ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( true ) ; <nl> + <nl> + <nl> for ( auto it = opaqueQueue . cbegin ( ) ; it ! = opaqueQueue . cend ( ) ; + + it ) <nl> { <nl> processRenderCommand ( * it ) ; <nl> void Renderer : : visitRenderQueue ( RenderQueue & queue ) <nl> { <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> glDepthMask ( false ) ; <nl> - <nl> + <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( false ) ; <nl> + <nl> + <nl> for ( auto it = transQueue . cbegin ( ) ; it ! = transQueue . cend ( ) ; + + it ) <nl> { <nl> processRenderCommand ( * it ) ; <nl> void Renderer : : visitRenderQueue ( RenderQueue & queue ) <nl> { <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> glDepthMask ( true ) ; <nl> + <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( true ) ; <nl> + <nl> } <nl> else <nl> { <nl> glDisable ( GL_DEPTH_TEST ) ; <nl> glDepthMask ( false ) ; <nl> + <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( false ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthWrite ( false ) ; <nl> + <nl> } <nl> for ( auto it = zZeroQueue . cbegin ( ) ; it ! = zZeroQueue . cend ( ) ; + + it ) <nl> { <nl> void Renderer : : setDepthTest ( bool enable ) <nl> glClearDepth ( 1 . 0f ) ; <nl> glEnable ( GL_DEPTH_TEST ) ; <nl> glDepthFunc ( GL_LEQUAL ) ; <nl> + <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( true ) ; <nl> + RenderState : : StateBlock : : _defaultState - > setDepthFunction ( RenderState : : DEPTH_LEQUAL ) ; <nl> + <nl> / / glHint ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ) ; <nl> } <nl> else <nl> { <nl> glDisable ( GL_DEPTH_TEST ) ; <nl> + <nl> + RenderState : : StateBlock : : _defaultState - > setDepthTest ( false ) ; <nl> } <nl> - <nl> + <nl> _isDepthTestFor2D = enable ; <nl> CHECK_GL_ERROR_DEBUG ( ) ; <nl> } <nl> void Renderer : : drawBatchedQuads ( ) <nl> { <nl> / / TODO : we can improve the draw performance by insert material switching command before hand . <nl> <nl> - int indexToDraw = 0 ; <nl> + ssize_t indexToDraw = 0 ; <nl> int startIndex = 0 ; <nl> <nl> / / Upload buffer to VBO <nl> void Renderer : : drawBatchedQuads ( ) <nl> <nl> glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , _quadbuffersVBO [ 1 ] ) ; <nl> } <nl> - <nl> - / / Start drawing verties in batch <nl> + <nl> + <nl> + / / FIXME : The logic of this code is confusing , and error prone <nl> + / / Needs refactoring <nl> + <nl> + / / Start drawing vertices in batch <nl> for ( const auto & cmd : _batchQuadCommands ) <nl> { <nl> + bool commandQueued = true ; <nl> auto newMaterialID = cmd - > getMaterialID ( ) ; <nl> if ( _lastMaterialID ! = newMaterialID | | newMaterialID = = MATERIAL_ID_DO_NOT_BATCH ) <nl> { <nl> - / / Draw quads <nl> + / / flush buffer <nl> if ( indexToDraw > 0 ) <nl> { <nl> glDrawElements ( GL_TRIANGLES , ( GLsizei ) indexToDraw , GL_UNSIGNED_SHORT , ( GLvoid * ) ( startIndex * sizeof ( _indices [ 0 ] ) ) ) ; <nl> void Renderer : : drawBatchedQuads ( ) <nl> } <nl> <nl> / / Use new material <nl> - cmd - > useMaterial ( ) ; <nl> _lastMaterialID = newMaterialID ; <nl> + <nl> + if ( cmd - > isMultiplePass ( ) ) { <nl> + <nl> + indexToDraw = cmd - > getQuadCount ( ) * 6 ; <nl> + <nl> + for ( auto & pass : cmd - > getMaterial ( ) - > _currentTechnique - > _passes ) { <nl> + <nl> + pass - > bind ( cmd - > getModelView ( ) ) ; <nl> + <nl> + glDrawElements ( GL_TRIANGLES , ( GLsizei ) indexToDraw , GL_UNSIGNED_SHORT , ( GLvoid * ) ( startIndex * sizeof ( _indices [ 0 ] ) ) ) ; <nl> + _drawnBatches + + ; <nl> + _drawnVertices + = indexToDraw ; <nl> + <nl> + pass - > unbind ( ) ; <nl> + } <nl> + <nl> + indexToDraw = 0 ; <nl> + commandQueued = false ; <nl> + <nl> + } else { <nl> + cmd - > useMaterial ( ) ; <nl> + } <nl> + } <nl> + <nl> + if ( commandQueued ) <nl> + { <nl> + indexToDraw + = cmd - > getQuadCount ( ) * 6 ; <nl> } <nl> - <nl> - indexToDraw + = cmd - > getQuadCount ( ) * 6 ; <nl> } <nl> <nl> / / Draw any remaining quad <nl> new file mode 100644 <nl> index 000000000000 . . e006780058bb <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCTechnique . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # include " renderer / CCTechnique . h " <nl> + # include " renderer / CCGLProgramState . h " <nl> + # include " renderer / CCMaterial . h " <nl> + # include " renderer / CCPass . h " <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + Technique * Technique : : createWithGLProgramState ( Material * parent , GLProgramState * state ) <nl> + { <nl> + auto technique = new ( std : : nothrow ) Technique ( ) ; <nl> + if ( technique & & technique - > init ( parent ) ) <nl> + { <nl> + auto pass = Pass : : createWithGLProgramState ( technique , state ) ; <nl> + technique - > addPass ( pass ) ; <nl> + <nl> + technique - > autorelease ( ) ; <nl> + return technique ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + Technique * Technique : : create ( Material * material ) <nl> + { <nl> + auto technique = new ( std : : nothrow ) Technique ( ) ; <nl> + if ( technique & & technique - > init ( material ) ) <nl> + { <nl> + technique - > autorelease ( ) ; <nl> + return technique ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + Technique : : Technique ( ) <nl> + : _name ( " " ) <nl> + { <nl> + } <nl> + <nl> + Technique : : ~ Technique ( ) <nl> + { <nl> + } <nl> + <nl> + bool Technique : : init ( Material * parent ) <nl> + { <nl> + _parent = parent ; <nl> + return true ; <nl> + } <nl> + <nl> + void Technique : : addPass ( Pass * pass ) <nl> + { <nl> + _passes . pushBack ( pass ) ; <nl> + } <nl> + <nl> + std : : string Technique : : getName ( ) const <nl> + { <nl> + return _name ; <nl> + } <nl> + <nl> + void Technique : : setName ( const std : : string & name ) <nl> + { <nl> + _name = name ; <nl> + } <nl> + <nl> + Pass * Technique : : getPassByIndex ( ssize_t index ) const <nl> + { <nl> + CC_ASSERT ( index > = 0 & & index < _passes . size ( ) & & " Invalid index " ) ; <nl> + return _passes . at ( index ) ; <nl> + } <nl> + <nl> + ssize_t Technique : : getPassCount ( ) const <nl> + { <nl> + return _passes . size ( ) ; <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 5c7f0b8aeedd <nl> mmm / dev / null <nl> ppp b / cocos / renderer / CCTechnique . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + <nl> + Ideas taken from : <nl> + - GamePlay3D : http : / / gameplay3d . org / <nl> + - OGRE3D : http : / / www . ogre3d . org / <nl> + - Qt3D : http : / / qt - project . org / <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __cocos2d_libs__CCTechnique__ <nl> + # define __cocos2d_libs__CCTechnique__ <nl> + <nl> + # include < string > <nl> + # include " renderer / CCRenderState . h " <nl> + # include " renderer / CCPass . h " <nl> + # include " base / CCRef . h " <nl> + # include " platform / CCPlatformMacros . h " <nl> + # include " base / CCVector . h " <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + class Pass ; <nl> + class GLProgramState ; <nl> + class Material ; <nl> + <nl> + / / / Technique <nl> + class CC_DLL Technique : public RenderState <nl> + { <nl> + friend class Material ; <nl> + friend class Renderer ; <nl> + friend class Pass ; <nl> + friend class MeshCommand ; <nl> + friend class Mesh ; <nl> + <nl> + public : <nl> + / * * Creates a new Technique with a GLProgramState . <nl> + Method added to support legacy code <nl> + * / <nl> + static Technique * createWithGLProgramState ( Material * parent , GLProgramState * state ) ; <nl> + static Technique * create ( Material * parent ) ; <nl> + <nl> + / * * Adds a new pass to the Technique . <nl> + Order matters . First added , first rendered <nl> + * / <nl> + void addPass ( Pass * pass ) ; <nl> + <nl> + / * * Returns the name of the Technique * / <nl> + std : : string getName ( ) const ; <nl> + <nl> + / * * Returns the Pass at given index * / <nl> + Pass * getPassByIndex ( ssize_t index ) const ; <nl> + <nl> + / * * Returns the number of Passes in the Technique * / <nl> + ssize_t getPassCount ( ) const ; <nl> + <nl> + protected : <nl> + Technique ( ) ; <nl> + ~ Technique ( ) ; <nl> + bool init ( Material * parent ) ; <nl> + <nl> + void setName ( const std : : string & name ) ; <nl> + <nl> + std : : string _name ; <nl> + Vector < Pass * > _passes ; <nl> + } ; <nl> + <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __cocos2d_libs__CCTechnique__ ) * / <nl> mmm a / cocos / renderer / CMakeLists . txt <nl> ppp b / cocos / renderer / CMakeLists . txt <nl> <nl> <nl> set ( COCOS_RENDERER_SRC <nl> - <nl> renderer / CCBatchCommand . cpp <nl> renderer / CCCustomCommand . cpp <nl> renderer / CCGLProgram . cpp <nl> set ( COCOS_RENDERER_SRC <nl> renderer / CCGLProgramState . cpp <nl> renderer / CCGLProgramStateCache . cpp <nl> renderer / CCGroupCommand . cpp <nl> + renderer / CCMaterial . cpp <nl> renderer / CCMeshCommand . cpp <nl> + renderer / CCPass . cpp <nl> renderer / CCPrimitive . cpp <nl> renderer / CCPrimitiveCommand . cpp <nl> renderer / CCQuadCommand . cpp <nl> renderer / CCRenderCommand . cpp <nl> + renderer / CCRenderState . cpp <nl> renderer / CCRenderer . cpp <nl> + renderer / CCTechnique . cpp <nl> renderer / CCTexture2D . cpp <nl> renderer / CCTextureAtlas . cpp <nl> renderer / CCTextureCache . cpp <nl> set ( COCOS_RENDERER_SRC <nl> renderer / CCVertexIndexData . cpp <nl> renderer / ccGLStateCache . cpp <nl> renderer / ccShaders . cpp <nl> - <nl> ) <nl> mmm a / extensions / Particle3D / CCParticle3DRender . cpp <nl> ppp b / extensions / Particle3D / CCParticle3DRender . cpp <nl> void Particle3DQuadRender : : render ( Renderer * renderer , const Mat4 & transform , Par <nl> GLuint texId = ( _texture ? _texture - > getName ( ) : 0 ) ; <nl> float depthZ = - ( viewMat . m [ 2 ] * transform . m [ 12 ] + viewMat . m [ 6 ] * transform . m [ 13 ] + viewMat . m [ 10 ] * transform . m [ 14 ] + viewMat . m [ 14 ] ) ; <nl> _meshCommand - > init ( depthZ , texId , _glProgramState , particleSystem - > getBlendFunc ( ) , _vertexBuffer - > getVBO ( ) , _indexBuffer - > getVBO ( ) , GL_TRIANGLES , GL_UNSIGNED_SHORT , index , transform , 0 ) ; <nl> + _glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( 1 , 1 , 1 , 1 ) ) ; <nl> renderer - > addCommand ( _meshCommand ) ; <nl> } <nl> <nl> mmm a / extensions / Particle3D / PU / CCPUBillboardChain . cpp <nl> ppp b / extensions / Particle3D / PU / CCPUBillboardChain . cpp <nl> void PUBillboardChain : : render ( Renderer * renderer , const Mat4 & transform , Partic <nl> GLuint texId = ( _texture ? _texture - > getName ( ) : 0 ) ; <nl> _meshCommand - > init ( 0 , texId , _glProgramState , particleSystem - > getBlendFunc ( ) , _vertexBuffer - > getVBO ( ) , _indexBuffer - > getVBO ( ) , GL_TRIANGLES , GL_UNSIGNED_SHORT , _indices . size ( ) , transform , Node : : FLAGS_RENDER_AS_3D ) ; <nl> _meshCommand - > setTransparent ( true ) ; <nl> + _glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( 1 , 1 , 1 , 1 ) ) ; <nl> renderer - > addCommand ( _meshCommand ) ; <nl> } <nl> } <nl> mmm a / extensions / Particle3D / PU / CCPURender . cpp <nl> ppp b / extensions / Particle3D / PU / CCPURender . cpp <nl> void PUParticle3DQuadRender : : render ( Renderer * renderer , const Mat4 & transform , P <nl> GLuint texId = ( _texture ? _texture - > getName ( ) : 0 ) ; <nl> _meshCommand - > init ( 0 , texId , _glProgramState , particleSystem - > getBlendFunc ( ) , _vertexBuffer - > getVBO ( ) , _indexBuffer - > getVBO ( ) , GL_TRIANGLES , GL_UNSIGNED_SHORT , index , transform , Node : : FLAGS_RENDER_AS_3D ) ; <nl> _meshCommand - > setTransparent ( true ) ; <nl> + _glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( 1 , 1 , 1 , 1 ) ) ; <nl> renderer - > addCommand ( _meshCommand ) ; <nl> } <nl> } <nl> void PUParticle3DBoxRender : : render ( Renderer * renderer , const Mat4 & transform , P <nl> GLuint texId = ( _texture ? _texture - > getName ( ) : 0 ) ; <nl> _meshCommand - > init ( 0 , texId , _glProgramState , particleSystem - > getBlendFunc ( ) , _vertexBuffer - > getVBO ( ) , _indexBuffer - > getVBO ( ) , GL_TRIANGLES , GL_UNSIGNED_SHORT , index , transform , Node : : FLAGS_RENDER_AS_3D ) ; <nl> _meshCommand - > setTransparent ( true ) ; <nl> + _glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( 1 , 1 , 1 , 1 ) ) ; <nl> renderer - > addCommand ( _meshCommand ) ; <nl> } <nl> } <nl> void PUSphereRender : : render ( Renderer * renderer , const Mat4 & transform , Particle <nl> GLuint texId = ( _texture ? _texture - > getName ( ) : 0 ) ; <nl> _meshCommand - > init ( 0 , texId , _glProgramState , particleSystem - > getBlendFunc ( ) , _vertexBuffer - > getVBO ( ) , _indexBuffer - > getVBO ( ) , GL_TRIANGLES , GL_UNSIGNED_SHORT , index , transform , Node : : FLAGS_RENDER_AS_3D ) ; <nl> _meshCommand - > setTransparent ( true ) ; <nl> + _glProgramState - > setUniformVec4 ( " u_color " , Vec4 ( 1 , 1 , 1 , 1 ) ) ; <nl> renderer - > addCommand ( _meshCommand ) ; <nl> } <nl> } <nl> mmm a / tests / cpp - tests / CMakeLists . txt <nl> ppp b / tests / cpp - tests / CMakeLists . txt <nl> else ( ) <nl> endif ( ) <nl> <nl> set ( TESTS_SRC <nl> - Classes / CocosStudio3DTest / CocosStudio3DTest . cpp <nl> Classes / ActionManagerTest / ActionManagerTest . cpp <nl> Classes / ActionsEaseTest / ActionsEaseTest . cpp <nl> Classes / ActionsProgressTest / ActionsProgressTest . cpp <nl> Classes / ActionsTest / ActionsTest . cpp <nl> Classes / AllocatorTest / AllocatorTest . cpp <nl> + Classes / AppDelegate . cpp <nl> + Classes / BaseTest . cpp <nl> Classes / BillBoardTest / BillBoardTest . cpp <nl> Classes / BugsTest / Bug - 1159 . cpp <nl> Classes / BugsTest / Bug - 1174 . cpp <nl> set ( TESTS_SRC <nl> Classes / BugsTest / Bug - 886 . cpp <nl> Classes / BugsTest / Bug - 899 . cpp <nl> Classes / BugsTest / Bug - 914 . cpp <nl> - Classes / BugsTest / BugsTest . cpp <nl> Classes / BugsTest / Bug - Child . cpp <nl> + Classes / BugsTest / BugsTest . cpp <nl> Classes / Camera3DTest / Camera3DTest . cpp <nl> Classes / ChipmunkTest / ChipmunkTest . cpp <nl> Classes / ClickAndMoveTest / ClickAndMoveTest . cpp <nl> Classes / ClippingNodeTest / ClippingNodeTest . cpp <nl> Classes / CocosDenshionTest / CocosDenshionTest . cpp <nl> + Classes / CocosStudio3DTest / CocosStudio3DTest . cpp <nl> + Classes / CocosStudio3DTest / CocosStudio3DTest . cpp <nl> + Classes / ConfigurationTest / ConfigurationTest . cpp <nl> + Classes / ConsoleTest / ConsoleTest . cpp <nl> Classes / CurlTest / CurlTest . cpp <nl> Classes / CurrentLanguageTest / CurrentLanguageTest . cpp <nl> + Classes / DataVisitorTest / DataVisitorTest . cpp <nl> Classes / DrawPrimitivesTest / DrawPrimitivesTest . cpp <nl> Classes / EffectsAdvancedTest / EffectsAdvancedTest . cpp <nl> Classes / EffectsTest / EffectsTest . cpp <nl> Classes / ExtensionsTest / AssetsManagerExTest / AssetsManagerExTest . cpp <nl> + Classes / ExtensionsTest / CocoStudioActionTimelineTest / ActionTimelineTestScene . cpp <nl> + Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / ComponentsTestScene . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / EnemyController . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / GameOverScene . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / PlayerController . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / ProjectileController . cpp <nl> + Classes / ExtensionsTest / CocoStudioComponentsTest / SceneController . cpp <nl> + Classes / ExtensionsTest / CocoStudioSceneTest / SceneEditorTest . cpp <nl> + Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / acts . cpp <nl> + Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / cons . cpp <nl> + Classes / ExtensionsTest / CocosBuilderTest / AnimationsTest / AnimationsTestLayer . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / ButtonTest / ButtonTestLayer . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / CocosBuilderTest . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / HelloCocosBuilder / HelloCocosBuilderLayer . cpp <nl> - Classes / ExtensionsTest / CocosBuilderTest / AnimationsTest / AnimationsTestLayer . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / MenuTest / MenuTestLayer . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / TestHeader / TestHeaderLayer . cpp <nl> Classes / ExtensionsTest / CocosBuilderTest / TimelineCallbackTest / TimelineCallbackTestLayer . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlButtonTest / CCControlButtonTest . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlColourPicker / CCControlColourPickerTest . cpp <nl> + Classes / ExtensionsTest / ControlExtensionTest / CCControlPotentiometerTest / CCControlPotentiometerTest . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlScene . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlSceneManager . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlSliderTest / CCControlSliderTest . cpp <nl> - Classes / ExtensionsTest / ControlExtensionTest / CCControlSwitchTest / CCControlSwitchTest . cpp <nl> - Classes / ExtensionsTest / ControlExtensionTest / CCControlPotentiometerTest / CCControlPotentiometerTest . cpp <nl> Classes / ExtensionsTest / ControlExtensionTest / CCControlStepperTest / CCControlStepperTest . cpp <nl> - Classes / ExtensionsTest / TableViewTest / TableViewTestScene . cpp <nl> - Classes / ExtensionsTest / TableViewTest / CustomTableViewCell . cpp <nl> + Classes / ExtensionsTest / ControlExtensionTest / CCControlSwitchTest / CCControlSwitchTest . cpp <nl> Classes / ExtensionsTest / ExtensionsTest . cpp <nl> - Classes / ExtensionsTest / NotificationCenterTest / NotificationCenterTest . cpp <nl> Classes / ExtensionsTest / NetworkTest / HttpClientTest . cpp <nl> - Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp <nl> - Classes / ExtensionsTest / CocoStudioActionTimelineTest / ActionTimelineTestScene . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / ComponentsTestScene . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / EnemyController . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / GameOverScene . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / PlayerController . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / ProjectileController . cpp <nl> - Classes / ExtensionsTest / CocoStudioComponentsTest / SceneController . cpp <nl> - Classes / ExtensionsTest / CocoStudioSceneTest / SceneEditorTest . cpp <nl> - Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / acts . cpp <nl> - Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / cons . cpp <nl> - Classes / UITest / CocoStudioGUITest / CocoStudioGUITest . cpp <nl> - Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp <nl> - Classes / UITest / CocoStudioGUITest / GUIEditorTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomGUIScene . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIScene . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIScale9SpriteTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UISceneManager . cpp <nl> - Classes / UITest / CocoStudioGUITest / CocostudioParserTest / CocostudioParserJsonTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / CocostudioParserTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIFocusTest / UIFocusTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIRichTextTest / UIRichTextTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIScene_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UISceneManager_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest_Editor . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageView . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageViewReader . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidget . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidgetReader . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomWidget / CustomReader . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomTest / CustomImageTest / CustomImageTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomTest / CustomParticleWidgetTest / CustomParticleWidgetTest . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNode . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNodeReader . cpp <nl> - Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomWidgetCallbackBindTest . cpp <nl> - Classes / NewRendererTest / NewRendererTest . cpp <nl> - Classes / NewEventDispatcherTest / NewEventDispatcherTest . cpp <nl> - Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> + Classes / ExtensionsTest / NotificationCenterTest / NotificationCenterTest . cpp <nl> + Classes / ExtensionsTest / TableViewTest / CustomTableViewCell . cpp <nl> + Classes / ExtensionsTest / TableViewTest / TableViewTestScene . cpp <nl> + Classes / FileUtilsTest / FileUtilsTest . cpp <nl> Classes / FontTest / FontTest . cpp <nl> - Classes / IntervalTest / IntervalTest . cpp <nl> Classes / InputTest / MouseTest . cpp <nl> + Classes / IntervalTest / IntervalTest . cpp <nl> Classes / LabelTest / LabelTest . cpp <nl> Classes / LabelTest / LabelTestNew . cpp <nl> Classes / LayerTest / LayerTest . cpp <nl> Classes / LightTest / LightTest . cpp <nl> + Classes / MaterialSystemTest / MaterialSystemTest <nl> Classes / MenuTest / MenuTest . cpp <nl> Classes / MotionStreakTest / MotionStreakTest . cpp <nl> Classes / MutiTouchTest / MutiTouchTest . cpp <nl> + Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> + Classes / NewEventDispatcherTest / NewEventDispatcherTest . cpp <nl> + Classes / NewRendererTest / NewRendererTest . cpp <nl> Classes / NodeTest / NodeTest . cpp <nl> Classes / OpenURLTest / OpenURLTest . cpp <nl> Classes / ParallaxTest / ParallaxTest . cpp <nl> - Classes / ParticleTest / ParticleTest . cpp <nl> Classes / Particle3DTest / Particle3DTest . cpp <nl> - Classes / CocosStudio3DTest / CocosStudio3DTest . cpp <nl> + Classes / ParticleTest / ParticleTest . cpp <nl> Classes / PerformanceTest / PerformanceAllocTest . cpp <nl> + Classes / PerformanceTest / PerformanceCallbackTest . cpp <nl> + Classes / PerformanceTest / PerformanceContainerTest . cpp <nl> + Classes / PerformanceTest / PerformanceEventDispatcherTest . cpp <nl> + Classes / PerformanceTest / PerformanceLabelTest . cpp <nl> + Classes / PerformanceTest / PerformanceMathTest . cpp <nl> Classes / PerformanceTest / PerformanceNodeChildrenTest . cpp <nl> - Classes / PerformanceTest / PerformanceParticleTest . cpp <nl> Classes / PerformanceTest / PerformanceParticle3DTest . cpp <nl> + Classes / PerformanceTest / PerformanceParticleTest . cpp <nl> + Classes / PerformanceTest / PerformanceRendererTest . cpp <nl> + Classes / PerformanceTest / PerformanceScenarioTest . cpp <nl> Classes / PerformanceTest / PerformanceSpriteTest . cpp <nl> Classes / PerformanceTest / PerformanceTest . cpp <nl> Classes / PerformanceTest / PerformanceTextureTest . cpp <nl> Classes / PerformanceTest / PerformanceTouchesTest . cpp <nl> - Classes / PerformanceTest / PerformanceLabelTest . cpp <nl> - Classes / PerformanceTest / PerformanceRendererTest . cpp <nl> - Classes / PerformanceTest / PerformanceContainerTest . cpp <nl> - Classes / PerformanceTest / PerformanceEventDispatcherTest . cpp <nl> - Classes / PerformanceTest / PerformanceScenarioTest . cpp <nl> - Classes / PerformanceTest / PerformanceCallbackTest . cpp <nl> - Classes / PerformanceTest / PerformanceMathTest . cpp <nl> Classes / PhysicsTest / PhysicsTest . cpp <nl> Classes / ReleasePoolTest / ReleasePoolTest . cpp <nl> Classes / RenderTextureTest / RenderTextureTest . cpp <nl> set ( TESTS_SRC <nl> Classes / SchedulerTest / SchedulerTest . cpp <nl> Classes / ShaderTest / ShaderTest . cpp <nl> Classes / ShaderTest / ShaderTest2 . cpp <nl> - Classes / SpriteTest / SpriteTest . cpp <nl> - Classes / SpritePolygonTest / SpritePolygonTest . cpp <nl> - Classes / Sprite3DTest / Sprite3DTest . cpp <nl> + Classes / SpineTest / SpineTest . cpp <nl> Classes / Sprite3DTest / DrawNode3D . cpp <nl> + Classes / Sprite3DTest / Sprite3DTest . cpp <nl> + Classes / SpritePolygonTest / SpritePolygonTest . cpp <nl> + Classes / SpriteTest / SpriteTest . cpp <nl> Classes / TerrainTest / TerrainTest . cpp <nl> Classes / TextInputTest / TextInputTest . cpp <nl> Classes / Texture2dTest / Texture2dTest . cpp <nl> - Classes / TexturePackerEncryptionTest / TextureAtlasEncryptionTest . cpp <nl> Classes / TextureCacheTest / TextureCacheTest . cpp <nl> + Classes / TexturePackerEncryptionTest / TextureAtlasEncryptionTest . cpp <nl> Classes / TileMapTest / TileMapTest . cpp <nl> Classes / TileMapTest / TileMapTest2 . cpp <nl> Classes / TouchesTest / Ball . cpp <nl> Classes / TouchesTest / Paddle . cpp <nl> Classes / TouchesTest / TouchesTest . cpp <nl> Classes / TransitionsTest / TransitionsTest . cpp <nl> - Classes / UserDefaultTest / UserDefaultTest . cpp <nl> - Classes / ZwoptexTest / ZwoptexTest . cpp <nl> - Classes / FileUtilsTest / FileUtilsTest . cpp <nl> - Classes / SpineTest / SpineTest . cpp <nl> - Classes / DataVisitorTest / DataVisitorTest . cpp <nl> - Classes / ConfigurationTest / ConfigurationTest . cpp <nl> - Classes / ConsoleTest / ConsoleTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CocoStudioGUITest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp <nl> + Classes / UITest / CocoStudioGUITest / CocostudioParserTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CocostudioParserTest / CocostudioParserJsonTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomGUIScene . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomTest / CustomImageTest / CustomImageTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomTest / CustomParticleWidgetTest / CustomParticleWidgetTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNode . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNodeReader . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomWidgetCallbackBindTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageView . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageViewReader . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidget . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidgetReader . cpp <nl> + Classes / UITest / CocoStudioGUITest / CustomWidget / CustomReader . cpp <nl> + Classes / UITest / CocoStudioGUITest / GUIEditorTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIFocusTest / UIFocusTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIRichTextTest / UIRichTextTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIScale9SpriteTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIScene . cpp <nl> + Classes / UITest / CocoStudioGUITest / UISceneManager . cpp <nl> + Classes / UITest / CocoStudioGUITest / UISceneManager_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIScene_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest_Editor . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . cpp <nl> + Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest_Editor . cpp <nl> + Classes / UITest / UITest . cpp <nl> Classes / UnitTest / RefPtrTest . cpp <nl> Classes / UnitTest / UnitTest . cpp <nl> - Classes / UITest / UITest . cpp <nl> + Classes / UserDefaultTest / UserDefaultTest . cpp <nl> + Classes / VisibleRect . cpp <nl> + Classes / ZwoptexTest / ZwoptexTest . cpp <nl> Classes / controller . cpp <nl> Classes / testBasic . cpp <nl> - Classes / AppDelegate . cpp <nl> - Classes / BaseTest . cpp <nl> - Classes / VisibleRect . cpp <nl> $ { PLATFORM_SRC } <nl> ) <nl> <nl> mmm a / tests / cpp - tests / Classes / ExtensionsTest / CocoStudioComponentsTest / SceneController . cpp <nl> ppp b / tests / cpp - tests / Classes / ExtensionsTest / CocoStudioComponentsTest / SceneController . cpp <nl> void SceneController : : spriteMoveFinished ( Node * sender ) <nl> auto gameOverScene = GameOverScene : : create ( ) ; <nl> gameOverScene - > getLayer ( ) - > getLabel ( ) - > setString ( " You Lose : [ " ) ; <nl> <nl> - director - > replaceScene ( gameOverScene ) ; <nl> + director - > replaceScene ( gameOverScene ) ; <nl> } <nl> else if ( sprite - > getTag ( ) = = 3 ) <nl> { <nl> new file mode 100644 <nl> index 000000000000 . . 871c385ab3a5 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Classes / MaterialSystemTest / MaterialSystemTest . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2012 cocos2d - x . org <nl> + Copyright ( c ) 2013 - 2014 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # include " MaterialSystemTest . h " <nl> + # include " . . / testResource . h " <nl> + # include " cocos2d . h " <nl> + <nl> + # include " renderer / CCMaterial . h " <nl> + <nl> + <nl> + USING_NS_CC ; <nl> + <nl> + MaterialSystemTest : : MaterialSystemTest ( ) <nl> + { <nl> + ADD_TEST_CASE ( Material_MultipleSprite3D ) ; <nl> + ADD_TEST_CASE ( Material_SpriteTest ) ; <nl> + ADD_TEST_CASE ( Material_Sprite3DTest ) ; <nl> + } <nl> + <nl> + / / MARK : <nl> + <nl> + std : : string MaterialSystemBaseTest : : title ( ) const <nl> + { <nl> + return " Material System " ; <nl> + } <nl> + <nl> + / / MARK : Tests start here <nl> + <nl> + void Material_SpriteTest : : onEnter ( ) <nl> + { <nl> + MaterialSystemBaseTest : : onEnter ( ) ; <nl> + auto layer = LayerColor : : create ( Color4B : : BLUE ) ; <nl> + this - > addChild ( layer ) ; <nl> + <nl> + <nl> + auto sprite = Sprite : : create ( " Images / grossini . png " ) ; <nl> + sprite - > setNormalizedPosition ( Vec2 ( 0 . 5 , 0 . 5 ) ) ; <nl> + this - > addChild ( sprite ) ; <nl> + <nl> + auto material = Material : : createWithFilename ( " Materials / effects . material " ) ; <nl> + sprite - > setMaterial ( material ) ; <nl> + <nl> + / / material - > setTechnique ( " blur " ) ; <nl> + / / material - > setTechnique ( " outline " ) ; <nl> + / / material - > setTechnique ( " noise " ) ; <nl> + / / material - > setTechnique ( " edge detect " ) ; <nl> + material - > setTechnique ( " gray + blur " ) ; <nl> + } <nl> + <nl> + std : : string Material_SpriteTest : : subtitle ( ) const <nl> + { <nl> + return " Material System on Sprite " ; <nl> + } <nl> + <nl> + <nl> + void Material_Sprite3DTest : : onEnter ( ) <nl> + { <nl> + MaterialSystemBaseTest : : onEnter ( ) ; <nl> + <nl> + auto sprite = Sprite3D : : create ( " Sprite3DTest / boss1 . obj " ) ; <nl> + sprite - > setScale ( 8 . f ) ; <nl> + sprite - > setTexture ( " Sprite3DTest / boss . png " ) ; <nl> + this - > addChild ( sprite ) ; <nl> + sprite - > setNormalizedPosition ( Vec2 ( 0 . 5 , 0 . 5 ) ) ; <nl> + <nl> + / / auto material = Material : : createWithFilename ( " Materials / spaceship . material " ) ; <nl> + / / sprite - > setMaterial ( material ) ; <nl> + } <nl> + <nl> + std : : string Material_Sprite3DTest : : subtitle ( ) const <nl> + { <nl> + return " Material System on Sprite3D " ; <nl> + } <nl> + <nl> + <nl> + / / <nl> + / / <nl> + / / <nl> + void Material_MultipleSprite3D : : onEnter ( ) <nl> + { <nl> + MaterialSystemBaseTest : : onEnter ( ) ; <nl> + <nl> + const char * names [ ] = { <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + " Sprite3DTest / ReskinGirl . c3b " , <nl> + } ; <nl> + <nl> + const int totalNames = sizeof ( names ) / sizeof ( names [ 0 ] ) ; <nl> + <nl> + auto size = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> + <nl> + for ( int i = 0 ; i < totalNames ; i + + ) <nl> + { <nl> + auto sprite = Sprite3D : : create ( names [ i ] ) ; <nl> + this - > addChild ( sprite ) ; <nl> + sprite - > setPosition ( Vec2 ( ( size . width / ( totalNames + 1 ) ) * ( i + 1 ) , size . height / 4 ) ) ; <nl> + sprite - > setScale ( 3 ) ; <nl> + } <nl> + } <nl> + <nl> + std : : string Material_MultipleSprite3D : : subtitle ( ) const <nl> + { <nl> + return " Sprites with multiple meshes " ; <nl> + } <nl> + <nl> new file mode 100644 <nl> index 000000000000 . . 7ff09279d5e1 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Classes / MaterialSystemTest / MaterialSystemTest . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 Chukong Technologies Inc . <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # pragma once <nl> + <nl> + # include " . . / testBasic . h " <nl> + # include " . . / BaseTest . h " <nl> + <nl> + DEFINE_TEST_SUITE ( MaterialSystemTest ) ; <nl> + <nl> + class MaterialSystemBaseTest : public TestCase <nl> + { <nl> + public : <nl> + virtual std : : string title ( ) const override ; <nl> + } ; <nl> + <nl> + class Material_SpriteTest : public MaterialSystemBaseTest <nl> + { <nl> + public : <nl> + CREATE_FUNC ( Material_SpriteTest ) ; <nl> + <nl> + virtual void onEnter ( ) override ; <nl> + virtual std : : string subtitle ( ) const override ; <nl> + } ; <nl> + <nl> + class Material_Sprite3DTest : public MaterialSystemBaseTest <nl> + { <nl> + public : <nl> + CREATE_FUNC ( Material_Sprite3DTest ) ; <nl> + <nl> + virtual void onEnter ( ) override ; <nl> + virtual std : : string subtitle ( ) const override ; <nl> + } ; <nl> + <nl> + class Material_MultipleSprite3D : public MaterialSystemBaseTest <nl> + { <nl> + public : <nl> + CREATE_FUNC ( Material_MultipleSprite3D ) ; <nl> + <nl> + virtual void onEnter ( ) override ; <nl> + virtual std : : string subtitle ( ) const override ; <nl> + } ; <nl> + <nl> + <nl> mmm a / tests / cpp - tests / Classes / ShaderTest / ShaderTest . cpp <nl> ppp b / tests / cpp - tests / Classes / ShaderTest / ShaderTest . cpp <nl> void ShaderNode : : onDraw ( const Mat4 & transform , uint32_t flags ) <nl> <nl> auto glProgramState = getGLProgramState ( ) ; <nl> glProgramState - > setVertexAttribPointer ( " a_position " , 2 , GL_FLOAT , GL_FALSE , 0 , vertices ) ; <nl> + <nl> glProgramState - > apply ( transform ) ; <nl> <nl> glDrawArrays ( GL_TRIANGLES , 0 , 6 ) ; <nl> mmm a / tests / cpp - tests / Classes / ShaderTest / ShaderTest2 . cpp <nl> ppp b / tests / cpp - tests / Classes / ShaderTest / ShaderTest2 . cpp <nl> EffectSpriteTest : : EffectSpriteTest ( ) <nl> { <nl> if ( ShaderTestDemo2 : : init ( ) ) { <nl> <nl> + auto layer = LayerColor : : create ( Color4B : : BLUE ) ; <nl> + this - > addChild ( layer ) ; <nl> + <nl> auto s = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> <nl> auto itemPrev = MenuItemImage : : create ( " Images / b1 . png " , " Images / b2 . png " , <nl> mmm a / tests / cpp - tests / Classes / Sprite3DTest / Sprite3DTest . cpp <nl> ppp b / tests / cpp - tests / Classes / Sprite3DTest / Sprite3DTest . cpp <nl> void UseCaseSprite3D : : switchCase ( ) <nl> circleBack - > setScale ( 0 . 5f ) ; <nl> circleBack - > addChild ( circle ) ; <nl> circle - > runAction ( RepeatForever : : create ( RotateBy : : create ( 3 , Vec3 ( 0 . f , 0 . f , 360 . f ) ) ) ) ; <nl> - <nl> - circleBack - > setRotation3D ( Vec3 ( 90 , 0 , 0 ) ) ; <nl> + <nl> + circleBack - > setRotation3D ( Vec3 ( 90 , 90 , 0 ) ) ; <nl> <nl> auto pos = sprite - > getPosition3D ( ) ; <nl> circleBack - > setPosition3D ( Vec3 ( pos . x , pos . y , pos . z - 1 ) ) ; <nl> mmm a / tests / cpp - tests / Classes / controller . cpp <nl> ppp b / tests / cpp - tests / Classes / controller . cpp <nl> class RootTests : public TestList <nl> addTest ( " FileUtils " , [ ] ( ) { return new FileUtilsTests ( ) ; } ) ; <nl> addTest ( " Fonts " , [ ] ( ) { return new FontTests ( ) ; } ) ; <nl> addTest ( " Interval " , [ ] ( ) { return new IntervalTests ( ) ; } ) ; <nl> + addTest ( " Material System " , [ ] ( ) { return new MaterialSystemTest ( ) ; } ) ; <nl> addTest ( " Node : BillBoard Test " , [ ] ( ) { return new BillBoardTests ( ) ; } ) ; <nl> addTest ( " Node : Camera 3D Test " , [ ] ( ) { return new Camera3DTests ( ) ; } ) ; <nl> addTest ( " Node : Clipping " , [ ] ( ) { return new ClippingNodeTests ( ) ; } ) ; <nl> mmm a / tests / cpp - tests / Classes / tests . h <nl> ppp b / tests / cpp - tests / Classes / tests . h <nl> <nl> # include " CocosStudio3DTest / CocosStudio3DTest . h " <nl> # include " UITest / UITest . h " <nl> <nl> + # include " MaterialSystemTest / MaterialSystemTest . h " <nl> + <nl> # endif <nl> new file mode 100644 <nl> index 000000000000 . . bb5ff81a6fa1 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / Materials / effects . material <nl> <nl> + { <nl> + " metadata " : { <nl> + " version " : 1 , <nl> + " type " : " material " <nl> + } , <nl> + " name " : " simple effects " , <nl> + " techniques " : [ <nl> + { <nl> + " name " : " blur " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " THIS_IS_AN_EXAMPLE 1 ; TOMORROW_IS_HOLIDAY 2 " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_Blur . fsh " , <nl> + " blurRadius " : 10 , <nl> + " sampleNum " : 5 , <nl> + " resolution " : [ 100 , 100 ] <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " name " : " outline " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_outline . fsh " , <nl> + " u_outlineColor " : [ 0 . 1 , 0 . 2 , 0 . 3 ] , <nl> + " u_radius " : 0 . 01 , <nl> + " u_threshold " : 1 . 75 <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " name " : " noise " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_Noisy . fsh " , <nl> + " resolution " : [ 100 , 100 ] <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " name " : " edge detect " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_edgeDetection . fsh " , <nl> + " resolution " : [ 100 , 100 ] <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " name " : " gray + blur " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " TEXTURE_REPEAT " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_Blur . fsh " , <nl> + " blurRadius " : 10 , <nl> + " sampleNum " : 5 , <nl> + " resolution " : [ 100 , 100 ] <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } , <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE_MINUS_SRC_ALPHA " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " " , <nl> + " vertexShader " : " Shaders / example_simple . vsh " , <nl> + " fragmentShader " : " Shaders / example_greyScale . fsh " <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Images / grossinis_sister1 . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 285a1ea5e354 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / Materials / spaceship . material <nl> <nl> + { <nl> + " metadata " : { <nl> + " version " : 1 , <nl> + " type " : " material " <nl> + } , <nl> + " name " : " spaceship " , <nl> + " techniques " : [ <nl> + { <nl> + " name " : " simple " , <nl> + " passes " : [ <nl> + { <nl> + " renderState " : { <nl> + " blend " : " true " , <nl> + " blendSrc " : " ONE_MINUS_SRC_ALPHA " , <nl> + " blendDst " : " ONE_MINUS_SRC_ALPHA " <nl> + } , <nl> + " shader " : { <nl> + " defines " : " " , <nl> + " vertexShader " : " Shaders / example_3D_PositionTex . vsh " , <nl> + " fragmentShader " : " Shaders / example_3D_PositionTex . fsh " , <nl> + " u_color " : [ 1 , 1 , 1 , 1 ] <nl> + } , <nl> + " textures " : [ <nl> + { <nl> + " path " : " Sprite3DTest / boss . png " , <nl> + " wrapS " : " CLAMP_TO_EDGE " , <nl> + " wrapT " : " CLAMP_TO_EDGE " , <nl> + " minFilter " : " LINEAR " , <nl> + " magFilter " : " LINEAR " , <nl> + " mipmap " : " false " <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } <nl> + ] <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 0d87c7e22906 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / Shaders / example_3D_PositionTex . fsh <nl> <nl> + # ifdef GL_ES <nl> + varying mediump vec2 TextureCoordOut ; <nl> + # else <nl> + varying vec2 TextureCoordOut ; <nl> + # endif <nl> + uniform vec4 u_color ; <nl> + <nl> + void main ( void ) <nl> + { <nl> + gl_FragColor = texture2D ( CC_Texture0 , TextureCoordOut ) * u_color ; <nl> + } <nl> + <nl> new file mode 100644 <nl> index 000000000000 . . 7180be8fa8fa <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / Shaders / example_3D_PositionTex . vsh <nl> <nl> + attribute vec4 a_position ; <nl> + attribute vec2 a_texCoord ; <nl> + <nl> + varying vec2 TextureCoordOut ; <nl> + <nl> + void main ( void ) <nl> + { <nl> + gl_Position = CC_MVPMatrix * a_position ; <nl> + TextureCoordOut = a_texCoord ; <nl> + TextureCoordOut . y = 1 . 0 - TextureCoordOut . y ; <nl> + } <nl> mmm a / tests / cpp - tests / Resources / Shaders / example_Blur . fsh <nl> ppp b / tests / cpp - tests / Resources / Shaders / example_Blur . fsh <nl> uniform vec2 resolution ; <nl> uniform float blurRadius ; <nl> uniform float sampleNum ; <nl> <nl> - vec3 blur ( vec2 ) ; <nl> + vec4 blur ( vec2 ) ; <nl> <nl> void main ( void ) <nl> { <nl> - vec3 col = blur ( v_texCoord ) ; <nl> - gl_FragColor = vec4 ( col , 1 . 0 ) * v_fragmentColor ; <nl> + vec4 col = blur ( v_texCoord ) ; / / * v_fragmentColor . rgb ; <nl> + gl_FragColor = vec4 ( col ) * v_fragmentColor ; <nl> } <nl> <nl> - vec3 blur ( vec2 p ) <nl> + vec4 blur ( vec2 p ) <nl> { <nl> if ( blurRadius > 0 . 0 & & sampleNum > 1 . 0 ) <nl> { <nl> - vec3 col = vec3 ( 0 ) ; <nl> + vec4 col = vec4 ( 0 ) ; <nl> vec2 unit = 1 . 0 / resolution . xy ; <nl> <nl> float r = blurRadius ; <nl> vec3 blur ( vec2 p ) <nl> for ( float y = - r ; y < r ; y + = sampleStep ) <nl> { <nl> float weight = ( r - abs ( x ) ) * ( r - abs ( y ) ) ; <nl> - col + = texture2D ( CC_Texture0 , p + vec2 ( x * unit . x , y * unit . y ) ) . rgb * weight ; <nl> + col + = texture2D ( CC_Texture0 , p + vec2 ( x * unit . x , y * unit . y ) ) * weight ; <nl> count + = weight ; <nl> } <nl> } <nl> vec3 blur ( vec2 p ) <nl> return col / count ; <nl> } <nl> <nl> - return texture2D ( CC_Texture0 , p ) . rgb ; <nl> + return texture2D ( CC_Texture0 , p ) ; <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . d6b899fd4530 <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / Shaders / example_simple . vsh <nl> <nl> + attribute vec4 a_position ; <nl> + attribute vec2 a_texCoord ; <nl> + attribute vec4 a_color ; <nl> + <nl> + # ifdef GL_ES <nl> + varying lowp vec4 v_fragmentColor ; <nl> + varying mediump vec2 v_texCoord ; <nl> + # else <nl> + varying vec4 v_fragmentColor ; <nl> + varying vec2 v_texCoord ; <nl> + # endif <nl> + <nl> + void main ( ) <nl> + { <nl> + gl_Position = CC_PMatrix * a_position ; <nl> + v_fragmentColor = a_color ; <nl> + v_texCoord = a_texCoord ; <nl> + } <nl> mmm a / tests / cpp - tests / proj . android / jni / Android . mk <nl> ppp b / tests / cpp - tests / proj . android / jni / Android . mk <nl> LOCAL_MODULE : = cpp_tests_shared <nl> LOCAL_MODULE_FILENAME : = libcpp_tests <nl> <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> - . . / . . / Classes / AppDelegate . cpp \ <nl> - . . / . . / Classes / BaseTest . cpp \ <nl> - . . / . . / Classes / controller . cpp \ <nl> - . . / . . / Classes / testBasic . cpp \ <nl> - . . / . . / Classes / VisibleRect . cpp \ <nl> . . / . . / Classes / ActionManagerTest / ActionManagerTest . cpp \ <nl> . . / . . / Classes / ActionsEaseTest / ActionsEaseTest . cpp \ <nl> . . / . . / Classes / ActionsProgressTest / ActionsProgressTest . cpp \ <nl> . . / . . / Classes / ActionsTest / ActionsTest . cpp \ <nl> . . / . . / Classes / AllocatorTest / AllocatorTest . cpp \ <nl> + . . / . . / Classes / AppDelegate . cpp \ <nl> + . . / . . / Classes / BaseTest . cpp \ <nl> . . / . . / Classes / BillBoardTest / BillBoardTest . cpp \ <nl> . . / . . / Classes / Box2DTest / Box2dTest . cpp \ <nl> . . / . . / Classes / Box2DTestBed / Box2dView . cpp \ <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 1174 . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 350 . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 422 . cpp \ <nl> + . . / . . / Classes / BugsTest / Bug - 458 / Bug - 458 . cpp \ <nl> + . . / . . / Classes / BugsTest / Bug - 458 / QuestionContainerSprite . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 624 . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 886 . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 899 . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - 914 . cpp \ <nl> - . . / . . / Classes / BugsTest / BugsTest . cpp \ <nl> . . / . . / Classes / BugsTest / Bug - Child . cpp \ <nl> - . . / . . / Classes / BugsTest / Bug - 458 / Bug - 458 . cpp \ <nl> - . . / . . / Classes / BugsTest / Bug - 458 / QuestionContainerSprite . cpp \ <nl> + . . / . . / Classes / BugsTest / BugsTest . cpp \ <nl> . . / . . / Classes / Camera3DTest / Camera3DTest . cpp \ <nl> . . / . . / Classes / ChipmunkTest / ChipmunkTest . cpp \ <nl> . . / . . / Classes / ClickAndMoveTest / ClickAndMoveTest . cpp \ <nl> . . / . . / Classes / ClippingNodeTest / ClippingNodeTest . cpp \ <nl> . . / . . / Classes / CocosDenshionTest / CocosDenshionTest . cpp \ <nl> - . . / . . / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp \ <nl> + . . / . . / Classes / CocosStudio3DTest / CocosStudio3DTest . cpp \ <nl> . . / . . / Classes / ConfigurationTest / ConfigurationTest . cpp \ <nl> . . / . . / Classes / ConsoleTest / ConsoleTest . cpp \ <nl> . . / . . / Classes / CurlTest / CurlTest . cpp \ <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> . . / . . / Classes / DrawPrimitivesTest / DrawPrimitivesTest . cpp \ <nl> . . / . . / Classes / EffectsAdvancedTest / EffectsAdvancedTest . cpp \ <nl> . . / . . / Classes / EffectsTest / EffectsTest . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / ExtensionsTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / AssetsManagerExTest / AssetsManagerExTest . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / CocosBuilderTest . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / AnimationsTest / AnimationsTestLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / ButtonTest / ButtonTestLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / HelloCocosBuilder / HelloCocosBuilderLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / MenuTest / MenuTestLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / TestHeader / TestHeaderLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocosBuilderTest / TimelineCallbackTest / TimelineCallbackTestLayer . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioActionTimelineTest / ActionTimelineTestScene . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocoStudioArmatureTest / ArmatureScene . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / ComponentsTestScene . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / EnemyController . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / GameOverScene . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / PlayerController . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / ProjectileController . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioComponentsTest / SceneController . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CocoStudioGUITest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CocostudioParserTest / CocostudioParserJsonTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CocostudioParserTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / GUIEditorTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomGUIScene . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIScene . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIScale9SpriteTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIEditBoxTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UISceneManager . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIFocusTest / UIFocusTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIRichTextTest / UIRichTextTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIScene_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UISceneManager_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest_Editor . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIVideoPlayerTest / UIVideoPlayerTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / UIWebViewTest / UIWebViewTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageView . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageViewReader . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidget . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidgetReader . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomReader . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomImageTest / CustomImageTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomParticleWidgetTest / CustomParticleWidgetTest . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNode . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNodeReader . cpp \ <nl> - . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomWidgetCallbackBindTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioSceneTest / SceneEditorTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / acts . cpp \ <nl> . . / . . / Classes / ExtensionsTest / CocoStudioSceneTest / TriggerCode / cons . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlScene . cpp \ <nl> - . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlSceneManager . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / AnimationsTest / AnimationsTestLayer . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / ButtonTest / ButtonTestLayer . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / CocosBuilderTest . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / HelloCocosBuilder / HelloCocosBuilderLayer . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / MenuTest / MenuTestLayer . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / TestHeader / TestHeaderLayer . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / CocosBuilderTest / TimelineCallbackTest / TimelineCallbackTestLayer . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlButtonTest / CCControlButtonTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlColourPicker / CCControlColourPickerTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlPotentiometerTest / CCControlPotentiometerTest . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlScene . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlSceneManager . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlSliderTest / CCControlSliderTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlStepperTest / CCControlStepperTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / ControlExtensionTest / CCControlSwitchTest / CCControlSwitchTest . cpp \ <nl> + . . / . . / Classes / ExtensionsTest / ExtensionsTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / NetworkTest / HttpClientTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / NetworkTest / SocketIOTest . cpp \ <nl> . . / . . / Classes / ExtensionsTest / NetworkTest / WebSocketTest . cpp \ <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> . . / . . / Classes / LabelTest / LabelTestNew . cpp \ <nl> . . / . . / Classes / LayerTest / LayerTest . cpp \ <nl> . . / . . / Classes / LightTest / LightTest . cpp \ <nl> + . . / . . / Classes / MaterialSystemTest / MaterialSystemTest . cpp \ <nl> . . / . . / Classes / MenuTest / MenuTest . cpp \ <nl> . . / . . / Classes / MotionStreakTest / MotionStreakTest . cpp \ <nl> . . / . . / Classes / MutiTouchTest / MutiTouchTest . cpp \ <nl> + . . / . . / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp \ <nl> . . / . . / Classes / NewEventDispatcherTest / NewEventDispatcherTest . cpp \ <nl> . . / . . / Classes / NewRendererTest / NewRendererTest . cpp \ <nl> . . / . . / Classes / NodeTest / NodeTest . cpp \ <nl> + . . / . . / Classes / OpenURLTest / OpenURLTest . cpp \ <nl> . . / . . / Classes / ParallaxTest / ParallaxTest . cpp \ <nl> - . . / . . / Classes / ParticleTest / ParticleTest . cpp \ <nl> . . / . . / Classes / Particle3DTest / Particle3DTest . cpp \ <nl> - . . / . . / Classes / CocosStudio3DTest / CocosStudio3DTest . cpp \ <nl> + . . / . . / Classes / ParticleTest / ParticleTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceAllocTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceCallbackTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceContainerTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceEventDispatcherTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceLabelTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceMathTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceNodeChildrenTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceParticleTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceParticle3DTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceParticleTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceRendererTest . cpp \ <nl> + . . / . . / Classes / PerformanceTest / PerformanceScenarioTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceSpriteTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceTextureTest . cpp \ <nl> . . / . . / Classes / PerformanceTest / PerformanceTouchesTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceLabelTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceRendererTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceContainerTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceEventDispatcherTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceScenarioTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceCallbackTest . cpp \ <nl> - . . / . . / Classes / PerformanceTest / PerformanceMathTest . cpp \ <nl> . . / . . / Classes / PhysicsTest / PhysicsTest . cpp \ <nl> . . / . . / Classes / ReleasePoolTest / ReleasePoolTest . cpp \ <nl> . . / . . / Classes / RenderTextureTest / RenderTextureTest . cpp \ <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> . . / . . / Classes / ShaderTest / ShaderTest . cpp \ <nl> . . / . . / Classes / ShaderTest / ShaderTest2 . cpp \ <nl> . . / . . / Classes / SpineTest / SpineTest . cpp \ <nl> - . . / . . / Classes / SpriteTest / SpriteTest . cpp \ <nl> . . / . . / Classes / Sprite3DTest / DrawNode3D . cpp \ <nl> . . / . . / Classes / Sprite3DTest / Sprite3DTest . cpp \ <nl> + . . / . . / Classes / SpritePolygonTest / SpritePolygonTest . cpp \ <nl> + . . / . . / Classes / SpriteTest / SpriteTest . cpp \ <nl> + . . / . . / Classes / TerrainTest / TerrainTest . cpp \ <nl> . . / . . / Classes / TextInputTest / TextInputTest . cpp \ <nl> . . / . . / Classes / Texture2dTest / Texture2dTest . cpp \ <nl> . . / . . / Classes / TextureCacheTest / TextureCacheTest . cpp \ <nl> LOCAL_SRC_FILES : = main . cpp \ <nl> . . / . . / Classes / TouchesTest / Paddle . cpp \ <nl> . . / . . / Classes / TouchesTest / TouchesTest . cpp \ <nl> . . / . . / Classes / TransitionsTest / TransitionsTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CocoStudioGUITest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CocostudioParserTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CocostudioParserTest / CocostudioParserJsonTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomGUIScene . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomImageTest / CustomImageTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomParticleWidgetTest / CustomParticleWidgetTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNode . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomRootNodeReader . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomTest / CustomWidgetCallbackBindTest / CustomWidgetCallbackBindTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageView . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomImageViewReader . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidget . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomParticleWidgetReader . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / CustomWidget / CustomReader . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / GUIEditorTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIButtonTest / UIButtonTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIEditBoxTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIFocusTest / UIFocusTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIListViewTest / UIListViewTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIRichTextTest / UIRichTextTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIScale9SpriteTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIScene . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UISceneManager . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UISceneManager_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIScene_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UISliderTest / UISliderTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextAtlasTest / UITextAtlasTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextBMFontTest / UITextBMFontTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UITextTest / UITextTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIVideoPlayerTest / UIVideoPlayerTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIWebViewTest / UIWebViewTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . cpp \ <nl> + . . / . . / Classes / UITest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest_Editor . cpp \ <nl> + . . / . . / Classes / UITest / UITest . cpp \ <nl> . . / . . / Classes / UnitTest / RefPtrTest . cpp \ <nl> . . / . . / Classes / UnitTest / UnitTest . cpp \ <nl> - . . / . . / Classes / UITest / UITest . cpp \ <nl> . . / . . / Classes / UserDefaultTest / UserDefaultTest . cpp \ <nl> - . . / . . / Classes / OpenURLTest / OpenURLTest . cpp \ <nl> + . . / . . / Classes / VisibleRect . cpp \ <nl> . . / . . / Classes / ZwoptexTest / ZwoptexTest . cpp \ <nl> - . . / . . / Classes / TerrainTest / TerrainTest . cpp \ <nl> - . . / . . / Classes / SpritePolygonTest / SpritePolygonTest . cpp <nl> + . . / . . / Classes / controller . cpp \ <nl> + . . / . . / Classes / testBasic . cpp <nl> <nl> LOCAL_C_INCLUDES : = $ ( LOCAL_PATH ) / . . / . . / Classes \ <nl> $ ( LOCAL_PATH ) / . . / . . / . . / . . <nl> mmm a / tests / cpp - tests / proj . win32 / cpp - tests . vcxproj <nl> ppp b / tests / cpp - tests / proj . win32 / cpp - tests . vcxproj <nl> xcopy " $ ( OutDir ) . . \ * . dll " " $ ( OutDir ) " / D / Y < / Command > <nl> < ClCompile Include = " . . \ Classes \ InputTest \ MouseTest . cpp " / > <nl> < ClCompile Include = " . . \ Classes \ LabelTest \ LabelTestNew . cpp " / > <nl> < ClCompile Include = " . . \ Classes \ LightTest \ LightTest . cpp " / > <nl> + < ClCompile Include = " . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . cpp " / > <nl> < ClCompile Include = " . . \ Classes \ NewAudioEngineTest \ NewAudioEngineTest . cpp " / > <nl> < ClCompile Include = " . . \ Classes \ NewEventDispatcherTest \ NewEventDispatcherTest . cpp " / > <nl> < ClCompile Include = " . . \ Classes \ NewRendererTest \ NewRendererTest . cpp " / > <nl> xcopy " $ ( OutDir ) . . \ * . dll " " $ ( OutDir ) " / D / Y < / Command > <nl> < ClInclude Include = " . . \ Classes \ InputTest \ MouseTest . h " / > <nl> < ClInclude Include = " . . \ Classes \ LabelTest \ LabelTestNew . h " / > <nl> < ClInclude Include = " . . \ Classes \ LightTest \ LightTest . h " / > <nl> + < ClInclude Include = " . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . h " / > <nl> < ClInclude Include = " . . \ Classes \ NewAudioEngineTest \ NewAudioEngineTest . h " / > <nl> < ClInclude Include = " . . \ Classes \ NewEventDispatcherTest \ NewEventDispatcherTest . h " / > <nl> < ClInclude Include = " . . \ Classes \ NewRendererTest \ NewRendererTest . h " / > <nl> mmm a / tests / cpp - tests / proj . win32 / cpp - tests . vcxproj . filters <nl> ppp b / tests / cpp - tests / proj . win32 / cpp - tests . vcxproj . filters <nl> <nl> < Filter Include = " Classes \ SpritePolygonTest " > <nl> < UniqueIdentifier > { b35cfbde - 9e13 - 4981 - 8458 - f7596f089bde } < / UniqueIdentifier > <nl> < / Filter > <nl> + < Filter Include = " Classes \ MaterialSystemTest " > <nl> + < UniqueIdentifier > { 4fd79779 - ff32 - 4400 - aa05 - af4fd7f0f4a0 } < / UniqueIdentifier > <nl> + < / Filter > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " main . cpp " > <nl> <nl> < ClCompile Include = " . . \ Classes \ SpritePolygonTest \ SpritePolygonTest . cpp " > <nl> < Filter > Classes \ SpritePolygonTest < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . cpp " > <nl> + < Filter > Classes \ MaterialSystemTest < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " main . h " > <nl> <nl> < ClInclude Include = " . . \ Classes \ SpritePolygonTest \ SpritePolygonTest . h " > <nl> < Filter > Classes \ SpritePolygonTest < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . h " > <nl> + < Filter > Classes \ MaterialSystemTest < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> mmm a / tests / cpp - tests / proj . win8 . 1 - universal / cpp - tests . Shared / cpp - tests . Shared . vcxitems <nl> ppp b / tests / cpp - tests / proj . win8 . 1 - universal / cpp - tests . Shared / cpp - tests . Shared . vcxitems <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LabelTest \ LabelTestNew . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LayerTest \ LayerTest . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LightTest \ LightTest . cpp " / > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MenuTest \ MenuTest . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MotionStreakTest \ MotionStreakTest . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MutiTouchTest \ MutiTouchTest . cpp " / > <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LabelTest \ LabelTestNew . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LayerTest \ LayerTest . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ LightTest \ LightTest . h " / > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MenuTest \ MenuTest . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MotionStreakTest \ MotionStreakTest . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MutiTouchTest \ MutiTouchTest . h " / > <nl> mmm a / tests / cpp - tests / proj . win8 . 1 - universal / cpp - tests . Shared / cpp - tests . Shared . vcxitems . filters <nl> ppp b / tests / cpp - tests / proj . win8 . 1 - universal / cpp - tests . Shared / cpp - tests . Shared . vcxitems . filters <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ SpritePolygonTest \ SpritePolygonTest . cpp " > <nl> < Filter > Classes \ SpritePolygonTest < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . cpp " > <nl> + < Filter > Classes \ MaterialSystemTest < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ ActionManagerTest \ ActionManagerTest . cpp " > <nl> <nl> < Filter Include = " Classes \ SpritePolygonTest " > <nl> < UniqueIdentifier > { ee1c5d87 - 3c80 - 4a10 - 892e - 985fcd93a6c1 } < / UniqueIdentifier > <nl> < / Filter > <nl> + < Filter Include = " Classes \ MaterialSystemTest " > <nl> + < UniqueIdentifier > { 9113774a - 5e49 - 433b - b851 - 11533bc178ec } < / UniqueIdentifier > <nl> + < / Filter > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Page Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ cocos \ platform \ win8 . 1 - universal \ OpenGLESPage . xaml " / > <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ SpritePolygonTest \ SpritePolygonTest . h " > <nl> < Filter > Classes \ SpritePolygonTest < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ Classes \ MaterialSystemTest \ MaterialSystemTest . h " > <nl> + < Filter > Classes \ MaterialSystemTest < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> | Squashed commit of the following : | cocos2d/cocos2d-x | ce95bfe05945ba1bbce36ab3e4f03e2eaddbd7e7 | 2015-05-05T20:07:32Z |
new file mode 100644 <nl> index 0000000000000 . . 78034bca2d326 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / mlir / lite / tests / end2end / fake_quant_per_channel . pbtxt <nl> <nl> + # RUN : tf_tfl_translate - tf - input - arrays = input - tf - input - shapes = 1 , 1 , 1 , 256 - tf - input - data - types = DT_FLOAT - tf - inference - type = DT_QINT8 - tf - input - min - values = ' - 33 . 614346 ' - tf - input - max - values = ' 21 . 54917 ' - tf - output - arrays = output % s - o - - - output - mlir 2 > & 1 | FileCheck - - check - prefix = MLIR % s <nl> + # RUN : tf_tfl_translate - tf - input - arrays = input - tf - input - shapes = 1 , 1 , 1 , 256 - tf - input - data - types = DT_FLOAT - tf - inference - type = DT_QINT8 - tf - input - min - values = ' - 33 . 614346 ' - tf - input - max - values = ' 21 . 54917 ' - tf - output - arrays = output % s - o - | flatbuffer_to_string - | FileCheck % s <nl> + <nl> + node { <nl> + name : " input " <nl> + op : " Placeholder " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " shape " <nl> + value { <nl> + shape { <nl> + dim { <nl> + size : 1 <nl> + } <nl> + dim { <nl> + size : 1 <nl> + } <nl> + dim { <nl> + size : 1 <nl> + } <nl> + dim { <nl> + size : 256 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + dim { <nl> + size : 1 <nl> + } <nl> + dim { <nl> + size : 1 <nl> + } <nl> + dim { <nl> + size : 256 <nl> + } <nl> + dim { <nl> + size : 186 <nl> + } <nl> + } <nl> + float_val : 1 . 0 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / weights " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights_quant / min " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + dim { <nl> + size : 186 <nl> + } <nl> + } <nl> + tensor_content : " \ 217 \ 245 \ 177 \ 301 \ 005 @ d \ 276C \ 030x \ 276S \ 320 \ 177 \ 276 . \ 227q \ 277 \ 260 ] \ 223 \ 276j \ 016 \ 250 \ 276 \ 305 \ 017 \ 202 \ 276 \ 200 + \ 201 \ 276 \ 275 \ 377 \ 177 \ 276 \ 310 & \ 202 \ 276 \ 314 \ 210k \ 276 \ 3178W \ 277 \ 335 \ 356_ \ 276 \ 332GG \ 276 ` \ 200 > \ 276o_c \ 276 \ 312 \ 224k \ 2767 \ 033S \ 276M = \ 376 \ 300y - \ 271 \ 276 \ 225 \ 021g \ 276 \ 272lZ \ 276 \ 353r \ 251 \ 276 \ 025 \ 354G \ 276 \ 357 \ 220 \ \ \ 2765j0 \ 2765Q ( \ 276 \ 013 > 0 \ 276Y \ r \ ' \ 276 \ 224 \ 013 \ " \ 276G = \ 377 \ 300 \ 022 \ 211E \ 276 \ 344 \ 035O \ 276 \ 242 \ 220l \ 276w \ 307 \ 020 \ 2773 ` \ 376 \ 276 \ 331 \ 377 \ 202 \ 276 \ 374 \ 016Y \ 276 \ 224 \ 273 ^ \ 2767 ` ~ \ 276V \ 016 > \ 276 \ 226 \ 333g \ 276 * \ 241K \ 276 \ 224g \ 177 \ 276 \ 320 \ 315 ( \ 276t \ 376 \ 177 \ 276B \ 025B \ 276 @ \ 214 \ 226 \ 276 \ 377s \ 376 \ 276 \ 373 \ 365 \ 377 \ 277 \ 343 \ 211 ~ \ 276 \ 205 \ 320b \ 276 \ 213 \ 236 \ 377 \ 2763 \ 0136 \ 276u \ 237 : \ 276 \ 325 \ 373 ~ \ 276 \ 344 \ r \ 037 \ 276 > \ 035 ( \ 276 \ 247 \ 364 ! \ 276 \ 2613 % \ 276 \ 207 ] ! \ 276 \ 320S \ 376 \ 301 \ 354 _ \ 276 \ 337PT \ 276 \ 342 \ 226 [ \ 276 \ 304 \ 307 \ 177 \ 276 \ 360 \ " x \ 276 \ 312 \ 023 \ 200 \ 276Wfp \ 2768 $ W \ 276 \ 235 \ 014 \ 202 \ 276 \ 230 \ 210m \ 2761 \ 342L \ 276b \ 234 \ 013 \ 277 \ 362XM \ 276QPL \ 276 \ 006Va \ 276 \ 3168 > \ 276 \ 262 \ 367t \ 276x \ 252k \ 276 \ 266 \ 225 \ 231 \ 276z @ B \ 276 \ 244 \ 340 ? \ 276 > 8 ] \ 276 \ 214v \ 206 \ 276 \ 316 \ 210Z \ 276 \ 275 \ 343U \ 276 \ 366 \ 0321 \ 276b \ 2128 \ 276 \ 310 \ 2611 \ 276 \ 340n / \ 276 \ 312 \ 272 \ ' \ 276 \ 207 \ 274 \ 207 \ 276tl \ 034 \ 276 \ 214 [ \ 357 \ 275 \ 020 \ 345 @ \ 276 \ 1778 \ 376 \ 275 \ 264 ~ # \ 276 \ 326U * \ 276 \ 374g \ 003 \ 276 \ 377 \ 013 \ 000 \ 276 \ 361 \ 375T \ 276 \ 246 \ 330 \ 007 \ 276 \ 365 \ 203 ~ \ 276 \ 311 \ 367 \ 033 \ 276 \ 261 \ 240 \ 177 \ 2768 ` \ " \ 276i \ 364 \ 276 \ 321 \ 365 \ 363 \ 275 \ 0241 ~ \ 276 \ 005 \ 365 \ 376 \ 275S \ 303 \ 035 \ 277 \ 203 \ 003 \ 020 \ 276 \ 264 \ 322 \ 377 \ 276 $ \ 241 \ 177 \ 276 \ 264d \ t \ 276H \ 000C \ 276 \ 360 / ~ \ 276 \ 352 \ 301 \ 377 \ 275 \ 037 \ 300 \ n \ 276 \ 0000 \ 033 \ 276r | \ 377 \ 275 \ 025 \ 004 \ 002 \ 276 \ 276 \ 021 \ 262 \ 276 \ 343 \ 245M \ 2763 \ 302 \ 351 \ 276LE \ 005 \ 276 \ n \ " ~ \ 276 \ 341q \ 341 \ 276 \ 265 \ 022 ~ \ 276 \ 322 ^ \ 036 \ 276 \ 206 \ 216 \ 031 \ 276 \ 306 \ n \ 310 \ 276 \ 322_T \ 276 \ 367 \ 037w \ 276 \ 374 \ 227A \ 276 \ 010 \ 272G \ 276T & \ 022 \ 276y \ 217 > \ 276 \ 275H \ 033 \ 276 \ 002 = \ 376 \ 276 \ 232x0 \ 276 \ 322C ~ \ 276 \ 032 \ 350 \ 212 \ 276 \ 234 \ 322 \ 036 \ 2762 % \ 376 \ 276 \ 266 \ 345 # \ 276 . 1 \ 021 \ 276 \ 302 , \ 351 \ 276 \ 025x & \ 276 \ 354 \ 363 . \ 276 \ 362 \ 210 \ 025 \ 276 \ 035 \ 032 \ 036 \ 276 \ 267X \ 014 \ 276zc \ 177 \ 300 \ 336L_ \ 276 \ 274 , k \ 276 { \ 266 \ 203 \ 276 \ 366 \ 266 ~ \ 277 \ 225F \ 211 \ 276 \ 302 ~ \ 243 \ 276 \ 253 . \ 214 \ 2765 \ 241l \ 276g \ 021 \ 214 \ 276 \ 347 \ 376 \ 177 \ 276H \ 026T \ 276 \ 305 \ 220 \ 377 \ 276 \ 000 \ \ Y \ 276 \ 334 \ 332 > \ 276 \ 224 \ 2459 \ 276 \ 334ja \ 276 \ 260 \ 313p \ 276 \ 024 \ 026 \ \ \ 2769 \ 334 \ 177 \ 301 \ 334 \ 330 \ 222 \ 276 \ 347 \ 376e \ 276 \ 014 \ 230W \ 276 \ 253P \ 252 \ 276i \ 300C \ 276 \ 340 \ 261Y \ 276721 \ 276 # k ) \ 276 \ 035 . # \ 276R ( 0 \ 276 \ 224 \ 336 ! \ 276 " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights_quant / min / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights_quant / min " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / weights_quant / min " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights_quant / max " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + dim { <nl> + size : 186 <nl> + } <nl> + } <nl> + tensor_content : " \ 217 \ 245 \ 177A \ 005 @ d > C \ 030x > S \ 320 \ 177 > . \ 227q ? \ 260 ] \ 223 > j \ 016 \ 250 > \ 305 \ 017 \ 202 > \ 200 + \ 201 > \ 275 \ 377 \ 177 > \ 310 & \ 202 > \ 314 \ 210k > \ 3178W ? \ 335 \ 356_ > \ 332GG > ` \ 200 > > o_c > \ 312 \ 224k > 7 \ 033S > M = \ 376 @ y - \ 271 > \ 225 \ 021g > \ 272lZ > \ 353r \ 251 > \ 025 \ 354G > \ 357 \ 220 \ \ > 5j0 > 5Q ( > \ 013 > 0 > Y \ r \ ' > \ 224 \ 013 \ " > G = \ 377 @ \ 022 \ 211E > \ 344 \ 035O > \ 242 \ 220l > w \ 307 \ 020 ? 3 ` \ 376 > \ 331 \ 377 \ 202 > \ 374 \ 016Y > \ 224 \ 273 ^ > 7 ` ~ > V \ 016 > > \ 226 \ 333g > * \ 241K > \ 224g \ 177 > \ 320 \ 315 ( > t \ 376 \ 177 > B \ 025B > @ \ 214 \ 226 > \ 377s \ 376 > \ 373 \ 365 \ 377 ? \ 343 \ 211 ~ > \ 205 \ 320b > \ 213 \ 236 \ 377 > 3 \ 0136 > u \ 237 : > \ 325 \ 373 ~ > \ 344 \ r \ 037 > > \ 035 ( > \ 247 \ 364 ! > \ 2613 % > \ 207 ] ! > \ 320S \ 376A \ 354 _ > \ 337PT > \ 342 \ 226 [ > \ 304 \ 307 \ 177 > \ 360 \ " x > \ 312 \ 023 \ 200 > Wfp > 8 $ W > \ 235 \ 014 \ 202 > \ 230 \ 210m > 1 \ 342L > b \ 234 \ 013 ? \ 362XM > QPL > \ 006Va > \ 3168 > > \ 262 \ 367t > x \ 252k > \ 266 \ 225 \ 231 > z @ B > \ 244 \ 340 ? > > 8 ] > \ 214v \ 206 > \ 316 \ 210Z > \ 275 \ 343U > \ 366 \ 0321 > b \ 2128 > \ 310 \ 2611 > \ 340n / > \ 312 \ 272 \ ' > \ 207 \ 274 \ 207 > tl \ 034 > \ 214 [ \ 357 = \ 020 \ 345 @ > \ 1778 \ 376 = \ 264 ~ # > \ 326U * > \ 374g \ 003 > \ 377 \ 013 \ 000 > \ 361 \ 375T > \ 246 \ 330 \ 007 > \ 365 \ 203 ~ > \ 311 \ 367 \ 033 > \ 261 \ 240 \ 177 > 8 ` \ " > i \ 364 > \ 321 \ 365 \ 363 = \ 0241 ~ > \ 005 \ 365 \ 376 = S \ 303 \ 035 ? \ 203 \ 003 \ 020 > \ 264 \ 322 \ 377 > $ \ 241 \ 177 > \ 264d \ t > H \ 000C > \ 360 / ~ > \ 352 \ 301 \ 377 = \ 037 \ 300 \ n > \ 0000 \ 033 > r | \ 377 = \ 025 \ 004 \ 002 > \ 276 \ 021 \ 262 > \ 343 \ 245M > 3 \ 302 \ 351 > LE \ 005 > \ n \ " ~ > \ 341q \ 341 > \ 265 \ 022 ~ > \ 322 ^ \ 036 > \ 206 \ 216 \ 031 > \ 306 \ n \ 310 > \ 322_T > \ 367 \ 037w > \ 374 \ 227A > \ 010 \ 272G > T & \ 022 > y \ 217 > > \ 275H \ 033 > \ 002 = \ 376 > \ 232x0 > \ 322C ~ > \ 032 \ 350 \ 212 > \ 234 \ 322 \ 036 > 2 % \ 376 > \ 266 \ 345 # > . 1 \ 021 > \ 302 , \ 351 > \ 025x & > \ 354 \ 363 . > \ 362 \ 210 \ 025 > \ 035 \ 032 \ 036 > \ 267X \ 014 > zc \ 177 @ \ 336L_ > \ 274 , k > { \ 266 \ 203 > \ 366 \ 266 ~ ? \ 225F \ 211 > \ 302 ~ \ 243 > \ 253 . \ 214 > 5 \ 241l > g \ 021 \ 214 > \ 347 \ 376 \ 177 > H \ 026T > \ 305 \ 220 \ 377 > \ 000 \ \ Y > \ 334 \ 332 > > \ 224 \ 2459 > \ 334ja > \ 260 \ 313p > \ 024 \ 026 \ \ > 9 \ 334 \ 177A \ 334 \ 330 \ 222 > \ 347 \ 376e > \ 014 \ 230W > \ 253P \ 252 > i \ 300C > \ 340 \ 261Y > 721 > # k ) > \ 035 . # > R ( 0 > \ 224 \ 336 ! > " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights_quant / max / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights_quant / max " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / weights_quant / max " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / weights_quant / FakeQuantWithMinMaxVarsPerChannel " <nl> + op : " FakeQuantWithMinMaxVarsPerChannel " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights / read " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights_quant / min / read " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights_quant / max / read " <nl> + attr { <nl> + key : " narrow_range " <nl> + value { <nl> + b : true <nl> + } <nl> + } <nl> + attr { <nl> + key : " num_bits " <nl> + value { <nl> + i : 8 <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / Conv2D " <nl> + op : " Conv2D " <nl> + input : " input " <nl> + input : " BoxPredictor_4 / ClassPredictor / weights_quant / FakeQuantWithMinMaxVarsPerChannel " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " data_format " <nl> + value { <nl> + s : " NHWC " <nl> + } <nl> + } <nl> + attr { <nl> + key : " dilations " <nl> + value { <nl> + list { <nl> + i : 1 <nl> + i : 1 <nl> + i : 1 <nl> + i : 1 <nl> + } <nl> + } <nl> + } <nl> + attr { <nl> + key : " explicit_paddings " <nl> + value { <nl> + list { <nl> + } <nl> + } <nl> + } <nl> + attr { <nl> + key : " padding " <nl> + value { <nl> + s : " SAME " <nl> + } <nl> + } <nl> + attr { <nl> + key : " strides " <nl> + value { <nl> + list { <nl> + i : 1 <nl> + i : 1 <nl> + i : 1 <nl> + i : 1 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / biases " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + dim { <nl> + size : 186 <nl> + } <nl> + } <nl> + tensor_content : " \ 324 \ 202 \ 223 \ 276 \ 337 \ 210 \ 375 \ 275 \ 351 \ 212 \ 374 \ 275p @ \ 346 \ 275HD \ 364 \ 275W \ 236 \ 362 \ 275i \ 222 \ 001 \ 276 \ ' \ 370 \ 365 \ 275 : \ 250 \ 345 \ 275 \ 244 \ 214 \ 373 \ 275 } \ 373 \ 025 \ 276 ^ \ 351 \ 000 \ 2767_ \ 017 \ 276 \ 362 \ t \ 322 \ 2751 % \ 376 \ 275 \ 364 \ 020 \ 324 \ 275 , \ 352 \ 323 \ 275 \ 233 \ 350 \ 365 \ 275 \ 3777 \ 014 \ 276 \ 371 \ 022 \ 277 \ 2745 { \ 366 \ 275 \ 270 \ 207 \ 366 \ 275b \ 215 \ 010 \ 276 \ 332 \ 252 \ " \ 276 \ 273 \ 313 \ 332 \ 275 \ 354 \ 237 \ 361 \ 275 \ 365W9 \ 276o \ 364B \ 276 \ 236HD \ 276 $ \ 250B \ 276CRC \ 276K \ 265 \ 246 \ 275f5 \ 016 \ 276 [ I \ 017 \ 276 \ 206 \ 346 \ r \ 276 \ 306 \ 307 \ 032 \ 276 \ 267 \ 323 \ 375 \ 275 \ 222 \ 377 \ 002 \ 276 \ 037 \ 231 \ 030 \ 276 \ 346W \ 001 \ 2762F \ 004 \ 276 \ 021 / \ 034 \ 276 \ 273 \ 215 \ 357 \ 275 \ 014m5 \ 276 \ 307 [ \ 021 \ 276K \ r \ 022 \ 276Xv \ 365 \ 275 \ 312L \ 372 \ 275A4 \ 026 \ 276 \ 210 [ \ 024 \ 276 \ 254 \ 242 \ 003 \ 276 \ 207f \ 000 \ 276 \ \ C \ 023 \ 276 \ 322 \ 233 \ 000 \ 276 \ 266 \ 0018 \ 276 \ 233 \ 225 \ 370 \ 275 \ 243 \ 030 \ 004 \ 276 ] \ 201C \ 276 \ 374j : \ 276 \ 361 \ 257 @ \ 276 \ 017z < \ 276P ? A \ 276a : \ 375 \ 276 \ 023 \ 220 \ 342 \ 275W \ 026 \ 377 \ 275qD \ 005 \ 276 \ ' \ 271 \ 371 \ 275 \ 342 \ 207 \ n \ 276 \ 273 \ 221 \ 003 \ 276 \ 372 \ 205 \ 363 \ 275Ok \ 334 \ 275 \ 306 \ 233 \ 023 \ 276y \ 271 \ " \ 276 \ 313 \ 345 \ n \ 276UH \ " \ 276 \ 233j \ 366 \ 275 \ 0026 \ 377 \ 275O \ 263 \ 341 \ 275 \ 005 \ 340 \ 365 \ 275 , $ \ n \ 276 \ 222 \ 030 \ 010 \ 276 \ 243 \ 020 \ 346 \ 275 \ 301 \ 322 \ 007 \ 276n \ 252 \ 374 \ 275 \ 325 \ 251 \ 007 \ 276 \ 325 \ 033 , \ 276 \ 352 \ 217 \ 345 \ 275 \ 234 \ 334 \ t \ 276 \ 024 \ 241 @ \ 276 \ 256 \ 365H \ 276zbA \ 276 \ 262 \ 361A \ 276 \ 275C > \ 276 \ 353Z \ 005 > \ 2050 & \ 276 \ 035 \ 222 & \ 276 \ 2457 % \ 276 \ 377 / \ ' \ 276 ^ \ 263 \ 037 \ 276 \ 202 \ 341 % \ 276 } \ 312 \ 034 \ 276 & \ 2520 \ 276Y \ 313 , \ 276 \ 232C * \ 276 \ 233 \ 375 \ 032 \ 276 \ 212 \ 250 % \ 276 \ 020 \ 362 \ 034 \ 276 \ 212 \ 213 - \ 276 \ 211 \ 211 \ 030 \ 276P \ 256 \ " \ 276 \ 260 \ 307 \ 027 \ 276 ? \ 332 $ \ 276 \ 213 \ 326 \ 025 \ 2761 \ 243 \ 023 \ 276L \ 335 \ 034 \ 276 \ 375 \ 034 \ 035 \ 276L \ 2112 \ 276 \ 016 \ 3571 \ 276 \ 224 ] \ 036 \ 276 \ r \ 3165 \ 276 \ 232 \ 340 & \ 276 ? \ 2315 \ 276 ^ \ 342 , \ 276 \ 360 { 2 \ 276 \ 314 \ 031 \ 274 = s \ 363 \ r \ 276C \ 227 \ 035 \ 276 \ 332 ` \ 037 \ 276 \ 236 \ 332 \ 031 \ 276Kj0 \ 276 $ \ 034 \ 035 \ 276 \ 227 \ 262 \ 033 \ 276 \ 231 \ 260 \ 033 \ 2764 \ 213 \ 035 \ 276 \ 021 \ 363 $ \ 276y \ 372 & \ 276m ` / \ 276 < \ 272 \ 027 \ 276 \ 267l \ 025 \ 276 \ 034x \ 031 \ 276 \ 202 \ 313 \ 034 \ 276 \ 026 \ 363 \ 027 \ 276 \ 307 ( \ 014 \ 276 < \ 332 \ 005 \ 276 \ 231 \ 316 ! \ 276 \ 022 \ 355 \ 027 \ 276 - \ 251 \ 037 \ 2764 \ 203 + \ 276c \ 032 \ 276 \ 006 # \ 036 \ 276 \ 22064 \ 276 \ 27450 \ 2768O3 \ 276 \ 013 \ 2321 \ 276 \ 31143 \ 276a \ 367 \ n \ 2763 \ 347 \ 362 \ 275 ? \ 037 \ 003 \ 276 \ 241 \ 375 \ 001 \ 276 \ 340 \ 003 \ 332 \ 275e \ 342 \ 357 \ 275 \ 022 \ 226 \ 376 \ 275 \ 214 \ 206 \ 366 \ 275 \ 220 \ 303 \ 311 \ 275 \ 360 \ 342 \ 374 \ 275 \ 246 \ 361 \ 016 \ 276 \ 234 \ 227 \ 351 \ 275 \ 227 \ 306 \ 023 \ 276 \ 234 \ 252 \ 325 \ 275 \ 200 \ 002 \ 001 \ 276 \ \ \ 243 \ 317 \ 275 \ 302 \ 233 \ 311 \ 275 \ 177 \ 024 \ 002 \ 276 \ 325 \ 027 \ 002 \ 276 \ ' \ 351 \ 236 = \ 316q \ 366 \ 275 \ 243 > \ 010 \ 276 \ 203 \ 204 \ 373 \ 275 \ 365F / \ 276 \ 225 \ 323 \ 346 \ 275 \ 250 , \ 375 \ 275E \ 0048 \ 276 \ 306 \ 340 ? \ 276 [ / < \ 276 \ 212 \ 025B \ 276 \ 251 \ 264 ? \ 276 " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / biases / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / biases " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / biases " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / BiasAdd " <nl> + op : " BiasAdd " <nl> + input : " BoxPredictor_4 / ClassPredictor / Conv2D " <nl> + input : " BoxPredictor_4 / ClassPredictor / biases / read " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " data_format " <nl> + value { <nl> + s : " NHWC " <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / act_quant / min " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + } <nl> + float_val : - 14 . 066669 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / act_quant / min / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / act_quant / min " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / act_quant / min " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / act_quant / max " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_FLOAT <nl> + tensor_shape { <nl> + } <nl> + float_val : 9 . 810242 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / act_quant / max / read " <nl> + op : " Identity " <nl> + input : " BoxPredictor_4 / ClassPredictor / act_quant / max " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " _class " <nl> + value { <nl> + list { <nl> + s : " loc : @ BoxPredictor_4 / ClassPredictor / act_quant / max " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / ClassPredictor / act_quant / FakeQuantWithMinMaxVars " <nl> + op : " FakeQuantWithMinMaxVars " <nl> + input : " BoxPredictor_4 / ClassPredictor / BiasAdd " <nl> + input : " BoxPredictor_4 / ClassPredictor / act_quant / min / read " <nl> + input : " BoxPredictor_4 / ClassPredictor / act_quant / max / read " <nl> + attr { <nl> + key : " narrow_range " <nl> + value { <nl> + b : false <nl> + } <nl> + } <nl> + attr { <nl> + key : " num_bits " <nl> + value { <nl> + i : 8 <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " BoxPredictor_4 / Reshape_1 / shape " <nl> + op : " Const " <nl> + attr { <nl> + key : " dtype " <nl> + value { <nl> + type : DT_INT32 <nl> + } <nl> + } <nl> + attr { <nl> + key : " value " <nl> + value { <nl> + tensor { <nl> + dtype : DT_INT32 <nl> + tensor_shape { <nl> + dim { <nl> + size : 3 <nl> + } <nl> + } <nl> + tensor_content : " \ 001 \ 000 \ 000 \ 000 \ 377 \ 377 \ 377 \ 377 \ 037 \ 000 \ 000 \ 000 " <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " output " <nl> + op : " Reshape " <nl> + input : " BoxPredictor_4 / ClassPredictor / act_quant / FakeQuantWithMinMaxVars " <nl> + input : " BoxPredictor_4 / Reshape_1 / shape " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " Tshape " <nl> + value { <nl> + type : DT_INT32 <nl> + } <nl> + } <nl> + } <nl> + <nl> + # TODO ( fengliuai ) : make the storage type signed . <nl> + # MLIR - LABEL : func @ main ( % arg0 : tensor < 1x1x1x256x ! quant . uniform < u8 : f32 , 0 . 21632751372549019 : 155 > > ) - > tensor < 1x6x31x ! quant . uniform < u8 : f32 , 0 . 09363494573854933 : 150 > > <nl> + # MLIR : attributes { tf . entry_function = { inputs = " input " , outputs = " output " } <nl> + # MLIR : % [ [ shape : . * ] ] = constant dense < [ 1 , - 1 , 31 ] > : tensor < 3xi32 > <nl> + # MLIR : % [ [ input : . * ] ] = " tfl . pseudo_input " ( % arg0 ) : ( tensor < 1x1x1x256x ! quant . uniform < u8 : f32 , 0 . 21632751372549019 : 155 > > ) <nl> + # MLIR : % [ [ bias : . * ] ] = " tfl . pseudo_qconst " ( ) { qtype = tensor < 186x ! quant . uniform < i32 : f32 : 0 <nl> + # MLIR : % [ [ weight : . * ] ] = " tfl . pseudo_qconst " ( ) { qtype = tensor < 186x1x1x256x ! quant . uniform < u8 < 1 : 255 > : f32 : 0 , { 0 . 12581039038230116 : 128 , <nl> + # MLIR : % [ [ conv : . * ] ] = " tfl . conv_2d " ( % [ [ input ] ] , % [ [ weight ] ] , % [ [ bias ] ] ) { dilation_h_factor = 1 : i32 , dilation_w_factor = 1 : i32 , fused_activation_function = " NONE " , padding = " SAME " , stride_h = 1 : i32 , stride_w = 1 : i32 } <nl> + # MLIR : % [ [ reshape : . * ] ] = " tfl . reshape " ( % [ [ conv ] ] , % [ [ shape ] ] ) : ( tensor < 1x1x1x186x ! quant . uniform < u8 : f32 , 0 . 09363494573854933 : 150 > > , tensor < 3xi32 > ) <nl> + # MLIR : return % [ [ reshape ] ] : tensor < 1x6x31x ! quant . uniform < u8 : f32 , 0 . 09363494573854933 : 150 > > <nl> + # MLIR : } <nl> + <nl> + <nl> + # CHECK - LABEL : { <nl> + # CHECK : version : 3 , <nl> + # CHECK : operator_codes : [ { <nl> + # CHECK : builtin_code : CONV_2D , <nl> + # CHECK : version : 1 <nl> + # CHECK : } , { <nl> + # CHECK : builtin_code : RESHAPE , <nl> + # CHECK : version : 1 <nl> + # CHECK : } ] , <nl> + # CHECK : subgraphs : [ { <nl> + # CHECK : tensors : [ { <nl> + # CHECK : shape : [ 3 ] , <nl> + # CHECK : type : INT32 , <nl> + # CHECK : buffer : 1 , <nl> + # CHECK : name : " BoxPredictor_4 / Reshape_1 / shape " , <nl> + # CHECK : quantization : { <nl> + # CHECK - EMPTY <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : shape : [ 1 , 1 , 1 , 256 ] , <nl> + # CHECK : type : UINT8 , <nl> + # CHECK : buffer : 2 , <nl> + # CHECK : name : " input " , <nl> + # CHECK : quantization : { <nl> + # CHECK : scale : [ 0 . 216328 ] , <nl> + # CHECK : zero_point : [ 155 ] <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : shape : [ 186 ] , <nl> + # CHECK : type : INT32 , <nl> + # CHECK : buffer : 3 , <nl> + # CHECK : name : " tfl . pseudo_qconst " , <nl> + # CHECK : quantization : { <nl> + # CHECK : scale : [ 0 . 027216 , 0 . 00038 , 0 . 000413 , 0 . 000426 , 0 . 001607 , <nl> + # CHECK : zero_point : [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : shape : [ 186 , 1 , 1 , 256 ] , <nl> + # CHECK : type : UINT8 , <nl> + # CHECK : buffer : 4 , <nl> + # CHECK : name : " tfl . pseudo_qconst1 " , <nl> + # CHECK : quantization : { <nl> + # CHECK : scale : [ 0 . 12581 , 0 . 001755 , 0 . 001908 , 0 . 001967 , 0 . 007431 , <nl> + # CHECK : zero_point : [ 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : shape : [ 1 , 1 , 1 , 186 ] , <nl> + # CHECK : type : UINT8 , <nl> + # CHECK : buffer : 5 , <nl> + # CHECK : name : " tfl . conv_2d " , <nl> + # CHECK : quantization : { <nl> + # CHECK : scale : [ 0 . 093635 ] , <nl> + # CHECK : zero_point : [ 150 ] <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : shape : [ 1 , 6 , 31 ] , <nl> + # CHECK : type : UINT8 , <nl> + # CHECK : buffer : 6 , <nl> + # CHECK : name : " output " , <nl> + # CHECK : quantization : { <nl> + # CHECK : scale : [ 0 . 093635 ] , <nl> + # CHECK : zero_point : [ 150 ] <nl> + # CHECK : } <nl> + # CHECK : } ] , <nl> + # CHECK : inputs : [ 1 ] , <nl> + # CHECK : outputs : [ 5 ] , <nl> + # CHECK : operators : [ { <nl> + # CHECK : inputs : [ 1 , 3 , 2 ] , <nl> + # CHECK : outputs : [ 4 ] , <nl> + # CHECK : builtin_options_type : Conv2DOptions , <nl> + # CHECK : builtin_options : { <nl> + # CHECK : stride_w : 1 , <nl> + # CHECK : stride_h : 1 <nl> + # CHECK : } <nl> + # CHECK : } , { <nl> + # CHECK : opcode_index : 1 , <nl> + # CHECK : inputs : [ 4 , 0 ] , <nl> + # CHECK : outputs : [ 5 ] <nl> + # CHECK : } ] , <nl> + # CHECK : name : " main " <nl> + # CHECK : } ] , <nl> + # CHECK : description : " MLIR Converted . " , <nl> + # CHECK : buffers : [ { <nl> + # CHECK - EMPTY <nl> + # CHECK : } , { <nl> + # CHECK : data : [ 1 , 0 , 0 , 0 , 255 , 255 , 255 , 255 , 31 , 0 , 0 , 0 ] <nl> + # CHECK : } , { <nl> + # CHECK - EMPTY <nl> + # CHECK : } , { <nl> + # CHECK : data : [ 245 , 255 , 255 , 255 , 186 , 254 , 255 , 255 , 213 , 254 , 255 , 255 , <nl> + # CHECK : } , { <nl> + # CHECK : data : [ 136 , 136 , 136 , 136 , 136 , 136 , 136 , 136 , 136 , 136 , 136 , 136 , <nl> + # CHECK : } , { <nl> + # CHECK - EMPTY <nl> + # CHECK : } , { <nl> + # CHECK - EMPTY <nl> + # CHECK : } ] <nl> + # CHECK : } <nl> mmm a / tensorflow / compiler / mlir / lite / tf_tfl_translate . cc <nl> ppp b / tensorflow / compiler / mlir / lite / tf_tfl_translate . cc <nl> int main ( int argc , char * * argv ) { <nl> mlir : : TFL : : QuantizationSpecs quant_specs ; <nl> if ( mlir : : TFL : : ParseInputNodeQuantSpecs ( input_arrays , min_values , max_values , <nl> inference_type , & quant_specs ) ) { <nl> - llvm : : errs ( ) < < " UFailed to get input quant spec . " ; <nl> + llvm : : errs ( ) < < " Failed to get input quant spec . " ; <nl> return kTrFailure ; <nl> } <nl> if ( weight_quantization ! = " NONE " ) { <nl> | Add an end - to - end test for the per - channel fake quantization conversion | tensorflow/tensorflow | bd6e4990da9e3a398875f7788a2b3363979c64ba | 2019-09-30T23:30:47Z |
mmm a / build / fbcode_builder / getdeps . py <nl> ppp b / build / fbcode_builder / getdeps . py <nl> <nl> from getdeps . buildopts import setup_build_options <nl> from getdeps . dyndeps import create_dyn_dep_munger <nl> from getdeps . errors import TransientFailure <nl> - from getdeps . load import load_project , manifests_in_dependency_order <nl> + from getdeps . load import ManifestLoader <nl> from getdeps . manifest import ManifestParser <nl> from getdeps . platform import HostType <nl> from getdeps . subcmd import SubCmd , add_subcommands , cmd <nl> def setup_parser ( self , parser ) : <nl> <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> - ctx_gen = opts . get_context_generator ( ) <nl> - manifest = load_project ( opts , args . project ) <nl> + loader = ManifestLoader ( opts ) <nl> + manifest = loader . load_manifest ( args . project ) <nl> if args . recursive : <nl> - projects = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> + projects = loader . manifests_in_dependency_order ( ) <nl> else : <nl> projects = [ manifest ] <nl> for m in projects : <nl> - fetcher = m . create_fetcher ( opts , ctx_gen . get_context ( m . name ) ) <nl> + fetcher = m . create_fetcher ( opts , loader . ctx_gen . get_context ( m . name ) ) <nl> fetcher . update ( ) <nl> <nl> <nl> def run ( self , args ) : <nl> class ListDepsCmd ( SubCmd ) : <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> - ctx_gen = opts . get_context_generator ( ) <nl> - ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> - manifest = load_project ( opts , args . project ) <nl> - for m in manifests_in_dependency_order ( opts , manifest , ctx_gen ) : <nl> + loader = ManifestLoader ( opts ) <nl> + loader . ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> + loader . load_manifest ( args . project ) <nl> + for m in loader . manifests_in_dependency_order ( ) : <nl> print ( m . name ) <nl> return 0 <nl> <nl> def run ( self , args ) : <nl> class ShowInstDirCmd ( SubCmd ) : <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> - ctx_gen = opts . get_context_generator ( ) <nl> - ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> - manifest = load_project ( opts , args . project ) <nl> - projects = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> - manifests_by_name = { m . name : m for m in projects } <nl> + loader = ManifestLoader ( opts ) <nl> + loader . ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> + manifest = loader . load_manifest ( args . project ) <nl> + projects = loader . manifests_in_dependency_order ( ) <nl> <nl> if args . recursive : <nl> manifests = projects <nl> def run ( self , args ) : <nl> manifests = [ manifest ] <nl> <nl> for m in manifests : <nl> - ctx = ctx_gen . get_context ( m . name ) <nl> + ctx = loader . ctx_gen . get_context ( m . name ) <nl> fetcher = m . create_fetcher ( opts , ctx ) <nl> - dirs = opts . compute_dirs ( m , fetcher , manifests_by_name , ctx_gen ) <nl> + dirs = opts . compute_dirs ( <nl> + m , fetcher , loader . manifests_by_name , loader . ctx_gen <nl> + ) <nl> inst_dir = dirs [ " inst_dir " ] <nl> print ( inst_dir ) <nl> <nl> def setup_parser ( self , parser ) : <nl> class ShowSourceDirCmd ( SubCmd ) : <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> - ctx_gen = opts . get_context_generator ( ) <nl> - ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> - manifest = load_project ( opts , args . project ) <nl> + loader = ManifestLoader ( opts ) <nl> + loader . ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> + manifest = loader . load_manifest ( args . project ) <nl> <nl> if args . recursive : <nl> - manifests = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> + manifests = loader . manifests_in_dependency_order ( ) <nl> else : <nl> manifests = [ manifest ] <nl> <nl> for m in manifests : <nl> - fetcher = m . create_fetcher ( opts , ctx_gen . get_context ( m . name ) ) <nl> + fetcher = m . create_fetcher ( opts , loader . ctx_gen . get_context ( m . name ) ) <nl> print ( fetcher . get_src_dir ( ) ) <nl> <nl> def setup_parser ( self , parser ) : <nl> def setup_parser ( self , parser ) : <nl> class BuildCmd ( SubCmd ) : <nl> def run ( self , args ) : <nl> opts = setup_build_options ( args ) <nl> - if args . clean : <nl> - clean_dirs ( opts ) <nl> - <nl> ctx_gen = opts . get_context_generator ( facebook_internal = args . facebook_internal ) <nl> if args . enable_tests : <nl> ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> - manifest = load_project ( opts , args . project ) <nl> + loader = ManifestLoader ( opts , ctx_gen ) <nl> + <nl> + if args . clean : <nl> + clean_dirs ( opts ) <nl> + <nl> + manifest = loader . load_manifest ( args . project ) <nl> <nl> print ( " Building on % s " % ctx_gen . get_context ( args . project ) ) <nl> - projects = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> - manifests_by_name = { m . name : m for m in projects } <nl> + projects = loader . manifests_in_dependency_order ( ) <nl> <nl> # Accumulate the install directories so that the build steps <nl> # can find their dep installation <nl> def run ( self , args ) : <nl> if args . clean : <nl> fetcher . clean ( ) <nl> <nl> - dirs = opts . compute_dirs ( m , fetcher , manifests_by_name , ctx_gen ) <nl> + dirs = opts . compute_dirs ( m , fetcher , loader . manifests_by_name , ctx_gen ) <nl> build_dir = dirs [ " build_dir " ] <nl> inst_dir = dirs [ " inst_dir " ] <nl> <nl> def run ( self , args ) : <nl> if args . enable_tests : <nl> ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> <nl> - manifest = load_project ( opts , args . project ) <nl> + loader = ManifestLoader ( opts , ctx_gen ) <nl> + manifest = loader . load_manifest ( args . project ) <nl> <nl> - projects = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> - manifests_by_name = { m . name : m for m in projects } <nl> + projects = loader . manifests_in_dependency_order ( ) <nl> <nl> # Accumulate the install directories so that the build steps <nl> # can find their dep installation <nl> def run ( self , args ) : <nl> ctx = ctx_gen . get_context ( m . name ) <nl> fetcher = m . create_fetcher ( opts , ctx ) <nl> <nl> - dirs = opts . compute_dirs ( m , fetcher , manifests_by_name , ctx_gen ) <nl> + dirs = opts . compute_dirs ( m , fetcher , loader . manifests_by_name , ctx_gen ) <nl> inst_dir = dirs [ " inst_dir " ] <nl> <nl> install_dirs . append ( inst_dir ) <nl> def run ( self , args ) : <nl> else : <nl> ctx_gen . set_value_for_project ( args . project , " test " , " on " ) <nl> <nl> - manifest = load_project ( opts , args . project ) <nl> - projects = manifests_in_dependency_order ( opts , manifest , ctx_gen ) <nl> - manifests_by_name = { m . name : m for m in projects } <nl> + loader = ManifestLoader ( opts , ctx_gen ) <nl> + manifest = loader . load_manifest ( args . project ) <nl> + projects = loader . manifests_in_dependency_order ( ) <nl> <nl> # Accumulate the install directories so that the test steps <nl> # can find their dep installation <nl> def run ( self , args ) : <nl> ctx = ctx_gen . get_context ( m . name ) <nl> fetcher = m . create_fetcher ( opts , ctx ) <nl> <nl> - dirs = opts . compute_dirs ( m , fetcher , manifests_by_name , ctx_gen ) <nl> + dirs = opts . compute_dirs ( m , fetcher , loader . manifests_by_name , ctx_gen ) <nl> build_dir = dirs [ " build_dir " ] <nl> inst_dir = dirs [ " inst_dir " ] <nl> <nl> mmm a / build / fbcode_builder / getdeps / load . py <nl> ppp b / build / fbcode_builder / getdeps / load . py <nl> def load_all_manifests ( build_opts ) : <nl> return LOADER . load_all ( build_opts ) <nl> <nl> <nl> - def manifests_in_dependency_order ( build_opts , manifest , ctx_gen ) : <nl> - " " " Given a manifest , expand its dependencies and return a list <nl> - of the manifest objects that would need to be built in the order <nl> - that they would need to be built . This does not evaluate whether <nl> - a build is needed ; it just returns the list in the order specified <nl> - by the manifest files . " " " <nl> - # A dict to save loading a project multiple times <nl> - manifests_by_name = { manifest . name : manifest } <nl> - # The list of deps that have been fully processed <nl> - seen = set ( ) <nl> - # The list of deps which have yet to be evaluated . This <nl> - # can potentially contain duplicates . <nl> - deps = [ manifest ] <nl> - # The list of manifests in dependency order <nl> - dep_order = [ ] <nl> - <nl> - while len ( deps ) > 0 : <nl> - m = deps . pop ( 0 ) <nl> - if m . name in seen : <nl> - continue <nl> - <nl> - # Consider its deps , if any . <nl> - # We sort them for increased determinism ; we ' ll produce <nl> - # a correct order even if they aren ' t sorted , but we prefer <nl> - # to produce the same order regardless of how they are listed <nl> - # in the project manifest files . <nl> - ctx = ctx_gen . get_context ( m . name ) <nl> - dep_list = sorted ( m . get_section_as_dict ( " dependencies " , ctx ) . keys ( ) ) <nl> - builder = m . get ( " build " , " builder " , ctx = ctx ) <nl> - if builder = = " cmake " : <nl> - dep_list . append ( " cmake " ) <nl> - elif builder = = " autoconf " and m . name not in ( <nl> - " autoconf " , <nl> - " libtool " , <nl> - " automake " , <nl> - ) : <nl> - # they need libtool and its deps ( automake , autoconf ) so add <nl> - # those as deps ( but obviously not if we ' re building those <nl> - # projects themselves ) <nl> - dep_list . append ( " libtool " ) <nl> - <nl> - dep_count = 0 <nl> - for dep in dep_list : <nl> - # If we ' re not sure whether it is done , queue it up <nl> - if dep not in seen : <nl> - if dep not in manifests_by_name : <nl> - dep = load_project ( build_opts , dep ) <nl> - manifests_by_name [ dep . name ] = dep <nl> - else : <nl> - dep = manifests_by_name [ dep ] <nl> - <nl> - deps . append ( dep ) <nl> - dep_count + = 1 <nl> - <nl> - if dep_count > 0 : <nl> - # If we queued anything , re - queue this item , as it depends <nl> - # those new item ( s ) and their transitive deps . <nl> - deps . append ( m ) <nl> - continue <nl> - <nl> - # Its deps are done , so we can emit it <nl> - seen . add ( m . name ) <nl> - dep_order . append ( m ) <nl> - <nl> - return dep_order <nl> + class ManifestLoader ( object ) : <nl> + " " " ManifestLoader stores information about project manifest relationships for a <nl> + given set of ( build options + platform ) configuration . <nl> + <nl> + The ManifestLoader class primarily serves as a location to cache project dependency <nl> + relationships and project hash values for this build configuration . <nl> + " " " <nl> + <nl> + def __init__ ( self , build_opts , ctx_gen = None ) : <nl> + self . _loader = LOADER <nl> + self . build_opts = build_opts <nl> + if ctx_gen is None : <nl> + self . ctx_gen = self . build_opts . get_context_generator ( ) <nl> + else : <nl> + self . ctx_gen = ctx_gen <nl> + <nl> + self . manifests_by_name = { } <nl> + self . _loaded_all = False <nl> + <nl> + def load_manifest ( self , name ) : <nl> + manifest = self . manifests_by_name . get ( name ) <nl> + if manifest is None : <nl> + manifest = self . _loader . load_project ( self . build_opts , name ) <nl> + self . manifests_by_name [ name ] = manifest <nl> + return manifest <nl> + <nl> + def load_all_manifests ( self ) : <nl> + if not self . _loaded_all : <nl> + self . manifests_by_name = self . _loader . load_all ( self . build_opts ) <nl> + self . _loaded_all = True <nl> + <nl> + return self . manifests_by_name <nl> + <nl> + def manifests_in_dependency_order ( self , manifest = None ) : <nl> + " " " Compute all dependencies of the specified project . Returns a list of the <nl> + dependencies plus the project itself , in topologically sorted order . <nl> + <nl> + Each entry in the returned list only depends on projects that appear before it <nl> + in the list . <nl> + <nl> + If the input manifest is None , the dependencies for all currently loaded <nl> + projects will be computed . i . e . , if you call load_all_manifests ( ) followed by <nl> + manifests_in_dependency_order ( ) this will return a global dependency ordering of <nl> + all projects . " " " <nl> + # The list of deps that have been fully processed <nl> + seen = set ( ) <nl> + # The list of deps which have yet to be evaluated . This <nl> + # can potentially contain duplicates . <nl> + if manifest is None : <nl> + deps = list ( self . manifests_by_name . values ( ) ) <nl> + else : <nl> + assert manifest . name in self . manifests_by_name <nl> + deps = [ manifest ] <nl> + # The list of manifests in dependency order <nl> + dep_order = [ ] <nl> + <nl> + while len ( deps ) > 0 : <nl> + m = deps . pop ( 0 ) <nl> + if m . name in seen : <nl> + continue <nl> + <nl> + # Consider its deps , if any . <nl> + # We sort them for increased determinism ; we ' ll produce <nl> + # a correct order even if they aren ' t sorted , but we prefer <nl> + # to produce the same order regardless of how they are listed <nl> + # in the project manifest files . <nl> + ctx = self . ctx_gen . get_context ( m . name ) <nl> + dep_list = sorted ( m . get_section_as_dict ( " dependencies " , ctx ) . keys ( ) ) <nl> + builder = m . get ( " build " , " builder " , ctx = ctx ) <nl> + if builder = = " cmake " : <nl> + dep_list . append ( " cmake " ) <nl> + elif builder = = " autoconf " and m . name not in ( <nl> + " autoconf " , <nl> + " libtool " , <nl> + " automake " , <nl> + ) : <nl> + # they need libtool and its deps ( automake , autoconf ) so add <nl> + # those as deps ( but obviously not if we ' re building those <nl> + # projects themselves ) <nl> + dep_list . append ( " libtool " ) <nl> + <nl> + dep_count = 0 <nl> + for dep_name in dep_list : <nl> + # If we ' re not sure whether it is done , queue it up <nl> + if dep_name not in seen : <nl> + dep = self . manifests_by_name . get ( dep_name ) <nl> + if dep is None : <nl> + dep = self . _loader . load_project ( self . build_opts , dep_name ) <nl> + self . manifests_by_name [ dep . name ] = dep <nl> + <nl> + deps . append ( dep ) <nl> + dep_count + = 1 <nl> + <nl> + if dep_count > 0 : <nl> + # If we queued anything , re - queue this item , as it depends <nl> + # those new item ( s ) and their transitive deps . <nl> + deps . append ( m ) <nl> + continue <nl> + <nl> + # Its deps are done , so we can emit it <nl> + seen . add ( m . name ) <nl> + dep_order . append ( m ) <nl> + <nl> + return dep_order <nl> | add a new ManifestLoader class | facebook/folly | b2c3257cb061dcbafe2efaa9de984bf1d411acbd | 2019-08-01T03:56:59Z |
mmm a / js / server / modules / @ arangodb / cluster . js <nl> ppp b / js / server / modules / @ arangodb / cluster . js <nl> function createLocalCollections ( <nl> envelope [ agencyCols + database + ' / ' + collInfo . planId + ' / ' + shard ] = payload ; <nl> <nl> global . ArangoAgency . set ( ' Current / Collections / ' + database + ' / ' + <nl> - collInfo . planId + ' / ' + shard , payload ) <nl> + collInfo . planId + ' / ' + shard , payload ) ; <nl> global . ArangoAgency . write ( [ [ inccv ] ] ) ; <nl> <nl> console . debug ( ' creating Current / Collections / ' + database + ' / ' + <nl> | fixed jslint | arangodb/arangodb | dff5c448e4bc7141d5f912cc15430a931261aac1 | 2017-01-03T13:58:07Z |
mmm a / dbms / src / Processors / Transforms / MergingAggregatedMemoryEfficientTransform . cpp <nl> ppp b / dbms / src / Processors / Transforms / MergingAggregatedMemoryEfficientTransform . cpp <nl> struct ChunksToMerge : public ChunkInfo <nl> <nl> GroupingAggregatedTransform : : GroupingAggregatedTransform ( <nl> const Block & header , size_t num_inputs , AggregatingTransformParamsPtr params ) <nl> - : IProcessor ( InputPorts ( num_inputs , header ) , { header } ) <nl> + : IProcessor ( InputPorts ( num_inputs , header ) , { } ) <nl> , num_inputs ( num_inputs ) <nl> , params ( std : : move ( params ) ) <nl> , last_bucket_number ( num_inputs , - 1 ) <nl> Processors createMergingAggregatedMemoryEfficientPipe ( <nl> / / / - - > GroupingAggregated - - > ResizeProcessor - - > MergingAggregatedBucket - - > SortingAggregated - - > <nl> / / / - - > - - > MergingAggregatedBucket - - > <nl> <nl> - auto resize = std : : make_shared < ResizeProcessor > ( header , 1 , num_merging_processors ) ; <nl> + auto resize = std : : make_shared < ResizeProcessor > ( Block ( ) , 1 , num_merging_processors ) ; <nl> connect ( processors . back ( ) - > getOutputs ( ) . front ( ) , resize - > getInputs ( ) . front ( ) ) ; <nl> processors . emplace_back ( std : : move ( resize ) ) ; <nl> <nl> | Fix aggregated memory efficient transform headers . | ClickHouse/ClickHouse | 86b9e03358f35c0ea48510538391f0ada558de85 | 2019-04-11T15:16:18Z |
mmm a / src / csharp / Grpc . Microbenchmarks / Utf8Encode . cs <nl> ppp b / src / csharp / Grpc . Microbenchmarks / Utf8Encode . cs <nl> public void Setup ( ) <nl> var native = NativeMethods . Get ( ) ; <nl> <nl> / / nop the native - call via reflection <nl> - NativeMethods . Delegates . grpcsharp_call_send_status_from_server_delegate nop = ( CallSafeHandle call , BatchContextSafeHandle ctx , StatusCode statusCode , byte [ ] statusMessage , UIntPtr statusMessageLen , MetadataArraySafeHandle metadataArray , int sendEmptyInitialMetadata , byte [ ] optionalSendBuffer , UIntPtr optionalSendBufferLen , WriteFlags writeFlags ) = > { <nl> - completionRegistry . Extract ( ctx . Handle ) . OnComplete ( true ) ; / / drain the dictionary as we go <nl> - return CallError . OK ; <nl> - } ; <nl> - native . GetType ( ) . GetField ( nameof ( native . grpcsharp_call_send_status_from_server ) ) . SetValue ( native , nop ) ; <nl> + unsafe <nl> + { <nl> + NativeMethods . Delegates . grpcsharp_call_send_status_from_server_delegate nop = ( CallSafeHandle call , BatchContextSafeHandle ctx , StatusCode statusCode , byte * statusMessage , UIntPtr statusMessageLen , MetadataArraySafeHandle metadataArray , int sendEmptyInitialMetadata , byte [ ] optionalSendBuffer , UIntPtr optionalSendBufferLen , WriteFlags writeFlags ) = > { <nl> + completionRegistry . Extract ( ctx . Handle ) . OnComplete ( true ) ; / / drain the dictionary as we go <nl> + return CallError . OK ; <nl> + } ; <nl> + native . GetType ( ) . GetField ( nameof ( native . grpcsharp_call_send_status_from_server ) ) . SetValue ( native , nop ) ; <nl> + } <nl> <nl> environment = GrpcEnvironment . AddRef ( ) ; <nl> metadata = MetadataArraySafeHandle . Create ( Metadata . Empty ) ; <nl> | match delegate signature in benchmark | grpc/grpc | 264fca1eb6f0bc5118986c38bf53d39bbe02bf7a | 2019-07-02T14:40:36Z |
mmm a / grid / message . cpp <nl> ppp b / grid / message . cpp <nl> bool MessagingPort : : recv ( Message & m ) { <nl> <nl> assert ( x = = 4 ) ; <nl> <nl> - int z = ( len + 1023 ) & 0xfc00 ; assert ( z > = len ) ; <nl> + int z = ( len + 1023 ) & 0xfffffc00 ; assert ( z > = len ) ; <nl> MsgData * md = ( MsgData * ) malloc ( z ) ; <nl> md - > len = len ; <nl> char * p = ( char * ) & md - > id ; <nl> | assert z > len | mongodb/mongo | 6c86ae32789384895ad049a570b8779bf5f69643 | 2007-12-12T15:32:34Z |
mmm a / libraries / ESP8266WebServer / src / ESP8266WebServer . h <nl> ppp b / libraries / ESP8266WebServer / src / ESP8266WebServer . h <nl> class ESP8266WebServerTemplate <nl> void send ( int code , const char * content_type = NULL , const String & content = String ( " " ) ) ; <nl> void send ( int code , char * content_type , const String & content ) ; <nl> void send ( int code , const String & content_type , const String & content ) ; <nl> - void send ( int code , const char * content_type , const char * content , size_t content_length = 0 ) { <nl> - if ( content_length = = 0 ) { <nl> - content_length = strlen_P ( content ) ; <nl> - } <nl> + void send ( int code , const char * content_type , const char * content ) { <nl> + send_P ( code , content_type , content ) ; <nl> + } <nl> + void send ( int code , const char * content_type , const char * content , size_t content_length ) { <nl> send_P ( code , content_type , content , content_length ) ; <nl> } <nl> void send ( int code , const char * content_type , const uint8_t * content , size_t content_length ) { <nl> | webserver : fix sending char * ( ) | esp8266/Arduino | 326083044a458c2ee95aea09df3cfa83d567594e | 2019-12-03T23:51:51Z |
mmm a / js / apps / system / aardvark / test / karma / files . json <nl> ppp b / js / apps / system / aardvark / test / karma / files . json <nl> <nl> " test / specs / views / newLogsViewSpec . js " , <nl> " test / specs / views / notificationViewSpec . js " , <nl> " test / specs / views / statisticBarViewSpec . js " , <nl> - " test / specs / views / shellViewSpec . js " , <nl> <nl> <nl> " test / specs / router / routerSpec . js " , <nl> | removed shellviewspec from json | arangodb/arangodb | 70a7f1a45cc2b9e7d3ebb184036d0cfa23af1f03 | 2014-05-16T11:11:21Z |
mmm a / tensorflow / lite / experimental / micro / kernels / prelu_test . cc <nl> ppp b / tensorflow / lite / experimental / micro / kernels / prelu_test . cc <nl> TF_LITE_MICRO_TESTS_BEGIN <nl> TF_LITE_MICRO_TEST ( FloatPreluActivationsOpTest ) { <nl> const int output_dims_count = 12 ; <nl> float output_data [ output_dims_count ] ; <nl> - tflite : : testing : : TestPreluFloat ( { 1 , 2 , 2 , 3 } , / / input shape <nl> + tflite : : testing : : TestPreluFloat ( { 4 , 1 , 2 , 2 , 3 } , / / input shape <nl> { <nl> 0 . 0f , 0 . 0f , 0 . 0f , / / Row 1 , Column 1 <nl> 1 . 0f , 1 . 0f , 1 . 0f , / / Row 1 , Column 2 <nl> - 1 . 0f , - 1 . 0f , - 1 . 0f , / / Row 2 , Column 1 <nl> - 2 . 0f , - 2 . 0f , - 2 . 0f , / / Row 1 , Column 2 <nl> } , <nl> - { 1 , 1 , 3 } , / / alpha shape <nl> + { 3 , 1 , 1 , 3 } , / / alpha shape <nl> { 0 . 0f , 1 . 0f , 2 . 0f } , / / alpha values <nl> { <nl> 0 . 0f , 0 . 0f , 0 . 0f , / / Row 1 , Column 1 <nl> TF_LITE_MICRO_TEST ( FloatPreluActivationsOpTest ) { <nl> 0 . 0f , - 1 . 0f , - 2 . 0f , / / Row 2 , Column 1 <nl> 0 . 0f , - 2 . 0f , - 4 . 0f , / / Row 1 , Column 2 <nl> } , <nl> - { 1 , 2 , 2 , 3 } , / / output shape <nl> + { 4 , 1 , 2 , 2 , 3 } , / / output shape <nl> output_data ) ; <nl> } <nl> <nl> TF_LITE_MICRO_TEST ( QuantizedPreluActivationsOpTest ) { <nl> const int output_dims_count = 12 ; <nl> uint8_t output_data [ output_dims_count ] ; <nl> tflite : : testing : : TestPreluQuantized ( <nl> - { 1 , 2 , 2 , 3 } , / / input shape <nl> + { 4 , 1 , 2 , 2 , 3 } , / / input shape <nl> { F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( 0 . 0f , kMin , kMax ) , <nl> F2Q ( 0 . 5f , kMin , kMax ) , F2Q ( 0 . 5f , kMin , kMax ) , F2Q ( 0 . 5f , kMin , kMax ) , <nl> F2Q ( - 1 . 0f , kMin , kMax ) , F2Q ( - 1 . 0f , kMin , kMax ) , F2Q ( - 1 . 0f , kMin , kMax ) , <nl> F2Q ( - 0 . 25f , kMin , kMax ) , F2Q ( - 0 . 25f , kMin , kMax ) , <nl> F2Q ( - 0 . 25f , kMin , kMax ) } , <nl> - kMin , kMax , { 1 , 1 , 3 } , / / alpha shape <nl> + kMin , kMax , { 3 , 1 , 1 , 3 } , / / alpha shape <nl> { F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( 0 . 5f , kMin , kMax ) , F2Q ( - 0 . 5f , kMin , kMax ) } , <nl> kMin , kMax , <nl> { F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( 0 . 0f , kMin , kMax ) , <nl> TF_LITE_MICRO_TEST ( QuantizedPreluActivationsOpTest ) { <nl> F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( - 0 . 5f , kMin , kMax ) , F2Q ( 0 . 5f , kMin , kMax ) , <nl> F2Q ( 0 . 0f , kMin , kMax ) , F2Q ( - 0 . 125f , kMin , kMax ) , <nl> F2Q ( 0 . 125f , kMin , kMax ) } , <nl> - { 1 , 2 , 2 , 3 } , / / output shape <nl> + { 4 , 1 , 2 , 2 , 3 } , / / output shape <nl> kMin , kMax , output_data ) ; <nl> } <nl> <nl> | Fix micro prelu test with correct tensor dimension initialization . | tensorflow/tensorflow | d0d45a55582e9ac8b0a57532534f4e8d54b54767 | 2019-07-29T09:41:31Z |
mmm a / xbmc / cores / AudioEngine / Sinks / AESinkPULSE . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkPULSE . cpp <nl> <nl> # include " AESinkPULSE . h " <nl> # include " utils / log . h " <nl> # include " Util . h " <nl> + # include " utils / TimeUtils . h " <nl> # include " guilib / LocalizeStrings . h " <nl> # include " Application . h " <nl> <nl> CAESinkPULSE : : CAESinkPULSE ( ) <nl> m_MainLoop = NULL ; <nl> m_BytesPerSecond = 0 ; <nl> m_BufferSize = 0 ; <nl> + m_filled_bytes = 0 ; <nl> + m_lastPackageStamp = 0 ; <nl> m_Channels = 0 ; <nl> m_Stream = NULL ; <nl> m_Context = NULL ; <nl> bool CAESinkPULSE : : Initialize ( AEAudioFormat & format , std : : string & device ) <nl> m_passthrough = false ; <nl> m_BytesPerSecond = 0 ; <nl> m_BufferSize = 0 ; <nl> + m_filled_bytes = 0 ; <nl> + m_lastPackageStamp = 0 ; <nl> m_Channels = 0 ; <nl> m_Stream = NULL ; <nl> m_Context = NULL ; <nl> void CAESinkPULSE : : Deinitialize ( ) <nl> m_IsAllocated = false ; <nl> m_passthrough = false ; <nl> m_periodSize = 0 ; <nl> + m_filled_bytes = 0 ; <nl> + m_lastPackageStamp = 0 ; <nl> <nl> if ( m_Stream ) <nl> Drain ( ) ; <nl> void CAESinkPULSE : : GetDelay ( AEDelayStatus & status ) <nl> status . SetDelay ( 0 ) ; <nl> return ; <nl> } <nl> - int error = 0 ; <nl> - pa_usec_t latency = ( pa_usec_t ) - 1 ; <nl> + <nl> pa_threaded_mainloop_lock ( m_MainLoop ) ; <nl> - if ( ( error = pa_stream_get_latency ( m_Stream , & latency , NULL ) ) < 0 ) <nl> - { <nl> - if ( error = = - PA_ERR_NODATA ) <nl> - { <nl> - WaitForOperation ( pa_stream_update_timing_info ( m_Stream , NULL , NULL ) , m_MainLoop , " Update Timing Information " ) ; <nl> - if ( ( error = pa_stream_get_latency ( m_Stream , & latency , NULL ) ) < 0 ) <nl> - { <nl> - CLog : : Log ( LOGDEBUG , " GetDelay - Failed to get Latency % d " , error ) ; <nl> - } <nl> - } <nl> - } <nl> - if ( error < 0 ) <nl> - latency = ( pa_usec_t ) 0 ; <nl> + const pa_timing_info * pti = pa_stream_get_timing_info ( m_Stream ) ; <nl> + / / only incorporate local sink delay + internal PA transport delay <nl> + double sink_delay = ( pti - > configured_sink_usec / 1000000 . 0 ) ; <nl> + double transport_delay = pti - > transport_usec / 1000000 . 0 ; <nl> + <nl> + uint64_t diff = CurrentHostCounter ( ) - m_lastPackageStamp ; <nl> + unsigned int bytes_played = ( unsigned int ) ( ( double ) diff * ( double ) m_BytesPerSecond / ( double ) CurrentHostFrequency ( ) + 0 . 5 ) ; <nl> + <nl> + int buffer_delay = m_filled_bytes - bytes_played ; <nl> + if ( buffer_delay < 0 ) <nl> + buffer_delay = 0 ; <nl> <nl> pa_threaded_mainloop_unlock ( m_MainLoop ) ; <nl> - status . SetDelay ( latency / 1000000 . 0 ) ; <nl> + <nl> + double delay = buffer_delay / ( double ) m_BytesPerSecond + sink_delay + transport_delay ; <nl> + status . SetDelay ( delay ) ; <nl> } <nl> <nl> double CAESinkPULSE : : GetCacheTotal ( ) <nl> unsigned int CAESinkPULSE : : AddPackets ( uint8_t * * data , unsigned int frames , unsig <nl> while ( ( length = pa_stream_writable_size ( m_Stream ) ) < m_periodSize ) <nl> pa_threaded_mainloop_wait ( m_MainLoop ) ; <nl> <nl> + unsigned int free = length ; <nl> length = std : : min ( ( unsigned int ) length , available ) ; <nl> <nl> int error = pa_stream_write ( m_Stream , buffer , length , NULL , 0 , PA_SEEK_RELATIVE ) ; <nl> unsigned int CAESinkPULSE : : AddPackets ( uint8_t * * data , unsigned int frames , unsig <nl> CLog : : Log ( LOGERROR , " CPulseAudioDirectSound : : AddPackets - pa_stream_write failed \ n " ) ; <nl> return 0 ; <nl> } <nl> + m_lastPackageStamp = CurrentHostCounter ( ) ; <nl> + m_filled_bytes = m_BufferSize - ( free - length ) ; <nl> unsigned int res = ( unsigned int ) ( length / m_format . m_frameSize ) ; <nl> <nl> return res ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkPULSE . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkPULSE . h <nl> class CAESinkPULSE : public IAESink <nl> pa_cvolume m_Volume ; <nl> bool m_volume_needs_update ; <nl> uint32_t m_periodSize ; <nl> + uint64_t m_lastPackageStamp ; <nl> + uint64_t m_filled_bytes ; <nl> <nl> pa_context * m_Context ; <nl> pa_threaded_mainloop * m_MainLoop ; <nl> | Merge pull request from fritsch / bisect | xbmc/xbmc | ff79babadcf735efb0bea696b7bd7a9523d5fefc | 2015-10-01T07:23:28Z |
mmm a / utils / benchmark / Richards / richards . swift <nl> ppp b / utils / benchmark / Richards / richards . swift <nl> class Task { <nl> case TaskID ( var i ) : <nl> return i <nl> default : <nl> - assert ( " Task value is not a task ID " ) <nl> + assert ( false , " Task value is not a task ID " ) <nl> return 0 <nl> } <nl> } <nl> class Task { <nl> case None : <nl> return . None <nl> default : <nl> - assert ( " Task value is not a worklist " ) <nl> + assert ( false , " Task value is not a worklist " ) <nl> return . None <nl> } <nl> } <nl> class Task { <nl> case Count ( var i ) : <nl> return i <nl> default : <nl> - assert ( " Task value is not a count " ) <nl> + assert ( false , " Task value is not a count " ) <nl> return 0 <nl> } <nl> } <nl> class Task { <nl> case None : <nl> return . None <nl> default : <nl> - assert ( " Task value is not a worklist " ) <nl> + assert ( false , " Task value is not a worklist " ) <nl> return . None <nl> } <nl> } <nl> struct Richards { <nl> case . Count : <nl> break <nl> default : <nl> - assert ( " Task value is not a count " ) <nl> + assert ( false , " Task value is not a count " ) <nl> } <nl> for i in 0 . . < BufSize { <nl> + + v2 . count <nl> | Fix broken asserts in richards benchmark . | apple/swift | d30c430b11b0a29954f2159f1894626e1482dcbf | 2014-07-04T00:27:39Z |
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> function ( handle_swift_sources sourcesvar externalvar target ) <nl> list ( APPEND result $ { src } ) <nl> endif ( ) <nl> endforeach ( ) <nl> + <nl> + llvm_process_sources ( result $ { result } ) <nl> set ( $ { sourcesvar } " $ { result } " PARENT_SCOPE ) <nl> set ( $ { externalvar } " $ { externally_compiled } " PARENT_SCOPE ) <nl> endfunction ( ) <nl> mmm a / lib / IRGen / CMakeLists . txt <nl> ppp b / lib / IRGen / CMakeLists . txt <nl> <nl> add_swift_library ( swiftIRGen <nl> - ASTVisitor . h <nl> - Address . h <nl> - CMakeLists . txt <nl> - CallingConvention . h <nl> - CallEmission . h <nl> - Callee . h <nl> - Cleanup . h <nl> - Condition . h <nl> - Explosion . h <nl> GenArray . cpp <nl> GenClass . cpp <nl> - GenClass . h <nl> GenClosure . cpp <nl> - GenClosure . h <nl> GenConstructor . cpp <nl> GenControl . cpp <nl> GenDecl . cpp <nl> GenExpr . cpp <nl> GenFunc . cpp <nl> - GenFunc . h <nl> GenHeap . cpp <nl> - GenHeap . h <nl> GenInit . cpp <nl> - GenInit . h <nl> GenLValue . cpp <nl> - GenLValue . h <nl> GenMeta . cpp <nl> - GenMeta . h <nl> GenObjC . cpp <nl> - GenObjC . h <nl> GenOneOf . cpp <nl> GenPoly . cpp <nl> GenProto . cpp <nl> - GenProto . h <nl> GenStmt . cpp <nl> GenStruct . cpp <nl> GenTuple . cpp <nl> - GenTuple . h <nl> GenType . cpp <nl> - GenType . h <nl> - GetterSetter . h <nl> - HeapTypeInfo . h <nl> - IndirectTypeInfo . h <nl> - IRBuilder . h <nl> IRGen . cpp <nl> - IRGen . h <nl> IRGenFunction . cpp <nl> - IRGenFunction . h <nl> IRGenModule . cpp <nl> - IRGenModule . h <nl> - JumpDest . h <nl> - LValue . h <nl> - Linking . h <nl> Mangle . cpp <nl> - NecessaryBindings . h <nl> OptimizeARC . cpp <nl> - ProtocolInfo . h <nl> - Scope . h <nl> StructLayout . cpp <nl> - StructLayout . h <nl> - TypeInfo . h <nl> - ValueWitness . h <nl> DEPENDS swiftAST ) <nl> mmm a / lib / Parse / CMakeLists . txt <nl> ppp b / lib / Parse / CMakeLists . txt <nl> <nl> add_swift_library ( swiftParse <nl> Lexer . cpp <nl> Parser . cpp <nl> - Parser . h <nl> ParseDecl . cpp <nl> ParseExpr . cpp <nl> ParseGeneric . cpp <nl> add_swift_library ( swiftParse <nl> ParseStmt . cpp <nl> ParseType . cpp <nl> Scope . cpp <nl> - Scope . h <nl> DEPENDS swiftAST ) <nl> mmm a / lib / SIL / SILGen / CMakeLists . txt <nl> ppp b / lib / SIL / SILGen / CMakeLists . txt <nl> <nl> add_swift_library ( swiftSILGen <nl> Cleanup . cpp <nl> - Cleanup . h <nl> Condition . cpp <nl> - Condition . h <nl> - JumpDest . h <nl> - Scope . h <nl> SILGen . cpp <nl> - SILGen . h <nl> SILGenDecl . cpp <nl> SILGenExpr . cpp <nl> SILGenStmt . cpp <nl> mmm a / lib / Sema / CMakeLists . txt <nl> ppp b / lib / Sema / CMakeLists . txt <nl> <nl> add_swift_library ( swiftSema <nl> ArchetypeBuilder . cpp <nl> - ArchetypeBuilder . h <nl> CaptureAnalysis . cpp <nl> NameBinding . cpp <nl> TypeChecker . cpp <nl> - TypeChecker . h <nl> TypeCheckCoercion . cpp <nl> TypeCheckConstraints . cpp <nl> TypeCheckExpr . cpp <nl> mmm a / tools / swift / CMakeLists . txt <nl> ppp b / tools / swift / CMakeLists . txt <nl> <nl> add_swift_executable ( swift <nl> Frontend . cpp <nl> - Frontend . h <nl> Immediate . cpp <nl> - Immediate . h <nl> PrintingDiagnosticConsumer . cpp <nl> - PrintingDiagnosticConsumer . h <nl> swift . cpp <nl> DEPENDS swiftIRGen swiftParse swiftSema swiftAST swiftSIL swiftSILGen <nl> COMPONENT_DEPENDS bitwriter codegen ipo jit linker mcjit asmparser <nl> | [ CMake ] Automagically add private headers in Xcode as well as public headers . | apple/swift | ac5abd95d0a3bde6441ed80103bec25d7c634189 | 2012-11-13T19:05:17Z |
mmm a / tensorflow / python / data / ops / dataset_ops . py <nl> ppp b / tensorflow / python / data / ops / dataset_ops . py <nl> def element_spec ( self ) : <nl> class _NumpyIterator ( object ) : <nl> " " " Iterator over a dataset with elements converted to numpy . " " " <nl> <nl> + __slots__ = [ " _iterator " ] <nl> + <nl> def __init__ ( self , dataset ) : <nl> self . _iterator = iter ( dataset ) <nl> <nl> mmm a / tensorflow / python / data / ops / iterator_ops . py <nl> ppp b / tensorflow / python / data / ops / iterator_ops . py <nl> class IteratorResourceDeleter ( object ) : <nl> object is part of a reference cycle , the cycle will be collectable . <nl> " " " <nl> <nl> + __slots__ = [ " _deleter " , " _handle " , " _device " , " _eager_mode " ] <nl> + <nl> def __init__ ( self , handle , device , deleter ) : <nl> self . _deleter = deleter <nl> self . _handle = handle <nl> mmm a / tensorflow / python / data / ops / multi_device_iterator_ops . py <nl> ppp b / tensorflow / python / data / ops / multi_device_iterator_ops . py <nl> class MultiDeviceIteratorResourceDeleter ( object ) : <nl> object is part of a reference cycle , the cycle will be collectible . <nl> " " " <nl> <nl> + __slots__ = [ <nl> + " _deleter " , " _multi_device_iterator " , " _iterators " , " _device " , <nl> + " _eager_mode " <nl> + ] <nl> + <nl> def __init__ ( self , multi_device_iterator , iterators , device , deleter ) : <nl> self . _deleter = deleter <nl> self . _multi_device_iterator = multi_device_iterator <nl> mmm a / tensorflow / python / distribute / device_util . py <nl> ppp b / tensorflow / python / distribute / device_util . py <nl> def resolve ( d ) : <nl> class _FakeNodeDef ( object ) : <nl> " " " A fake NodeDef for _FakeOperation . " " " <nl> <nl> + __slots__ = [ " op " , " name " ] <nl> + <nl> def __init__ ( self ) : <nl> self . op = " " <nl> self . name = " " <nl> mmm a / tensorflow / python / distribute / distribute_lib . py <nl> ppp b / tensorflow / python / distribute / distribute_lib . py <nl> def get_update_replica_id ( ) : <nl> class UpdateContext ( object ) : <nl> " " " Context manager when you are in ` update ( ) ` or ` update_non_slot ( ) ` . " " " <nl> <nl> + __slots__ = [ " _replica_id " , " _old_replica_id " ] <nl> + <nl> def __init__ ( self , replica_id ) : <nl> self . _replica_id = replica_id <nl> self . _old_replica_id = None <nl> class InputContext ( object ) : <nl> source etc ) . <nl> " " " <nl> <nl> + __slots__ = [ <nl> + " _num_input_pipelines " , " _input_pipeline_id " , " _num_replicas_in_sync " <nl> + ] <nl> + <nl> def __init__ ( self , <nl> num_input_pipelines = 1 , <nl> input_pipeline_id = 0 , <nl> class ValueContext ( object ) : <nl> <nl> " " " <nl> <nl> + __slots__ = [ " _replica_id_in_sync_group " , " _num_replicas_in_sync " ] <nl> + <nl> def __init__ ( self , <nl> replica_id_in_sync_group = 0 , <nl> num_replicas_in_sync = 1 ) : <nl> def __deepcopy__ ( self , memo ) : <nl> class _DefaultDistributionContext ( object ) : <nl> " " " Context manager setting the default ` tf . distribute . Strategy ` . " " " <nl> <nl> + __slots__ = [ " _var_creator_scope " , " _strategy " , " _nested_count " ] <nl> + <nl> def __init__ ( self , strategy ) : <nl> <nl> def creator ( next_creator , * * kwargs ) : <nl> mmm a / tensorflow / python / eager / cancellation . py <nl> ppp b / tensorflow / python / eager / cancellation . py <nl> <nl> class CancellationManager ( object ) : <nl> " " " A mechanism for cancelling blocking computation . " " " <nl> <nl> + __slots__ = [ " _impl " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _impl = pywrap_tfe . TFE_NewCancellationManager ( ) <nl> <nl> mmm a / tensorflow / python / eager / context . py <nl> ppp b / tensorflow / python / eager / context . py <nl> <nl> class _EagerTensorCache ( object ) : <nl> " " " Simple cache which evicts items based on length in a FIFO manner . " " " <nl> <nl> + __slots__ = [ " _data " , " _max_items " , " _max_tensor_size " ] <nl> + <nl> def __init__ ( self , max_items = 256 , max_tensor_size = 10000 ) : <nl> self . _data = collections . OrderedDict ( ) <nl> self . _max_items = max_items <nl> class FunctionCallOptions ( object ) : <nl> Eager functions are functions decorated with tf . contrib . eager . defun . <nl> " " " <nl> <nl> + __slots__ = [ " _config_proto_serialized " , " _executor_type " ] <nl> + <nl> def __init__ ( self , executor_type = None , config_proto = None ) : <nl> " " " Constructor . <nl> <nl> def config_proto_serialized ( self , config ) : <nl> class _TensorCaches ( threading . local ) : <nl> " " " Thread local tensor caches . " " " <nl> <nl> + __slots__ = [ " _ones_rank_cache " , " _zeros_cache " ] <nl> + <nl> def __init__ ( self ) : <nl> super ( _TensorCaches , self ) . __init__ ( ) <nl> self . _ones_rank_cache = None <nl> class PhysicalDevice ( <nl> class _AtomicCounter ( object ) : <nl> " " " A simple atomic counter . " " " <nl> <nl> + __slots__ = [ " _value " , " _lock " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _value = 0 <nl> self . _lock = threading . Lock ( ) <nl> def increment_and_get ( self ) : <nl> class _TensorCacheDeleter ( object ) : <nl> " " " Deletes tensor caches for a given context . " " " <nl> <nl> + __slots__ = [ " _context_id " ] <nl> + <nl> def __init__ ( self , context_id ) : <nl> self . _context_id = context_id <nl> <nl> def end_step ( self ) : <nl> class _EagerDeviceContext ( object ) : <nl> " " " Context - manager forcing placement of ops and Tensors on a device . " " " <nl> <nl> + __slots__ = [ " _device_name " , " _ctx " , " _stack " ] <nl> + <nl> def __init__ ( self , ctx , device_name ) : <nl> self . _device_name = device_name <nl> self . _ctx = ctx <nl> mmm a / tensorflow / python / eager / def_function . py <nl> ppp b / tensorflow / python / eager / def_function . py <nl> <nl> class _CallCounter ( object ) : <nl> " " " Class keeping track of how many recent calls triggered tracing . " " " <nl> <nl> + __slots__ = [ " _max_call_history " , " _calls_per_tracings " , " call_count " ] <nl> + <nl> def __init__ ( self , max_call_history ) : <nl> self . _max_call_history = max_call_history <nl> self . _calls_per_tracings = [ ] <nl> def get_tracing_count ( self ) : <nl> class _FrequentTracingDetector ( object ) : <nl> " " " Class for frequent retracing detection and warning . " " " <nl> <nl> + __slots__ = [ " _counters " , " _lock " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _counters = weakref . WeakKeyDictionary ( ) # GUARDED_BY ( self . _lock ) <nl> self . _lock = threading . Lock ( ) <nl> def functions_run_eagerly ( ) : <nl> <nl> class FunctionDeleter ( object ) : <nl> <nl> + __slots__ = [ " func_graph " ] <nl> + <nl> def __init__ ( self , func_graph ) : <nl> self . func_graph = func_graph <nl> <nl> mmm a / tensorflow / python / eager / executor . py <nl> ppp b / tensorflow / python / eager / executor . py <nl> def thread_function ( ) : <nl> ` ` ` <nl> " " " <nl> <nl> + __slots__ = [ " _handle " ] <nl> + <nl> def __init__ ( self , handle ) : <nl> self . _handle = handle <nl> <nl> mmm a / tensorflow / python / eager / function . py <nl> ppp b / tensorflow / python / eager / function . py <nl> def _parse_func_attrs ( attributes ) : <nl> class _InterpolateFunctionError ( object ) : <nl> " " " Context Manager that interpolates the exception from ' top_level_func ' . " " " <nl> <nl> + __slots__ = [ " _func " ] <nl> + <nl> def __init__ ( self , top_level_func ) : <nl> self . _func = top_level_func <nl> <nl> def _enclosing_xla_context ( ) : <nl> class _EagerDefinedFunctionDeleter ( object ) : <nl> " " " Unregister function from eager context . " " " <nl> <nl> + __slots__ = [ " name " ] <nl> + <nl> def __init__ ( self , name ) : <nl> self . name = name <nl> <nl> def _forward_and_backward_functions ( self , inference_args , input_tangents ) : <nl> class _ForwardBackwardCall ( object ) : <nl> " " " Holds the state of a function call between execution and recording . " " " <nl> <nl> + __slots__ = [ <nl> + " _functions " , " _inference_args " , " _input_tangents " , " _tape_watching " <nl> + ] <nl> + <nl> def __init__ ( self , functions , inference_args , input_tangents , tape_watching ) : <nl> " " " Collects information about the function call . <nl> <nl> class FunctionCache ( object ) : <nl> " " " A lightweight container for cached functions . <nl> " " " <nl> <nl> + __slots__ = [ <nl> + " missed " , " primary " , " arg_relaxed_specs " , " arg_relaxed " , <nl> + " _garbage_collectors " <nl> + ] <nl> + <nl> def __init__ ( self ) : <nl> # The set of functions that have been missed ; entries are CacheKey with <nl> # input_signature ` None ` ( e . g . a " call context key " ) <nl> def bound_method_wrapper ( * args , * * kwargs ) : <nl> class _FunctionGarbageCollector ( object ) : <nl> " " " Cleans up cycles when a defun goes out of scope . " " " <nl> <nl> + __slots__ = [ " _cache " ] <nl> + <nl> def __init__ ( self , cache ) : <nl> self . _cache = cache <nl> <nl> def __del__ ( self ) : <nl> class ConcreteFunctionGarbageCollector ( object ) : <nl> " " " Cleans up reference cycles when a ` ConcreteFunction ` goes out of scope . " " " <nl> <nl> + __slots__ = [ " _func_graph " ] <nl> + <nl> def __init__ ( self , func_graph ) : <nl> self . _func_graph = func_graph <nl> <nl> def __del__ ( self ) : <nl> class _Marker ( object ) : <nl> " " " Markers used to pretty - print nested args in function signatures . " " " <nl> <nl> + __slots__ = [ " _s " ] <nl> + <nl> def __init__ ( self , s ) : <nl> self . _s = s <nl> <nl> mmm a / tensorflow / python / eager / monitoring . py <nl> ppp b / tensorflow / python / eager / monitoring . py <nl> <nl> class Metric ( object ) : <nl> " " " The base class of metric . " " " <nl> <nl> + __slots__ = [ " _metric " , " _metric_name " , " _metric_methods " , " _label_length " ] <nl> + <nl> def __init__ ( self , metric_name , metric_methods , label_length , * args ) : <nl> " " " Creates a new metric . <nl> <nl> def get_cell ( self , * labels ) : <nl> class CounterCell ( object ) : <nl> " " " CounterCell stores each value of a Counter . " " " <nl> <nl> + __slots__ = [ " _cell " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new CounterCell . <nl> <nl> class Counter ( Metric ) : <nl> user to increment each value . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , name , description , * labels ) : <nl> " " " Creates a new Counter . <nl> <nl> def get_cell ( self , * labels ) : <nl> class IntGaugeCell ( object ) : <nl> " " " A single integer value stored in an ` IntGauge ` . " " " <nl> <nl> + __slots__ = [ " _cell " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new IntGaugeCell . <nl> <nl> class IntGauge ( Metric ) : <nl> allows the user to set each value . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , name , description , * labels ) : <nl> " " " Creates a new IntGauge . <nl> <nl> def get_cell ( self , * labels ) : <nl> class StringGaugeCell ( object ) : <nl> " " " A single string value stored in an ` StringGauge ` . " " " <nl> <nl> + __slots__ = [ " _cell " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new StringGaugeCell . <nl> <nl> class StringGauge ( Metric ) : <nl> allows the user to set each value . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , name , description , * labels ) : <nl> " " " Creates a new StringGauge . <nl> <nl> def get_cell ( self , * labels ) : <nl> class BoolGaugeCell ( object ) : <nl> " " " A single boolean value stored in an ` BoolGauge ` . " " " <nl> <nl> + __slots__ = [ " _cell " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new BoolGaugeCell . <nl> <nl> class BoolGauge ( Metric ) : <nl> allows the user to set each value . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , name , description , * labels ) : <nl> " " " Creates a new BoolGauge . <nl> <nl> def get_cell ( self , * labels ) : <nl> class SamplerCell ( object ) : <nl> " " " SamplerCell stores each value of a Sampler . " " " <nl> <nl> + __slots__ = [ " _cell " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new SamplerCell . <nl> <nl> def value ( self ) : <nl> class Buckets ( object ) : <nl> " " " Bucketing strategies for the samplers . " " " <nl> <nl> + __slots__ = [ " buckets " ] <nl> + <nl> def __init__ ( self , buckets ) : <nl> " " " Creates a new Buckets . <nl> <nl> class ExponentialBuckets ( Buckets ) : <nl> scale * growth_factor ^ ( i + 1 ) , . . . , DBL_MAX ] . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , scale , growth_factor , bucket_count ) : <nl> " " " Creates a new exponential Buckets . <nl> <nl> class Sampler ( Metric ) : <nl> user to add a sample to each histogram value . <nl> " " " <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __init__ ( self , name , buckets , description , * labels ) : <nl> " " " Creates a new Sampler . <nl> <nl> def get_cell ( self , * labels ) : <nl> class MonitoredTimer ( object ) : <nl> " " " A context manager to measure the walltime and increment a Counter cell . " " " <nl> <nl> + __slots__ = [ " cell " , " t " ] <nl> + <nl> def __init__ ( self , cell ) : <nl> " " " Creates a new MonitoredTimer . <nl> <nl> mmm a / tensorflow / python / eager / tape . py <nl> ppp b / tensorflow / python / eager / tape . py <nl> <nl> class Tape ( object ) : <nl> " " " Represents a gradient propagation trace . " " " <nl> <nl> + __slots__ = [ " _tape " ] <nl> + <nl> def __init__ ( self , tape ) : <nl> self . _tape = tape <nl> <nl> class VariableWatcher ( object ) : <nl> assert variable_watcher . watched_variables = = [ var ] <nl> " " " <nl> <nl> + __slots__ = [ " _variable_watcher " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _variable_watcher = None <nl> <nl> mmm a / tensorflow / python / framework / auto_control_deps . py <nl> ppp b / tensorflow / python / framework / auto_control_deps . py <nl> class AutomaticControlDependencies ( object ) : <nl> NOT THREAD SAFE <nl> " " " <nl> <nl> + __slots__ = [ <nl> + " _returned_tensors " , " ops_which_must_run " , " _graph " , " _n_operations " , <nl> + " collective_manager_ids_used " <nl> + ] <nl> + <nl> def __init__ ( self ) : <nl> self . _returned_tensors = object_identity . ObjectIdentitySet ( ) <nl> self . ops_which_must_run = set ( ) <nl> mmm a / tensorflow / python / framework / c_api_util . py <nl> ppp b / tensorflow / python / framework / c_api_util . py <nl> <nl> class ScopedTFStatus ( object ) : <nl> " " " Wrapper around TF_Status that handles deletion . " " " <nl> <nl> + __slots__ = [ " status " ] <nl> + <nl> def __init__ ( self ) : <nl> self . status = c_api . TF_NewStatus ( ) <nl> <nl> def __del__ ( self ) : <nl> class ScopedTFGraph ( object ) : <nl> " " " Wrapper around TF_Graph that handles deletion . " " " <nl> <nl> + __slots__ = [ " graph " , " deleter " ] <nl> + <nl> def __init__ ( self ) : <nl> self . graph = c_api . TF_NewGraph ( ) <nl> # Note : when we ' re destructing the global context ( i . e when the process is <nl> def __del__ ( self ) : <nl> class ScopedTFImportGraphDefOptions ( object ) : <nl> " " " Wrapper around TF_ImportGraphDefOptions that handles deletion . " " " <nl> <nl> + __slots__ = [ " options " ] <nl> + <nl> def __init__ ( self ) : <nl> self . options = c_api . TF_NewImportGraphDefOptions ( ) <nl> <nl> def __del__ ( self ) : <nl> class ScopedTFImportGraphDefResults ( object ) : <nl> " " " Wrapper around TF_ImportGraphDefOptions that handles deletion . " " " <nl> <nl> + __slots__ = [ " results " ] <nl> + <nl> def __init__ ( self , results ) : <nl> self . results = results <nl> <nl> def __del__ ( self ) : <nl> class ScopedTFFunction ( object ) : <nl> " " " Wrapper around TF_Function that handles deletion . " " " <nl> <nl> + __slots__ = [ " func " , " deleter " ] <nl> + <nl> def __init__ ( self , func ) : <nl> self . func = func <nl> # Note : when we ' re destructing the global context ( i . e when the process is <nl> def __del__ ( self ) : <nl> class ScopedTFBuffer ( object ) : <nl> " " " An internal class to help manage the TF_Buffer lifetime . " " " <nl> <nl> + __slots__ = [ " buffer " ] <nl> + <nl> def __init__ ( self , buf_string ) : <nl> self . buffer = c_api . TF_NewBufferFromString ( compat . as_bytes ( buf_string ) ) <nl> <nl> class ApiDefMap ( object ) : <nl> be queried by op name . <nl> " " " <nl> <nl> + __slots__ = [ " _api_def_map " , " _op_per_name " ] <nl> + <nl> def __init__ ( self ) : <nl> op_def_proto = op_def_pb2 . OpList ( ) <nl> buf = c_api . TF_GetAllOpList ( ) <nl> mmm a / tensorflow / python / framework / device . py <nl> ppp b / tensorflow / python / framework / device . py <nl> class MergeDevice ( object ) : <nl> performance of device placement . <nl> " " " <nl> <nl> + __slots__ = [ " _spec " ] <nl> + <nl> def __init__ ( self , spec ) : <nl> if isinstance ( spec , device_spec . DeviceSpecV2 ) : <nl> self . _spec = spec <nl> mmm a / tensorflow / python / framework / function . py <nl> ppp b / tensorflow / python / framework / function . py <nl> def __call__ ( self , func ) : <nl> class _DefinedFunctionDeleter ( object ) : <nl> " " " Unregister function from eager context . " " " <nl> <nl> + __slots__ = [ " name " ] <nl> + <nl> def __init__ ( self , name ) : <nl> self . name = name <nl> <nl> mmm a / tensorflow / python / framework / ops . py <nl> ppp b / tensorflow / python / framework / ops . py <nl> def _sub_grad ( unused_op , grad ) : <nl> that defines the operation . <nl> " " " <nl> <nl> + __slots__ = [ " _op_type " ] <nl> + <nl> def __init__ ( self , op_type ) : <nl> " " " Creates a new decorator with ` op_type ` as the Operation type . <nl> <nl> class OpStats ( object ) : <nl> <nl> " " " <nl> <nl> + __slots__ = [ " _statistic_type " , " _value " ] <nl> + <nl> def __init__ ( self , statistic_type , value = None ) : <nl> " " " Sets up the initial placeholders for the statistics . " " " <nl> self . statistic_type = statistic_type <nl> def _calc_foo_bojangles ( unused_graph , unused_node_def ) : <nl> <nl> " " " <nl> <nl> + __slots__ = [ " _op_type " , " _statistic_type " ] <nl> + <nl> def __init__ ( self , op_type , statistic_type ) : <nl> " " " Saves the ` op_type ` as the ` Operation ` type . " " " <nl> if not isinstance ( op_type , six . string_types ) : <nl> class enable_auto_cast_variables ( object ) : <nl> ` dtype ` is floating - point . Otherwise , ` AutoCastVariable ` s will not be cast . <nl> " " " <nl> <nl> + __slots__ = [ " _dtype " , " _graph " , " _prev_read_dtype " ] <nl> + <nl> def __init__ ( self , dtype , graph = None ) : <nl> if dtype and not dtype . is_floating : <nl> self . _dtype = None <nl> def my_op ( a , b , c , name = None ) : <nl> ` ` ` <nl> " " " <nl> <nl> + __slots__ = [ " _name " , " _name_scope " ] <nl> + <nl> @ property <nl> def name ( self ) : <nl> return self . _name <nl> def my_op ( a , b , c , name = None ) : <nl> will generate ` MyOp_1 / a ` , etc . <nl> " " " <nl> <nl> + __slots__ = [ " _name " , " _exit_fns " ] <nl> + <nl> def __init__ ( self , name ) : <nl> " " " Initialize the context manager . <nl> <nl> def _reconstruct_sequence_inputs ( op_def , inputs , attrs ) : <nl> class _TensorIterator ( object ) : <nl> " " " Iterates over the leading dim of a Tensor . Performs no error checks . " " " <nl> <nl> + __slots__ = [ " _tensor " , " _index " , " _limit " ] <nl> + <nl> def __init__ ( self , tensor , dim0 ) : <nl> self . _tensor = tensor <nl> self . _index = 0 <nl> mmm a / tensorflow / python / framework / registry . py <nl> ppp b / tensorflow / python / framework / registry . py <nl> <nl> class Registry ( object ) : <nl> " " " Provides a registry for saving objects . " " " <nl> <nl> + __slots__ = [ " _name " , " _registry " ] <nl> + <nl> def __init__ ( self , name ) : <nl> " " " Creates a new registry . " " " <nl> self . _name = name <nl> mmm a / tensorflow / python / framework / subscribe . py <nl> ppp b / tensorflow / python / framework / subscribe . py <nl> def _recursive_apply ( tensors , apply_fn ) : <nl> class _ControlOutputCache ( object ) : <nl> " " " Helper class to manage calculating and caching control_outputs in graph . " " " <nl> <nl> + __slots__ = [ ' cache ' ] <nl> + <nl> def __init__ ( self ) : <nl> self . cache = { } <nl> <nl> mmm a / tensorflow / python / keras / mixed_precision / experimental / loss_scale_optimizer . py <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / loss_scale_optimizer . py <nl> class _UnwrapPreventer ( object ) : <nl> unwrapped by DistributionStrategy <nl> " " " <nl> <nl> + __slots__ = [ ' value ' ] <nl> + <nl> def __init__ ( self , value ) : <nl> self . value = value <nl> <nl> mmm a / tensorflow / python / ops / parallel_for / pfor . py <nl> ppp b / tensorflow / python / ops / parallel_for / pfor . py <nl> class ConversionNotImplementedError ( Exception ) : <nl> class _PforInput ( object ) : <nl> " " " Input object passed to registered pfor converters . " " " <nl> <nl> + __slots__ = [ " pfor " , " _op " , " _inputs " ] <nl> + <nl> def __init__ ( self , pfor , op , inputs ) : <nl> " " " Creates a _PforInput object . <nl> <nl> mmm a / tensorflow / python / ops / resource_variable_ops . py <nl> ppp b / tensorflow / python / ops / resource_variable_ops . py <nl> class EagerResourceDeleter ( object ) : <nl> the cycle will be collectable . <nl> " " " <nl> <nl> + __slots__ = [ " _handle " , " _handle_device " , " _context " ] <nl> + <nl> def __init__ ( self , handle , handle_device ) : <nl> if not isinstance ( handle , ops . Tensor ) : <nl> raise ValueError ( <nl> mmm a / tensorflow / python / ops / variable_scope . py <nl> ppp b / tensorflow / python / ops / variable_scope . py <nl> <nl> class _PartitionInfo ( object ) : <nl> " " " Holds partition info used by initializer functions . " " " <nl> <nl> + __slots__ = [ " _full_shape " , " _var_offset " ] <nl> + <nl> def __init__ ( self , full_shape , var_offset ) : <nl> " " " Constructor . <nl> <nl> class _VariableStore ( object ) : <nl> the corresponding TensorFlow Variables as values . <nl> " " " <nl> <nl> + __slots__ = [ " _vars " , " _partitioned_vars " , " _store_eager_variables " ] <nl> + <nl> def __init__ ( self ) : <nl> " " " Create a variable store . " " " <nl> self . _vars = { } # A dictionary of the stored TensorFlow variables . <nl> mmm a / tensorflow / python / training / saving / functional_saver . py <nl> ppp b / tensorflow / python / training / saving / functional_saver . py <nl> <nl> class _SingleDeviceSaver ( object ) : <nl> " " " Saves and restores checkpoints from the current device . " " " <nl> <nl> + __slots__ = [ " _saveable_objects " ] <nl> + <nl> def __init__ ( self , saveable_objects ) : <nl> " " " Specify a list of ` SaveableObject ` s to save and restore . <nl> <nl> mmm a / tensorflow / python / training / session_manager . py <nl> ppp b / tensorflow / python / training / session_manager . py <nl> def _ready ( op , sess , msg ) : <nl> <nl> class _CountDownTimer ( object ) : <nl> <nl> + __slots__ = [ " _start_time_secs " , " _duration_secs " ] <nl> + <nl> def __init__ ( self , duration_secs ) : <nl> self . _start_time_secs = time . time ( ) <nl> self . _duration_secs = duration_secs <nl> mmm a / tensorflow / python / training / tracking / base . py <nl> ppp b / tensorflow / python / training / tracking / base . py <nl> def restore ( self , restored_tensors , restored_shapes ) : <nl> class CheckpointPosition ( object ) : <nl> " " " Indicates a position within a ` _CheckpointRestoreCoordinator ` . " " " <nl> <nl> + __slots__ = [ " _checkpoint " , " _proto_id " ] <nl> + <nl> def __init__ ( self , checkpoint , proto_id ) : <nl> " " " Specify an object within a checkpoint . <nl> <nl> mmm a / tensorflow / python / training / tracking / data_structures . py <nl> ppp b / tensorflow / python / training / tracking / data_structures . py <nl> class NoDependency ( object ) : <nl> variables will appear in ` Model . variables ` ) . <nl> " " " <nl> <nl> + __slots__ = [ " value " ] <nl> + <nl> def __init__ ( self , value ) : <nl> self . value = value <nl> <nl> mmm a / tensorflow / python / training / tracking / tracking . py <nl> ppp b / tensorflow / python / training / tracking / tracking . py <nl> def delete_tracking ( obj , name ) : <nl> class ResourceTracker ( object ) : <nl> " " " An object that tracks a list of resources . " " " <nl> <nl> + __slots__ = [ " _resources " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _resources = [ ] <nl> <nl> def resource_tracker_scope ( resource_tracker ) : <nl> class CapturableResourceDeleter ( object ) : <nl> " " " Deleter to destroy CapturableResource without overriding its __del__ ( ) . " " " <nl> <nl> + __slots__ = [ " _destruction_context " , " _destroy_resource " ] <nl> + <nl> def __init__ ( self , destroy_resource_fn = None ) : <nl> if destroy_resource_fn : <nl> self . _destroy_resource = destroy_resource_fn <nl> mmm a / tensorflow / python / training / tracking / util . py <nl> ppp b / tensorflow / python / training / tracking / util . py <nl> class _ObjectGraphProtoPrettyPrinter ( object ) : <nl> repeated naming is cheap after the first . <nl> " " " <nl> <nl> + __slots__ = [ " _object_graph_proto " , " _node_name_cache " ] <nl> + <nl> def __init__ ( self , object_graph_proto ) : <nl> self . _object_graph_proto = object_graph_proto <nl> self . _node_name_cache = None <nl> def node_names ( self ) : <nl> class _CheckpointRestoreCoordinatorDeleter ( object ) : <nl> " " " Deleter to avoid overriding _CheckpointRestoreCoordinator . __del__ ( ) . " " " <nl> <nl> + __slots__ = [ <nl> + " expect_partial " , " object_graph_proto " , " matched_proto_ids " , <nl> + " unused_attributes " <nl> + ] <nl> + <nl> def __init__ ( self , expect_partial , object_graph_proto , matched_proto_ids , <nl> unused_attributes ) : <nl> self . expect_partial = expect_partial <nl> mmm a / tensorflow / python / util / lock_util . py <nl> ppp b / tensorflow / python / util / lock_util . py <nl> class GroupLock ( object ) : <nl> can also use the ` acquire ` and ` release ` method directly . <nl> " " " <nl> <nl> + __slots__ = [ " _ready " , " _num_groups " , " _group_member_counts " ] <nl> + <nl> def __init__ ( self , num_groups = 2 ) : <nl> " " " Initialize a group lock . <nl> <nl> def _validate_group_id ( self , group_id ) : <nl> class _Context ( object ) : <nl> " " " Context manager helper for ` GroupLock ` . " " " <nl> <nl> + __slots__ = [ " _lock " , " _group_id " ] <nl> + <nl> def __init__ ( self , lock , group_id ) : <nl> self . _lock = lock <nl> self . _group_id = group_id <nl> mmm a / tensorflow / python / util / nest . py <nl> ppp b / tensorflow / python / util / nest . py <nl> def flatten ( structure , expand_composites = False ) : <nl> <nl> class _DotString ( object ) : <nl> <nl> + __slots__ = [ ] <nl> + <nl> def __str__ ( self ) : <nl> return " . " <nl> <nl> mmm a / tensorflow / python / util / object_identity . py <nl> ppp b / tensorflow / python / util / object_identity . py <nl> class ObjectIdentityDictionary ( collections_abc . MutableMapping ) : <nl> and comparing based on the equality of their contents by default ) . <nl> " " " <nl> <nl> + __slots__ = [ " _storage " ] <nl> + <nl> def __init__ ( self ) : <nl> self . _storage = { } <nl> <nl> def __iter__ ( self ) : <nl> class ObjectIdentitySet ( collections_abc . MutableSet ) : <nl> " " " Like the built - in set , but compares objects with " is " . " " " <nl> <nl> + __slots__ = [ " _storage " ] <nl> + <nl> def __init__ ( self , * args ) : <nl> self . _storage = set ( self . _wrap_key ( obj ) for obj in list ( * args ) ) <nl> <nl> | Merge pull request from lgeiger : slots | tensorflow/tensorflow | 61a985bb48e4d38d05966132a347afe6f8a9a353 | 2020-07-09T20:13:04Z |
mmm a / test / core / support / time_test . c <nl> ppp b / test / core / support / time_test . c <nl> static void to_fp ( void * arg , const char * buf , size_t len ) { <nl> fwrite ( buf , 1 , len , ( FILE * ) arg ) ; <nl> } <nl> <nl> - / * Convert gpr_uintmax x to ascii base b ( 2 . . 16 ) , and write with <nl> - ( * writer ) ( arg , . . . ) , zero padding to " chars " digits ) . * / <nl> - static void u_to_s ( uintmax_t x , unsigned base , int chars , <nl> - void ( * writer ) ( void * arg , const char * buf , size_t len ) , <nl> - void * arg ) { <nl> - char buf [ 64 ] ; <nl> - char * p = buf + sizeof ( buf ) ; <nl> - do { <nl> - * - - p = " 0123456789abcdef " [ x % base ] ; <nl> - x / = base ; <nl> - chars - - ; <nl> - } while ( x ! = 0 | | chars > 0 ) ; <nl> - ( * writer ) ( arg , p , ( size_t ) ( buf + sizeof ( buf ) - p ) ) ; <nl> - } <nl> - <nl> / * Convert gpr_intmax x to ascii base b ( 2 . . 16 ) , and write with <nl> ( * writer ) ( arg , . . . ) , zero padding to " chars " digits ) . * / <nl> - static void i_to_s ( intmax_t x , unsigned base , int chars , <nl> + static void i_to_s ( intmax_t x , int base , int chars , <nl> void ( * writer ) ( void * arg , const char * buf , size_t len ) , <nl> void * arg ) { <nl> - if ( x < 0 ) { <nl> - ( * writer ) ( arg , " - " , 1 ) ; <nl> - u_to_s ( ( uintmax_t ) - x , base , chars - 1 , writer , arg ) ; <nl> - } else { <nl> - u_to_s ( ( uintmax_t ) x , base , chars , writer , arg ) ; <nl> - } <nl> + char buf [ 64 ] ; <nl> + char fmt [ 32 ] ; <nl> + GPR_ASSERT ( base = = 16 | | base = = 10 ) ; <nl> + sprintf ( fmt , " % % 0 % d % s " , chars , base = = 16 ? PRIxMAX : PRIdMAX ) ; <nl> + sprintf ( buf , fmt , x ) ; <nl> + ( * writer ) ( arg , buf , strlen ( buf ) ) ; <nl> } <nl> <nl> / * Convert ts to ascii , and write with ( * writer ) ( arg , . . . ) . * / <nl> | Use stdlib to avoid ubsan errors | grpc/grpc | d1a6423199d3b38007e65d2a9cad492e7ebc25cc | 2017-04-19T22:34:29Z |
mmm a / src / api / capi . h <nl> ppp b / src / api / capi . h <nl> typedef enum TessPageSegMode { <nl> PSM_SINGLE_CHAR , <nl> PSM_SPARSE_TEXT , <nl> PSM_SPARSE_TEXT_OSD , <nl> + PSM_RAW_LINE , <nl> PSM_COUNT <nl> } TessPageSegMode ; <nl> typedef enum TessPageIteratorLevel { <nl> | Merge pull request from stweil / master | tesseract-ocr/tesseract | d889a38f80139522c845ff0145774cc901b341f9 | 2019-08-25T13:36:43Z |
mmm a / modules / tools / prediction / mlp_train / cruiseMLP_train . py <nl> ppp b / modules / tools / prediction / mlp_train / cruiseMLP_train . py <nl> <nl> from torch . autograd import Variable <nl> from torch . utils . data import Dataset , DataLoader , sampler <nl> <nl> + import sklearn <nl> from sklearn . model_selection import train_test_split <nl> from sklearn . utils import class_weight <nl> <nl> class FullyConn_NN ( torch . nn . Module ) : <nl> def __init__ ( self ) : <nl> super ( FullyConn_NN , self ) . __init__ ( ) <nl> self . classify = torch . nn . Sequential ( \ <nl> - nn . Linear ( 83 , 55 ) , \ <nl> + nn . Linear ( 174 , 88 ) , \ <nl> nn . Sigmoid ( ) , \ <nl> nn . Dropout ( 0 . 3 ) , \ <nl> <nl> - nn . Linear ( 55 , 23 ) , \ <nl> + nn . Linear ( 88 , 55 ) , \ <nl> nn . Sigmoid ( ) , \ <nl> nn . Dropout ( 0 . 2 ) , \ <nl> <nl> - nn . Linear ( 23 , 11 ) , \ <nl> + nn . Linear ( 55 , 23 ) , \ <nl> nn . Sigmoid ( ) , \ <nl> nn . Dropout ( 0 . 3 ) , \ <nl> <nl> - nn . Linear ( 11 , 5 ) , \ <nl> + nn . Linear ( 23 , 10 ) , \ <nl> nn . Sigmoid ( ) , \ <nl> nn . Dropout ( 0 . 0 ) , \ <nl> <nl> - nn . Linear ( 5 , 1 ) , \ <nl> + nn . Linear ( 10 , 1 ) , \ <nl> nn . Sigmoid ( ) <nl> ) <nl> self . regress = torch . nn . Sequential ( \ <nl> - nn . Linear ( dim_input , dim_hidden_1 ) , \ <nl> + nn . Linear ( 174 , 88 ) , \ <nl> nn . ReLU ( ) , \ <nl> nn . Dropout ( 0 . 1 ) , \ <nl> <nl> - nn . Linear ( dim_hidden_1 , dim_hidden_2 ) , \ <nl> + nn . Linear ( 88 , 23 ) , \ <nl> nn . ReLU ( ) , \ <nl> nn . Dropout ( 0 . 1 ) , \ <nl> <nl> - nn . Linear ( dim_hidden_2 , 1 ) , \ <nl> + nn . Linear ( 23 , 1 ) , \ <nl> nn . ReLU ( ) <nl> ) <nl> def forward ( self , x ) : <nl> def forward ( self , x ) : <nl> def loss_fn ( c_pred , r_pred , target ) : <nl> loss_C = nn . BCEWithLogitsLoss ( pos_weight = torch . FloatTensor ( [ 1 . 0 ] ) . cuda ( ) ) # nn . BCELoss ( ) <nl> loss_R = nn . MSELoss ( ) <nl> + <nl> loss = loss_C ( c_pred , target [ : , 0 ] . view ( target . shape [ 0 ] , 1 ) ) <nl> # loss = 4 * loss_C ( c_pred , target [ : , 0 ] . view ( target . shape [ 0 ] , 1 ) ) + \ <nl> # loss_R ( ( target [ : , 1 ] < 10 . 0 ) . float ( ) . view ( target . shape [ 0 ] , 1 ) * r_pred + \ <nl> def loss_fn ( c_pred , r_pred , target ) : <nl> return loss <nl> <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - # Data Loading and preprocessing <nl> + # Data Loading and preprocessing ( Non Data - Loader case ) <nl> <nl> ' ' ' <nl> Load the data from h5 file to the numpy format . <nl> - ( Only works for small datasets that can be entirely loaded into memory ) <nl> + ( Only for non data - loader case ) <nl> ' ' ' <nl> def load_data ( filename ) : <nl> <nl> def load_data ( filename ) : <nl> return samples [ ' data ' ] <nl> <nl> ' ' ' <nl> - Preprocess the data : <nl> + Preprocess the data . <nl> + ( Only for non data - loader case ) <nl> - separate input X and output y <nl> - - process output label from { - 1 , 0 , 1 , 2 } to { 0 , 1 } <nl> + - process output label from { - 1 , 0 , 1 , 2 , 3 , 4 } to { 0 , 1 } <nl> + - Take out only those meaningful features <nl> - shuffle data <nl> ' ' ' <nl> def data_preprocessing ( data ) : <nl> - X = data [ : , : - dim_output ] <nl> + X_obs_now = data [ : , 23 : 29 ] <nl> + X_obs_hist_5 = data [ : , 29 : 53 ] <nl> + mask5 = ( data [ : , 53 ] ! = 100 ) <nl> + X_lane = data [ : , 91 : - dim_output ] <nl> + X = np . concatenate ( ( X_obs_hist_5 , X_lane ) , axis = 1 ) <nl> + X = X [ mask5 , : ] <nl> + <nl> + # X = data [ : , : - dim_output ] <nl> y = data [ : , - dim_output : ] <nl> + y = y [ mask5 , : ] <nl> y [ : , 0 ] = ( y [ : , 0 ] > 0 ) . astype ( float ) <nl> <nl> - X_new , X_dummy , y_new , y_dummy = train_test_split ( X , y , test_size = 0 . 0 , random_state = 233 ) <nl> + X_new , X_dummy , y_new , y_dummy = train_test_split ( X , y , test_size = 0 . 1 , random_state = 233 ) <nl> <nl> - return X_new , y_new <nl> + return X_new , y_new , X_dummy , y_dummy <nl> <nl> ' ' ' <nl> Get the full path of all files under the directory : ' dirName ' <nl> def print_dist ( label ) : <nl> <nl> <nl> <nl> + <nl> + <nl> ' ' ' <nl> TODO : implement custom collate_fn to incorporate down - sampling function <nl> for certain labels . <nl> def train_vanilla ( train_X , train_y , model , optimizer , epoch , batch_size = 2048 ) : <nl> logging . info ( ' Epoch : { } ' . format ( epoch ) ) <nl> num_of_data = train_X . shape [ 0 ] <nl> num_of_batch = int ( num_of_data / batch_size ) + 1 <nl> - train_correct_class = 0 . 0 <nl> + train_correct_class = 0 <nl> for i in range ( num_of_batch ) : <nl> optimizer . zero_grad ( ) <nl> X = train_X [ i * batch_size : min ( num_of_data , ( i + 1 ) * batch_size ) , ] <nl> def train_vanilla ( train_X , train_y , model , optimizer , epoch , batch_size = 2048 ) : <nl> optimizer . step ( ) <nl> train_correct_class + = \ <nl> np . sum ( ( c_pred . data . cpu ( ) . numpy ( ) > 0 . 5 ) . astype ( float ) = = \ <nl> - y [ : , 0 ] . data . cpu ( ) . numpy ( ) . reshape ( c_pred . data . cpu ( ) . numpy ( ) . shape [ 0 ] , 1 ) ) <nl> - <nl> + y [ : , 0 ] . data . cpu ( ) . numpy ( ) . reshape ( y . data . cpu ( ) . numpy ( ) . shape [ 0 ] , 1 ) ) <nl> <nl> if i % 100 = = 0 : <nl> logging . info ( ' Step : { } , train_loss : { } ' . format ( i , np . mean ( loss_history [ - 100 : ] ) ) ) <nl> def train_vanilla ( train_X , train_y , model , optimizer , epoch , batch_size = 2048 ) : <nl> train_classification_accuracy = train_correct_class / train_y . data . cpu ( ) . numpy ( ) . shape [ 0 ] <nl> train_loss = np . mean ( loss_history ) <nl> logging . info ( ' Training loss : { } ' . format ( train_loss ) ) <nl> - print ( ' Epoch : { } . \ n Training Loss : { } . Training classification accuracy : { } ' \ <nl> - . format ( epoch , train_loss , train_classification_accuracy ) ) <nl> - print ( ' Trainin accuracy : { } . ' \ <nl> - . format ( train_classification_accuracy ) ) <nl> + logging . info ( ' Training Accuracy : { } . ' . format ( train_classification_accuracy ) ) <nl> + print ( ' Epoch : { } . ' . format ( epoch ) ) <nl> + print ( ' Training Loss : { } ' . format ( train_loss ) ) <nl> + print ( ' Training Accuracy : { } . ' . format ( train_classification_accuracy ) ) <nl> <nl> ' ' ' <nl> Train the data . ( using dataloader ) <nl> def train_dataloader ( train_loader , model , optimizer , epoch ) : <nl> ' ' ' <nl> Validation ( vanilla version without dataloader ) <nl> ' ' ' <nl> - def validate_vanilla ( valid_X , valid_y , model , batch_size = 1024 ) : <nl> + def validate_vanilla ( valid_X , valid_y , model , batch_size = 2048 ) : <nl> model . eval ( ) <nl> <nl> loss_history = [ ] <nl> valid_correct_class = 0 . 0 <nl> num_of_data = valid_X . shape [ 0 ] <nl> num_of_batch = int ( num_of_data / batch_size ) + 1 <nl> + pred_y = None <nl> for i in range ( num_of_batch ) : <nl> X = valid_X [ i * batch_size : min ( num_of_data , ( i + 1 ) * batch_size ) , ] <nl> y = valid_y [ i * batch_size : min ( num_of_data , ( i + 1 ) * batch_size ) , ] <nl> c_pred , r_pred = model ( X ) <nl> valid_loss = loss_fn ( c_pred , r_pred , y ) <nl> loss_history . append ( valid_loss . data [ 0 ] ) <nl> - valid_correct_class + = \ <nl> - np . sum ( ( c_pred . data . cpu ( ) . numpy ( ) > 0 . 5 ) . astype ( float ) = = \ <nl> - y [ : , 0 ] . data . cpu ( ) . numpy ( ) . reshape ( c_pred . data . cpu ( ) . numpy ( ) . shape [ 0 ] , 1 ) ) <nl> <nl> - valid_classification_accuracy = valid_correct_class / valid_y . data . cpu ( ) . numpy ( ) . shape [ 0 ] <nl> - logging . info ( ' Validation loss : { } . Validation classification accuracy : { } ' \ <nl> - . format ( np . mean ( loss_history ) , valid_classification_accuracy ) ) <nl> - print ( ' Validation loss : { } . Classification accuracy : { } . ' \ <nl> - . format ( np . mean ( loss_history ) , valid_classification_accuracy ) ) <nl> + c_pred = c_pred . data . cpu ( ) . numpy ( ) <nl> + c_pred = c_pred . reshape ( c_pred . shape [ 0 ] , 1 ) <nl> + <nl> + pred_y = np . concatenate ( ( pred_y , c_pred ) , axis = 0 ) if pred_y is not None \ <nl> + else c_pred <nl> + # valid_correct_class + = \ <nl> + # np . sum ( ( c_pred . data . cpu ( ) . numpy ( ) > 0 . 5 ) . astype ( float ) = = \ <nl> + # y [ : , 0 ] . data . cpu ( ) . numpy ( ) . reshape ( c_pred . data . cpu ( ) . numpy ( ) . shape [ 0 ] , 1 ) ) <nl> + <nl> + # valid_classification_accuracy = valid_correct_class / valid_y . data . cpu ( ) . numpy ( ) . shape [ 0 ] <nl> + pred_y = ( pred_y > 0 . 5 ) <nl> + valid_y = valid_y . data . cpu ( ) . numpy ( ) <nl> + # print ( min ( valid_y [ : , 0 ] ) ) <nl> + # print ( max ( valid_y [ : , 0 ] ) ) <nl> + # print ( min ( pred_y ) ) <nl> + # print ( max ( pred_y ) ) <nl> + <nl> + valid_accuracy = sklearn . metrics . accuracy_score ( valid_y [ : , 0 ] , pred_y . reshape ( - 1 ) ) <nl> + valid_precision = sklearn . metrics . precision_score ( valid_y [ : , 0 ] , pred_y . reshape ( - 1 ) ) <nl> + valid_recall = sklearn . metrics . recall_score ( valid_y [ : , 0 ] , pred_y . reshape ( - 1 ) ) <nl> + valid_auc = sklearn . metrics . roc_auc_score ( valid_y [ : , 0 ] , pred_y . reshape ( - 1 ) ) <nl> + <nl> + logging . info ( ' Validation loss : { } . Accuracy : { } . \ <nl> + Precision : { } . Recall : { } . AUC : { } . ' <nl> + . format ( np . mean ( loss_history ) , valid_accuracy , valid_precision , \ <nl> + valid_recall , valid_auc ) ) <nl> + print ( ' Validation loss : { } . Accuracy : { } . \ <nl> + Precision : { } . Recall : { } . AUC : { } . ' <nl> + . format ( np . mean ( loss_history ) , valid_accuracy , valid_precision , \ <nl> + valid_recall , valid_auc ) ) <nl> <nl> return valid_loss <nl> <nl> + <nl> ' ' ' <nl> Validation ( using dataloader ) <nl> ' ' ' <nl> def validate_dataloader ( valid_loader , model ) : <nl> print ( " Validation data size = " , valid_data . shape ) <nl> <nl> # Data preprocessing <nl> - X_train , y_train = data_preprocessing ( train_data ) <nl> - X_valid , y_valid = data_preprocessing ( valid_data ) <nl> - <nl> + # X_train , y_train = data_preprocessing ( train_data ) <nl> + # X_valid , y_valid = data_preprocessing ( valid_data ) <nl> + X_train , y_train , X_valid , y_valid = data_preprocessing ( train_data ) <nl> + <nl> # Model declaration <nl> - model = FCNN_CNN1D ( ) <nl> + model = FullyConn_NN ( ) <nl> print ( " The model used is : " ) <nl> print ( model ) <nl> - learning_rate = 5e - 4 <nl> + learning_rate = 6 . 561e - 4 <nl> optimizer = optim . Adam ( model . parameters ( ) , lr = learning_rate ) <nl> scheduler = optim . lr_scheduler . ReduceLROnPlateau \ <nl> - ( optimizer , factor = 0 . 5 , patience = 3 , min_lr = 1e - 8 , verbose = 1 , mode = ' min ' ) <nl> + ( optimizer , factor = 0 . 3 , patience = 2 , min_lr = 1e - 8 , verbose = 1 , mode = ' min ' ) <nl> <nl> # CUDA set - up : <nl> cuda_is_available = torch . cuda . is_available ( ) <nl> | Prediction : modified cruise training . | ApolloAuto/apollo | f546619cd2c6c6c1cf045267ba944871bc6a6229 | 2018-12-13T23:18:56Z |
mmm a / ChangeLog . markdown <nl> ppp b / ChangeLog . markdown <nl> Not all changes are documented here . In particular , new features , user - oriented <nl> <nl> Current Trunk <nl> mmmmmmmmmmmm - <nl> + - Update libc + + to 6 . 0 , bringing c + + 17 support ( std : : byte etc . ) <nl> <nl> v1 . 38 . 4 : 05 / 29 / 2018 <nl> mmmmmmmmmmmmmmmmmm - <nl> | update changelog [ ci skip ] | emscripten-core/emscripten | 8f142333a806520a3304944268a2f800a7caeb17 | 2018-06-03T15:06:16Z |
mmm a / hphp / hack / src / errors / errors . ml <nl> ppp b / hphp / hack / src / errors / errors . ml <nl> type format = <nl> | Raw <nl> | Highlighted <nl> <nl> - type typing_error_callback = ? code : int - > ( Pos . t * string ) list - > unit <nl> + type typing_error_callback = <nl> + ? code : int - > Pos . t * string - > ( Pos . t * string ) list - > unit <nl> <nl> type name_context = <nl> | FunctionNamespace <nl> let run_in_decl_mode filename f = <nl> in_lazy_decl : = Some filename ; <nl> Utils . try_finally ~ f ~ finally : ( fun ( ) - > in_lazy_decl : = old_in_lazy_decl ) <nl> <nl> - and make_error code ( x : ( Pos . t * string ) list ) : error = <nl> - match x with <nl> - | [ ] - > failwith " an error must have at least one message " <nl> - | claim : : reasons - > { code ; claim ; reasons } <nl> + and make_error code claim reasons : error = { code ; claim ; reasons } <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Accessors . * ) <nl> let ( is_hh_fixme_disallowed : ( Pos . t - > error_code - > bool ) ref ) = <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> <nl> ( * If primary position in error list isn ' t in current file , wrap with a sentinel error * ) <nl> - let check_pos_msg pos_msg_l = <nl> - let pos = fst ( List . hd_exn pos_msg_l ) in <nl> + let check_pos_msg ( claim , pos_msg_l ) = <nl> + let pos = fst claim in <nl> let current_file = fst ! current_context in <nl> let current_span = ! current_span in <nl> ( * If error is reported inside the current span , or no span has been set but the error <nl> let check_pos_msg pos_msg_l = <nl> & & Relative_path . equal ( Pos . filename pos ) current_file <nl> | | Relative_path . equal current_file Relative_path . default <nl> then <nl> - pos_msg_l <nl> + ( claim , pos_msg_l ) <nl> else <nl> + let pos_msg_l = claim : : pos_msg_l in <nl> let message = <nl> pos_msg_l <nl> | > List . map ~ f : ( fun ( pos , msg ) - > <nl> let check_pos_msg pos_msg_l = <nl> else <nl> ( current_span , badpos_message_2 ) <nl> in <nl> - err : : pos_msg_l <nl> + ( err , pos_msg_l ) <nl> <nl> - let add_error_with_fixme_error code explanation pos_msg_list = <nl> - let ( pos , _ ) = List . hd_exn pos_msg_list in <nl> + let add_error_with_fixme_error error explanation = <nl> + let { code ; claim ; reasons = _ } = error in <nl> + let ( pos , _ ) = claim in <nl> let pos = Option . value ( ! get_hh_fixme_pos pos code ) ~ default : pos in <nl> - add_error_impl ( make_error code pos_msg_list ) ; <nl> - add_error_impl ( make_error code [ ( pos , explanation ) ] ) <nl> + add_error_impl error ; <nl> + add_error_impl { code ; claim = ( pos , explanation ) ; reasons = [ ] } <nl> <nl> let rec add_applied_fixme code pos = <nl> if ServerLoadFlag . get_no_load ( ) then <nl> let rec add_applied_fixme code pos = <nl> else <nl> ( ) <nl> <nl> - and add code pos msg = add_list code [ ( pos , msg ) ] <nl> + and add code pos msg = add_list code ( pos , msg ) [ ] <nl> <nl> and fixme_present pos code = <nl> ! is_hh_fixme pos code | | ! is_hh_fixme_disallowed pos code <nl> <nl> - and add_list code errl = make_error code errl | > add_error <nl> + and add_list code ( claim : _ message ) reasons = <nl> + add_error { code ; claim ; reasons } <nl> + <nl> + and add_error error = <nl> + let { code ; claim ; reasons } = error in <nl> + let ( claim , reasons ) = check_pos_msg ( claim , reasons ) in <nl> + let error = { code ; claim ; reasons } in <nl> <nl> - and add_error { code ; claim ; reasons } = <nl> let pos = fst claim in <nl> - let pos_msg_l = check_pos_msg ( claim : : reasons ) in <nl> <nl> if ISet . mem code hard_banned_codes then <nl> if fixme_present pos code then <nl> and add_error { code ; claim ; reasons } = <nl> " You cannot use ` HH_FIXME ` or ` HH_IGNORE_ERROR ` comments to suppress error % d , and this cannot be enabled by configuration " <nl> code <nl> in <nl> - add_error_with_fixme_error code explanation pos_msg_l <nl> + add_error_with_fixme_error error explanation <nl> else <nl> - add_error_impl ( make_error code pos_msg_l ) <nl> + add_error_impl error <nl> else if <nl> is_not_raised_partial code & & Relative_path . is_partial ( Pos . filename pos ) <nl> then <nl> and add_error { code ; claim ; reasons } = <nl> * the position information after the fact . This is the default case , where an HH_FIXME <nl> * comment is not present . Therefore , the remaining cases are variations on behavior when <nl> * a fixme is present * ) <nl> - add_error_impl ( make_error code pos_msg_l ) <nl> + add_error_impl error <nl> else if Relative_path . ( is_hhi ( prefix ( Pos . filename pos ) ) ) then <nl> add_applied_fixme code pos <nl> else if ! report_pos_from_reason & & Pos . get_from_reason pos then <nl> let explanation = <nl> " You cannot use ` HH_FIXME ` or ` HH_IGNORE_ERROR ` comments to suppress an error whose position was derived from reason information " <nl> in <nl> - add_error_with_fixme_error code explanation pos_msg_l <nl> + add_error_with_fixme_error error explanation <nl> else if ! is_hh_fixme_disallowed pos code then <nl> let explanation = <nl> Printf . sprintf <nl> " You cannot use ` HH_FIXME ` or ` HH_IGNORE_ERROR ` comments to suppress error % d in declarations " <nl> code <nl> in <nl> - add_error_with_fixme_error code explanation pos_msg_l <nl> + add_error_with_fixme_error error explanation <nl> else <nl> let whitelist = <nl> if <nl> and add_error { code ; claim ; reasons } = <nl> " You cannot use ` HH_FIXME ` or ` HH_IGNORE_ERROR ` comments to suppress error % d " <nl> code <nl> in <nl> - add_error_with_fixme_error code explanation pos_msg_l <nl> + add_error_with_fixme_error error explanation <nl> <nl> and merge ( err ' , fixmes ' ) ( err , fixmes ) = <nl> let append _ _ x y = <nl> let experimental_feature pos msg = <nl> <nl> let strip_ns id = id | > Utils . strip_ns | > Hh_autoimport . reverse_type <nl> <nl> - let on_error_or_add ( on_error : typing_error_callback option ) code errl = <nl> + let on_error_or_add ( on_error : typing_error_callback option ) code claim reasons <nl> + = <nl> match on_error with <nl> - | None - > make_error code errl | > add_error <nl> - | Some f - > f ~ code errl <nl> + | None - > add_error { code ; claim ; reasons } <nl> + | Some f - > f ~ code claim reasons <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Parsing errors . * ) <nl> let highlight_differences base to_highlight = <nl> let error_name_already_bound name name_prev p p_prev = <nl> let name = strip_ns name in <nl> let name_prev = strip_ns name_prev in <nl> - let errs = <nl> - [ <nl> - ( p , " Name already bound : " ^ Markdown_lite . md_codify name ) ; <nl> - ( p_prev , <nl> - if String . equal name name_prev then <nl> - " Previous definition is here " <nl> - else <nl> - " Previous definition " <nl> - ^ ( highlight_differences name name_prev | > Markdown_lite . md_codify ) <nl> - ^ " differs only by case " ) ; <nl> - ] <nl> + let ( claim , reasons ) = <nl> + ( ( p , " Name already bound : " ^ Markdown_lite . md_codify name ) , <nl> + [ <nl> + ( p_prev , <nl> + if String . equal name name_prev then <nl> + " Previous definition is here " <nl> + else <nl> + " Previous definition " <nl> + ^ ( highlight_differences name name_prev | > Markdown_lite . md_codify ) <nl> + ^ " differs only by case " ) ; <nl> + ] ) <nl> in <nl> let hhi_msg = <nl> " This appears to be defined in an hhi file included in your project " <nl> let error_name_already_bound name name_prev p p_prev = <nl> ^ " do this by deleting the \ " hhi \ " directory you copied into your " <nl> ^ " project when first starting with Hack . " <nl> in <nl> - let errs = <nl> + let reasons = <nl> if Relative_path . ( is_hhi ( prefix ( Pos . filename p ) ) ) then <nl> - errs @ [ ( p_prev , hhi_msg ) ] <nl> + reasons @ [ ( p_prev , hhi_msg ) ] <nl> else if Relative_path . ( is_hhi ( prefix ( Pos . filename p_prev ) ) ) then <nl> - errs @ [ ( p , hhi_msg ) ] <nl> + reasons @ [ ( p , hhi_msg ) ] <nl> else <nl> - errs <nl> + reasons <nl> in <nl> - add_list ( Naming . err_code Naming . ErrorNameAlreadyBound ) errs <nl> + add_list ( Naming . err_code Naming . ErrorNameAlreadyBound ) claim reasons <nl> <nl> let error_class_attribute_already_bound name name_prev p p_prev = <nl> let name = strip_ns name in <nl> let name_prev = strip_ns name_prev in <nl> - let errs = <nl> - [ <nl> - ( p , <nl> + let ( claim , reasons ) = <nl> + ( ( p , <nl> " A class and an attribute class cannot share the same name . Conflicting class : " <nl> - ^ Markdown_lite . md_codify name ) ; <nl> - ( p_prev , " Previous definition : " ^ Markdown_lite . md_codify name_prev ) ; <nl> - ] <nl> + ^ Markdown_lite . md_codify name ) , <nl> + [ ( p_prev , " Previous definition : " ^ Markdown_lite . md_codify name_prev ) ] ) <nl> in <nl> - add_list ( Naming . err_code Naming . AttributeClassNameConflict ) errs <nl> + add_list ( Naming . err_code Naming . AttributeClassNameConflict ) claim reasons <nl> <nl> let unbound_name pos name kind = <nl> let kind_str = <nl> let undefined ~ in_rx_scope pos var_name did_you_mean = <nl> | Some ( did_you_mean , pos ) - > [ hint_message var_name did_you_mean pos ] <nl> | None - > [ ] <nl> in <nl> - add_list ( Naming . err_code Naming . Undefined ) ( ( pos , msg ) : : suggestion ) <nl> + add_list ( Naming . err_code Naming . Undefined ) ( pos , msg ) suggestion <nl> <nl> let this_reserved pos = <nl> add <nl> let unexpected_typedef pos def_pos expected_kind = <nl> let expected_type = name_context_to_string expected_kind in <nl> add_list <nl> ( Naming . err_code Naming . UnexpectedTypedef ) <nl> - [ <nl> - ( pos , <nl> - Printf . sprintf <nl> - " Expected a % s but got a type alias . " <nl> - ( Markdown_lite . md_codify expected_type ) ) ; <nl> - ( def_pos , " Alias definition is here . " ) ; <nl> - ] <nl> + ( pos , <nl> + Printf . sprintf <nl> + " Expected a % s but got a type alias . " <nl> + ( Markdown_lite . md_codify expected_type ) ) <nl> + [ ( def_pos , " Alias definition is here . " ) ] <nl> <nl> let mk_fd_name_already_bound pos = <nl> { <nl> let repeated_record_field name pos prev_pos = <nl> in <nl> add_list <nl> ( NastCheck . err_code NastCheck . RepeatedRecordFieldName ) <nl> - [ ( pos , msg ) ; ( prev_pos , " Previous field is here " ) ] <nl> + ( pos , msg ) <nl> + [ ( prev_pos , " Previous field is here " ) ] <nl> <nl> let unexpected_record_field_name ~ field_name ~ field_pos ~ record_name ~ decl_pos = <nl> let msg = <nl> let unexpected_record_field_name ~ field_name ~ field_pos ~ record_name ~ decl_pos = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . RecordUnknownField ) <nl> - [ ( field_pos , msg ) ; ( decl_pos , " Definition is here " ) ] <nl> + ( field_pos , msg ) <nl> + [ ( decl_pos , " Definition is here " ) ] <nl> <nl> let missing_record_field_name ~ field_name ~ new_pos ~ record_name ~ field_decl_pos <nl> = <nl> let missing_record_field_name ~ field_name ~ new_pos ~ record_name ~ field_decl_pos <nl> in <nl> add_list <nl> ( Typing . err_code Typing . RecordMissingRequiredField ) <nl> - [ ( new_pos , msg ) ; ( field_decl_pos , " Field definition is here " ) ] <nl> + ( new_pos , msg ) <nl> + [ ( field_decl_pos , " Field definition is here " ) ] <nl> <nl> let type_not_record id pos = <nl> add <nl> let invalid_type_access_root ( pos , id ) = <nl> let duplicate_user_attribute ( pos , name ) existing_attr_pos = <nl> add_list <nl> ( Naming . err_code Naming . DuplicateUserAttribute ) <nl> + ( pos , " You cannot reuse the attribute " ^ Markdown_lite . md_codify name ) <nl> [ <nl> - ( pos , " You cannot reuse the attribute " ^ Markdown_lite . md_codify name ) ; <nl> ( existing_attr_pos , <nl> Markdown_lite . md_codify name ^ " was already used here " ) ; <nl> ] <nl> let tparam_with_tparam pos x = <nl> let shadowed_type_param p pos name = <nl> add_list <nl> ( Naming . err_code Naming . ShadowedTypeParam ) <nl> + ( p , <nl> + Printf . sprintf <nl> + " You cannot re - bind the type parameter % s " <nl> + ( Markdown_lite . md_codify name ) ) <nl> [ <nl> - ( p , <nl> - Printf . sprintf <nl> - " You cannot re - bind the type parameter % s " <nl> - ( Markdown_lite . md_codify name ) ) ; <nl> ( pos , <nl> Printf . sprintf " % s is already bound here " ( Markdown_lite . md_codify name ) <nl> ) ; <nl> let unexpected_ty_in_tast pos ~ actual_ty ~ expected_ty = <nl> <nl> let uninstantiable_class usage_pos decl_pos name reason_msgl = <nl> let name = strip_ns name in <nl> - let msgl = <nl> - [ <nl> - ( usage_pos , Markdown_lite . md_codify name ^ " is uninstantiable " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + let ( claim , reasons ) = <nl> + ( ( usage_pos , Markdown_lite . md_codify name ^ " is uninstantiable " ) , <nl> + [ ( decl_pos , " Declaration is here " ) ] ) <nl> in <nl> - let msgl = <nl> + let ( claim , reasons ) = <nl> match reason_msgl with <nl> | ( reason_pos , reason_str ) : : tail - > <nl> - ( ( reason_pos , reason_str ^ " which must be instantiable " ) : : tail ) @ msgl <nl> - | _ - > msgl <nl> + let reasons = tail @ ( claim : : reasons ) in <nl> + let claim = ( reason_pos , reason_str ^ " which must be instantiable " ) in <nl> + ( claim , reasons ) <nl> + | [ ] - > ( claim , reasons ) <nl> in <nl> - add_list ( Typing . err_code Typing . UninstantiableClass ) msgl <nl> + add_list ( Typing . err_code Typing . UninstantiableClass ) claim reasons <nl> <nl> let new_abstract_record ( pos , name ) = <nl> let name = strip_ns name in <nl> let abstract_const_usage usage_pos decl_pos name = <nl> let name = strip_ns name in <nl> add_list <nl> ( Typing . err_code Typing . AbstractConstUsage ) <nl> - [ <nl> - ( usage_pos , <nl> - " Cannot reference abstract constant " <nl> - ^ Markdown_lite . md_codify name <nl> - ^ " directly " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( usage_pos , <nl> + " Cannot reference abstract constant " <nl> + ^ Markdown_lite . md_codify name <nl> + ^ " directly " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let concrete_const_interface_override <nl> child_pos parent_pos parent_origin name ( on_error : typing_error_callback ) = <nl> let parent_origin = strip_ns parent_origin in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . ConcreteConstInterfaceOverride ) <nl> + ( child_pos , <nl> + " Non - abstract constants defined in an interface cannot be overridden when implementing or extending that interface . " <nl> + ) <nl> [ <nl> - ( child_pos , <nl> - " Non - abstract constants defined in an interface cannot be overridden when implementing or extending that interface . " <nl> - ) ; <nl> ( parent_pos , <nl> " You could make " <nl> ^ Markdown_lite . md_codify name <nl> let did_you_mean_naming pos name suggest_pos suggest_name = <nl> let suggest_name = strip_ns suggest_name in <nl> add_list <nl> ( Naming . err_code Naming . DidYouMeanNaming ) <nl> - [ <nl> - ( pos , " Could not find " ^ Markdown_lite . md_codify name ^ " . " ) ; <nl> - hint_message name suggest_name suggest_pos ; <nl> - ] <nl> + ( pos , " Could not find " ^ Markdown_lite . md_codify name ^ " . " ) <nl> + [ hint_message name suggest_name suggest_pos ] <nl> <nl> let using_internal_class pos name = <nl> add <nl> let invalid_mutability_in_return_type_hint pos = <nl> let illegal_use_of_dynamically_callable attr_pos meth_pos visibility = <nl> add_list <nl> ( Naming . err_code Naming . IllegalUseOfDynamicallyCallable ) <nl> + ( attr_pos , " ` __DynamicallyCallable ` can only be used on public methods " ) <nl> [ <nl> - ( attr_pos , " ` __DynamicallyCallable ` can only be used on public methods " ) ; <nl> ( meth_pos , <nl> sprintf " But this method is % s " ( Markdown_lite . md_codify visibility ) ) ; <nl> ] <nl> let not_initialized ( pos , cname ) props = <nl> in <nl> add_list <nl> ( NastCheck . err_code NastCheck . NotInitialized ) <nl> - ( ( pos , <nl> - " Class " <nl> - ^ Markdown_lite . md_codify cname <nl> - ^ " has properties that cannot be null and aren ' t always set in ` __construct ` . " <nl> - ) <nl> - : : prop_msgs ) <nl> + ( pos , <nl> + " Class " <nl> + ^ Markdown_lite . md_codify cname <nl> + ^ " has properties that cannot be null and aren ' t always set in ` __construct ` . " <nl> + ) <nl> + prop_msgs <nl> <nl> let call_before_init pos cv = <nl> add <nl> let call_before_init pos cv = <nl> let type_arity use_pos def_pos ~ expected ~ actual = <nl> add_list <nl> ( Typing . err_code Typing . TypeArityMismatch ) <nl> - [ <nl> - ( use_pos , <nl> - Printf . sprintf <nl> - " Wrong number of type arguments ( expected % d , got % d ) " <nl> - expected <nl> - actual ) ; <nl> - ( def_pos , " Definition is here " ) ; <nl> - ] <nl> + ( use_pos , <nl> + Printf . sprintf <nl> + " Wrong number of type arguments ( expected % d , got % d ) " <nl> + expected <nl> + actual ) <nl> + [ ( def_pos , " Definition is here " ) ] <nl> <nl> let abstract_with_body ( p , _ ) = <nl> add <nl> let not_abstract_without_typeconst node = <nl> let typeconst_depends_on_external_tparam pos ext_pos ext_name = <nl> add_list <nl> ( NastCheck . err_code NastCheck . TypeconstDependsOnExternalTparam ) <nl> + ( pos , <nl> + " A type constant can only use type parameters declared in its own " <nl> + ^ " type parameter list " ) <nl> [ <nl> - ( pos , <nl> - " A type constant can only use type parameters declared in its own " <nl> - ^ " type parameter list " ) ; <nl> ( ext_pos , <nl> Markdown_lite . md_codify ext_name <nl> ^ " was declared as a type parameter here " ) ; <nl> let inout_params_special pos = <nl> let inout_params_memoize fpos pos = <nl> let msg1 = ( fpos , " Functions with ` inout ` parameters cannot be memoized " ) in <nl> let msg2 = ( pos , " This is an ` inout ` parameter " ) in <nl> - add_list ( NastCheck . err_code NastCheck . InoutParamsMemoize ) [ msg1 ; msg2 ] <nl> + add_list ( NastCheck . err_code NastCheck . InoutParamsMemoize ) msg1 [ msg2 ] <nl> <nl> let reading_from_append pos = <nl> add <nl> let switch_multiple_default pos = <nl> let case_fallthrough pos1 pos2 = <nl> add_list <nl> ( NastCheck . err_code NastCheck . CaseFallthrough ) <nl> + ( pos1 , <nl> + " This ` switch ` has a ` case ` that implicitly falls through and is " <nl> + ^ " not annotated with ` / / FALLTHROUGH ` " ) <nl> [ <nl> - ( pos1 , <nl> - " This ` switch ` has a ` case ` that implicitly falls through and is " <nl> - ^ " not annotated with ` / / FALLTHROUGH ` " ) ; <nl> ( pos2 , <nl> " This ` case ` implicitly falls through . Did you forget to add ` break ` or ` return ` ? " <nl> ) ; <nl> let visibility_extends <nl> let msg2 = <nl> ( parent_pos , Markdown_lite . md_codify parent_vis ^ " was expected " ) <nl> in <nl> - on_error ~ code : ( Typing . err_code Typing . VisibilityExtends ) [ msg1 ; msg2 ] <nl> + on_error ~ code : ( Typing . err_code Typing . VisibilityExtends ) msg1 [ msg2 ] <nl> <nl> let member_not_implemented member_name parent_pos pos defn_pos = <nl> let msg1 = <nl> let member_not_implemented member_name parent_pos pos defn_pos = <nl> in <nl> let msg2 = ( parent_pos , " Which is required by this interface " ) in <nl> let msg3 = ( defn_pos , " As defined here " ) in <nl> - add_list ( Typing . err_code Typing . MemberNotImplemented ) [ msg1 ; msg2 ; msg3 ] <nl> + add_list ( Typing . err_code Typing . MemberNotImplemented ) msg1 [ msg2 ; msg3 ] <nl> <nl> let bad_decl_override parent_pos parent_name pos name msgl = <nl> let msg1 = <nl> let bad_decl_override parent_pos parent_name pos name msgl = <nl> ^ ( strip_ns parent_name | > Markdown_lite . md_codify ) ) <nl> in <nl> ( * This is a cascading error message * ) <nl> - add_list ( Typing . err_code Typing . BadDeclOverride ) ( msg1 : : msg2 : : msgl ) <nl> + add_list ( Typing . err_code Typing . BadDeclOverride ) msg1 ( msg2 : : msgl ) <nl> <nl> let bad_method_override pos member_name msgl ( on_error : typing_error_callback ) <nl> = <nl> let bad_method_override pos member_name msgl ( on_error : typing_error_callback ) <nl> ^ " is not compatible with the overridden method " ) <nl> in <nl> ( * This is a cascading error message * ) <nl> - on_error ~ code : ( Typing . err_code Typing . BadMethodOverride ) ( msg : : msgl ) <nl> + on_error ~ code : ( Typing . err_code Typing . BadMethodOverride ) msg msgl <nl> <nl> let bad_prop_override pos member_name msgl ( on_error : typing_error_callback ) = <nl> let msg = <nl> let bad_prop_override pos member_name msgl ( on_error : typing_error_callback ) = <nl> ^ " has the wrong type " ) <nl> in <nl> ( * This is a cascading error message * ) <nl> - on_error ~ code : ( Typing . err_code Typing . BadMethodOverride ) ( msg : : msgl ) <nl> + on_error ~ code : ( Typing . err_code Typing . BadMethodOverride ) msg msgl <nl> <nl> let bad_enum_decl pos msgl = <nl> let msg = ( pos , " This enum declaration is invalid . " ) in <nl> ( * This is a cascading error message * ) <nl> - add_list ( Typing . err_code Typing . BadEnumExtends ) ( msg : : msgl ) <nl> + add_list ( Typing . err_code Typing . BadEnumExtends ) msg msgl <nl> <nl> let missing_constructor pos ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MissingConstructor ) <nl> - [ ( pos , " The constructor is not implemented " ) ] <nl> + ( pos , " The constructor is not implemented " ) <nl> + [ ] <nl> <nl> let typedef_trail_entry pos = ( pos , " Typedef definition comes from here " ) <nl> <nl> let abstract_tconst_not_allowed pos ( p , tconst_name ) = <nl> add_list <nl> ( Typing . err_code Typing . AbstractTconstNotAllowed ) <nl> + ( pos , " An abstract type constant is not allowed in this position . " ) <nl> [ <nl> - ( pos , " An abstract type constant is not allowed in this position . " ) ; <nl> ( p , <nl> Printf . sprintf <nl> " % s is abstract here . " <nl> ( Markdown_lite . md_codify tconst_name ) ) ; <nl> ] <nl> <nl> - let add_with_trail code errs trail = <nl> - add_list code ( errs @ List . map trail typedef_trail_entry ) <nl> + let add_with_trail code claim reasons trail = <nl> + add_list code claim ( reasons @ List . map trail typedef_trail_entry ) <nl> <nl> let enum_constant_type_bad pos ty_pos ty trail = <nl> add_with_trail <nl> ( Typing . err_code Typing . EnumConstantTypeBad ) <nl> - [ <nl> - ( pos , " Enum constants must be an ` int ` or ` string ` " ) ; <nl> - ( ty_pos , " Not " ^ Markdown_lite . md_codify ty ) ; <nl> - ] <nl> + ( pos , " Enum constants must be an ` int ` or ` string ` " ) <nl> + [ ( ty_pos , " Not " ^ Markdown_lite . md_codify ty ) ] <nl> trail <nl> <nl> let enum_type_bad pos ty_dependent ty trail = <nl> let enum_type_bad pos ty_dependent ty trail = <nl> else <nl> " Enums must be ` int ` or ` string ` or ` arraykey ` , not " <nl> in <nl> - add_with_trail ( Typing . err_code Typing . EnumTypeBad ) [ ( pos , msg ^ ty ) ] trail <nl> + add_with_trail ( Typing . err_code Typing . EnumTypeBad ) ( pos , msg ^ ty ) [ ] trail <nl> <nl> let enum_type_typedef_nonnull pos = <nl> add <nl> let enum_type_typedef_nonnull pos = <nl> let enum_switch_redundant const first_pos second_pos = <nl> add_list <nl> ( Typing . err_code Typing . EnumSwitchRedundant ) <nl> - [ <nl> - ( second_pos , " Redundant ` case ` statement " ) ; <nl> - ( first_pos , Markdown_lite . md_codify const ^ " already handled here " ) ; <nl> - ] <nl> + ( second_pos , " Redundant ` case ` statement " ) <nl> + [ ( first_pos , Markdown_lite . md_codify const ^ " already handled here " ) ] <nl> <nl> let enum_switch_nonexhaustive pos missing enum_pos = <nl> add_list <nl> ( Typing . err_code Typing . EnumSwitchNonexhaustive ) <nl> - [ <nl> - ( pos , <nl> - " ` switch ` statement nonexhaustive ; the following cases are missing : " <nl> - ^ ( List . map ~ f : Markdown_lite . md_codify missing <nl> - | > String . concat ~ sep : " , " ) ) ; <nl> - ( enum_pos , " Enum declared here " ) ; <nl> - ] <nl> + ( pos , <nl> + " ` switch ` statement nonexhaustive ; the following cases are missing : " <nl> + ^ ( List . map ~ f : Markdown_lite . md_codify missing | > String . concat ~ sep : " , " ) <nl> + ) <nl> + [ ( enum_pos , " Enum declared here " ) ] <nl> <nl> let enum_switch_redundant_default pos enum_pos = <nl> add_list <nl> ( Typing . err_code Typing . EnumSwitchRedundantDefault ) <nl> - [ <nl> - ( pos , <nl> - " All cases already covered ; a redundant ` default ` case prevents " <nl> - ^ " detecting future errors . If your goal is to guard against " <nl> - ^ " invalid values for this type , do an ` is ` check before the switch . " ) ; <nl> - ( enum_pos , " Enum declared here " ) ; <nl> - ] <nl> + ( pos , <nl> + " All cases already covered ; a redundant ` default ` case prevents " <nl> + ^ " detecting future errors . If your goal is to guard against " <nl> + ^ " invalid values for this type , do an ` is ` check before the switch . " ) <nl> + [ ( enum_pos , " Enum declared here " ) ] <nl> <nl> let enum_switch_not_const pos = <nl> add <nl> let invalid_shape_field_name_empty p = <nl> let invalid_shape_field_type pos ty_pos ty trail = <nl> add_with_trail <nl> ( Typing . err_code Typing . InvalidShapeFieldType ) <nl> - [ <nl> - ( pos , " A shape field name must be an ` int ` or ` string ` " ) ; <nl> - ( ty_pos , " Not " ^ ty ) ; <nl> - ] <nl> + ( pos , " A shape field name must be an ` int ` or ` string ` " ) <nl> + [ ( ty_pos , " Not " ^ ty ) ] <nl> trail <nl> <nl> let invalid_shape_field_literal key_pos witness_pos = <nl> add_list <nl> ( Typing . err_code Typing . InvalidShapeFieldLiteral ) <nl> - [ <nl> - ( key_pos , " Shape uses literal string as field name " ) ; <nl> - ( witness_pos , " But expected a class constant " ) ; <nl> - ] <nl> + ( key_pos , " Shape uses literal string as field name " ) <nl> + [ ( witness_pos , " But expected a class constant " ) ] <nl> <nl> let invalid_shape_field_const key_pos witness_pos = <nl> add_list <nl> ( Typing . err_code Typing . InvalidShapeFieldConst ) <nl> - [ <nl> - ( key_pos , " Shape uses class constant as field name " ) ; <nl> - ( witness_pos , " But expected a literal string " ) ; <nl> - ] <nl> + ( key_pos , " Shape uses class constant as field name " ) <nl> + [ ( witness_pos , " But expected a literal string " ) ] <nl> <nl> let shape_field_class_mismatch key_pos witness_pos key_class witness_class = <nl> add_list <nl> ( Typing . err_code Typing . ShapeFieldClassMismatch ) <nl> + ( key_pos , <nl> + " Shape field name is class constant from " <nl> + ^ Markdown_lite . md_codify key_class ) <nl> [ <nl> - ( key_pos , <nl> - " Shape field name is class constant from " <nl> - ^ Markdown_lite . md_codify key_class ) ; <nl> ( witness_pos , <nl> " But expected constant from " ^ Markdown_lite . md_codify witness_class ) ; <nl> ] <nl> let shape_field_class_mismatch key_pos witness_pos key_class witness_class = <nl> let shape_field_type_mismatch key_pos witness_pos key_ty witness_ty = <nl> add_list <nl> ( Typing . err_code Typing . ShapeFieldTypeMismatch ) <nl> - [ <nl> - ( key_pos , " Shape field name is " ^ key_ty ^ " class constant " ) ; <nl> - ( witness_pos , " But expected " ^ witness_ty ) ; <nl> - ] <nl> + ( key_pos , " Shape field name is " ^ key_ty ^ " class constant " ) <nl> + [ ( witness_pos , " But expected " ^ witness_ty ) ] <nl> <nl> let missing_field pos1 pos2 name ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MissingField ) <nl> - [ <nl> - ( pos1 , " The field " ^ Markdown_lite . md_codify name ^ " is missing " ) ; <nl> - ( pos2 , " The field " ^ Markdown_lite . md_codify name ^ " is defined " ) ; <nl> - ] <nl> + ( pos1 , " The field " ^ Markdown_lite . md_codify name ^ " is missing " ) <nl> + [ ( pos2 , " The field " ^ Markdown_lite . md_codify name ^ " is defined " ) ] <nl> <nl> let shape_fields_unknown pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . ShapeFieldsUnknown ) <nl> + ( pos1 , <nl> + " This shape type allows unknown fields , and so it may contain fields other than those explicitly declared in its declaration . " <nl> + ) <nl> [ <nl> - ( pos1 , <nl> - " This shape type allows unknown fields , and so it may contain fields other than those explicitly declared in its declaration . " <nl> - ) ; <nl> ( pos2 , <nl> " It is incompatible with a shape that does not allow unknown fields . " ) ; <nl> ] <nl> let invalid_shape_remove_key p = <nl> let unification_cycle pos ty = <nl> add_list <nl> ( Typing . err_code Typing . UnificationCycle ) <nl> - [ <nl> - ( pos , <nl> - " Type circularity : in order to type - check this expression it " <nl> - ^ " is necessary for a type [ rec ] to be equal to type " <nl> - ^ Markdown_lite . md_codify ty ) ; <nl> - ] <nl> + ( pos , <nl> + " Type circularity : in order to type - check this expression it " <nl> + ^ " is necessary for a type [ rec ] to be equal to type " <nl> + ^ Markdown_lite . md_codify ty ) <nl> + [ ] <nl> <nl> let violated_constraint <nl> p_cstr ( p_tparam , tparam ) left right ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . TypeConstraintViolation ) <nl> + ( p_cstr , " Some type constraint ( s ) are violated here " ) <nl> ( [ <nl> - ( p_cstr , " Some type constraint ( s ) are violated here " ) ; <nl> ( p_tparam , <nl> Printf . sprintf <nl> " % s is a constrained type parameter " <nl> let method_variance pos = <nl> pos <nl> " Covariance or contravariance is not allowed in type parameter of method or function . " <nl> <nl> - let explain_constraint ~ use_pos ~ definition_pos ~ param_name msgl = <nl> + let explain_constraint ~ use_pos ~ definition_pos ~ param_name claim reasons = <nl> let inst_msg = " Some type constraint ( s ) here are violated " in <nl> ( * There may be multiple constraints instantiated at one spot ; avoid <nl> * duplicating the instantiation message * ) <nl> + let ( p , msg ) = claim in <nl> let msgl = <nl> - match msgl with <nl> - | ( p , x ) : : rest when String . equal x inst_msg & & Pos . equal p use_pos - > rest <nl> - | _ - > msgl <nl> + if String . equal msg inst_msg & & Pos . equal p use_pos then <nl> + reasons <nl> + else <nl> + claim : : reasons <nl> in <nl> let name = strip_ns param_name in <nl> add_list <nl> ( Typing . err_code Typing . TypeConstraintViolation ) <nl> - ( [ <nl> - ( use_pos , inst_msg ) ; <nl> - ( definition_pos , <nl> - Markdown_lite . md_codify name ^ " is a constrained type parameter " ) ; <nl> - ] <nl> - @ msgl ) <nl> + ( use_pos , inst_msg ) <nl> + ( ( definition_pos , <nl> + Markdown_lite . md_codify name ^ " is a constrained type parameter " ) <nl> + : : msgl ) <nl> <nl> - let explain_where_constraint ~ in_class ~ use_pos ~ definition_pos msgl = <nl> + let explain_where_constraint ~ in_class ~ use_pos ~ definition_pos claim reasons = <nl> let callsite_ty = <nl> if in_class then <nl> " class " <nl> let explain_where_constraint ~ in_class ~ use_pos ~ definition_pos msgl = <nl> let inst_msg = " A ` where ` type constraint is violated here " in <nl> add_list <nl> ( Typing . err_code Typing . TypeConstraintViolation ) <nl> - ( [ ( use_pos , inst_msg ) ; ( definition_pos , definition_head ) ] @ msgl ) <nl> + ( use_pos , inst_msg ) <nl> + ( [ ( definition_pos , definition_head ) ] @ ( claim : : reasons ) ) <nl> <nl> let explain_tconst_where_constraint ~ use_pos ~ definition_pos msgl = <nl> let inst_msg = " A ` where ` type constraint is violated here " in <nl> add_list <nl> ( Typing . err_code Typing . TypeConstraintViolation ) <nl> + ( use_pos , inst_msg ) <nl> ( [ <nl> - ( use_pos , inst_msg ) ; <nl> ( definition_pos , <nl> " This method ' s ` where ` constraints contain a generic type access " ) ; <nl> ] <nl> let explain_tconst_where_constraint ~ use_pos ~ definition_pos msgl = <nl> let format_string pos snippet s class_pos fname class_suggest = <nl> add_list <nl> ( Typing . err_code Typing . FormatString ) <nl> + ( pos , <nl> + " Invalid format string " <nl> + ^ Markdown_lite . md_codify snippet <nl> + ^ " in " <nl> + ^ Markdown_lite . md_codify ( " \ " " ^ s ^ " \ " " ) ) <nl> [ <nl> - ( pos , <nl> - " Invalid format string " <nl> - ^ Markdown_lite . md_codify snippet <nl> - ^ " in " <nl> - ^ Markdown_lite . md_codify ( " \ " " ^ s ^ " \ " " ) ) ; <nl> ( class_pos , <nl> " You can add a new format specifier by adding " <nl> ^ Markdown_lite . md_codify ( fname ^ " ( ) " ) <nl> let must_extend_disposable pos = <nl> let accept_disposable_invariant pos1 pos2 ( on_error : typing_error_callback ) = <nl> let msg1 = ( pos1 , " This parameter is marked ` < < __AcceptDisposable > > ` " ) in <nl> let msg2 = ( pos2 , " This parameter is not marked ` < < __AcceptDisposable > > ` " ) in <nl> - on_error ~ code : ( Typing . err_code Typing . AcceptDisposableInvariant ) [ msg1 ; msg2 ] <nl> + on_error ~ code : ( Typing . err_code Typing . AcceptDisposableInvariant ) msg1 [ msg2 ] <nl> <nl> let ifc_external_contravariant pos1 pos2 ( on_error : typing_error_callback ) = <nl> let msg1 = <nl> let ifc_external_contravariant pos1 pos2 ( on_error : typing_error_callback ) = <nl> ) <nl> in <nl> let msg2 = ( pos2 , " But this parameter is not marked ` < < __External > > ` " ) in <nl> - on_error ~ code : ( Typing . err_code Typing . IFCExternalContravariant ) [ msg1 ; msg2 ] <nl> + on_error ~ code : ( Typing . err_code Typing . IFCExternalContravariant ) msg1 [ msg2 ] <nl> <nl> let field_kinds pos1 pos2 = <nl> add_list <nl> ( Typing . err_code Typing . FieldKinds ) <nl> - [ <nl> - ( pos1 , " You cannot use this kind of field ( value ) " ) ; <nl> - ( pos2 , " Mixed with this kind of field ( key = > value ) " ) ; <nl> - ] <nl> + ( pos1 , " You cannot use this kind of field ( value ) " ) <nl> + [ ( pos2 , " Mixed with this kind of field ( key = > value ) " ) ] <nl> <nl> let unbound_name_typing pos name = <nl> add <nl> let unbound_name_typing pos name = <nl> let unbound_name_type_constant_access ~ access_pos ~ name_pos name = <nl> add_list <nl> ( Typing . err_code Typing . UnboundNameTypeConstantAccess ) <nl> - ( [ <nl> - ( access_pos , <nl> - " Unbound name " <nl> - ^ Markdown_lite . md_codify ( strip_ns name ) <nl> - ^ " in type constant access " ) ; <nl> - ] <nl> + ( access_pos , <nl> + " Unbound name " <nl> + ^ Markdown_lite . md_codify ( strip_ns name ) <nl> + ^ " in type constant access " ) <nl> + ( [ ] <nl> @ <nl> if Pos . equal name_pos access_pos then <nl> [ ] <nl> let too_many_type_arguments p = <nl> let return_in_void pos1 pos2 = <nl> add_list <nl> ( Typing . err_code Typing . ReturnInVoid ) <nl> - [ ( pos1 , " You cannot return a value " ) ; ( pos2 , " This is a ` void ` function " ) ] <nl> + ( pos1 , " You cannot return a value " ) <nl> + [ ( pos2 , " This is a ` void ` function " ) ] <nl> <nl> let this_var_outside_class p = <nl> add <nl> let unbound_global cst_pos = <nl> let private_inst_meth ~ def_pos ~ use_pos = <nl> add_list <nl> ( Typing . err_code Typing . PrivateInstMeth ) <nl> - [ <nl> - ( use_pos , <nl> - " You cannot use this method with ` inst_meth ` ( whether you are in the same class or not ) . " <nl> - ) ; <nl> - ( def_pos , " It is declared as ` private ` here " ) ; <nl> - ] <nl> + ( use_pos , <nl> + " You cannot use this method with ` inst_meth ` ( whether you are in the same class or not ) . " <nl> + ) <nl> + [ ( def_pos , " It is declared as ` private ` here " ) ] <nl> <nl> let protected_inst_meth ~ def_pos ~ use_pos = <nl> add_list <nl> ( Typing . err_code Typing . ProtectedInstMeth ) <nl> - [ <nl> - ( use_pos , <nl> - " You cannot use this method with ` inst_meth ` ( whether you are in the same class hierarchy or not ) . " <nl> - ) ; <nl> - ( def_pos , " It is declared as ` protected ` here " ) ; <nl> - ] <nl> + ( use_pos , <nl> + " You cannot use this method with ` inst_meth ` ( whether you are in the same class hierarchy or not ) . " <nl> + ) <nl> + [ ( def_pos , " It is declared as ` protected ` here " ) ] <nl> <nl> let private_class_meth ~ def_pos ~ use_pos = <nl> add_list <nl> ( Typing . err_code Typing . PrivateClassMeth ) <nl> - [ <nl> - ( use_pos , <nl> - " You cannot use this method with ` class_meth ` ( whether you are in the same class or not ) . " <nl> - ) ; <nl> - ( def_pos , " It is declared as ` private ` here " ) ; <nl> - ] <nl> + ( use_pos , <nl> + " You cannot use this method with ` class_meth ` ( whether you are in the same class or not ) . " <nl> + ) <nl> + [ ( def_pos , " It is declared as ` private ` here " ) ] <nl> <nl> let protected_class_meth ~ def_pos ~ use_pos = <nl> add_list <nl> ( Typing . err_code Typing . ProtectedClassMeth ) <nl> - [ <nl> - ( use_pos , <nl> - " You cannot use this method with ` class_meth ` ( whether you are in the same class hierarchy or not ) . " <nl> - ) ; <nl> - ( def_pos , " It is declared as ` protected ` here " ) ; <nl> - ] <nl> + ( use_pos , <nl> + " You cannot use this method with ` class_meth ` ( whether you are in the same class hierarchy or not ) . " <nl> + ) <nl> + [ ( def_pos , " It is declared as ` protected ` here " ) ] <nl> <nl> let array_cast pos = <nl> add <nl> let string_cast pos ty = <nl> let nullable_cast pos ty ty_pos = <nl> add_list <nl> ( Typing . err_code Typing . NullableCast ) <nl> - [ <nl> - ( pos , " Casting from a nullable type is forbidden " ) ; <nl> - ( ty_pos , " This is " ^ Markdown_lite . md_codify ty ) ; <nl> - ] <nl> + ( pos , " Casting from a nullable type is forbidden " ) <nl> + [ ( ty_pos , " This is " ^ Markdown_lite . md_codify ty ) ] <nl> <nl> let static_outside_class pos = <nl> add <nl> let new_inconsistent_construct new_pos ( cpos , cname ) kind = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . NewStaticInconsistent ) <nl> + ( new_pos , <nl> + preamble <nl> + ^ " ; ` __construct ` arguments are not guaranteed to be consistent in child classes " <nl> + ) <nl> [ <nl> - ( new_pos , <nl> - preamble <nl> - ^ " ; ` __construct ` arguments are not guaranteed to be consistent in child classes " <nl> - ) ; <nl> ( cpos , <nl> " This declaration is neither ` final ` nor uses the ` < < __ConsistentConstruct > > ` attribute " <nl> ) ; <nl> let parent_outside_class pos = <nl> let parent_abstract_call meth_name call_pos decl_pos = <nl> add_list <nl> ( Typing . err_code Typing . AbstractCall ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot call " <nl> - ^ Markdown_lite . md_codify ( " parent : : " ^ meth_name ^ " ( ) " ) <nl> - ^ " ; it is abstract " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot call " <nl> + ^ Markdown_lite . md_codify ( " parent : : " ^ meth_name ^ " ( ) " ) <nl> + ^ " ; it is abstract " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let self_abstract_call meth_name call_pos decl_pos = <nl> add_list <nl> ( Typing . err_code Typing . AbstractCall ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot call " <nl> - ^ Markdown_lite . md_codify ( " self : : " ^ meth_name ^ " ( ) " ) <nl> - ^ " ; it is abstract . Did you mean " <nl> - ^ Markdown_lite . md_codify ( " static : : " ^ meth_name ^ " ( ) " ) <nl> - ^ " ? " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot call " <nl> + ^ Markdown_lite . md_codify ( " self : : " ^ meth_name ^ " ( ) " ) <nl> + ^ " ; it is abstract . Did you mean " <nl> + ^ Markdown_lite . md_codify ( " static : : " ^ meth_name ^ " ( ) " ) <nl> + ^ " ? " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let classname_abstract_call cname meth_name call_pos decl_pos = <nl> let cname = strip_ns cname in <nl> add_list <nl> ( Typing . err_code Typing . AbstractCall ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot call " <nl> - ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ^ " ( ) " ) <nl> - ^ " ; it is abstract " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot call " <nl> + ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ^ " ( ) " ) <nl> + ^ " ; it is abstract " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let static_synthetic_method cname meth_name call_pos decl_pos = <nl> let cname = strip_ns cname in <nl> add_list <nl> ( Typing . err_code Typing . StaticSyntheticMethod ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot call " <nl> - ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ^ " ( ) " ) <nl> - ^ " ; " <nl> - ^ Markdown_lite . md_codify meth_name <nl> - ^ " is not defined in " <nl> - ^ Markdown_lite . md_codify cname ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot call " <nl> + ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ^ " ( ) " ) <nl> + ^ " ; " <nl> + ^ Markdown_lite . md_codify meth_name <nl> + ^ " is not defined in " <nl> + ^ Markdown_lite . md_codify cname ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let isset_in_strict pos = <nl> add <nl> let isset_in_strict pos = <nl> let unset_nonidx_in_strict pos msgs = <nl> add_list <nl> ( Typing . err_code Typing . UnsetNonidxInStrict ) <nl> - ( [ <nl> - ( pos , <nl> - " In ` strict ` mode , ` unset ` is banned except on dynamic , " <nl> - ^ " darray , keyset , or dict indexing " ) ; <nl> - ] <nl> - @ msgs ) <nl> + ( pos , <nl> + " In ` strict ` mode , ` unset ` is banned except on dynamic , " <nl> + ^ " darray , keyset , or dict indexing " ) <nl> + ( [ ] @ msgs ) <nl> <nl> let unpacking_disallowed_builtin_function pos name = <nl> let name = strip_ns name in <nl> let unpacking_disallowed_builtin_function pos name = <nl> let invalid_destructure pos1 pos2 ty ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . InvalidDestructure ) <nl> - [ <nl> - ( pos1 , <nl> - " This expression cannot be destructured with a ` list ( . . . ) ` expression " <nl> - ) ; <nl> - ( pos2 , " This is " ^ Markdown_lite . md_codify ty ) ; <nl> - ] <nl> + ( pos1 , <nl> + " This expression cannot be destructured with a ` list ( . . . ) ` expression " ) <nl> + [ ( pos2 , " This is " ^ Markdown_lite . md_codify ty ) ] <nl> <nl> let unpack_array_required_argument p fp ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . SplatArrayRequired ) <nl> - [ <nl> - ( p , <nl> - " An array cannot be unpacked into the required arguments of a function " <nl> - ) ; <nl> - ( fp , " Definition is here " ) ; <nl> - ] <nl> + ( p , " An array cannot be unpacked into the required arguments of a function " ) <nl> + [ ( fp , " Definition is here " ) ] <nl> <nl> let unpack_array_variadic_argument p fp ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . SplatArrayRequired ) <nl> - [ <nl> - ( p , <nl> - " A function that receives an unpacked array as an argument must have a variadic parameter to accept the elements of the array " <nl> - ) ; <nl> - ( fp , " Definition is here " ) ; <nl> - ] <nl> + ( p , <nl> + " A function that receives an unpacked array as an argument must have a variadic parameter to accept the elements of the array " <nl> + ) <nl> + [ ( fp , " Definition is here " ) ] <nl> <nl> let array_get_arity pos1 name pos2 = <nl> add_list <nl> ( Typing . err_code Typing . ArrayGetArity ) <nl> - [ <nl> - ( pos1 , " You cannot use this " ^ ( strip_ns name | > Markdown_lite . md_codify ) ) ; <nl> - ( pos2 , " It is missing its type parameters " ) ; <nl> - ] <nl> + ( pos1 , " You cannot use this " ^ ( strip_ns name | > Markdown_lite . md_codify ) ) <nl> + [ ( pos2 , " It is missing its type parameters " ) ] <nl> <nl> let typing_error pos msg = add ( Typing . err_code Typing . GenericUnify ) pos msg <nl> <nl> let undefined_field ~ use_pos ~ name ~ shape_type_pos = <nl> add_list <nl> ( Typing . err_code Typing . UndefinedField ) <nl> - [ <nl> - ( use_pos , " The field " ^ Markdown_lite . md_codify name ^ " is undefined " ) ; <nl> - ( shape_type_pos , " Definition is here " ) ; <nl> - ] <nl> + ( use_pos , " The field " ^ Markdown_lite . md_codify name ^ " is undefined " ) <nl> + [ ( shape_type_pos , " Definition is here " ) ] <nl> <nl> let array_access code pos1 pos2 ty = <nl> add_list <nl> ( Typing . err_code code ) <nl> - ( ( pos1 , " This is not an object of type ` KeyedContainer ` , this is " ^ ty ) <nl> - : : <nl> + ( pos1 , " This is not an object of type ` KeyedContainer ` , this is " ^ ty ) <nl> ( if not ( phys_equal pos2 Pos . none ) then <nl> [ ( pos2 , " Definition is here " ) ] <nl> else <nl> - [ ] ) ) <nl> + [ ] ) <nl> <nl> let array_access_read = array_access Typing . ArrayAccessRead <nl> <nl> let array_access_write = array_access Typing . ArrayAccessWrite <nl> let keyset_set pos1 pos2 = <nl> add_list <nl> ( Typing . err_code Typing . KeysetSet ) <nl> - ( ( pos1 , " Elements in a keyset cannot be assigned , use append instead . " ) <nl> - : : <nl> + ( pos1 , " Elements in a keyset cannot be assigned , use append instead . " ) <nl> ( if not ( phys_equal pos2 Pos . none ) then <nl> [ ( pos2 , " Definition is here " ) ] <nl> else <nl> - [ ] ) ) <nl> + [ ] ) <nl> <nl> let array_append pos1 pos2 ty = <nl> add_list <nl> ( Typing . err_code Typing . ArrayAppend ) <nl> - ( ( pos1 , ty ^ " does not allow array append " ) <nl> - : : <nl> + ( pos1 , ty ^ " does not allow array append " ) <nl> ( if not ( phys_equal pos2 Pos . none ) then <nl> [ ( pos2 , " Definition is here " ) ] <nl> else <nl> - [ ] ) ) <nl> + [ ] ) <nl> <nl> let const_mutation pos1 pos2 ty = <nl> add_list <nl> ( Typing . err_code Typing . ConstMutation ) <nl> - ( ( pos1 , " You cannot mutate this " ) <nl> - : : <nl> + ( pos1 , " You cannot mutate this " ) <nl> ( if not ( phys_equal pos2 Pos . none ) then <nl> [ ( pos2 , " This is " ^ ty ) ] <nl> else <nl> - [ ] ) ) <nl> + [ ] ) <nl> <nl> let expected_class ? ( suffix = " " ) pos = <nl> add <nl> let expected_class ? ( suffix = " " ) pos = <nl> <nl> let unknown_type description pos r = <nl> let msg = " Was expecting " ^ description ^ " but type is unknown " in <nl> - add_list ( Typing . err_code Typing . UnknownType ) ( [ ( pos , msg ) ] @ r ) <nl> + add_list ( Typing . err_code Typing . UnknownType ) ( pos , msg ) r <nl> <nl> let not_found_hint orig hint = <nl> match hint with <nl> let smember_not_found <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . SmemberNotFound ) <nl> - ( let claim = ( pos , msg ) in <nl> - let hint = <nl> + ( pos , msg ) <nl> + ( let hint = <nl> match snot_found_hint member_name hint with <nl> | None - > [ ] <nl> | Some hint - > [ hint ] <nl> in <nl> - ( claim : : hint ) <nl> + hint <nl> @ [ <nl> ( cpos , <nl> " Declaration of " ^ Markdown_lite . md_codify class_name ^ " is here " <nl> let member_not_found <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MemberNotFound ) <nl> - ( let claim = ( pos , msg ) in <nl> - let hint = <nl> + ( pos , msg ) <nl> + ( let hint = <nl> match not_found_hint member_name hint with <nl> | None - > [ ] <nl> | Some hint - > [ hint ] <nl> in <nl> - ( claim : : hint ) <nl> - @ reason <nl> - @ [ ( cpos , " Declaration of " ^ type_name ^ " is here " ) ] ) <nl> + hint @ reason @ [ ( cpos , " Declaration of " ^ type_name ^ " is here " ) ] ) <nl> <nl> let expr_tree_unsupported_operator cls_name meth_name pos = <nl> let msg = <nl> let constructor_no_args pos = <nl> " This constructor expects no argument " <nl> <nl> let visibility p msg1 p_vis msg2 = <nl> - add_list ( Typing . err_code Typing . Visibility ) [ ( p , msg1 ) ; ( p_vis , msg2 ) ] <nl> + add_list ( Typing . err_code Typing . Visibility ) ( p , msg1 ) [ ( p_vis , msg2 ) ] <nl> <nl> let typing_too_many_args expected actual pos pos_def on_error = <nl> on_error_or_add <nl> on_error <nl> ( Typing . err_code Typing . TypingTooManyArgs ) <nl> - [ <nl> - ( pos , <nl> - Printf . sprintf <nl> - " Too many arguments ( expected % d but got % d ) " <nl> - expected <nl> - actual ) ; <nl> - ( pos_def , " Definition is here " ) ; <nl> - ] <nl> + ( pos , <nl> + Printf . sprintf <nl> + " Too many arguments ( expected % d but got % d ) " <nl> + expected <nl> + actual ) <nl> + [ ( pos_def , " Definition is here " ) ] <nl> <nl> let typing_too_few_args required actual pos pos_def on_error = <nl> on_error_or_add <nl> on_error <nl> ( Typing . err_code Typing . TypingTooFewArgs ) <nl> - [ <nl> - ( pos , <nl> - Printf . sprintf <nl> - " Too few arguments ( required % d but got % d ) " <nl> - required <nl> - actual ) ; <nl> - ( pos_def , " Definition is here " ) ; <nl> - ] <nl> + ( pos , <nl> + Printf . sprintf <nl> + " Too few arguments ( required % d but got % d ) " <nl> + required <nl> + actual ) <nl> + [ ( pos_def , " Definition is here " ) ] <nl> <nl> let bad_call pos ty = <nl> add <nl> let extend_final extend_pos decl_pos name = <nl> let name = strip_ns name in <nl> add_list <nl> ( Typing . err_code Typing . ExtendFinal ) <nl> - [ <nl> - ( extend_pos , <nl> - " You cannot extend final class " ^ Markdown_lite . md_codify name ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( extend_pos , " You cannot extend final class " ^ Markdown_lite . md_codify name ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let extend_non_abstract_record name extend_pos decl_pos = <nl> let name = strip_ns name in <nl> let extend_non_abstract_record name extend_pos decl_pos = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . ExtendFinal ) <nl> - [ ( extend_pos , msg ) ; ( decl_pos , " Declaration is here " ) ] <nl> + ( extend_pos , msg ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let extend_sealed child_pos parent_pos parent_name parent_kind verb = <nl> let name = strip_ns parent_name in <nl> add_list <nl> ( Typing . err_code Typing . ExtendSealed ) <nl> - [ <nl> - ( child_pos , <nl> - " You cannot " <nl> - ^ verb <nl> - ^ " sealed " <nl> - ^ parent_kind <nl> - ^ " " <nl> - ^ Markdown_lite . md_codify name ) ; <nl> - ( parent_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( child_pos , <nl> + " You cannot " <nl> + ^ verb <nl> + ^ " sealed " <nl> + ^ parent_kind <nl> + ^ " " <nl> + ^ Markdown_lite . md_codify name ) <nl> + [ ( parent_pos , " Declaration is here " ) ] <nl> <nl> let trait_prop_const_class pos x = <nl> add <nl> let implement_abstract ~ is_final pos1 pos2 kind x = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . ImplementAbstract ) <nl> - [ ( pos1 , msg1 ) ; ( pos2 , " Declaration is here " ) ] <nl> + ( pos1 , msg1 ) <nl> + [ ( pos2 , " Declaration is here " ) ] <nl> <nl> let generic_static pos x = <nl> add <nl> let fun_too_many_args <nl> required actual pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunTooManyArgs ) <nl> - [ <nl> - ( pos1 , <nl> - Printf . sprintf <nl> - " Too many mandatory arguments ( expected % d but got % d ) " <nl> - required <nl> - actual ) ; <nl> - ( pos2 , " Because of this definition " ) ; <nl> - ] <nl> + ( pos1 , <nl> + Printf . sprintf <nl> + " Too many mandatory arguments ( expected % d but got % d ) " <nl> + required <nl> + actual ) <nl> + [ ( pos2 , " Because of this definition " ) ] <nl> <nl> let fun_too_few_args <nl> required actual pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunTooFewArgs ) <nl> - [ <nl> - ( pos1 , <nl> - Printf . sprintf <nl> - " Too few arguments ( required % d but got % d ) " <nl> - required <nl> - actual ) ; <nl> - ( pos2 , " Because of this definition " ) ; <nl> - ] <nl> + ( pos1 , <nl> + Printf . sprintf <nl> + " Too few arguments ( required % d but got % d ) " <nl> + required <nl> + actual ) <nl> + [ ( pos2 , " Because of this definition " ) ] <nl> <nl> let fun_unexpected_nonvariadic pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunUnexpectedNonvariadic ) <nl> - [ <nl> - ( pos1 , " Should have a variadic argument " ) ; <nl> - ( pos2 , " Because of this definition " ) ; <nl> - ] <nl> + ( pos1 , " Should have a variadic argument " ) <nl> + [ ( pos2 , " Because of this definition " ) ] <nl> <nl> let fun_variadicity_hh_vs_php56 pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunVariadicityHhVsPhp56 ) <nl> - [ <nl> - ( pos1 , " Variadic arguments : ` . . . ` - style is not a subtype of ` . . . $ args ` " ) ; <nl> - ( pos2 , " Because of this definition " ) ; <nl> - ] <nl> + ( pos1 , " Variadic arguments : ` . . . ` - style is not a subtype of ` . . . $ args ` " ) <nl> + [ ( pos2 , " Because of this definition " ) ] <nl> <nl> let ellipsis_strict_mode ~ require pos = <nl> let msg = <nl> let untyped_lambda_strict_mode pos = <nl> <nl> let expected_tparam <nl> ~ use_pos ~ definition_pos n ( on_error : typing_error_callback option ) = <nl> - let errl = <nl> - [ <nl> - ( use_pos , <nl> - " Expected " <nl> - ^ <nl> - match n with <nl> - | 0 - > " no type parameters " <nl> - | 1 - > " exactly one type parameter " <nl> - | n - > string_of_int n ^ " type parameters " ) ; <nl> - ( definition_pos , " Definition is here " ) ; <nl> - ] <nl> - in <nl> - on_error_or_add on_error ( Typing . err_code Typing . ExpectedTparam ) errl <nl> + let claim = <nl> + ( use_pos , <nl> + " Expected " <nl> + ^ <nl> + match n with <nl> + | 0 - > " no type parameters " <nl> + | 1 - > " exactly one type parameter " <nl> + | n - > string_of_int n ^ " type parameters " ) <nl> + in <nl> + let reasons = [ ( definition_pos , " Definition is here " ) ] in <nl> + on_error_or_add on_error ( Typing . err_code Typing . ExpectedTparam ) claim reasons <nl> <nl> let object_string pos1 pos2 = <nl> add_list <nl> ( Typing . err_code Typing . ObjectString ) <nl> - [ <nl> - ( pos1 , " You cannot use this object as a string " ) ; <nl> - ( pos2 , " This object doesn ' t implement ` __toString ` " ) ; <nl> - ] <nl> + ( pos1 , " You cannot use this object as a string " ) <nl> + [ ( pos2 , " This object doesn ' t implement ` __toString ` " ) ] <nl> <nl> let object_string_deprecated pos = <nl> add <nl> let object_string_deprecated pos = <nl> let cyclic_typedef def_pos use_pos = <nl> add_list <nl> ( Typing . err_code Typing . CyclicTypedef ) <nl> - [ ( def_pos , " Cyclic type definition " ) ; ( use_pos , " Cyclic use is here " ) ] <nl> + ( def_pos , " Cyclic type definition " ) <nl> + [ ( use_pos , " Cyclic use is here " ) ] <nl> <nl> let type_arity_mismatch pos1 n1 pos2 n2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . TypeArityMismatch ) <nl> - [ ( pos1 , " This type has " ^ n1 ^ " arguments " ) ; ( pos2 , " This one has " ^ n2 ) ] <nl> + ( pos1 , " This type has " ^ n1 ^ " arguments " ) <nl> + [ ( pos2 , " This one has " ^ n2 ) ] <nl> <nl> let this_final id pos2 = <nl> let n = strip_ns ( snd id ) | > Markdown_lite . md_codify in <nl> let exact_class_final id pos2 = <nl> let fun_arity_mismatch pos1 pos2 ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunArityMismatch ) <nl> - [ <nl> - ( pos1 , " Number of arguments doesn ' t match " ) ; <nl> - ( pos2 , " Because of this definition " ) ; <nl> - ] <nl> + ( pos1 , " Number of arguments doesn ' t match " ) <nl> + [ ( pos2 , " Because of this definition " ) ] <nl> <nl> let fun_reactivity_mismatch <nl> pos1 kind1 pos2 kind2 ( on_error : typing_error_callback ) = <nl> let f k = " This function is " ^ k ^ " . " in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . FunReactivityMismatch ) <nl> - [ ( pos1 , f kind1 ) ; ( pos2 , f kind2 ) ] <nl> + ( pos1 , f kind1 ) <nl> + [ ( pos2 , f kind2 ) ] <nl> <nl> let inconsistent_mutability pos1 mut1 p2_opt = <nl> match p2_opt with <nl> | Some ( pos2 , mut2 ) - > <nl> add_list <nl> ( Typing . err_code Typing . InconsistentMutability ) <nl> - [ <nl> - ( pos1 , <nl> - " Inconsistent mutability of local variable , here local is " ^ mut1 ) ; <nl> - ( pos2 , " But here it is " ^ mut2 ) ; <nl> - ] <nl> + ( pos1 , " Inconsistent mutability of local variable , here local is " ^ mut1 ) <nl> + [ ( pos2 , " But here it is " ^ mut2 ) ] <nl> | None - > <nl> add <nl> ( Typing . err_code Typing . InconsistentMutability ) <nl> let inconsistent_mutability pos1 mut1 p2_opt = <nl> let inconsistent_mutability_for_conditional p_mut p_other = <nl> add_list <nl> ( Typing . err_code Typing . InconsistentMutability ) <nl> - [ <nl> - ( p_mut , <nl> - " Inconsistent mutability of conditional expression , this branch returns owned mutable value " <nl> - ) ; <nl> - ( p_other , " But this one does not . " ) ; <nl> - ] <nl> + ( p_mut , <nl> + " Inconsistent mutability of conditional expression , this branch returns owned mutable value " <nl> + ) <nl> + [ ( p_other , " But this one does not . " ) ] <nl> <nl> let invalid_mutability_flavor pos mut1 mut2 = <nl> add <nl> let mutable_expression_as_multiple_mutable_arguments <nl> pos param_kind prev_pos prev_param_kind = <nl> add_list <nl> ( Typing . err_code Typing . MutableExpressionAsMultipleMutableArguments ) <nl> + ( pos , <nl> + " A mutable expression may not be passed as multiple arguments where at least one matching parameter is mutable . Matching parameter here is " <nl> + ^ param_kind ) <nl> [ <nl> - ( pos , <nl> - " A mutable expression may not be passed as multiple arguments where at least one matching parameter is mutable . Matching parameter here is " <nl> - ^ param_kind ) ; <nl> ( prev_pos , <nl> " This is where it was used before , being passed as " ^ prev_param_kind <nl> ) ; <nl> let mutable_call_on_immutable fpos pos1 rx_mutable_hint_pos = <nl> ] <nl> | None - > [ ] <nl> in <nl> - let l = <nl> - ( pos1 , " Cannot call mutable function on immutable expression " ) <nl> - : : ( fpos , <nl> - " This function is marked ` < < __Mutable > > ` , so it has a mutable ` $ this ` . " <nl> - ) <nl> + let claim = ( pos1 , " Cannot call mutable function on immutable expression " ) in <nl> + let reasons = <nl> + ( fpos , <nl> + " This function is marked ` < < __Mutable > > ` , so it has a mutable ` $ this ` . " ) <nl> : : l <nl> in <nl> - add_list ( Typing . err_code Typing . MutableCallOnImmutable ) l <nl> + add_list ( Typing . err_code Typing . MutableCallOnImmutable ) claim reasons <nl> <nl> let immutable_call_on_mutable fpos pos1 = <nl> add_list <nl> ( Typing . err_code Typing . ImmutableCallOnMutable ) <nl> - [ <nl> - ( pos1 , " Cannot call non - mutable function on mutable expression " ) ; <nl> - ( fpos , " This function is not marked as ` < < __Mutable > > ` . " ) ; <nl> - ] <nl> + ( pos1 , " Cannot call non - mutable function on mutable expression " ) <nl> + [ ( fpos , " This function is not marked as ` < < __Mutable > > ` . " ) ] <nl> <nl> let mutability_mismatch <nl> ~ is_receiver pos1 mut1 pos2 mut2 ( on_error : typing_error_callback ) = <nl> let mutability_mismatch <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MutabilityMismatch ) <nl> - [ ( pos1 , " Incompatible mutabilities : " ) ; ( pos1 , msg mut1 ) ; ( pos2 , msg mut2 ) ] <nl> + ( pos1 , " Incompatible mutabilities : " ) <nl> + [ ( pos1 , msg mut1 ) ; ( pos2 , msg mut2 ) ] <nl> <nl> let invalid_call_on_maybe_mutable ~ fun_is_mutable pos fpos = <nl> let msg = <nl> let invalid_call_on_maybe_mutable ~ fun_is_mutable pos fpos = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . InvalidCallMaybeMutable ) <nl> - [ ( pos , msg ) ; ( fpos , " This function is not marked as ` < < __MaybeMutable > > ` . " ) ] <nl> + ( pos , msg ) <nl> + [ ( fpos , " This function is not marked as ` < < __MaybeMutable > > ` . " ) ] <nl> <nl> let mutable_argument_mismatch param_pos arg_pos = <nl> add_list <nl> ( Typing . err_code Typing . MutableArgumentMismatch ) <nl> + ( arg_pos , " Invalid argument " ) <nl> [ <nl> - ( arg_pos , " Invalid argument " ) ; <nl> ( param_pos , " This parameter is marked mutable " ) ; <nl> ( arg_pos , " But this expression is not " ) ; <nl> ] <nl> let mutable_argument_mismatch param_pos arg_pos = <nl> let immutable_argument_mismatch param_pos arg_pos = <nl> add_list <nl> ( Typing . err_code Typing . ImmutableArgumentMismatch ) <nl> + ( arg_pos , " Invalid argument " ) <nl> [ <nl> - ( arg_pos , " Invalid argument " ) ; <nl> ( param_pos , " This parameter is not marked as mutable " ) ; <nl> ( arg_pos , " But this expression is mutable " ) ; <nl> ] <nl> let mutably_owned_argument_mismatch ~ arg_is_owned_local param_pos arg_pos = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . ImmutableArgumentMismatch ) <nl> + ( arg_pos , " Invalid argument " ) <nl> [ <nl> - ( arg_pos , " Invalid argument " ) ; <nl> ( param_pos , " This parameter is marked with ` < < __OwnedMutable > > ` " ) ; <nl> ( arg_pos , arg_msg ) ; <nl> ] <nl> let mutably_owned_argument_mismatch ~ arg_is_owned_local param_pos arg_pos = <nl> let maybe_mutable_argument_mismatch param_pos arg_pos = <nl> add_list <nl> ( Typing . err_code Typing . MaybeMutableArgumentMismatch ) <nl> + ( arg_pos , " Invalid argument " ) <nl> [ <nl> - ( arg_pos , " Invalid argument " ) ; <nl> ( param_pos , " This parameter is not marked ` < < __MaybeMutable > > ` " ) ; <nl> ( arg_pos , " But this expression is maybe mutable " ) ; <nl> ] <nl> let maybe_mutable_argument_mismatch param_pos arg_pos = <nl> let invalid_mutable_return_result error_pos function_pos value_kind = <nl> add_list <nl> ( Typing . err_code Typing . InvalidMutableReturnResult ) <nl> + ( error_pos , <nl> + " Functions marked ` < < __MutableReturn > > ` must return mutably owned values : mutably owned local variables and results of calling ` Rx \ \ mutable ` . " <nl> + ) <nl> [ <nl> - ( error_pos , <nl> - " Functions marked ` < < __MutableReturn > > ` must return mutably owned values : mutably owned local variables and results of calling ` Rx \ \ mutable ` . " <nl> - ) ; <nl> ( function_pos , " This function is marked ` < < __MutableReturn > > ` " ) ; <nl> ( error_pos , " This expression is " ^ value_kind ) ; <nl> ] <nl> let invalid_argument_type_for_condition_in_rx <nl> in <nl> add_list <nl> ( Typing . err_code Typing . InvalidConditionallyReactiveCall ) <nl> - [ <nl> - ( f_pos , <nl> - " Cannot invoke conditionally reactive function in reactive context , because at least one reactivity condition is not met . " <nl> - ) ; <nl> - ( arg_pos , arg_msg ) ; <nl> - ( def_pos , " This is the function declaration " ) ; <nl> - ] <nl> + ( f_pos , <nl> + " Cannot invoke conditionally reactive function in reactive context , because at least one reactivity condition is not met . " <nl> + ) <nl> + [ ( arg_pos , arg_msg ) ; ( def_pos , " This is the function declaration " ) ] <nl> <nl> let callsite_reactivity_mismatch <nl> f_pos def_pos callee_reactivity cause_pos_opt caller_reactivity = <nl> add_list <nl> ( Typing . err_code Typing . CallSiteReactivityMismatch ) <nl> - ( [ <nl> - ( f_pos , <nl> - " Reactivity mismatch : " <nl> - ^ caller_reactivity <nl> - ^ " function cannot call " <nl> - ^ callee_reactivity <nl> - ^ " function . " ) ; <nl> - ( def_pos , " This is the declaration of the function being called . " ) ; <nl> - ] <nl> + ( f_pos , <nl> + " Reactivity mismatch : " <nl> + ^ caller_reactivity <nl> + ^ " function cannot call " <nl> + ^ callee_reactivity <nl> + ^ " function . " ) <nl> + ( [ ( def_pos , " This is the declaration of the function being called . " ) ] <nl> @ Option . value_map cause_pos_opt ~ default : [ ] ~ f : ( fun cause_pos - > <nl> [ <nl> ( cause_pos , <nl> let callsite_reactivity_mismatch <nl> let callsite_cipp_mismatch f_pos def_pos callee_cipp caller_cipp = <nl> add_list <nl> ( Typing . err_code Typing . CallsiteCIPPMismatch ) <nl> - [ <nl> - ( f_pos , <nl> - " CIPP mismatch : " <nl> - ^ caller_cipp <nl> - ^ " function cannot call " <nl> - ^ callee_cipp <nl> - ^ " function . " ) ; <nl> - ( def_pos , " This is the declaration of the function being called . " ) ; <nl> - ] <nl> + ( f_pos , <nl> + " CIPP mismatch : " <nl> + ^ caller_cipp <nl> + ^ " function cannot call " <nl> + ^ callee_cipp <nl> + ^ " function . " ) <nl> + [ ( def_pos , " This is the declaration of the function being called . " ) ] <nl> <nl> let invalid_argument_of_rx_mutable_function pos = <nl> add <nl> let invalid_move_use pos1 = <nl> let require_args_reify def_pos arg_pos = <nl> add_list <nl> ( Typing . err_code Typing . RequireArgsReify ) <nl> - [ <nl> - ( arg_pos , <nl> - " All type arguments must be specified because a type parameter is reified " <nl> - ) ; <nl> - ( def_pos , " Definition is here " ) ; <nl> - ] <nl> + ( arg_pos , <nl> + " All type arguments must be specified because a type parameter is reified " <nl> + ) <nl> + [ ( def_pos , " Definition is here " ) ] <nl> <nl> let require_generic_explicit ( def_pos , def_name ) arg_pos = <nl> add_list <nl> ( Typing . err_code Typing . RequireGenericExplicit ) <nl> - [ <nl> - ( arg_pos , <nl> - " Generic type parameter " <nl> - ^ Markdown_lite . md_codify def_name <nl> - ^ " must be specified explicitly " ) ; <nl> - ( def_pos , " Definition is here " ) ; <nl> - ] <nl> + ( arg_pos , <nl> + " Generic type parameter " <nl> + ^ Markdown_lite . md_codify def_name <nl> + ^ " must be specified explicitly " ) <nl> + [ ( def_pos , " Definition is here " ) ] <nl> <nl> let invalid_reified_argument ( def_pos , def_name ) hint_pos arg_info = <nl> let ( arg_pos , arg_kind ) = List . hd_exn arg_info in <nl> add_list <nl> ( Typing . err_code Typing . InvalidReifiedArgument ) <nl> + ( hint_pos , " Invalid reified hint " ) <nl> [ <nl> - ( hint_pos , " Invalid reified hint " ) ; <nl> ( arg_pos , <nl> " This is " ^ arg_kind ^ " , it cannot be used as a reified type argument " <nl> ) ; <nl> let invalid_reified_argument_reifiable ( def_pos , def_name ) arg_pos ty_pos ty_msg <nl> = <nl> add_list <nl> ( Typing . err_code Typing . InvalidReifiedArgument ) <nl> + ( arg_pos , " PHP arrays cannot be used as a reified type argument " ) <nl> [ <nl> - ( arg_pos , " PHP arrays cannot be used as a reified type argument " ) ; <nl> ( ty_pos , String . capitalize ty_msg ) ; <nl> ( def_pos , Markdown_lite . md_codify def_name ^ " is reified " ) ; <nl> ] <nl> let class_get_reified pos = <nl> let static_meth_with_class_reified_generic meth_pos generic_pos = <nl> add_list <nl> ( Typing . err_code Typing . StaticMethWithClassReifiedGeneric ) <nl> - [ <nl> - ( meth_pos , <nl> - " Static methods cannot use generics reified at the class level . Try reifying them at the static method itself . " <nl> - ) ; <nl> - ( generic_pos , " Class - level reified generic used here . " ) ; <nl> - ] <nl> + ( meth_pos , <nl> + " Static methods cannot use generics reified at the class level . Try reifying them at the static method itself . " <nl> + ) <nl> + [ ( generic_pos , " Class - level reified generic used here . " ) ] <nl> <nl> let consistent_construct_reified pos = <nl> add <nl> let new_without_newable pos name = <nl> let invalid_freeze_target pos1 var_pos var_mutability_str = <nl> add_list <nl> ( Typing . err_code Typing . InvalidFreezeTarget ) <nl> - [ <nl> - ( pos1 , " Invalid argument - ` freeze ( ) ` takes a single mutable variable " ) ; <nl> - ( var_pos , " This variable is " ^ var_mutability_str ) ; <nl> - ] <nl> + ( pos1 , " Invalid argument - ` freeze ( ) ` takes a single mutable variable " ) <nl> + [ ( var_pos , " This variable is " ^ var_mutability_str ) ] <nl> <nl> let invalid_move_target pos1 var_pos var_mutability_str = <nl> add_list <nl> ( Typing . err_code Typing . InvalidMoveTarget ) <nl> - [ <nl> - ( pos1 , " Invalid argument - ` move ( ) ` takes a single mutably - owned variable " ) ; <nl> - ( var_pos , " This variable is " ^ var_mutability_str ) ; <nl> - ] <nl> + ( pos1 , " Invalid argument - ` move ( ) ` takes a single mutably - owned variable " ) <nl> + [ ( var_pos , " This variable is " ^ var_mutability_str ) ] <nl> <nl> let discarded_awaitable pos1 pos2 = <nl> add_list <nl> ( Typing . err_code Typing . DiscardedAwaitable ) <nl> - [ <nl> - ( pos1 , <nl> - " This expression is of type ` Awaitable ` , but it ' s " <nl> - ^ " either being discarded or used in a dangerous way before " <nl> - ^ " being awaited " ) ; <nl> - ( pos2 , " This is why I think it is ` Awaitable ` " ) ; <nl> - ] <nl> + ( pos1 , <nl> + " This expression is of type ` Awaitable ` , but it ' s " <nl> + ^ " either being discarded or used in a dangerous way before " <nl> + ^ " being awaited " ) <nl> + [ ( pos2 , " This is why I think it is ` Awaitable ` " ) ] <nl> <nl> - let unify_error ? code errl = <nl> - add_list ( Option . value code ~ default : ( Typing . err_code Typing . UnifyError ) ) errl <nl> + let unify_error ? code err = <nl> + add_list ( Option . value code ~ default : ( Typing . err_code Typing . UnifyError ) ) err <nl> <nl> - let unify_error_at pos ? code errl = <nl> - unify_error ? code ( ( pos , " Typing error " ) : : errl ) <nl> + let unify_error_at : Pos . t - > typing_error_callback = <nl> + fun pos ? code claim reasons - > <nl> + unify_error ? code ( pos , " Typing error " ) ( claim : : reasons ) <nl> <nl> let maybe_unify_error specific_code ? code errl = <nl> add_list ( Option . value code ~ default : ( Typing . err_code specific_code ) ) errl <nl> let static_redeclared_as_dynamic <nl> in <nl> add_list <nl> ( Typing . err_code Typing . StaticDynamic ) <nl> - [ ( dyn_position , msg_dynamic ) ; ( static_position , msg_static ) ] <nl> + ( dyn_position , msg_dynamic ) <nl> + [ ( static_position , msg_static ) ] <nl> <nl> let dynamic_redeclared_as_static <nl> static_position dyn_position member_name ~ elt_type = <nl> let dynamic_redeclared_as_static <nl> in <nl> add_list <nl> ( Typing . err_code Typing . StaticDynamic ) <nl> - [ ( static_position , msg_static ) ; ( dyn_position , msg_dynamic ) ] <nl> + ( static_position , msg_static ) <nl> + [ ( dyn_position , msg_dynamic ) ] <nl> <nl> let null_member code ~ is_method s pos r = <nl> let msg = <nl> let null_member code ~ is_method s pos r = <nl> " property " ) <nl> ( Markdown_lite . md_codify s ) <nl> in <nl> - add_list ( Typing . err_code code ) ( [ ( pos , msg ) ] @ r ) <nl> + add_list ( Typing . err_code code ) ( pos , msg ) r <nl> <nl> let null_member_read = null_member Typing . NullMemberRead <nl> <nl> let top_member null_code nonnull_code ~ is_method ~ is_nullable s pos1 ty pos2 = <nl> null_code <nl> else <nl> nonnull_code ) ) <nl> - [ ( pos1 , msg ) ; ( pos2 , " Definition is here " ) ] <nl> + ( pos1 , msg ) <nl> + [ ( pos2 , " Definition is here " ) ] <nl> <nl> let top_member_read = <nl> top_member Typing . NullMemberRead Typing . NonObjectMemberRead <nl> let non_object_member <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code code ) <nl> - [ ( pos1 , msg ) ; ( pos2 , " Definition is here " ) ] <nl> + ( pos1 , msg ) <nl> + [ ( pos2 , " Definition is here " ) ] <nl> <nl> let non_object_member_read = non_object_member Typing . NonObjectMemberRead <nl> <nl> let unknown_object_member ~ is_method s pos r = <nl> " property " ) <nl> ( Markdown_lite . md_codify s ) <nl> in <nl> - add_list ( Typing . err_code Typing . UnknownObjectMember ) ( [ ( pos , msg ) ] @ r ) <nl> + add_list ( Typing . err_code Typing . UnknownObjectMember ) ( pos , msg ) r <nl> <nl> let non_class_member ~ is_method s pos1 ty pos2 = <nl> let msg = <nl> let non_class_member ~ is_method s pos1 ty pos2 = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . NonClassMember ) <nl> - [ ( pos1 , msg ) ; ( pos2 , " Definition is here " ) ] <nl> + ( pos1 , msg ) <nl> + [ ( pos2 , " Definition is here " ) ] <nl> <nl> let null_container p null_witness = <nl> add_list <nl> ( Typing . err_code Typing . NullContainer ) <nl> - ( [ <nl> - ( p , <nl> - " You are trying to access an element of this container " <nl> - ^ " but the container could be ` null ` . " ) ; <nl> - ] <nl> - @ null_witness ) <nl> + ( p , <nl> + " You are trying to access an element of this container " <nl> + ^ " but the container could be ` null ` . " ) <nl> + ( [ ] @ null_witness ) <nl> <nl> let option_mixed pos = <nl> add <nl> let option_null pos = <nl> let declared_covariant pos1 pos2 emsg = <nl> add_list <nl> ( Typing . err_code Typing . DeclaredCovariant ) <nl> - ( [ <nl> - ( pos2 , " Illegal usage of a covariant type parameter " ) ; <nl> - ( pos1 , " This is where the parameter was declared as covariant ` + ` " ) ; <nl> - ] <nl> + ( pos2 , " Illegal usage of a covariant type parameter " ) <nl> + ( [ ( pos1 , " This is where the parameter was declared as covariant ` + ` " ) ] <nl> @ emsg ) <nl> <nl> let declared_contravariant pos1 pos2 emsg = <nl> add_list <nl> ( Typing . err_code Typing . DeclaredContravariant ) <nl> - ( [ <nl> - ( pos2 , " Illegal usage of a contravariant type parameter " ) ; <nl> - ( pos1 , " This is where the parameter was declared as contravariant ` - ` " ) ; <nl> - ] <nl> + ( pos2 , " Illegal usage of a contravariant type parameter " ) <nl> + ( [ ( pos1 , " This is where the parameter was declared as contravariant ` - ` " ) ] <nl> @ emsg ) <nl> <nl> let static_property_type_generic_param ~ class_pos ~ var_type_pos ~ generic_pos = <nl> add_list <nl> ( Typing . err_code Typing . ClassVarTypeGenericParam ) <nl> + ( generic_pos , <nl> + " A generic parameter cannot be used in the type of a static property " ) <nl> [ <nl> - ( generic_pos , <nl> - " A generic parameter cannot be used in the type of a static property " ) ; <nl> ( var_type_pos , <nl> " This is where the type of the static property was declared " ) ; <nl> ( class_pos , " This is the class containing the static property " ) ; <nl> let abstract_concrete_override pos parent_pos kind = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . AbstractConcreteOverride ) <nl> - [ <nl> - ( pos , " Cannot re - declare this " ^ kind_str ^ " as abstract " ) ; <nl> - ( parent_pos , " Previously defined here " ) ; <nl> - ] <nl> + ( pos , " Cannot re - declare this " ^ kind_str ^ " as abstract " ) <nl> + [ ( parent_pos , " Previously defined here " ) ] <nl> <nl> let required_field_is_optional pos1 pos2 name ( on_error : typing_error_callback ) <nl> = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . RequiredFieldIsOptional ) <nl> + ( pos1 , " The field " ^ Markdown_lite . md_codify name ^ " is * * optional * * " ) <nl> [ <nl> - ( pos1 , " The field " ^ Markdown_lite . md_codify name ^ " is * * optional * * " ) ; <nl> ( pos2 , <nl> " The field " <nl> ^ Markdown_lite . md_codify name <nl> let required_field_is_optional pos1 pos2 name ( on_error : typing_error_callback ) <nl> let array_get_with_optional_field pos1 pos2 name = <nl> add_list <nl> ( Typing . err_code Typing . ArrayGetWithOptionalField ) <nl> - [ <nl> - ( pos1 , <nl> - Printf . sprintf <nl> - " The field % s may not be present in this shape . Use ` Shapes : : idx ( ) ` instead . " <nl> - ( Markdown_lite . md_codify name ) ) ; <nl> - ( pos2 , " This is where the field was declared as optional . " ) ; <nl> - ] <nl> + ( pos1 , <nl> + Printf . sprintf <nl> + " The field % s may not be present in this shape . Use ` Shapes : : idx ( ) ` instead . " <nl> + ( Markdown_lite . md_codify name ) ) <nl> + [ ( pos2 , " This is where the field was declared as optional . " ) ] <nl> <nl> let return_disposable_mismatch <nl> pos1_return_disposable pos1 pos2 ( on_error : typing_error_callback ) = <nl> let return_disposable_mismatch <nl> let m2 = " This is not marked ` < < __ReturnDisposable > > ` . " in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . ReturnDisposableMismatch ) <nl> + ( pos1 , <nl> + if pos1_return_disposable then <nl> + m1 <nl> + else <nl> + m2 ) <nl> [ <nl> - ( pos1 , <nl> - if pos1_return_disposable then <nl> - m1 <nl> - else <nl> - m2 ) ; <nl> ( pos2 , <nl> if pos1_return_disposable then <nl> m2 <nl> let ifc_policy_mismatch <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . IFCPolicyMismatch ) <nl> - [ ( pos_sub , m1 ) ; ( pos_super , m2 ) ] <nl> + ( pos_sub , m1 ) <nl> + [ ( pos_super , m2 ) ] <nl> <nl> let return_void_to_rx_mismatch <nl> ~ pos1_has_attribute pos1 pos2 ( on_error : typing_error_callback ) = <nl> let return_void_to_rx_mismatch <nl> let m2 = " This is not marked ` < < __ReturnsVoidToRx > > ` . " in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . ReturnVoidToRxMismatch ) <nl> + ( pos1 , <nl> + if pos1_has_attribute then <nl> + m1 <nl> + else <nl> + m2 ) <nl> [ <nl> - ( pos1 , <nl> - if pos1_has_attribute then <nl> - m1 <nl> - else <nl> - m2 ) ; <nl> ( pos2 , <nl> if pos1_has_attribute then <nl> m2 <nl> let overriding_prop_const_mismatch <nl> let m2 = " This property is not ` __Const ` " in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . OverridingPropConstMismatch ) <nl> + ( child_pos , <nl> + if child_const then <nl> + m1 <nl> + else <nl> + m2 ) <nl> [ <nl> - ( child_pos , <nl> - if child_const then <nl> - m1 <nl> - else <nl> - m2 ) ; <nl> ( parent_pos , <nl> if parent_const then <nl> m1 <nl> let mutable_return_result_mismatch <nl> let m2 = " This is not marked ` < < __MutableReturn > > ` . " in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MutableReturnResultMismatch ) <nl> + ( pos1 , <nl> + if pos1_has_mutable_return then <nl> + m1 <nl> + else <nl> + m2 ) <nl> [ <nl> - ( pos1 , <nl> - if pos1_has_mutable_return then <nl> - m1 <nl> - else <nl> - m2 ) ; <nl> ( pos2 , <nl> if pos1_has_mutable_return then <nl> m2 <nl> let wrong_extend_kind <nl> in <nl> let msg1 = ( child_pos , child_msg ) in <nl> let msg2 = ( parent_pos , " This is " ^ parent_kind_str ^ " . " ) in <nl> - add_list ( Typing . err_code Typing . WrongExtendKind ) [ msg1 ; msg2 ] <nl> + add_list ( Typing . err_code Typing . WrongExtendKind ) msg1 [ msg2 ] <nl> <nl> let unsatisfied_req parent_pos req_name req_pos = <nl> let s1 = " Failure to satisfy requirement : " ^ strip_ns req_name in <nl> let unsatisfied_req parent_pos req_name req_pos = <nl> else <nl> add_list <nl> ( Typing . err_code Typing . UnsatisfiedReq ) <nl> - [ ( parent_pos , s1 ) ; ( req_pos , s2 ) ] <nl> + ( parent_pos , s1 ) <nl> + [ ( req_pos , s2 ) ] <nl> <nl> let cyclic_class_def stack pos = <nl> let stack = <nl> let trait_reuse_with_final_method use_pos trait_name parent_cls_name trace = <nl> ( strip_ns trait_name ) <nl> ( strip_ns parent_cls_name ) <nl> in <nl> - add_list ( Typing . err_code Typing . TraitReuse ) ( ( use_pos , msg ) : : trace ) <nl> + add_list ( Typing . err_code Typing . TraitReuse ) ( use_pos , msg ) trace <nl> <nl> let trait_reuse p_pos p_name class_name trait = <nl> let ( c_pos , c_name ) = class_name in <nl> let trait_reuse p_pos p_name class_name trait = <nl> let err ' = <nl> " It is already used through " ^ ( strip_ns p_name | > Markdown_lite . md_codify ) <nl> in <nl> - add_list ( Typing . err_code Typing . TraitReuse ) [ ( c_pos , err ) ; ( p_pos , err ' ) ] <nl> + add_list ( Typing . err_code Typing . TraitReuse ) ( c_pos , err ) [ ( p_pos , err ' ) ] <nl> <nl> let trait_reuse_inside_class class_name trait occurrences = <nl> let ( c_pos , c_name ) = class_name in <nl> let trait_reuse_inside_class class_name trait occurrences = <nl> let err = " Class " ^ c_name ^ " uses trait " ^ trait ^ " multiple times " in <nl> add_list <nl> ( Typing . err_code Typing . TraitReuseInsideClass ) <nl> - ( [ ( c_pos , err ) ] @ List . map ~ f : ( fun p - > ( p , " used here " ) ) occurrences ) <nl> + ( c_pos , err ) <nl> + ( List . map ~ f : ( fun p - > ( p , " used here " ) ) occurrences ) <nl> <nl> let invalid_is_as_expression_hint op hint_pos reasons = <nl> add_list <nl> ( Typing . err_code Typing . InvalidIsAsExpressionHint ) <nl> - ( ( hint_pos , " Invalid " ^ Markdown_lite . md_codify op ^ " expression hint " ) <nl> - : : List . map reasons ~ f : ( fun ( ty_pos , ty_str ) - > <nl> - ( ty_pos , <nl> - " The " <nl> - ^ Markdown_lite . md_codify op <nl> - ^ " operator cannot be used with " <nl> - ^ ty_str ) ) ) <nl> + ( hint_pos , " Invalid " ^ Markdown_lite . md_codify op ^ " expression hint " ) <nl> + ( List . map reasons ~ f : ( fun ( ty_pos , ty_str ) - > <nl> + ( ty_pos , <nl> + " The " <nl> + ^ Markdown_lite . md_codify op <nl> + ^ " operator cannot be used with " <nl> + ^ ty_str ) ) ) <nl> <nl> let invalid_enforceable_type kind_str ( tp_pos , tp_name ) targ_pos ty_info = <nl> let ( ty_pos , ty_str ) = List . hd_exn ty_info in <nl> add_list <nl> ( Typing . err_code Typing . InvalidEnforceableTypeArgument ) <nl> + ( targ_pos , " Invalid type " ) <nl> [ <nl> - ( targ_pos , " Invalid type " ) ; <nl> ( tp_pos , <nl> " Type " <nl> ^ kind_str <nl> let reifiable_attr attr_pos decl_kind decl_pos ty_info = <nl> let ( ty_pos , ty_msg ) = List . hd_exn ty_info in <nl> add_list <nl> ( Typing . err_code Typing . DisallowPHPArraysAttr ) <nl> + ( decl_pos , " Invalid " ^ decl_kind ) <nl> [ <nl> - ( decl_pos , " Invalid " ^ decl_kind ) ; <nl> ( attr_pos , " This type constant has the ` __Reifiable ` attribute " ) ; <nl> ( ty_pos , " It cannot contain " ^ ty_msg ) ; <nl> ] <nl> let reifiable_attr attr_pos decl_kind decl_pos ty_info = <nl> let invalid_newable_type_argument ( tp_pos , tp_name ) ta_pos = <nl> add_list <nl> ( Typing . err_code Typing . InvalidNewableTypeArgument ) <nl> + ( ta_pos , <nl> + " A newable type argument must be a concrete class or a newable type parameter . " <nl> + ) <nl> [ <nl> - ( ta_pos , <nl> - " A newable type argument must be a concrete class or a newable type parameter . " <nl> - ) ; <nl> ( tp_pos , <nl> " Type parameter " <nl> ^ Markdown_lite . md_codify tp_name <nl> let invalid_newable_type_param_constraints <nl> let override_final ~ parent ~ child ~ ( on_error : typing_error_callback option ) = <nl> let msg1 = ( child , " You cannot override this method " ) in <nl> let msg2 = ( parent , " It was declared as final " ) in <nl> - on_error_or_add on_error ( Typing . err_code Typing . OverrideFinal ) [ msg1 ; msg2 ] <nl> + on_error_or_add on_error ( Typing . err_code Typing . OverrideFinal ) msg1 [ msg2 ] <nl> <nl> let override_lsb ~ member_name ~ parent ~ child ( on_error : typing_error_callback ) <nl> = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . OverrideLSB ) <nl> - [ <nl> - ( child , <nl> - " Member " <nl> - ^ Markdown_lite . md_codify member_name <nl> - ^ " may not override ` __LSB ` member of parent " ) ; <nl> - ( parent , " This is being overridden " ) ; <nl> - ] <nl> + ( child , <nl> + " Member " <nl> + ^ Markdown_lite . md_codify member_name <nl> + ^ " may not override ` __LSB ` member of parent " ) <nl> + [ ( parent , " This is being overridden " ) ] <nl> <nl> let should_be_override pos class_id id = <nl> add <nl> let override_per_trait class_name meth_name trait_name m_pos = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . OverridePerTrait ) <nl> + ( c_pos , err_msg ) <nl> [ <nl> - ( c_pos , err_msg ) ; <nl> ( m_pos , " Declaration of " ^ Markdown_lite . md_codify meth_name ^ " is here " ) ; <nl> ] <nl> <nl> let missing_assign pos = <nl> let invalid_memoized_param pos ty_reason_msg = <nl> add_list <nl> ( Typing . err_code Typing . InvalidMemoizedParam ) <nl> - ( ( pos , <nl> - " Parameters to memoized function must be null , bool , int , float , string , an object deriving IMemoizeParam , or a Container thereof . See also http : / / docs . hhvm . com / hack / attributes / special # __memoize " <nl> - ) <nl> - : : ty_reason_msg ) <nl> + ( pos , <nl> + " Parameters to memoized function must be null , bool , int , float , string , an object deriving IMemoizeParam , or a Container thereof . See also http : / / docs . hhvm . com / hack / attributes / special # __memoize " <nl> + ) <nl> + ty_reason_msg <nl> <nl> let invalid_disposable_hint pos class_name = <nl> add <nl> let xhp_required pos why_xhp ty_reason_msg = <nl> let msg = " An XHP instance was expected " in <nl> add_list <nl> ( Typing . err_code Typing . XhpRequired ) <nl> - ( ( pos , msg ) : : ( pos , why_xhp ) : : ty_reason_msg ) <nl> + ( pos , msg ) <nl> + ( ( pos , why_xhp ) : : ty_reason_msg ) <nl> <nl> let illegal_xhp_child pos ty_reason_msg = <nl> let msg = " XHP children must be compatible with XHPChild " in <nl> - add_list ( Typing . err_code Typing . IllegalXhpChild ) ( ( pos , msg ) : : ty_reason_msg ) <nl> + add_list ( Typing . err_code Typing . IllegalXhpChild ) ( pos , msg ) ty_reason_msg <nl> <nl> let missing_xhp_required_attr pos attr ty_reason_msg = <nl> let msg = <nl> let missing_xhp_required_attr pos attr ty_reason_msg = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . MissingXhpRequiredAttr ) <nl> - ( ( pos , msg ) : : ty_reason_msg ) <nl> + ( pos , msg ) <nl> + ty_reason_msg <nl> <nl> let nullsafe_not_needed p nonnull_witness = <nl> add_list <nl> ( Typing . err_code Typing . NullsafeNotNeeded ) <nl> - ( [ ( p , " You are using the ` ? - > ` operator but this object cannot be null . " ) ] <nl> - @ nonnull_witness ) <nl> + ( p , " You are using the ` ? - > ` operator but this object cannot be null . " ) <nl> + nonnull_witness <nl> <nl> let generic_at_runtime p prefix = <nl> add <nl> let trivial_strict_eq p b left right left_trail right_trail = <nl> let right_trail = List . map right_trail typedef_trail_entry in <nl> add_list <nl> ( Typing . err_code Typing . TrivialStrictEq ) <nl> - ( ( ( p , msg ) : : left ) @ left_trail @ right @ right_trail ) <nl> + ( p , msg ) <nl> + ( left @ left_trail @ right @ right_trail ) <nl> <nl> let trivial_strict_not_nullable_compare_null p result type_reason = <nl> let msg = " This expression is always " ^ result in <nl> add_list <nl> ( Typing . err_code Typing . NotNullableCompareNullTrivial ) <nl> - ( ( p , msg ) : : type_reason ) <nl> + ( p , msg ) <nl> + type_reason <nl> <nl> let eq_incompatible_types p left right = <nl> let msg = " This equality test has incompatible types " in <nl> - add_list <nl> - ( Typing . err_code Typing . EqIncompatibleTypes ) <nl> - ( ( ( p , msg ) : : left ) @ right ) <nl> + add_list ( Typing . err_code Typing . EqIncompatibleTypes ) ( p , msg ) ( left @ right ) <nl> <nl> let comparison_invalid_types p left right = <nl> let msg = <nl> let comparison_invalid_types p left right = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . ComparisonInvalidTypes ) <nl> - ( ( ( p , msg ) : : left ) @ right ) <nl> + ( p , msg ) <nl> + ( left @ right ) <nl> <nl> let void_usage p void_witness = <nl> let msg = " You are using the return value of a ` void ` function " in <nl> - add_list ( Typing . err_code Typing . VoidUsage ) ( ( p , msg ) : : void_witness ) <nl> + add_list ( Typing . err_code Typing . VoidUsage ) ( p , msg ) void_witness <nl> <nl> let noreturn_usage p noreturn_witness = <nl> let msg = " You are using the return value of a ` noreturn ` function " in <nl> - add_list ( Typing . err_code Typing . NoreturnUsage ) ( ( p , msg ) : : noreturn_witness ) <nl> + add_list ( Typing . err_code Typing . NoreturnUsage ) ( p , msg ) noreturn_witness <nl> <nl> let attribute_too_few_arguments pos x n = <nl> let n = string_of_int n in <nl> let deprecated_use pos ? ( pos_def = None ) msg = <nl> | Some pos_def - > [ ( pos_def , " Definition is here " ) ] <nl> | None - > [ ] <nl> in <nl> - add_list ( Typing . err_code Typing . DeprecatedUse ) ( ( pos , msg ) : : def_message ) <nl> + add_list ( Typing . err_code Typing . DeprecatedUse ) ( pos , msg ) def_message <nl> <nl> let cannot_declare_constant kind pos ( class_pos , class_name ) = <nl> let kind_str = <nl> let cannot_declare_constant kind pos ( class_pos , class_name ) = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . CannotDeclareConstant ) <nl> + ( pos , " Cannot declare a constant in " ^ kind_str ) <nl> [ <nl> - ( pos , " Cannot declare a constant in " ^ kind_str ) ; <nl> ( class_pos , <nl> ( strip_ns class_name | > Markdown_lite . md_codify ) <nl> ^ " was defined as " <nl> let cannot_declare_constant kind pos ( class_pos , class_name ) = <nl> ] <nl> <nl> let ambiguous_inheritance <nl> - pos class_ origin ( error : error ) ( on_error : typing_error_callback ) = <nl> + pos class_ origin error ( on_error : typing_error_callback ) = <nl> + let { code ; claim ; reasons } = error in <nl> let origin = strip_ns origin in <nl> let class_ = strip_ns class_ in <nl> let message = <nl> let ambiguous_inheritance <nl> ^ Markdown_lite . md_codify class_ <nl> ^ " with a compatible signature . " <nl> in <nl> - let ( code , msgl ) = ( get_code error , to_list error ) in <nl> - on_error ~ code ( msgl @ [ ( pos , message ) ] ) <nl> + on_error ~ code claim ( reasons @ [ ( pos , message ) ] ) <nl> <nl> let multiple_concrete_defs <nl> child_pos <nl> let multiple_concrete_defs <nl> let class_ = strip_ns class_ in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . MultipleConcreteDefs ) <nl> + ( child_pos , <nl> + Markdown_lite . md_codify child_origin <nl> + ^ " and " <nl> + ^ Markdown_lite . md_codify parent_origin <nl> + ^ " both declare ambiguous implementations of " <nl> + ^ Markdown_lite . md_codify name <nl> + ^ " . " ) <nl> [ <nl> - ( child_pos , <nl> - Markdown_lite . md_codify child_origin <nl> - ^ " and " <nl> - ^ Markdown_lite . md_codify parent_origin <nl> - ^ " both declare ambiguous implementations of " <nl> - ^ Markdown_lite . md_codify name <nl> - ^ " . " ) ; <nl> ( child_pos , <nl> Markdown_lite . md_codify child_origin ^ " ' s definition is here . " ) ; <nl> ( parent_pos , <nl> let local_variable_modified_and_used pos_modified pos_used_l = <nl> let used_msg p = ( p , " And accessed here " ) in <nl> add_list <nl> ( Typing . err_code Typing . LocalVariableModifedAndUsed ) <nl> - ( ( pos_modified , <nl> - " Unsequenced modification and access to local variable . Modified here " <nl> - ) <nl> - : : List . map pos_used_l used_msg ) <nl> + ( pos_modified , <nl> + " Unsequenced modification and access to local variable . Modified here " ) <nl> + ( List . map pos_used_l used_msg ) <nl> <nl> let local_variable_modified_twice pos_modified pos_modified_l = <nl> let modified_msg p = ( p , " And also modified here " ) in <nl> add_list <nl> ( Typing . err_code Typing . LocalVariableModifedTwice ) <nl> - ( ( pos_modified , <nl> - " Unsequenced modifications to local variable . Modified here " ) <nl> - : : List . map pos_modified_l modified_msg ) <nl> + ( pos_modified , " Unsequenced modifications to local variable . Modified here " ) <nl> + ( List . map pos_modified_l modified_msg ) <nl> <nl> let assign_during_case p = <nl> add <nl> let illegal_typeconst_direct_access pos = <nl> let override_no_default_typeconst pos_child pos_parent = <nl> add_list <nl> ( Typing . err_code Typing . OverrideNoDefaultTypeconst ) <nl> + ( pos_child , " This abstract type constant does not have a default type " ) <nl> [ <nl> - ( pos_child , " This abstract type constant does not have a default type " ) ; <nl> ( pos_parent , <nl> " It cannot override an abstract type constant that has a default type " <nl> ) ; <nl> let override_no_default_typeconst pos_child pos_parent = <nl> let inout_annotation_missing pos1 pos2 = <nl> let msg1 = ( pos1 , " This argument should be annotated with ` inout ` " ) in <nl> let msg2 = ( pos2 , " Because this is an ` inout ` parameter " ) in <nl> - add_list ( Typing . err_code Typing . InoutAnnotationMissing ) [ msg1 ; msg2 ] <nl> + add_list ( Typing . err_code Typing . InoutAnnotationMissing ) msg1 [ msg2 ] <nl> <nl> let inout_annotation_unexpected pos1 pos2 pos2_is_variadic = <nl> let msg1 = ( pos1 , " Unexpected ` inout ` annotation for argument " ) in <nl> let inout_annotation_unexpected pos1 pos2 pos2_is_variadic = <nl> else <nl> " This is a normal parameter ( does not have ` inout ` ) " ) <nl> in <nl> - add_list ( Typing . err_code Typing . InoutAnnotationUnexpected ) [ msg1 ; msg2 ] <nl> + add_list ( Typing . err_code Typing . InoutAnnotationUnexpected ) msg1 [ msg2 ] <nl> <nl> let inoutness_mismatch pos1 pos2 ( on_error : typing_error_callback ) = <nl> let msg1 = ( pos1 , " This is an ` inout ` parameter " ) in <nl> let msg2 = ( pos2 , " It is incompatible with a normal parameter " ) in <nl> - on_error ~ code : ( Typing . err_code Typing . InoutnessMismatch ) [ msg1 ; msg2 ] <nl> + on_error ~ code : ( Typing . err_code Typing . InoutnessMismatch ) msg1 [ msg2 ] <nl> <nl> let invalid_new_disposable pos = <nl> let msg = <nl> let invalid_return_disposable pos = <nl> let nonreactive_function_call pos decl_pos callee_reactivity cause_pos_opt = <nl> add_list <nl> ( Typing . err_code Typing . NonreactiveFunctionCall ) <nl> - ( [ <nl> - ( pos , " Reactive functions can only call other reactive functions . " ) ; <nl> - ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ; <nl> - ] <nl> + ( pos , " Reactive functions can only call other reactive functions . " ) <nl> + ( [ ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ] <nl> @ Option . value_map cause_pos_opt ~ default : [ ] ~ f : ( fun cause_pos - > <nl> [ <nl> ( cause_pos , <nl> let nonreactive_function_call pos decl_pos callee_reactivity cause_pos_opt = <nl> let nonpure_function_call pos decl_pos callee_reactivity = <nl> add_list <nl> ( Typing . err_code Typing . NonpureFunctionCall ) <nl> - [ <nl> - ( pos , " Pure functions can only call other pure functions . " ) ; <nl> - ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ; <nl> - ] <nl> + ( pos , " Pure functions can only call other pure functions . " ) <nl> + [ ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ] <nl> <nl> let nonreactive_call_from_shallow pos decl_pos callee_reactivity cause_pos_opt = <nl> add_list <nl> ( Typing . err_code Typing . NonreactiveCallFromShallow ) <nl> - ( [ <nl> - ( pos , " Shallow reactive functions cannot call non - reactive functions . " ) ; <nl> - ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ; <nl> - ] <nl> + ( pos , " Shallow reactive functions cannot call non - reactive functions . " ) <nl> + ( [ ( decl_pos , " This function is " ^ callee_reactivity ^ " . " ) ] <nl> @ Option . value_map cause_pos_opt ~ default : [ ] ~ f : ( fun cause_pos - > <nl> [ <nl> ( cause_pos , <nl> let rx_parameter_condition_mismatch <nl> cond pos def_pos ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . RxParameterConditionMismatch ) <nl> - [ <nl> - ( pos , <nl> - " This parameter does not satisfy " <nl> - ^ cond <nl> - ^ " condition defined on matching parameter in function super type . " ) ; <nl> - ( def_pos , " This is parameter declaration from the function super type . " ) ; <nl> - ] <nl> + ( pos , <nl> + " This parameter does not satisfy " <nl> + ^ cond <nl> + ^ " condition defined on matching parameter in function super type . " ) <nl> + [ ( def_pos , " This is parameter declaration from the function super type . " ) ] <nl> <nl> let nonreactive_indexing is_append pos = <nl> let msg = <nl> let inout_argument_bad_type pos msgl = <nl> ^ " a value - typed container ( e . g . vec , dict , keyset , array ) . " <nl> ^ " To use ` inout ` here , assign to / from a temporary local variable . " <nl> in <nl> - add_list ( Typing . err_code Typing . InoutArgumentBadType ) ( ( pos , msg ) : : msgl ) <nl> + add_list ( Typing . err_code Typing . InoutArgumentBadType ) ( pos , msg ) msgl <nl> <nl> let ambiguous_lambda pos uses = <nl> let msg1 = <nl> let ambiguous_lambda pos uses = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . AmbiguousLambda ) <nl> - ( [ ( pos , msg1 ) ; ( pos , msg2 ) ] <nl> - @ List . map uses ( fun ( pos , ty ) - > <nl> - ( pos , " This use has type " ^ Markdown_lite . md_codify ty ) ) ) <nl> + ( pos , msg1 ) <nl> + ( ( pos , msg2 ) <nl> + : : List . map uses ( fun ( pos , ty ) - > <nl> + ( pos , " This use has type " ^ Markdown_lite . md_codify ty ) ) ) <nl> <nl> let wrong_expression_kind_attribute <nl> expr_kind pos attr attr_class_pos attr_class_name intf_name = <nl> let wrong_expression_kind_attribute <nl> in <nl> add_list <nl> ( Typing . err_code Typing . WrongExpressionKindAttribute ) <nl> - [ ( pos , msg1 ) ; ( attr_class_pos , msg2 ) ] <nl> + ( pos , msg1 ) <nl> + [ ( attr_class_pos , msg2 ) ] <nl> <nl> let wrong_expression_kind_builtin_attribute expr_kind pos attr = <nl> let msg1 = <nl> let wrong_expression_kind_builtin_attribute expr_kind pos attr = <nl> ( strip_ns attr | > Markdown_lite . md_codify ) <nl> expr_kind <nl> in <nl> - add_list ( Typing . err_code Typing . WrongExpressionKindAttribute ) [ ( pos , msg1 ) ] <nl> + add_list ( Typing . err_code Typing . WrongExpressionKindAttribute ) ( pos , msg1 ) [ ] <nl> <nl> let cannot_return_borrowed_value_as_immutable fun_pos value_pos = <nl> add_list <nl> ( Typing . err_code Typing . CannotReturnBorrowedValueAsImmutable ) <nl> + ( fun_pos , <nl> + " Values returned from reactive function by default are treated as immutable . " <nl> + ) <nl> [ <nl> - ( fun_pos , <nl> - " Values returned from reactive function by default are treated as immutable . " <nl> - ) ; <nl> ( value_pos , <nl> " This value is mutably borrowed and cannot be returned as immutable " ) ; <nl> ] <nl> let cannot_return_borrowed_value_as_immutable fun_pos value_pos = <nl> let decl_override_missing_hint pos ( on_error : typing_error_callback ) = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . DeclOverrideMissingHint ) <nl> - [ <nl> - ( pos , <nl> - " When redeclaring class members , both declarations must have a typehint " <nl> - ) ; <nl> - ] <nl> + ( pos , <nl> + " When redeclaring class members , both declarations must have a typehint " <nl> + ) <nl> + [ ] <nl> <nl> let invalid_type_for_atmost_rx_as_rxfunc_parameter pos type_str = <nl> add <nl> let superglobal_in_reactive_context pos name = <nl> let returns_void_to_rx_function_as_non_expression_statement pos fpos = <nl> add_list <nl> ( Typing . err_code Typing . ReturnsVoidToRxAsNonExpressionStatement ) <nl> - [ <nl> - ( pos , <nl> - " Cannot use result of function annotated with ` < < __ReturnsVoidToRx > > ` in reactive context " <nl> - ) ; <nl> - ( fpos , " This is function declaration . " ) ; <nl> - ] <nl> + ( pos , <nl> + " Cannot use result of function annotated with ` < < __ReturnsVoidToRx > > ` in reactive context " <nl> + ) <nl> + [ ( fpos , " This is function declaration . " ) ] <nl> <nl> let non_awaited_awaitable_in_rx pos = <nl> add <nl> let non_awaited_awaitable_in_rx pos = <nl> let shapes_key_exists_always_true pos1 name pos2 = <nl> add_list <nl> ( Typing . err_code Typing . ShapesKeyExistsAlwaysTrue ) <nl> + ( pos1 , " This ` Shapes : : keyExists ( ) ` check is always true " ) <nl> [ <nl> - ( pos1 , " This ` Shapes : : keyExists ( ) ` check is always true " ) ; <nl> ( pos2 , <nl> " The field " <nl> ^ Markdown_lite . md_codify name <nl> let shape_field_non_existence_reason pos name = function <nl> : : reason <nl> <nl> let shapes_key_exists_always_false pos1 name pos2 reason = <nl> - add_list ( Typing . err_code Typing . ShapesKeyExistsAlwaysFalse ) <nl> - @ @ ( pos1 , " This ` Shapes : : keyExists ( ) ` check is always false " ) <nl> - : : shape_field_non_existence_reason pos2 name reason <nl> + add_list <nl> + ( Typing . err_code Typing . ShapesKeyExistsAlwaysFalse ) <nl> + ( pos1 , " This ` Shapes : : keyExists ( ) ` check is always false " ) <nl> + @ @ shape_field_non_existence_reason pos2 name reason <nl> <nl> let shapes_method_access_with_non_existent_field <nl> pos1 name pos2 method_name reason = <nl> - add_list ( Typing . err_code Typing . ShapesMethodAccessWithNonExistentField ) <nl> - @ @ ( pos1 , <nl> - " You are calling " <nl> - ^ Markdown_lite . md_codify ( " Shapes : : " ^ method_name ^ " ( ) " ) <nl> - ^ " on a field known to not exist " ) <nl> - : : shape_field_non_existence_reason pos2 name reason <nl> + add_list <nl> + ( Typing . err_code Typing . ShapesMethodAccessWithNonExistentField ) <nl> + ( pos1 , <nl> + " You are calling " <nl> + ^ Markdown_lite . md_codify ( " Shapes : : " ^ method_name ^ " ( ) " ) <nl> + ^ " on a field known to not exist " ) <nl> + @ @ shape_field_non_existence_reason pos2 name reason <nl> <nl> let shape_access_with_non_existent_field pos1 name pos2 reason = <nl> - add_list ( Typing . err_code Typing . ShapeAccessWithNonExistentField ) <nl> - @ @ ( pos1 , " You are accessing a field known to not exist " ) <nl> - : : shape_field_non_existence_reason pos2 name reason <nl> + add_list <nl> + ( Typing . err_code Typing . ShapeAccessWithNonExistentField ) <nl> + ( pos1 , " You are accessing a field known to not exist " ) <nl> + @ @ shape_field_non_existence_reason pos2 name reason <nl> <nl> let ambiguous_object_access <nl> pos name self_pos vis subclass_pos class_self class_subclass = <nl> let ambiguous_object_access <nl> let class_subclass = strip_ns class_subclass in <nl> add_list <nl> ( Typing . err_code Typing . AmbiguousObjectAccess ) <nl> + ( pos , <nl> + " This object access to " ^ Markdown_lite . md_codify name ^ " is ambiguous " <nl> + ) <nl> [ <nl> - ( pos , <nl> - " This object access to " <nl> - ^ Markdown_lite . md_codify name <nl> - ^ " is ambiguous " ) ; <nl> ( self_pos , <nl> " You will access the private instance declared in " <nl> ^ Markdown_lite . md_codify class_self ) ; <nl> let bad_lateinit_override <nl> in <nl> on_error <nl> ~ code : ( Typing . err_code Typing . BadLateInitOverride ) <nl> - [ <nl> - ( child_pos , <nl> - " Redeclared properties must be consistently declared ` __LateInit ` " ) ; <nl> - ( parent_pos , " The property " ^ verb ^ " declared ` __LateInit ` here " ) ; <nl> - ] <nl> + ( child_pos , <nl> + " Redeclared properties must be consistently declared ` __LateInit ` " ) <nl> + [ ( parent_pos , " The property " ^ verb ^ " declared ` __LateInit ` here " ) ] <nl> <nl> let bad_xhp_attr_required_override <nl> parent_tag child_tag parent_pos child_pos ( on_error : typing_error_callback ) <nl> = <nl> on_error <nl> ~ code : ( Typing . err_code Typing . BadXhpAttrRequiredOverride ) <nl> + ( child_pos , " Redeclared attribute must not be less strict " ) <nl> [ <nl> - ( child_pos , " Redeclared attribute must not be less strict " ) ; <nl> ( parent_pos , <nl> " The attribute is " <nl> ^ parent_tag <nl> let redundant_rx_condition pos = <nl> let invalid_arraykey code pos ( cpos , ctype ) ( kpos , ktype ) = <nl> add_list <nl> ( Typing . err_code code ) <nl> + ( pos , " This value is not a valid key type for this container " ) <nl> [ <nl> - ( pos , " This value is not a valid key type for this container " ) ; <nl> ( cpos , " This container is " ^ ctype ) ; <nl> ( kpos , String . capitalize ktype ^ " cannot be used as a key for " ^ ctype ) ; <nl> ] <nl> let meth_caller_trait pos trait_name = <nl> let duplicate_interface pos name others = <nl> add_list <nl> ( Typing . err_code Typing . DuplicateInterface ) <nl> - ( ( pos , <nl> - Printf . sprintf <nl> - " Interface % s is used more than once in this declaration . " <nl> - ( strip_ns name | > Markdown_lite . md_codify ) ) <nl> - : : List . map others ( fun pos - > ( pos , " Here is another occurrence " ) ) ) <nl> + ( pos , <nl> + Printf . sprintf <nl> + " Interface % s is used more than once in this declaration . " <nl> + ( strip_ns name | > Markdown_lite . md_codify ) ) <nl> + ( List . map others ( fun pos - > ( pos , " Here is another occurrence " ) ) ) <nl> <nl> let hk_var_description because_nested var_name = <nl> if because_nested then <nl> let illegal_information_flow <nl> in <nl> let source = Markdown_lite . md_codify source in <nl> let sink = Markdown_lite . md_codify sink in <nl> + let sprintf_main = sprintf " Data with policy % s appears in context % s . " in <nl> + let claim = ( primary , sprintf_main source sink ) in <nl> let reasons = <nl> let sprintf = Printf . sprintf in <nl> - let sprintf_main = sprintf " Data with policy % s appears in context % s . " in <nl> let sprintf_source = sprintf " This may be the data source with policy % s " in <nl> let sprintf_sink = sprintf " This may be the data sink with policy % s " in <nl> let other_occurrences = <nl> let f p = ( p , " Another program point contributing to the illegal flow " ) in <nl> List . map ~ f secondaries <nl> in <nl> - [ ( primary , sprintf_main source sink ) ] <nl> + [ ] <nl> | > explain source_poss source sprintf_source <nl> | > explain sink_poss sink sprintf_sink <nl> | > List . append other_occurrences <nl> | > List . rev <nl> in <nl> - add_list ( Typing . err_code Typing . IllegalInformationFlow ) reasons <nl> + add_list ( Typing . err_code Typing . IllegalInformationFlow ) claim reasons <nl> <nl> let context_implicit_policy_leakage <nl> primary secondaries ( source_poss , source ) ( sink_poss , sink ) = <nl> let context_implicit_policy_leakage <nl> in <nl> let explain_source p = ( p , " Leakage source " ) in <nl> let explain_sink p = ( p , " Leakage sink " ) in <nl> - let reasons = <nl> + let claim = <nl> ( primary , <nl> Printf . sprintf <nl> " Context - implicit policy leaks into % s via % s . " <nl> ( Markdown_lite . md_codify sink ) <nl> ( Markdown_lite . md_codify source ) ) <nl> - : : List . map ~ f : program_point secondaries <nl> + in <nl> + let reasons = <nl> + List . map ~ f : program_point secondaries <nl> @ List . map ~ f : explain_source source_poss <nl> @ List . map ~ f : explain_sink sink_poss <nl> in <nl> - add_list ( Typing . err_code Typing . ContextImplicitPolicyLeakage ) reasons <nl> + add_list ( Typing . err_code Typing . ContextImplicitPolicyLeakage ) claim reasons <nl> <nl> let unknown_information_flow pos str = <nl> add <nl> let class_meth_abstract_call cname meth_name call_pos decl_pos = <nl> let cname = strip_ns cname in <nl> add_list <nl> ( Typing . err_code Typing . ClassMethAbstractCall ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot create a class_meth of " <nl> - ^ cname <nl> - ^ " : : " <nl> - ^ meth_name <nl> - ^ " ; it is abstract . " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot create a class_meth of " <nl> + ^ cname <nl> + ^ " : : " <nl> + ^ meth_name <nl> + ^ " ; it is abstract . " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let higher_kinded_partial_application pos count = <nl> add <nl> let implicit_type_argument_for_higher_kinded_type ~ use_pos ~ def_pos param_name = <nl> in <nl> add_list <nl> ( Naming . err_code Naming . HigherKindedTypesUnsupportedFeature ) <nl> - [ <nl> - ( use_pos , <nl> - " You left out the type arguments here such that they may be inferred . " <nl> - ^ " However , a higher - kinded type is expected in place of " <nl> - ^ param_desc <nl> - ^ " , meaning that the type arguments cannot be inferred . " <nl> - ^ " Please provide the type arguments explicitly . " ) ; <nl> - ( def_pos , param_desc ^ " was declared to be higher - kinded here . " ) ; <nl> - ] <nl> + ( use_pos , <nl> + " You left out the type arguments here such that they may be inferred . " <nl> + ^ " However , a higher - kinded type is expected in place of " <nl> + ^ param_desc <nl> + ^ " , meaning that the type arguments cannot be inferred . " <nl> + ^ " Please provide the type arguments explicitly . " ) <nl> + [ ( def_pos , param_desc ^ " was declared to be higher - kinded here . " ) ] <nl> <nl> ( * This is only to be used in a context where we expect something higher - kinded , <nl> meaning that expected_kind_repr should never just be * * ) <nl> let kind_mismatch <nl> ~ use_pos ~ def_pos ~ tparam_name ~ expected_kind_repr ~ actual_kind_repr = <nl> add_list <nl> ( Typing . err_code Typing . KindMismatch ) <nl> + ( use_pos , <nl> + " This is " <nl> + ^ actual_kind_repr <nl> + ^ " , but " <nl> + ^ expected_kind_repr <nl> + ^ " was expected here . " ) <nl> [ <nl> - ( use_pos , <nl> - " This is " <nl> - ^ actual_kind_repr <nl> - ^ " , but " <nl> - ^ expected_kind_repr <nl> - ^ " was expected here . " ) ; <nl> ( def_pos , <nl> " We are expecting " <nl> ^ expected_kind_repr <nl> let alias_with_implicit_constraints_as_hk_type <nl> ~ used_class_tparam_name = <nl> add_list <nl> ( Naming . err_code Naming . HigherKindedTypesUnsupportedFeature ) <nl> + ( use_pos , <nl> + " The type " <nl> + ^ strip_ns typedef_name <nl> + ^ " implicitly imposes constraints on its type parameters . Therefore , it cannot be used as a higher - kinded type at this time . " <nl> + ) <nl> [ <nl> - ( use_pos , <nl> - " The type " <nl> - ^ strip_ns typedef_name <nl> - ^ " implicitly imposes constraints on its type parameters . Therefore , it cannot be used as a higher - kinded type at this time . " <nl> - ) ; <nl> ( typedef_pos , " The definition of " ^ strip_ns typedef_name ^ " is here . " ) ; <nl> ( used_class_in_def_pos , <nl> " The definition of " <nl> let reinheriting_classish_const <nl> const_name = <nl> add_list <nl> ( Typing . err_code Typing . RedeclaringClassishConstant ) <nl> + ( src_classish_pos , <nl> + strip_ns dest_classish_name <nl> + ^ " cannot re - inherit constant " <nl> + ^ const_name <nl> + ^ " from " <nl> + ^ src_classish_name ) <nl> [ <nl> - ( src_classish_pos , <nl> - strip_ns dest_classish_name <nl> - ^ " cannot re - inherit constant " <nl> - ^ const_name <nl> - ^ " from " <nl> - ^ src_classish_name ) ; <nl> ( dest_classish_pos , <nl> " because it already inherited it via " ^ strip_ns existing_const_origin <nl> ) ; <nl> let redeclaring_classish_const <nl> const_name = <nl> add_list <nl> ( Typing . err_code Typing . RedeclaringClassishConstant ) <nl> + ( redeclaration_pos , <nl> + strip_ns classish_name ^ " cannot re - declare constant " ^ const_name ) <nl> [ <nl> - ( redeclaration_pos , <nl> - strip_ns classish_name ^ " cannot re - declare constant " ^ const_name ) ; <nl> ( classish_pos , <nl> " because it already inherited it via " ^ strip_ns existing_const_origin <nl> ) ; <nl> let incompatible_enum_inclusion_base <nl> dest_classish_pos dest_classish_name src_classish_name = <nl> add_list <nl> ( Typing . err_code Typing . IncompatibleEnumInclusion ) <nl> - [ <nl> - ( dest_classish_pos , <nl> - " Enum " <nl> - ^ strip_ns dest_classish_name <nl> - ^ " includes enum " <nl> - ^ strip_ns src_classish_name <nl> - ^ " but their base types are incompatible " ) ; <nl> - ] <nl> + ( dest_classish_pos , <nl> + " Enum " <nl> + ^ strip_ns dest_classish_name <nl> + ^ " includes enum " <nl> + ^ strip_ns src_classish_name <nl> + ^ " but their base types are incompatible " ) <nl> + [ ] <nl> <nl> let incompatible_enum_inclusion_constraint <nl> dest_classish_pos dest_classish_name src_classish_name = <nl> add_list <nl> ( Typing . err_code Typing . IncompatibleEnumInclusion ) <nl> - [ <nl> - ( dest_classish_pos , <nl> - " Enum " <nl> - ^ strip_ns dest_classish_name <nl> - ^ " includes enum " <nl> - ^ strip_ns src_classish_name <nl> - ^ " but their constraints are incompatible " ) ; <nl> - ] <nl> + ( dest_classish_pos , <nl> + " Enum " <nl> + ^ strip_ns dest_classish_name <nl> + ^ " includes enum " <nl> + ^ strip_ns src_classish_name <nl> + ^ " but their constraints are incompatible " ) <nl> + [ ] <nl> <nl> let enum_inclusion_not_enum <nl> dest_classish_pos dest_classish_name src_classish_name = <nl> add_list <nl> ( Typing . err_code Typing . IncompatibleEnumInclusion ) <nl> - [ <nl> - ( dest_classish_pos , <nl> - " Enum " <nl> - ^ strip_ns dest_classish_name <nl> - ^ " includes " <nl> - ^ strip_ns src_classish_name <nl> - ^ " which is not an enum " ) ; <nl> - ] <nl> + ( dest_classish_pos , <nl> + " Enum " <nl> + ^ strip_ns dest_classish_name <nl> + ^ " includes " <nl> + ^ strip_ns src_classish_name <nl> + ^ " which is not an enum " ) <nl> + [ ] <nl> <nl> let call_coeffect_error <nl> ~ available_incl_unsafe ~ available_pos ~ required ~ required_pos call_pos = <nl> add_list <nl> ( Typing . err_code Typing . CallCoeffects ) <nl> + ( call_pos , <nl> + " This call is not allowed because its coeffects are incompatible with the context " <nl> + ) <nl> [ <nl> - ( call_pos , <nl> - " This call is not allowed because its coeffects are incompatible with the context " <nl> - ) ; <nl> ( available_pos , <nl> " From this declaration , the context of this function body provides " <nl> ^ available_incl_unsafe ) ; <nl> let op_coeffect_error <nl> ~ locally_available ~ available_pos ~ err_code ~ required op op_pos = <nl> add_list <nl> err_code <nl> + ( op_pos , <nl> + op ^ " requires " ^ required ^ " , which is not provided by the context . " <nl> + ) <nl> [ <nl> - ( op_pos , <nl> - op ^ " requires " ^ required ^ " , which is not provided by the context . " <nl> - ) ; <nl> ( available_pos , <nl> " The local ( enclosing ) context provides " ^ locally_available ) ; <nl> ] <nl> let abstract_function_pointer cname meth_name call_pos decl_pos = <nl> let cname = strip_ns cname in <nl> add_list <nl> ( Typing . err_code Typing . AbstractFunctionPointer ) <nl> - [ <nl> - ( call_pos , <nl> - " Cannot create a function pointer to " <nl> - ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ) <nl> - ^ " ; it is abstract " ) ; <nl> - ( decl_pos , " Declaration is here " ) ; <nl> - ] <nl> + ( call_pos , <nl> + " Cannot create a function pointer to " <nl> + ^ Markdown_lite . md_codify ( cname ^ " : : " ^ meth_name ) <nl> + ^ " ; it is abstract " ) <nl> + [ ( decl_pos , " Declaration is here " ) ] <nl> <nl> let unnecessary_attribute pos ~ attr ~ reason ~ suggestion = <nl> let attr = strip_ns attr in <nl> let unnecessary_attribute pos ~ attr ~ reason ~ suggestion = <nl> in <nl> add_list <nl> ( Typing . err_code Typing . UnnecessaryAttribute ) <nl> - [ <nl> - ( pos , sprintf " The attribute ` % s ` is unnecessary " attr ) ; <nl> - ( reason_pos , " It is unnecessary because " ^ reason_msg ) ; <nl> - ( pos , suggestion ) ; <nl> - ] <nl> + ( pos , sprintf " The attribute ` % s ` is unnecessary " attr ) <nl> + [ ( reason_pos , " It is unnecessary because " ^ reason_msg ) ; ( pos , suggestion ) ] <nl> <nl> let inherited_class_member_with_different_case <nl> member_type name name_prev p child_class prev_class prev_class_pos = <nl> let inherited_class_member_with_different_case <nl> let name_prev = strip_ns name_prev in <nl> let child_class = strip_ns child_class in <nl> let prev_class = strip_ns prev_class in <nl> - let errs = <nl> + let claim = <nl> + ( p , <nl> + child_class <nl> + ^ " inherits a " <nl> + ^ member_type <nl> + ^ " named " <nl> + ^ Markdown_lite . md_codify name_prev <nl> + ^ " which differs from this one ( " <nl> + ^ name <nl> + ^ " ) only by case . " ) <nl> + in <nl> + let reasons = <nl> [ <nl> - ( p , <nl> - child_class <nl> - ^ " inherits a " <nl> - ^ member_type <nl> - ^ " named " <nl> - ^ Markdown_lite . md_codify name_prev <nl> - ^ " which differs from this one ( " <nl> - ^ name <nl> - ^ " ) only by case . " ) ; <nl> ( prev_class_pos , <nl> " It was inherited from " <nl> ^ prev_class <nl> let inherited_class_member_with_different_case <nl> ^ " Otherwise , please choose a different name for the new method . " ) ; <nl> ] <nl> in <nl> - add_list ( Typing . err_code Typing . InheritedMethodCaseDiffers ) errs <nl> + add_list ( Typing . err_code Typing . InheritedMethodCaseDiffers ) claim reasons <nl> <nl> let multiple_inherited_class_member_with_different_case <nl> ~ member_type ~ name1 ~ name2 ~ class1 ~ class2 ~ child_class ~ child_p ~ p1 ~ p2 = <nl> let multiple_inherited_class_member_with_different_case <nl> let class1 = strip_ns class1 in <nl> let class2 = strip_ns class2 in <nl> let child_class = strip_ns child_class in <nl> - let errs = <nl> + let claim = <nl> + ( child_p , <nl> + Markdown_lite . md_codify child_class <nl> + ^ " inherited two versions of the " <nl> + ^ member_type <nl> + ^ " " <nl> + ^ Markdown_lite . md_codify name1 <nl> + ^ " that differ only by case . " ) <nl> + in <nl> + let reasons = <nl> [ <nl> - ( child_p , <nl> - Markdown_lite . md_codify child_class <nl> - ^ " inherited two versions of the " <nl> - ^ member_type <nl> - ^ " " <nl> - ^ Markdown_lite . md_codify name1 <nl> - ^ " that differ only by case . " ) ; <nl> ( p1 , <nl> " It inherited " <nl> ^ Markdown_lite . md_codify name1 <nl> let multiple_inherited_class_member_with_different_case <nl> ^ " here . Please rename these methods to the same casing . " ) ; <nl> ] <nl> in <nl> - add_list ( Typing . err_code Typing . InheritedMethodCaseDiffers ) errs <nl> + add_list ( Typing . err_code Typing . InheritedMethodCaseDiffers ) claim reasons <nl> <nl> let atom_invalid_parameter pos = <nl> add_list <nl> ( Typing . err_code Typing . AtomInvalidParameter ) <nl> - [ <nl> - ( pos , <nl> - " Attribute " <nl> - ^ Naming_special_names . UserAttributes . uaAtom <nl> - ^ " is only allowed on " <nl> - ^ Naming_special_names . Classes . cElt ) ; <nl> - ] <nl> + ( pos , <nl> + " Attribute " <nl> + ^ Naming_special_names . UserAttributes . uaAtom <nl> + ^ " is only allowed on " <nl> + ^ Naming_special_names . Classes . cElt ) <nl> + [ ] <nl> <nl> let atom_invalid_parameter_in_enum_class pos = <nl> add_list <nl> ( Typing . err_code Typing . AtomInvalidParameter ) <nl> - [ <nl> - ( pos , <nl> - " When using " <nl> - ^ Naming_special_names . UserAttributes . uaAtom <nl> - ^ " , only type parameters bounded by enum classes and " <nl> - ^ " enum classes are allowed as the first parameters of " <nl> - ^ Naming_special_names . Classes . cElt ) ; <nl> - ] <nl> + ( pos , <nl> + " When using " <nl> + ^ Naming_special_names . UserAttributes . uaAtom <nl> + ^ " , only type parameters bounded by enum classes and " <nl> + ^ " enum classes are allowed as the first parameters of " <nl> + ^ Naming_special_names . Classes . cElt ) <nl> + [ ] <nl> <nl> let atom_invalid_generic pos name = <nl> add_list <nl> ( Typing . err_code Typing . AtomInvalidParameter ) <nl> - [ <nl> - ( pos , <nl> - " The type " <nl> - ^ name <nl> - ^ " must be a type constant or a reified generic " <nl> - ^ " in order to be used with " <nl> - ^ Naming_special_names . UserAttributes . uaAtom ) ; <nl> - ] <nl> + ( pos , <nl> + " The type " <nl> + ^ name <nl> + ^ " must be a type constant or a reified generic " <nl> + ^ " in order to be used with " <nl> + ^ Naming_special_names . UserAttributes . uaAtom ) <nl> + [ ] <nl> <nl> let atom_unknown pos atom_name class_name = <nl> let class_name = strip_ns class_name in <nl> add_list <nl> ( Typing . err_code Typing . AtomUnknown ) <nl> - [ ( pos , " Unknown constant " ^ atom_name ^ " in " ^ class_name ) ] <nl> + ( pos , " Unknown constant " ^ atom_name ^ " in " ^ class_name ) <nl> + [ ] <nl> <nl> let atom_as_expr pos = <nl> add_list <nl> ( Typing . err_code Typing . AtomAsExpression ) <nl> - [ <nl> - ( pos , <nl> - " Atoms are not allowed in this position . They are only allowed " <nl> - ^ " in function call , if the function parameter is annotated with " <nl> - ^ Naming_special_names . UserAttributes . uaAtom ) ; <nl> - ] <nl> + ( pos , <nl> + " Atoms are not allowed in this position . They are only allowed " <nl> + ^ " in function call , if the function parameter is annotated with " <nl> + ^ Naming_special_names . UserAttributes . uaAtom ) <nl> + [ ] <nl> <nl> let atom_invalid_argument pos = <nl> add_list <nl> ( Typing . err_code Typing . AtomInvalidArgument ) <nl> - [ ( pos , " An atom is required here , not a class constant projection " ) ] <nl> + ( pos , " An atom is required here , not a class constant projection " ) <nl> + [ ] <nl> <nl> let ifc_internal_error pos reason = <nl> add <nl> mmm a / hphp / hack / src / errors / errors . mli <nl> ppp b / hphp / hack / src / errors / errors . mli <nl> type format = <nl> | Raw <nl> | Highlighted <nl> <nl> - type typing_error_callback = ? code : int - > ( Pos . t * string ) list - > unit <nl> + type typing_error_callback = <nl> + ? code : int - > Pos . t * string - > ( Pos . t * string ) list - > unit <nl> <nl> type name_context = <nl> | FunctionNamespace <nl> val get_severity : ' a error_ - > severity <nl> <nl> val get_messages : ' a error_ - > ' a message list <nl> <nl> - val make_error : int - > ( Pos . t * string ) list - > error <nl> + val make_error : int - > Pos . t * string - > ( Pos . t * string ) list - > error <nl> <nl> val make_absolute_error : <nl> int - > ( Pos . absolute * string ) list - > Pos . absolute error_ <nl> val explain_constraint : <nl> use_pos : Pos . t - > <nl> definition_pos : Pos . t - > <nl> param_name : string - > <nl> + Pos . t * string - > <nl> ( Pos . t * string ) list - > <nl> unit <nl> <nl> val explain_where_constraint : <nl> in_class : bool - > <nl> use_pos : Pos . t - > <nl> definition_pos : Pos . t - > <nl> + Pos . t * string - > <nl> ( Pos . t * string ) list - > <nl> unit <nl> <nl> mmm a / hphp / hack / src / typing / tast_check / invalid_index_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / invalid_index_check . ml <nl> let rec array_get ~ array_pos ~ expr_pos ~ index_pos env array_ty index_ty = <nl> let ty_expect_str = Env . print_error_ty env ty_expect in <nl> let ty_have_str = Env . print_error_ty env ty_have in <nl> Errors . index_type_mismatch <nl> - ( ( expr_pos , Reason . string_of_ureason reason ) <nl> - : : Typing_reason . to_string <nl> - ( " This is " ^ ty_expect_str ) <nl> - ( get_reason ty_expect ) <nl> + ( expr_pos , Reason . string_of_ureason reason ) <nl> + ( Typing_reason . to_string <nl> + ( " This is " ^ ty_expect_str ) <nl> + ( get_reason ty_expect ) <nl> @ Typing_reason . to_string <nl> ( " It is incompatible with " ^ ty_have_str ) <nl> ( get_reason ty_have ) ) <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and check_shape_keys_validity env pos keys = <nl> env <nl> ty <nl> ( MakeType . arraykey r ) <nl> - ( fun ? code : _ _ - > <nl> + ( fun ? code : _ _ _ - > <nl> Errors . invalid_shape_field_type <nl> key_pos <nl> ( get_pos ty ) <nl> and call <nl> env <nl> env_capability <nl> capability <nl> - ( fun ? code : _c _subtype_error_list - > <nl> + ( fun ? code : _c _ _ - > <nl> Errors . call_coeffect_error <nl> pos <nl> ~ available_incl_unsafe : <nl> mmm a / hphp / hack / src / typing / typing_array_access . ml <nl> ppp b / hphp / hack / src / typing / typing_array_access . ml <nl> let check_arraykey_index error env pos container_ty index_ty = <nl> env <nl> index_ty <nl> { et_type = ty_arraykey ; et_enforced = true } <nl> - ( fun ? code : _ _ - > <nl> + ( fun ? code : _ _ _ - > <nl> error pos ( info_of_type container_ty ) ( info_of_type index_ty ) ) <nl> else <nl> env <nl> mmm a / hphp / hack / src / typing / typing_coercion . ml <nl> ppp b / hphp / hack / src / typing / typing_coercion . ml <nl> module MakeType = Typing_make_type <nl> * ) <nl> <nl> ( * does coercion , including subtyping * ) <nl> - let coerce_type_impl env ty_have ty_expect on_error = <nl> + let coerce_type_impl <nl> + env ty_have ty_expect ( on_error : Errors . typing_error_callback ) = <nl> let complex_coercion = <nl> TypecheckerOptions . complex_coercion ( Typing_env . get_tcopt env ) <nl> in <nl> let coerce_type_impl env ty_have ty_expect on_error = <nl> on_error <nl> | _ - > Typing_utils . sub_type env ty_have ty_expect . et_type on_error <nl> <nl> - let coerce_type p ur env ty_have ty_expect on_error = <nl> - coerce_type_impl env ty_have ty_expect ( fun ? code errl - > <nl> - let errl = ( p , Reason . string_of_ureason ur ) : : errl in <nl> - on_error ? code errl ) <nl> + let coerce_type <nl> + p ur env ty_have ty_expect ( on_error : Errors . typing_error_callback ) = <nl> + coerce_type_impl env ty_have ty_expect ( fun ? code claim reasons - > <nl> + on_error ? code ( p , Reason . string_of_ureason ur ) ( claim : : reasons ) ) <nl> <nl> ( * does coercion if possible , returning Some env with resultant coercion constraints <nl> * otherwise suppresses errors from attempted coercion and returns None * ) <nl> mmm a / hphp / hack / src / typing / typing_enum . ml <nl> ppp b / hphp / hack / src / typing / typing_enum . ml <nl> let enum_check_type env pos ur ty_interface ty _on_error = <nl> [ ] ; <nl> env <nl> | None - > <nl> - Typing_ops . sub_type pos ur env ty ty_arraykey ( fun ? code : _ _ - > <nl> + Typing_ops . sub_type pos ur env ty ty_arraykey ( fun ? code : _ _ _ - > <nl> Errors . enum_type_bad pos false ( Typing_print . full_strip_ns env ty ) [ ] ) <nl> <nl> ( * Check an enum declaration of the form <nl> mmm a / hphp / hack / src / typing / typing_extends . ml <nl> ppp b / hphp / hack / src / typing / typing_extends . ml <nl> let check_override <nl> else <nl> ` property ) ; <nl> if check_params then ( <nl> - let on_error ? code : _ errorl = <nl> + let on_error ? code : _ claim reasons = <nl> ( if is_method then <nl> Errors . bad_method_override <nl> else <nl> Errors . bad_prop_override ) <nl> pos <nl> member_name <nl> - errorl <nl> + ( claim : : reasons ) <nl> on_error <nl> in <nl> let ( lazy fty_child ) = class_elt . ce_type in <nl> let check_implements env parent_type type_to_be_checked = <nl> env <nl> ( parent_class , parent_type ) <nl> ( class_ , type_to_be_checked ) <nl> - ( fun ? code : _ errorl - > <nl> + ( fun ? code : _ claim reasons - > <nl> ( * sadly , enum error reporting requires this to keep the error in the file <nl> with the enum * ) <nl> if String . equal parent_name_str SN . Classes . cHH_BuiltinEnum then <nl> - Errors . bad_enum_decl name_pos errorl <nl> + Errors . bad_enum_decl name_pos ( claim : : reasons ) <nl> else <nl> Errors . bad_decl_override <nl> parent_name_pos <nl> parent_name_str <nl> name_pos <nl> name_str <nl> - errorl ) <nl> + ( claim : : reasons ) ) <nl> mmm a / hphp / hack / src / typing / typing_generic_constraint . ml <nl> ppp b / hphp / hack / src / typing / typing_generic_constraint . ml <nl> module Env = Typing_env <nl> open Typing_defs <nl> open Typing_env_types <nl> <nl> - let check_constraint env ck ty ~ cstr_ty on_error = <nl> + let check_constraint <nl> + env ck ty ~ cstr_ty ( on_error : Errors . typing_error_callback ) = <nl> Typing_log . ( <nl> log_with_level env " sub " 1 ( fun ( ) - > <nl> log_types <nl> let check_constraint env ck ty ~ cstr_ty on_error = <nl> TUtils . sub_type env ecstr_ty ty on_error <nl> <nl> let check_tparams_constraint ( env : env ) ~ use_pos ( pos , name ) ck cstr_ty ty = <nl> - check_constraint env ck ty ~ cstr_ty ( fun ? code : _ err - > <nl> + check_constraint env ck ty ~ cstr_ty ( fun ? code : _ claim reasons - > <nl> Errors . explain_constraint <nl> ~ use_pos <nl> ~ definition_pos : pos <nl> ~ param_name : name <nl> - err ) <nl> + claim <nl> + reasons ) <nl> <nl> let check_where_constraint <nl> ~ in_class ( env : env ) ~ use_pos ~ definition_pos ck cstr_ty ty = <nl> - check_constraint env ck ty ~ cstr_ty ( fun ? code : _ err - > <nl> - Errors . explain_where_constraint ~ in_class ~ use_pos ~ definition_pos err ) <nl> + check_constraint env ck ty ~ cstr_ty ( fun ? code : _ claim reasons - > <nl> + Errors . explain_where_constraint <nl> + ~ in_class <nl> + ~ use_pos <nl> + ~ definition_pos <nl> + claim <nl> + reasons ) <nl> mmm a / hphp / hack / src / typing / typing_global_inference . ml <nl> ppp b / hphp / hack / src / typing / typing_global_inference . ml <nl> module StateErrors = struct <nl> let cardinal t = IdentMap . fold ( fun _ l acc - > acc + List . length l ) ! t 0 <nl> end <nl> <nl> - let make_error_callback errors var ? code msgl = <nl> + let convert_on_error : ( Errors . error - > unit ) - > Errors . typing_error_callback = <nl> + fun on_error ? code claim reasons - > <nl> let code = <nl> Option . value code ~ default : Error_codes . Typing . ( err_code UnifyError ) <nl> in <nl> - StateErrors . add errors var ( Errors . make_error code msgl ) <nl> + on_error ( Errors . make_error code claim reasons ) <nl> <nl> let catch_exc <nl> pos <nl> - ( on_error : Errors . typing_error_callback ) <nl> + ( on_error : Errors . error - > unit ) <nl> ( r : ' a ) <nl> ? ( verbose = false ) <nl> ( f : Errors . typing_error_callback - > ' a ) : ' a = <nl> try <nl> let ( other_errors , v ) = <nl> Errors . do_with_context ( Pos . filename pos ) Errors . Typing ( fun ( ) - > <nl> - f on_error ) <nl> + f @ @ convert_on_error on_error ) <nl> in <nl> - List . iter ( Errors . get_error_list other_errors ) ~ f : ( fun error - > <nl> - on_error ( Errors . to_list error ) ) ; <nl> + List . iter ( Errors . get_error_list other_errors ) ~ f : on_error ; <nl> v <nl> with Inf . InconsistentTypeVarState _ as e - > <nl> if verbose then ( <nl> let catch_exc <nl> Caml . Printexc . print_raw_backtrace stderr stack <nl> ) ; <nl> let e = Printf . sprintf " Exception : % s " ( Exn . to_string e ) in <nl> - on_error [ ( pos , e ) ] ; <nl> + on_error <nl> + ( Errors . make_error Error_codes . Typing . ( err_code UnifyError ) ( pos , e ) [ ] ) ; <nl> r <nl> <nl> let is_ordered_solving env = GlobalOptions . tco_ordered_solving env . genv . tcopt <nl> module StateConstraintGraph = struct <nl> in <nl> let ty = MakeType . tyvar Reason . Rnone var <nl> and ty ' = MakeType . tyvar Reason . Rnone var ' in <nl> - let on_err = make_error_callback errors var in <nl> + let on_err = StateErrors . add errors var in <nl> let env = catch_exc on_err env ( Sub . sub_type env ty ty ' ) in <nl> let env = catch_exc on_err env ( Sub . sub_type env ty ' ty ) in <nl> let ( env , vars_in_lower_bounds , vars_in_upper_bounds ) = <nl> module StateSolvedGraph = struct <nl> else <nl> env ) <nl> in <nl> - let make_on_error = make_error_callback errors in <nl> + let make_on_error = StateErrors . add errors in <nl> let env = <nl> catch_exc Pos . none ( make_on_error 0 ) env @ @ fun _ - > <nl> + let make_on_error v = convert_on_error @ @ make_on_error v in <nl> if is_ordered_solving env then <nl> Typing_ordered_solver . solve_env env make_on_error <nl> else <nl> mmm a / hphp / hack / src / typing / typing_kinding . ml <nl> ppp b / hphp / hack / src / typing / typing_kinding . ml <nl> let check_typedef_usable_as_hk_type env use_pos typedef_name typedef_info = <nl> ck <nl> ty <nl> ~ cstr_ty <nl> - ( fun ? code : _ _l - > report_constraint ty cls_name x ) <nl> + ( fun ? code : _ _ _ - > report_constraint ty cls_name x ) <nl> in <nl> ( ) ) <nl> end <nl> mmm a / hphp / hack / src / typing / typing_ops . ml <nl> ppp b / hphp / hack / src / typing / typing_ops . ml <nl> let log_sub_type env p ty_sub ty_super = <nl> ] ) ) <nl> <nl> ( * Tries to add constraint that ty_sub is subtype of ty_super in envs * ) <nl> - let sub_type_i p ur env ty_sub ty_super on_error = <nl> + let sub_type_i <nl> + p ur env ty_sub ty_super ( on_error : Errors . typing_error_callback ) = <nl> log_sub_type env p ty_sub ty_super ; <nl> - Typing_utils . sub_type_i env ty_sub ty_super ( fun ? code errl - > <nl> - let errl = ( p , Reason . string_of_ureason ur ) : : errl in <nl> - on_error ? code errl ) <nl> + Typing_utils . sub_type_i env ty_sub ty_super ( fun ? code claim reasons - > <nl> + on_error ? code ( p , Reason . string_of_ureason ur ) ( claim : : reasons ) ) <nl> <nl> let sub_type p ur env ty_sub ty_super on_error = <nl> sub_type_i p ur env ( LoclType ty_sub ) ( LoclType ty_super ) on_error <nl> mmm a / hphp / hack / src / typing / typing_reactivity . ml <nl> ppp b / hphp / hack / src / typing / typing_reactivity . ml <nl> let check_reactivity_matches <nl> callee_reactivity <nl> pos <nl> caller_reactivity <nl> - ( fun ? code : _ _ - > <nl> + ( fun ? code : _ _ _ - > <nl> ( * for better error reporting remove rxvar from caller reactivity * ) <nl> let caller_reactivity = <nl> match caller_reactivity with <nl> mmm a / hphp / hack / src / typing / typing_reason . mli <nl> ppp b / hphp / hack / src / typing / typing_reason . mli <nl> val none : t <nl> val compare : t - > t - > int <nl> <nl> val explain_generic_constraint : <nl> - Pos . t - > t - > string - > ( Pos . t * string ) list - > unit <nl> + Pos . t - > t - > string - > Pos . t * string - > ( Pos . t * string ) list - > unit <nl> mmm a / hphp / hack / src / typing / typing_subtype . ml <nl> ppp b / hphp / hack / src / typing / typing_subtype . ml <nl> and simplify_subtype_i <nl> | ( Reason . Rcstr_on_generics ( p , tparam ) , _ ) <nl> | ( _ , Reason . Rcstr_on_generics ( p , tparam ) ) - > <nl> Errors . violated_constraint p tparam left right subtype_env . on_error <nl> - | _ - > subtype_env . on_error ( left @ right ) <nl> + | _ - > <nl> + let claim = List . hd_exn left in <nl> + let reasons = List . tl_exn left @ right in <nl> + subtype_env . on_error claim reasons <nl> in <nl> let fail ( ) = fail_with_suffix [ ] in <nl> let ( | | | ) = ( | | | ) ~ fail in <nl> and simplify_subtype_reactivity <nl> let msg_sub = <nl> " This function is " ^ TUtils . reactivity_to_string env r_sub ^ " . " <nl> in <nl> - subtype_env . on_error [ ( p_super , msg_super ) ; ( p_sub , msg_sub ) ] <nl> + subtype_env . on_error ( p_super , msg_super ) [ ( p_sub , msg_sub ) ] <nl> in <nl> let ( | | | ) = ( | | | ) ~ fail in <nl> let invalid_env env = invalid ~ fail env in <nl> and simplify_subtype_fun_params_reactivity <nl> { <nl> subtype_env with <nl> on_error = <nl> - ( fun ? code : _ _ - > <nl> + ( fun ? code : _ _ _ - > <nl> Errors . rx_parameter_condition_mismatch <nl> SN . UserAttributes . uaOnlyRxIfImpl <nl> p_sub . fp_pos <nl> and simplify_subtype_funs_attributes <nl> env = <nl> let p_sub = Reason . to_pos r_sub in <nl> let p_super = Reason . to_pos r_super in <nl> - let on_error_reactivity ? code : _ _ = <nl> + let on_error_reactivity ? code : _ _ _ = <nl> Errors . fun_reactivity_mismatch <nl> p_super <nl> ( TUtils . reactivity_to_string env ft_super . ft_reactive ) <nl> let subtype_funs <nl> old_env <nl> <nl> let sub_type_or_fail env ty1 ty2 fail = <nl> - sub_type env ty1 ty2 ( fun ? code : _ _ - > fail ( ) ) <nl> + sub_type env ty1 ty2 ( fun ? code : _ _ _ - > fail ( ) ) <nl> <nl> let set_fun_refs ( ) = <nl> Typing_utils . sub_type_ref : = sub_type ; <nl> | Change signature of Errors . add_list | facebook/hhvm | 19f1265d88702da3d63ea44249970e6a67b2df71 | 2020-12-07T16:47:37Z |
mmm a / aten / src / ATen / core / interned_strings . h <nl> ppp b / aten / src / ATen / core / interned_strings . h <nl> namespace c10 { <nl> _ ( onnx , Mod ) \ <nl> _ ( onnx , Sqrt ) \ <nl> _ ( onnx , SplitToSequence ) \ <nl> + _ ( onnx , SequenceAt ) \ <nl> _ ( onnx , SequenceConstruct ) \ <nl> _ ( onnx , SequenceEmpty ) \ <nl> _ ( onnx , SequenceInsert ) \ <nl> mmm a / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> ppp b / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> def forward ( self , input ) : <nl> x = torch . randn ( 5 , 4 , 3 ) <nl> self . run_test ( SplitModel2 ( ) , x ) <nl> <nl> + @ skipIfUnsupportedMinOpsetVersion ( 11 ) <nl> + def test_split_size_as_list ( self ) : <nl> + class SplitModel ( torch . nn . Module ) : <nl> + def forward ( self , input ) : <nl> + out = [ ] <nl> + split_sizes = [ input . shape [ 0 ] - 1 , 1 ] <nl> + for ob in input . split ( split_sizes ) : <nl> + out . append ( ob ) <nl> + return torch . cat ( out , dim = 0 ) <nl> + <nl> + x = torch . randn ( 5 , 4 , 3 ) <nl> + self . run_test ( SplitModel ( ) , x ) <nl> + <nl> @ skipIfUnsupportedMinOpsetVersion ( 11 ) <nl> def test_split_dynamic ( self ) : <nl> class SplitModel ( torch . jit . ScriptModule ) : <nl> mmm a / torch / csrc / jit / passes / onnx / peephole . cpp <nl> ppp b / torch / csrc / jit / passes / onnx / peephole . cpp <nl> static void fuseUnbindListUnpack ( Block * b ) { <nl> } <nl> } <nl> <nl> + / / Traced Split with list of sizes is being converted to ONNX as SplitToSequence + SequenceAt . <nl> + / / Example IR <nl> + / / % 2 : Tensor [ ] = onnx : : SplitToSequence [ axis = 0 ] ( % input , % split_list ) <nl> + / / % 3 : Float ( ) , % 4 : Float ( ) = prim : : ListUnpack ( % 2 ) <nl> + / / <nl> + / / Translates to ONNX : <nl> + / / % 2 : Tensor [ ] = onnx : : SplitToSequence [ axis = 0 ] ( % input , % split_list ) <nl> + / / % 3 : Tensor = onnx : : Constant [ value = { 1 } ] ( ) <nl> + / / % 4 : Float ( ) = onnx : : SequenceAt ( % 2 , % 3 ) <nl> + / / % 5 : Tensor = onnx : : Constant [ value = { 0 } ] ( ) <nl> + / / % 6 : Float ( ) = onnx : : SequenceAt ( % 2 , % 5 ) <nl> + static void fuseSplitToSequenceListUnpack ( Block * b ) { <nl> + for ( auto it = b - > nodes ( ) . begin ( ) , end = b - > nodes ( ) . end ( ) ; it ! = end ; + + it ) { <nl> + for ( auto * child_block : it - > blocks ( ) ) { <nl> + fuseSplitToSequenceListUnpack ( child_block ) ; <nl> + } <nl> + if ( it - > kind ( ) = = prim : : ListUnpack & & <nl> + it - > input ( ) - > node ( ) - > kind ( ) = = onnx : : SplitToSequence ) { <nl> + Node * orig_split_to_sequence_node = it - > input ( ) - > node ( ) ; <nl> + for ( size_t i = 0 ; i < it - > outputs ( ) . size ( ) ; + + i ) { <nl> + Node * split_const_node = b - > owningGraph ( ) - > create ( onnx : : Constant , 1 ) ; <nl> + auto tensor = at : : empty ( 1 , c10 : : kLong ) ; <nl> + int64_t * data = tensor . data_ptr < int64_t > ( ) ; <nl> + * data = i ; <nl> + split_const_node - > t_ ( <nl> + attr : : value , <nl> + autograd : : make_variable ( tensor ) ) ; <nl> + split_const_node - > insertAfter ( orig_split_to_sequence_node ) ; <nl> + Node * seq_at_node = b - > owningGraph ( ) - > create ( onnx : : SequenceAt , { it - > input ( ) , split_const_node - > output ( ) } ) ; <nl> + seq_at_node - > output ( ) - > copyMetadata ( it - > output ( i ) ) ; <nl> + it - > output ( i ) - > replaceAllUsesWith ( seq_at_node - > output ( ) ) ; <nl> + seq_at_node - > insertAfter ( split_const_node ) ; <nl> + } <nl> + it - > removeAllInputs ( ) ; <nl> + it . destroyCurrent ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> / / For ops such as meshgrid where output is a list of Tensors <nl> / / ( returns prim : : ListConstruct ) , we need to unpack the list <nl> / / before the pass which deletes ListConstruct . <nl> static void convertSplitToDynamic ( Block * b , int opset_version ) { <nl> for ( auto * child_block : it - > blocks ( ) ) { <nl> convertSplitToDynamic ( child_block , opset_version ) ; <nl> } <nl> - <nl> if ( it - > kind ( ) = = onnx : : Split ) { <nl> if ( it - > outputs ( ) . size ( ) = = 1 & & it - > output ( ) - > type ( ) - > kind ( ) = = TypeKind : : ListType ) { <nl> auto dim = it - > i ( attr : : axis ) ; <nl> void PeepholeOptimizeONNX ( std : : shared_ptr < Graph > & graph , int opset_version , bool <nl> fuseTransposeIntoGemm ( graph - > block ( ) ) ; <nl> speculateOps ( graph - > block ( ) ) ; <nl> fuseListConstructListUnpack ( graph - > block ( ) ) ; <nl> + fuseSplitToSequenceListUnpack ( graph - > block ( ) ) ; <nl> fuseSplitListUnpack ( graph - > block ( ) ) ; <nl> convertUnbindToSplit ( graph - > block ( ) , opset_version ) ; <nl> convertSplitToDynamic ( graph - > block ( ) , opset_version ) ; <nl> mmm a / torch / onnx / symbolic_opset11 . py <nl> ppp b / torch / onnx / symbolic_opset11 . py <nl> def round ( g , self ) : <nl> return g . op ( " Round " , self ) <nl> <nl> <nl> + @ parse_args ( ' v ' , ' v ' , ' i ' ) <nl> + def split_with_sizes ( g , self , split_sizes , dim ) : <nl> + if sym_help . _is_value ( split_sizes ) and split_sizes . node ( ) . kind ( ) = = ' prim : : ListConstruct ' : <nl> + return g . op ( " SplitToSequence " , self , split_sizes , axis_i = dim ) <nl> + else : <nl> + return torch . onnx . symbolic_opset9 . split_with_sizes ( g , self , split_sizes , dim ) <nl> + <nl> + <nl> # Generate paddings in ONNX order based on pad in pytorch . <nl> # Arguments : <nl> # dim : the dimension of the tensor . <nl> | [ ONNX ] Export split with list of sizes ( ) | pytorch/pytorch | 9823662b43d3558e1a05f92c1c0e94f231bdcac0 | 2020-02-14T20:46:33Z |
mmm a / Code / CryEngine / CryAction / GameObjects / GameObjectSystem . cpp <nl> ppp b / Code / CryEngine / CryAction / GameObjects / GameObjectSystem . cpp <nl> IGameObject * CGameObjectSystem : : CreateGameObjectForEntity ( EntityId entityId ) <nl> IEntity * pEntity = gEnv - > pEntitySystem - > GetEntity ( entityId ) ; <nl> if ( pEntity ) <nl> { <nl> - auto pGameObject = pEntity - > CreateComponentClass < CGameObject > ( ) ; <nl> + auto pGameObject = pEntity - > GetOrCreateComponentClass < CGameObject > ( ) ; <nl> <nl> / / call sink <nl> for ( SinkList : : iterator si = m_lstSinks . begin ( ) ; si ! = m_lstSinks . end ( ) ; + + si ) <nl> IGameObject * CGameObjectSystem : : CreateGameObjectForEntity ( EntityId entityId ) <nl> <nl> IEntityComponent * CGameObjectSystem : : CreateGameObjectEntityProxy ( IEntity & entity , IGameObject * * ppGameObject ) <nl> { <nl> - auto pGameObject = entity . CreateComponentClass < CGameObject > ( ) ; <nl> + auto pGameObject = entity . GetOrCreateComponentClass < CGameObject > ( ) ; <nl> if ( ppGameObject ) <nl> { <nl> * ppGameObject = pGameObject ; <nl> IGameObjectExtension * CGameObjectSystem : : Instantiate ( ExtensionID id , IGameObject <nl> / * static * / <nl> IEntityComponent * CGameObjectSystem : : CreateGameObjectWithPreactivatedExtension ( IEntity * pEntity , SEntitySpawnParams & params , void * pUserData ) <nl> { <nl> - auto pGameObject = pEntity - > CreateComponentClass < CGameObject > ( ) ; <nl> + auto pGameObject = pEntity - > GetOrCreateComponentClass < CGameObject > ( ) ; <nl> if ( ! pGameObject - > ActivateExtension ( params . pClass - > GetName ( ) ) ) <nl> { <nl> pEntity - > RemoveComponent ( pGameObject ) ; <nl> mmm a / Code / CryEngine / CryAction / GameObjects / GameObjectSystem_FactoryRegistration . cpp <nl> ppp b / Code / CryEngine / CryAction / GameObjects / GameObjectSystem_FactoryRegistration . cpp <nl> <nl> { \ <nl> IGameObjectExtension * Create ( IEntity * pEntity ) \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < C # # extensionClassName > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < C # # extensionClassName > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) \ <nl> { \ <nl> void CGameObjectSystem : : RegisterFactories ( IGameFramework * pFrameWork ) <nl> { <nl> static IEntityComponent * Create ( IEntity * pEntity , SEntitySpawnParams & params , void * pUserData ) <nl> { <nl> - return pEntity - > CreateComponentClass < CMannequinObject > ( ) ; <nl> + return pEntity - > GetOrCreateComponentClass < CMannequinObject > ( ) ; <nl> } <nl> } ; <nl> clsDesc . pUserProxyCreateFunc = & CObjectCreator : : Create ; <nl> mmm a / Code / CryEngine / CryAction / GameRulesSystem . cpp <nl> ppp b / Code / CryEngine / CryAction / GameRulesSystem . cpp <nl> IEntityComponent * CGameRulesSystem : : CreateGameObject ( IEntity * pEntity , SEntitySp <nl> TGameRulesMap : : iterator it = pThis - > m_GameRules . find ( params . pClass - > GetName ( ) ) ; <nl> CRY_ASSERT ( it ! = pThis - > m_GameRules . end ( ) ) ; <nl> <nl> - auto pGameObject = pEntity - > CreateComponentClass < CGameObject > ( ) ; <nl> + auto pGameObject = pEntity - > GetOrCreateComponentClass < CGameObject > ( ) ; <nl> <nl> if ( ! it - > second . extension . empty ( ) ) <nl> { <nl> mmm a / Code / CryEngine / CryAction / Network / GameClientChannel . cpp <nl> ppp b / Code / CryEngine / CryAction / Network / GameClientChannel . cpp <nl> NET_IMPLEMENT_IMMEDIATE_MESSAGE ( CGameClientChannel , DefaultSpawn , eNRT_Unreliabl <nl> <nl> if ( ! param . baseComponent . IsNull ( ) ) <nl> { <nl> - pEntity - > AddComponent ( param . baseComponent , nullptr , false , nullptr ) ; <nl> + if ( pEntity - > QueryComponentByInterfaceID ( param . baseComponent ) = = nullptr ) <nl> + { <nl> + pEntity - > CreateComponentByInterfaceID ( param . baseComponent , nullptr ) ; <nl> + } <nl> } <nl> <nl> if ( ! pEntitySystem - > InitEntity ( pEntity , esp ) ) <nl> mmm a / Code / CryEngine / CryCommon / CryEntitySystem / IEntity . h <nl> ppp b / Code / CryEngine / CryCommon / CryEntitySystem / IEntity . h <nl> <nl> # include < CryEntitySystem / IEntityBasicTypes . h > <nl> # include < CryEntitySystem / IEntityComponent . h > <nl> <nl> + # include < type_traits > <nl> + <nl> / / Forward declarations . <nl> struct IPhysicalEntity ; <nl> struct IEntityClass ; <nl> struct IEntity <nl> / / EntityComponents <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - / / ! Register or unregisters a component with the entity . <nl> - / / ! \ param typeId The GUID of the component we want to add , can not be an interface ID ! <nl> - / / ! \ param pComponent The target component . <nl> - / / ! \ param flags IEntityComponent . h contains the relevent flags to control registration behaviour . <nl> - / / ! \ param eventMask is a bit mask of the EEntityEvents flags . <nl> - / / ! \ return if input param pComponent is null AddComponent will try to create a component for the provided interface id . <nl> - virtual IEntityComponent * AddComponent ( CryInterfaceID typeId , std : : shared_ptr < IEntityComponent > pComponent , bool bAllowDuplicate , IEntityComponent : : SInitParams * pInitParams ) = 0 ; <nl> + / / ! Queries an entity component type by interface , and then creates the component inside this entity <nl> + / / ! \ param interfaceId The GUID of the component we want to add <nl> + / / ! \ param pInitParams Optional initialization parameters to determine the initial state of the component <nl> + / / ! \ return The newly created entity component pointer ( owned by the entity ) , or null if creation failed . <nl> + virtual IEntityComponent * CreateComponentByInterfaceID ( const CryInterfaceID & interfaceId , IEntityComponent : : SInitParams * pInitParams = nullptr ) = 0 ; <nl> + <nl> + / / ! Adds an already created component to the entity <nl> + / / ! \ param pComponent A shared pointer to the component we want to add , can not be null ! <nl> + / / ! \ param pInitParams Optional initialization parameters to determine the initial state of the component <nl> + / / ! \ return True if the component was added , otherwise false . <nl> + virtual bool AddComponent ( std : : shared_ptr < IEntityComponent > pComponent , IEntityComponent : : SInitParams * pInitParams = nullptr ) = 0 ; <nl> <nl> / / ! Remove previously created component from the Entity <nl> / / ! \ param pComponent Component pointer to remove from the Entity <nl> struct IEntity <nl> / / ! Queries an entity component implementing the specified component interface <nl> virtual IEntityComponent * QueryComponentByInterfaceID ( const CryInterfaceID & interfaceID ) const = 0 ; <nl> <nl> - / / ! Get existing or Create a new initialized component inside the entity . <nl> - template < typename ComponentType > <nl> - ComponentType * GetOrCreateComponent ( ) ; <nl> - <nl> - / / ! Get existing or Create a new initialized component using the new operator of the class type , typeid of the component is null guid . <nl> - template < typename ComponentType > <nl> - ComponentType * GetOrCreateComponentClass ( ) ; <nl> - <nl> / / ! Create a new initialized component using interface type id to create a class using factory component class creation . <nl> / / ! ComponentType must be a valid interface that can be queried with cryidof < ComponentType > ( ) <nl> / / ! Instance of the component is created by the lookup in the class registry for the first class that implements ComponentType interface , <nl> / / ! If such class is not previously registered the assert will be raised and method will fail . <nl> template < typename ComponentType > <nl> - ComponentType * CreateComponent ( bool bAllowDuplicate = false ) ; <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type CreateComponent ( ) <nl> + { <nl> + CRY_ASSERT_MESSAGE ( cryiidof < ComponentType > ( ) ! = cryiidof < IEntityComponent > ( ) , " Component must implement an IID function returning CryGUID ! " ) ; <nl> + <nl> + ComponentType * pReturn = static_cast < ComponentType * > ( CreateComponentByInterfaceID ( cryiidof < ComponentType > ( ) ) ) ; <nl> + assert ( pReturn ! = nullptr ) ; / / Must return a valid component interface <nl> + return pReturn ; <nl> + } <nl> + <nl> + / / ! Get existing or Create a new initialized component inside the entity . <nl> + template < typename ComponentType > <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type GetOrCreateComponent ( ) <nl> + { <nl> + auto component = GetComponent < ComponentType > ( ) ; <nl> + if ( component ) <nl> + return component ; <nl> + else <nl> + return CreateComponent < ComponentType > ( ) ; <nl> + } <nl> + <nl> + / / ! Create a new initialized component using a new operator of the class type <nl> + template < class ComponentType > <nl> + typename std : : enable_if < ! Schematyc : : IsReflectedType < ComponentType > ( ) & & std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type CreateComponentClass ( ) <nl> + { <nl> + std : : shared_ptr < ComponentType > pComponent = std : : make_shared < ComponentType > ( ) ; <nl> + CRY_ASSERT ( pComponent - > GetFactory ( ) ! = nullptr ) ; <nl> + if ( AddComponent ( pComponent ) ) <nl> + { <nl> + return pComponent . get ( ) ; <nl> + } <nl> + <nl> + return nullptr ; <nl> + } <nl> + <nl> + / / ! Get existing or Create a new initialized component using the new operator of the class type , typeid of the component is null guid . <nl> + template < class ComponentType > <nl> + typename std : : enable_if < ! Schematyc : : IsReflectedType < ComponentType > ( ) & & std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type GetOrCreateComponentClass ( ) <nl> + { <nl> + ComponentType * pComponent = GetComponent < ComponentType > ( ) ; <nl> + if ( pComponent ) <nl> + return pComponent ; <nl> + else <nl> + return CreateComponentClass < ComponentType > ( ) ; <nl> + } <nl> <nl> - / / ! Create a new initialized component using a new operator of the class type , typeid of the component is null guid . <nl> - template < typename ComponentClass > <nl> - ComponentClass * CreateComponentClass ( bool bAllowDuplicate = false ) ; <nl> <nl> / / ! Helper template function to simplify finding the first component implementing the specified component type <nl> / / ! This will traverse the inheritance tree , and is therefore slower than GetComponentByImplementation which simply does an equality check . <nl> / / ! ex : auto pScriptProxy = pEntity - > GetComponent < IEntityScriptComponent > ( ) ; <nl> template < typename ComponentType > <nl> - ComponentType * GetComponent ( ) const <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type GetComponent ( ) const <nl> { <nl> return static_cast < ComponentType * > ( QueryComponentByInterfaceID ( cryiidof < ComponentType > ( ) ) ) ; <nl> } <nl> struct IEntity <nl> / / ! Helper template function to simplify finding all components implementing the specified component type <nl> / / ! This will traverse the inheritance tree , and is therefore slower than GetComponentsByImplementation which simply does an equality check . <nl> template < typename ComponentType > <nl> - void GetComponents ( DynArray < ComponentType > & components ) const <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , void > : : type GetComponents ( DynArray < ComponentType * > & components ) const <nl> { <nl> / / Hack to avoid copy of vectors , seeing as the interface querying guarantees that the pointers inside are compatible <nl> - DynArray < IEntityComponent > * pRawComponents = ( DynArray < IEntityComponent > * ) ( void * ) components ; <nl> + DynArray < IEntityComponent * > * pRawComponents = ( DynArray < IEntityComponent * > * ) ( void * ) & components ; <nl> QueryComponentsByInterfaceID ( cryiidof < ComponentType > ( ) , * pRawComponents ) ; <nl> + / / Static cast all types from IEntityComponent * to ComponentType * <nl> + for ( auto it = pRawComponents - > begin ( ) ; it ! = pRawComponents - > end ( ) ; + + it ) <nl> + { <nl> + * it = static_cast < ComponentType * > ( ( IEntityComponent * ) ( void * ) * it ) ; <nl> + } <nl> } <nl> <nl> / / ! Helper template function to simplify finding the first component of the specified component type , ignores inherited interfaces and classes ! <nl> template < typename ComponentType > <nl> - ComponentType * GetComponentByImplementation ( ) const <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , ComponentType * > : : type GetComponentByImplementation ( ) const <nl> { <nl> return static_cast < ComponentType * > ( GetComponentByTypeId ( cryiidof < ComponentType > ( ) ) ) ; <nl> } <nl> <nl> / / ! Helper template function to simplify finding all components of the specified component type , ignores inherited interfaces and classes ! <nl> template < typename ComponentType > <nl> - void GetComponentsByImplementation ( DynArray < ComponentType > & components ) const <nl> + typename std : : enable_if < std : : is_convertible < ComponentType , IEntityComponent > : : value , void > : : type GetComponentsByImplementation ( DynArray < ComponentType * > & components ) const <nl> { <nl> / / Hack to avoid copy of vectors , seeing as the interface querying guarantees that the pointers inside are compatible <nl> - DynArray < IEntityComponent > * pRawComponents = ( DynArray < IEntityComponent > * ) ( void * ) components ; <nl> + DynArray < IEntityComponent * > * pRawComponents = ( DynArray < IEntityComponent * > * ) ( void * ) & components ; <nl> GetComponentsByTypeId ( cryiidof < ComponentType > ( ) , * pRawComponents ) ; <nl> + / / Static cast all types from IEntityComponent * to ComponentType * <nl> + for ( auto it = pRawComponents - > begin ( ) ; it ! = pRawComponents - > end ( ) ; + + it ) <nl> + { <nl> + * it = static_cast < ComponentType * > ( ( IEntityComponent * ) ( void * ) * it ) ; <nl> + } <nl> } <nl> <nl> / / ! Creates instances of the components contained in the other entity <nl> typedef IEntity IEntityPhysicalProxy ; <nl> template < typename DST , typename SRC > <nl> DST crycomponent_cast ( SRC pComponent ) { return static_cast < DST > ( pComponent ) ; } <nl> <nl> - template < typename ComponentType > <nl> - inline ComponentType * IEntity : : CreateComponentClass ( bool bAllowDuplicate ) <nl> - { <nl> - return static_cast < ComponentType * > ( AddComponent ( cryiidof < ComponentType > ( ) , std : : make_shared < ComponentType > ( ) , bAllowDuplicate , nullptr ) ) ; <nl> - } <nl> - <nl> - template < typename ComponentInterfaceType > <nl> - inline ComponentInterfaceType * IEntity : : CreateComponent ( bool bAllowDuplicate ) <nl> - { <nl> - / / static_assert ( InterfaceCastSemantics : : cryhasiid < ComponentInterfaceType > : : Check , " Tried to create component class that was not declared with CRY_ENTITY_COMPONENT_INTERFACE_AND_CLASS , CRY_ENTITY_COMPONENT_CLASS or CRY_ENTITY_COMPONENT_INTERFACE in a public scope ! " ) ; <nl> - <nl> - ComponentInterfaceType * pReturn = static_cast < ComponentInterfaceType * > ( AddComponent ( cryiidof < ComponentInterfaceType > ( ) , nullptr , bAllowDuplicate , nullptr ) ) ; <nl> - assert ( pReturn ) ; / / Must return a valid component interface <nl> - <nl> - return pReturn ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - template < typename ComponentType > <nl> - inline ComponentType * IEntity : : GetOrCreateComponent ( ) <nl> - { <nl> - auto component = GetComponent < ComponentType > ( ) ; <nl> - if ( component ) <nl> - return component ; <nl> - else <nl> - return CreateComponent < ComponentType > ( ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - template < typename ComponentType > <nl> - inline ComponentType * IEntity : : GetOrCreateComponentClass ( ) <nl> - { <nl> - auto component = GetComponent < ComponentType > ( ) ; <nl> - if ( component ) <nl> - return component ; <nl> - else <nl> - return CreateComponentClass < ComponentType > ( ) ; <nl> - } <nl> - <nl> / / Helper methods <nl> / / ! Set the viewDistRatio on the render node . <nl> inline void IEntity : : SetViewDistRatio ( int nViewDistRatio ) <nl> mmm a / Code / CryEngine / CryCommon / CryEntitySystem / IEntityComponent . h <nl> ppp b / Code / CryEngine / CryCommon / CryEntitySystem / IEntityComponent . h <nl> struct IEntityComponent : public ICryUnknown <nl> IEntityComponent * pComponent ; <nl> } ; <nl> <nl> - public : <nl> CRY_ENTITY_COMPONENT_INTERFACE ( IEntityComponent , 0x6A6FFE9AA3D44CD6 , 0x9EF1FC42EE649776 ) <nl> <nl> typedef int ComponentEventPriority ; <nl> mmm a / Code / CryEngine / CryCommon / CryEntitySystem / IEntitySystem . h <nl> ppp b / Code / CryEngine / CryCommon / CryEntitySystem / IEntitySystem . h <nl> inline IEntityClass * RegisterEntityClassWithDefaultComponent ( <nl> EEntityComponentFlags : : None , <nl> nullptr , <nl> nullptr ) ; <nl> - entity . AddComponent ( pClassDesc - > GetGUID ( ) , nullptr , true , & initParams ) ; <nl> + entity . CreateComponentByInterfaceID ( pClassDesc - > GetGUID ( ) , & initParams ) ; <nl> return true ; <nl> } ; <nl> clsDesc . onSpawnCallback = onSpawnLambda ; <nl> mmm a / Code / CryEngine / CryCommon / CryExtension / CryGUID . h <nl> ppp b / Code / CryEngine / CryCommon / CryExtension / CryGUID . h <nl> struct CryGUID <nl> <nl> constexpr bool IsNull ( ) const { return hipart = = 0 & & lopart = = 0 ; } <nl> <nl> - bool operator = = ( const CryGUID & rhs ) const { return hipart = = rhs . hipart & & lopart = = rhs . lopart ; } <nl> - bool operator ! = ( const CryGUID & rhs ) const { return hipart ! = rhs . hipart | | lopart ! = rhs . lopart ; } <nl> - bool operator < ( const CryGUID & rhs ) const { return hipart < rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart < rhs . lopart ; } <nl> - bool operator > ( const CryGUID & rhs ) const { return hipart > rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart > rhs . lopart ; } <nl> - bool operator < = ( const CryGUID & rhs ) const { return hipart < rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart < = rhs . lopart ; } <nl> - bool operator > = ( const CryGUID & rhs ) const { return hipart > rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart > = rhs . lopart ; } <nl> + constexpr bool operator = = ( const CryGUID & rhs ) const { return hipart = = rhs . hipart & & lopart = = rhs . lopart ; } <nl> + constexpr bool operator ! = ( const CryGUID & rhs ) const { return hipart ! = rhs . hipart | | lopart ! = rhs . lopart ; } <nl> + constexpr bool operator < ( const CryGUID & rhs ) const { return hipart < rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart < rhs . lopart ; } <nl> + constexpr bool operator > ( const CryGUID & rhs ) const { return hipart > rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart > rhs . lopart ; } <nl> + constexpr bool operator < = ( const CryGUID & rhs ) const { return hipart < rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart < = rhs . lopart ; } <nl> + constexpr bool operator > = ( const CryGUID & rhs ) const { return hipart > rhs . hipart | | ( hipart = = rhs . hipart ) & & lopart > = rhs . lopart ; } <nl> <nl> struct StringUtils <nl> { <nl> mmm a / Code / CryEngine / CryCommon / CryExtension / ICryUnknown . h <nl> ppp b / Code / CryEngine / CryCommon / CryExtension / ICryUnknown . h <nl> struct ICryUnknown ; <nl> <nl> namespace InterfaceCastSemantics <nl> { <nl> + # if ! defined ( SWIG ) <nl> + template < class T > <nl> + struct has_cryiidof <nl> + { <nl> + typedef char ( & yes ) [ 1 ] ; <nl> + typedef char ( & no ) [ 2 ] ; <nl> + <nl> + template < typename C > static yes check ( decltype ( & C : : IID ) ) ; <nl> + template < typename > static no check ( . . . ) ; <nl> + <nl> + static constexpr bool value = sizeof ( check < T > ( 0 ) ) = = sizeof ( yes ) ; <nl> + } ; <nl> + # endif <nl> + <nl> template < class T > <nl> const CryInterfaceID & cryiidof ( ) <nl> { <nl> return T : : IID ( ) ; <nl> } <nl> <nl> + # if ! defined ( SWIG ) <nl> + # define _BEFRIEND_CRYIIDOF ( ) \ <nl> + template < class T > friend const CryInterfaceID & InterfaceCastSemantics : : cryiidof ( ) ; \ <nl> + template < class T > friend struct InterfaceCastSemantics : : has_cryiidof ; <nl> + # else <nl> # define _BEFRIEND_CRYIIDOF ( ) \ <nl> template < class T > friend const CryInterfaceID & InterfaceCastSemantics : : cryiidof ( ) ; <nl> + # endif <nl> <nl> template < class Dst , class Src > <nl> Dst * cryinterface_cast ( Src * p ) <nl> mmm a / Code / CryEngine / CryCommon / CryGame / IGameFramework . h <nl> ppp b / Code / CryEngine / CryCommon / CryGame / IGameFramework . h <nl> struct IGameObjectExtensionCreatorBase <nl> template < class T > \ <nl> struct C # # name # # Creator : public I # # name # # Creator \ <nl> { \ <nl> - IGameObjectExtension * Create ( IEntity * pEntity ) override \ <nl> + IGameObjectExtension * Create ( IEntity * pEntity ) override \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < T > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < T > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) override \ <nl> { \ <nl> mmm a / Code / CryEngine / CryCommon / CryMath / Angle . h <nl> ppp b / Code / CryEngine / CryCommon / CryMath / Angle . h <nl> class CAngle <nl> constexpr static CAngle FromDegrees ( float value ) { return CAngle ( DEG2RAD ( value ) ) ; } <nl> constexpr static CAngle FromRadians ( float value ) { return CAngle ( value ) ; } <nl> <nl> - float ToDegrees ( ) const { return RAD2DEG ( m_value ) ; } <nl> - float ToRadians ( ) const { return m_value ; } <nl> - float & ToRadians ( ) { return m_value ; } <nl> - <nl> - bool operator = = ( CAngle rhs ) const { return m_value = = rhs . m_value ; } <nl> - CAngle operator - ( CAngle rhs ) const { return CAngle ( m_value - rhs . m_value ) ; } <nl> - CAngle operator + ( CAngle rhs ) const { return CAngle ( m_value + rhs . m_value ) ; } <nl> - void operator - = ( CAngle rhs ) { m_value - = rhs . m_value ; } <nl> - void operator + = ( CAngle rhs ) { m_value + = rhs . m_value ; } <nl> - CAngle operator * ( CAngle rhs ) const { return CAngle ( m_value * rhs . m_value ) ; } <nl> - CAngle operator / ( CAngle rhs ) const { return CAngle ( m_value / rhs . m_value ) ; } <nl> + float & GetUnderlyingValueAsRadians ( ) { return m_value ; } <nl> + <nl> + constexpr float ToDegrees ( ) const { return RAD2DEG ( m_value ) ; } <nl> + constexpr float ToRadians ( ) const { return m_value ; } <nl> + constexpr CAngle Absolute ( ) const { return CAngle ( m_value < 0 ? - m_value : m_value ) ; } <nl> + <nl> + constexpr bool operator < ( CAngle rhs ) const { return m_value < rhs . m_value ; } <nl> + constexpr bool operator > ( CAngle rhs ) const { return m_value > rhs . m_value ; } <nl> + constexpr bool operator < = ( CAngle rhs ) const { return m_value < = rhs . m_value ; } <nl> + constexpr bool operator > = ( CAngle rhs ) const { return m_value > = rhs . m_value ; } <nl> + constexpr bool operator = = ( CAngle rhs ) const { return m_value = = rhs . m_value ; } <nl> + constexpr CAngle operator - ( CAngle rhs ) const { return CAngle ( m_value - rhs . m_value ) ; } <nl> + constexpr CAngle operator + ( CAngle rhs ) const { return CAngle ( m_value + rhs . m_value ) ; } <nl> + constexpr CAngle operator * ( CAngle rhs ) const { return CAngle ( m_value * rhs . m_value ) ; } <nl> + constexpr CAngle operator / ( CAngle rhs ) const { return CAngle ( m_value / rhs . m_value ) ; } <nl> + constexpr CAngle operator * ( float rhs ) const { return CAngle ( m_value * rhs ) ; } <nl> + constexpr CAngle operator / ( float rhs ) const { return CAngle ( m_value / rhs ) ; } <nl> + constexpr CAngle operator - ( ) const { return CAngle ( - m_value ) ; } <nl> + <nl> + / / These should be constexpr when we migrate to C + + 14 <nl> + CAngle operator - = ( const CAngle rhs ) { * this = * this - rhs ; return * this ; } <nl> + CAngle operator + = ( const CAngle rhs ) { * this = * this + rhs ; return * this ; } <nl> + CAngle operator * = ( const CAngle rhs ) { * this = * this * rhs ; return * this ; } <nl> + CAngle operator / = ( const CAngle rhs ) { * this = * this / rhs ; return * this ; } <nl> + CAngle operator * = ( const float rhs ) { * this = * this * rhs ; return * this ; } <nl> + CAngle operator / = ( const float rhs ) { * this = * this / rhs ; return * this ; } <nl> <nl> static void ReflectType ( Schematyc : : CTypeDesc < CAngle > & desc ) <nl> { <nl> class CAngle <nl> <nl> inline bool Serialize ( Serialization : : IArchive & archive , CAngle & value , const char * szName , const char * szLabel ) <nl> { <nl> - return archive ( Serialization : : RadiansAsDeg ( value . ToRadians ( ) ) , szName , szLabel ) ; <nl> + return archive ( Serialization : : RadiansAsDeg ( value . GetUnderlyingValueAsRadians ( ) ) , szName , szLabel ) ; <nl> } <nl> <nl> constexpr CAngle operator " " _radians ( unsigned long long int value ) <nl> class CAngles3 <nl> , y ( _y ) <nl> , z ( _z ) { } <nl> <nl> + CAngles3 ( Quat current , Quat previous ) <nl> + { <nl> + Quat delta = current / previous ; <nl> + Ang3 angles = Ang3 ( delta ) ; <nl> + <nl> + x = CAngle : : FromRadians ( angles . x ) ; <nl> + y = CAngle : : FromRadians ( angles . y ) ; <nl> + z = CAngle : : FromRadians ( angles . z ) ; <nl> + } <nl> + <nl> + void Multiply ( Vec3 vec ) <nl> + { <nl> + x * = vec . x ; <nl> + y * = vec . y ; <nl> + z * = vec . z ; <nl> + } <nl> + <nl> inline bool operator = = ( const CAngles3 & rhs ) const { return 0 = = memcmp ( this , & rhs , sizeof ( rhs ) ) ; } <nl> <nl> + constexpr CAngles3 operator * ( float rhs ) const { return CAngles3 ( x * rhs , y * rhs , z * rhs ) ; } <nl> + constexpr CAngles3 operator - ( ) const { return CAngles3 ( - x , - y , - z ) ; } <nl> + <nl> + CAngles3 operator * = ( float rhs ) { * this = * this * rhs ; return * this ; } <nl> + <nl> Ang3 ToAng3 ( ) const { return Ang3 ( x . ToRadians ( ) , y . ToRadians ( ) , z . ToRadians ( ) ) ; } <nl> <nl> inline void Serialize ( Serialization : : IArchive & archive ) <nl> inline void ReflectType ( Schematyc : : CTypeDesc < CClampedAngle < TMinDegrees , TMaxDegr <nl> template < int TMinDegrees , int TMaxDegrees > <nl> inline bool Serialize ( Serialization : : IArchive & archive , CClampedAngle < TMinDegrees , TMaxDegrees > & value , const char * szName , const char * szLabel ) <nl> { <nl> - if ( archive ( Serialization : : RadiansWithRangeAsDeg ( value . ToRadians ( ) , DEG2RAD ( ( float ) TMinDegrees ) , DEG2RAD ( ( float ) TMaxDegrees ) ) , szName , szLabel ) ) <nl> + if ( archive ( Serialization : : RadiansWithRangeAsDeg ( value . GetUnderlyingValueAsRadians ( ) , DEG2RAD ( ( float ) TMinDegrees ) , DEG2RAD ( ( float ) TMaxDegrees ) ) , szName , szLabel ) ) <nl> { <nl> return true ; <nl> } <nl> mmm a / Code / CryEngine / CryCommon / CryMath / Cry_Math . h <nl> ppp b / Code / CryEngine / CryCommon / CryMath / Cry_Math . h <nl> template < typename D > ILINE D convert ( ) { return D ( 0 ) ; } <nl> template < typename D , typename S > ILINE D convert ( S val ) { return D ( val ) ; } <nl> <nl> / / Definitions <nl> - const f32 gf_PI = f32 ( 3 . 14159265358979323846264338327950288419716939937510 ) ; <nl> - const f64 g_PI = 3 . 14159265358979323846264338327950288419716939937510 ; / / ! < pi <nl> + constexpr f32 gf_PI = f32 ( 3 . 14159265358979323846264338327950288419716939937510 ) ; <nl> + constexpr f64 g_PI = 3 . 14159265358979323846264338327950288419716939937510 ; / / ! < pi <nl> <nl> - const f32 gf_PI2 = f32 ( 3 . 14159265358979323846264338327950288419716939937510 * 2 . 0 ) ; <nl> - const f64 g_PI2 = 3 . 14159265358979323846264338327950288419716939937510 * 2 . 0 ; / / ! < 2 * pi <nl> + / / Workaround for MSVC 140 bug where constexpr expression did not evaluate <nl> + # if ! defined ( _MSC_VER ) | | _MSC_VER > = 1910 <nl> + constexpr f32 gf_PI2 = gf_PI * 2 . f ; <nl> + constexpr f64 g_PI2 = g_PI * 2 . 0 ; / / ! < 2 * pi <nl> + # else <nl> + constexpr f32 gf_PI2 = f32 ( 6 . 2831853071795864769252867665590057683943387987502 ) ; <nl> + constexpr f64 g_PI2 = 6 . 2831853071795864769252867665590057683943387987502 ; / / ! < 2 * pi <nl> + # endif <nl> <nl> - const f32 gf_ln2 = 0 . 69314718055994530941723212145818f ; / / ! < ln ( 2 ) <nl> + constexpr f32 gf_ln2 = 0 . 69314718055994530941723212145818f ; / / ! < ln ( 2 ) <nl> <nl> - const f64 sqrt2 = 1 . 4142135623730950488016887242097 ; <nl> - const f64 sqrt3 = 1 . 7320508075688772935274463415059 ; <nl> + constexpr f64 sqrt2 = 1 . 4142135623730950488016887242097 ; <nl> + constexpr f64 sqrt3 = 1 . 7320508075688772935274463415059 ; <nl> <nl> # define DEG2RAD ( a ) ( ( a ) * ( gf_PI / 180 . 0f ) ) <nl> # define RAD2DEG ( a ) ( ( a ) * ( 180 . 0f / gf_PI ) ) <nl> mmm a / Code / CryEngine / CryEntitySystem / BreakableManager . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / BreakableManager . cpp <nl> void SetEntityLifetime ( IEntity * pEntity , const char * props , bool visible ) <nl> } <nl> if ( timeout > 0 | | timeoutInvis > = 0 ) <nl> { <nl> - auto pTimeout = pEntity - > CreateComponent < CTimeoutKillComponent > ( ) ; <nl> + auto pTimeout = pEntity - > GetOrCreateComponent < CTimeoutKillComponent > ( ) ; <nl> pTimeout - > SetTimeout ( static_cast < int > ( 1000 * std : : max ( timeout , timeoutInvis ) ) ) ; <nl> } <nl> } <nl> mmm a / Code / CryEngine / CryEntitySystem / CMakeLists . txt <nl> ppp b / Code / CryEngine / CryEntitySystem / CMakeLists . txt <nl> add_sources ( " CryEntitySystem_uber_0 . cpp " <nl> " GeomCacheAttachmentManager . h " <nl> " GeomCacheAttachmentManager . cpp " <nl> " EntityUnitTests . cpp " <nl> + " EntityUnitTests . h " <nl> ) <nl> <nl> add_sources ( " CryEntitySystem_uber_1 . cpp " <nl> mmm a / Code / CryEngine / CryEntitySystem / CryEntityDLL . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / CryEntityDLL . cpp <nl> <nl> <nl> # include < CryEntitySystem / IEntitySystem . h > <nl> # include " EntitySystem . h " <nl> + # include " EntityUnitTests . h " <nl> <nl> # include " Schematyc / EntitySchematycActions . h " <nl> # include " Schematyc / EntitySchematycUtilFunctions . h " <nl> struct CSystemEventListener_Entity : public ISystemEventListener <nl> { <nl> switch ( event ) <nl> { <nl> - case ESYSTEM_EVENT_GAME_POST_INIT : <nl> + case ESYSTEM_EVENT_REGISTER_SCHEMATYC_ENV : <nl> { <nl> auto entitySchematycRegistration = [ ] ( Schematyc : : IEnvRegistrar & registrar ) <nl> { <nl> struct CSystemEventListener_Entity : public ISystemEventListener <nl> Schematyc : : CEntityDebugTextAction : : Register ( registrar ) ; <nl> Schematyc : : Entity : : RegisterUtilFunctions ( registrar ) ; <nl> Schematyc : : CEntityUtilsComponent : : Register ( registrar ) ; <nl> + <nl> + if ( gEnv - > bTesting ) <nl> + { <nl> + RegisterUnitTestComponents ( registrar ) ; <nl> + } <nl> } ; <nl> <nl> gEnv - > pSchematyc - > GetEnvRegistry ( ) . RegisterPackage ( <nl> mmm a / Code / CryEngine / CryEntitySystem / Entity . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / Entity . cpp <nl> CEntity : : CEntity ( SEntitySpawnParams & params ) <nl> CEntityScript * pCEntityScript = static_cast < CEntityScript * > ( pEntityScript ) ; <nl> if ( pCEntityScript - > LoadScript ( ) ) <nl> { <nl> - auto pScriptProxy = CreateComponent < IEntityScriptComponent > ( ) ; <nl> + auto pScriptProxy = GetOrCreateComponent < IEntityScriptComponent > ( ) ; <nl> pScriptProxy - > ChangeScript ( pEntityScript , & params ) ; <nl> } <nl> } <nl> void CEntity : : LoadComponent ( Serialization : : IArchive & archive ) <nl> / / classProperties . Apply ( componentClassDesc , pComponent . get ( ) ) ; <nl> Schematyc : : Utils : : SerializeClass ( archive , componentClassDesc , pComponent . get ( ) , " properties " , " properties " ) ; <nl> <nl> - / / Finally Add and Initialize the component <nl> - AddComponent ( typeGUID , pComponent , true , & initParams ) ; <nl> + / / Finally Create and Initialize the component <nl> + AddComponentInternal ( pComponent , typeGUID , & initParams , & componentClassDesc ) ; <nl> } <nl> else <nl> { <nl> bool CEntity : : LoadComponentLegacy ( XmlNodeRef & entityNode , XmlNodeRef & componentN <nl> { <nl> / / Only user created components , should create components , otherwise component should be created by entity class or Schematyc objects <nl> IEntityComponent : : SInitParams initParams ( this , CryGUID ( ) , " " , nullptr , EEntityComponentFlags : : None , nullptr , nullptr ) ; <nl> - pComponent = AddComponent ( componentTypeId , std : : shared_ptr < IEntityComponent > ( ) , true , & initParams ) ; <nl> + pComponent = CreateComponentByInterfaceID ( componentTypeId , & initParams ) ; <nl> } <nl> } <nl> <nl> IEntityComponent * CEntity : : CreateProxy ( EEntityProxy proxy ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - IEntityComponent * CEntity : : AddComponent ( CryInterfaceID typeId , std : : shared_ptr < IEntityComponent > pComponent , bool bAllowDuplicate , IEntityComponent : : SInitParams * pInitParams ) <nl> + IEntityComponent * CEntity : : CreateComponentByInterfaceID ( const CryInterfaceID & interfaceId , IEntityComponent : : SInitParams * pInitParams ) <nl> { <nl> const CEntityComponentClassDesc * pClassDescription = nullptr ; <nl> + CryGUID componentTypeID ; <nl> <nl> - if ( ! pComponent ) <nl> + / / First look for a unified Schematyc / Entity component type <nl> + / / TODO : Search hierarchy <nl> + const Schematyc : : IEnvComponent * pEnvComponent = gEnv - > pSchematyc - > GetEnvRegistry ( ) . GetComponent ( interfaceId ) ; <nl> + ICryFactory * pLegacyComponentFactory = nullptr ; <nl> + if ( pEnvComponent ! = nullptr ) <nl> { <nl> - const Schematyc : : IEnvComponent * pEnvComponent = gEnv - > pSchematyc - > GetEnvRegistry ( ) . GetComponent ( typeId ) ; <nl> - if ( pEnvComponent ) <nl> - { <nl> - pComponent = pEnvComponent - > CreateFromPool ( ) ; <nl> - pClassDescription = & pEnvComponent - > GetDesc ( ) ; <nl> - } <nl> - if ( ! pComponent ) <nl> + / / Resolve to implementation ID <nl> + componentTypeID = pEnvComponent - > GetGUID ( ) ; <nl> + pClassDescription = & pEnvComponent - > GetDesc ( ) ; <nl> + } <nl> + else <nl> + { <nl> + / / Fall back to legacy 5 . 3 creation <nl> + if ( ICryFactoryRegistry * pFactoryRegistry = gEnv - > pSystem - > GetCryFactoryRegistry ( ) ) <nl> { <nl> - / / Deprecated , Pre Schematyc creation . <nl> - if ( ! CryCreateClassInstanceForInterface ( typeId , pComponent ) ) <nl> + size_t numFactories = 1 ; <nl> + pFactoryRegistry - > IterateFactories ( interfaceId , & pLegacyComponentFactory , numFactories ) ; <nl> + if ( numFactories = = 0 | | pLegacyComponentFactory = = nullptr ) <nl> { <nl> - if ( ! CryCreateClassInstance ( typeId , pComponent ) ) <nl> - { <nl> - CRY_ASSERT_MESSAGE ( 0 , " No component implementation class registered for the given component interface " ) ; <nl> - return nullptr ; <nl> - } <nl> + / / Nothing found by interface , check by implementation id <nl> + pLegacyComponentFactory = pFactoryRegistry - > GetFactory ( interfaceId ) ; <nl> } <nl> - } <nl> - } <nl> <nl> - / / Assign type GUID , since the function could ' ve been called with an interface identifier <nl> - / / First check if the new unified class GUID is present <nl> - if ( pInitParams ! = nullptr & & pInitParams - > classDesc ! = nullptr & & ! pInitParams - > classDesc - > GetGUID ( ) . IsNull ( ) ) <nl> - { <nl> - typeId = pInitParams - > classDesc - > GetGUID ( ) ; <nl> - } <nl> - / / Fall back to checking if the legacy factory is present <nl> - else if ( ICryFactory * pFactory = pComponent - > GetFactory ( ) ) <nl> - { <nl> - typeId = pFactory - > GetClassID ( ) ; <nl> - } <nl> + if ( pLegacyComponentFactory = = nullptr | | ! pLegacyComponentFactory - > ClassSupports ( cryiidof < IEntityComponent > ( ) ) ) <nl> + { <nl> + CRY_ASSERT_MESSAGE ( 0 , " No component implementation registered for the given component interface " ) ; <nl> + return nullptr ; <nl> + } <nl> <nl> - bool bExist = false ; <nl> - for ( const SEntityComponentRecord & componentRecord : m_components . GetVector ( ) ) <nl> - { <nl> - if ( componentRecord . pComponent = = pComponent ) <nl> - { <nl> - CRY_ASSERT_MESSAGE ( 0 , " AddComponent called twice with the same pointer " ) ; <nl> - return nullptr ; <nl> - } <nl> - if ( ! bAllowDuplicate & & componentRecord . typeId = = typeId & & typeId ! = cryiidof < ICryUnknown > ( ) & & typeId ! = cryiidof < IEntityComponent > ( ) <nl> - & & componentRecord . IsValid ( ) ) / / checks if the component was just removed <nl> - { <nl> - CRY_ASSERT_MESSAGE ( 0 , " AddComponent called twice with the same interface type " ) ; <nl> - return nullptr ; <nl> + / / Resolve to implementation id , since we may have queried by interface <nl> + componentTypeID = pLegacyComponentFactory - > GetClassID ( ) ; <nl> } <nl> } <nl> - <nl> - IEntityComponent : : SInitParams tempInitParams ( this , CryGUID : : Create ( ) , " " , pClassDescription ! = nullptr ? pClassDescription : & pComponent - > GetClassDesc ( ) , EEntityComponentFlags : : None , nullptr , nullptr ) ; <nl> - if ( pInitParams = = nullptr ) <nl> + <nl> + / / All pre - checks successful , we can now create the component <nl> + / / There can never be any failures after this point , we must always add the component to storage <nl> + std : : shared_ptr < IEntityComponent > pComponent = pEnvComponent ! = nullptr ? pEnvComponent - > CreateFromPool ( ) : cryinterface_cast < IEntityComponent > ( pLegacyComponentFactory - > CreateClassInstance ( ) ) ; <nl> + CRY_ASSERT ( pComponent ! = nullptr ) ; <nl> + <nl> + AddComponentInternal ( pComponent , componentTypeID , pInitParams , pClassDescription ) ; <nl> + <nl> + return pComponent . get ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool CEntity : : AddComponent ( std : : shared_ptr < IEntityComponent > pComponent , IEntityComponent : : SInitParams * pInitParams ) <nl> + { <nl> + const CEntityComponentClassDesc * pClassDescription = pInitParams ! = nullptr ? pInitParams - > classDesc : nullptr ; <nl> + if ( pClassDescription ! = nullptr ) <nl> { <nl> - pInitParams = & tempInitParams ; <nl> + AddComponentInternal ( pComponent , pClassDescription - > GetGUID ( ) , pInitParams , pClassDescription ) ; <nl> + return true ; <nl> } <nl> - else if ( pInitParams - > classDesc = = nullptr ) <nl> + else if ( ICryFactory * pFactory = pComponent - > GetFactory ( ) ) <nl> { <nl> - pInitParams - > classDesc = & pComponent - > GetClassDesc ( ) ; <nl> + AddComponentInternal ( pComponent , pFactory - > GetClassID ( ) , pInitParams , nullptr ) ; <nl> + return true ; <nl> } <nl> - <nl> - pComponent - > PreInit ( * pInitParams ) ; <nl> + <nl> + AddComponentInternal ( pComponent , CryGUID : : Null ( ) , pInitParams , nullptr ) ; <nl> + return true ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CEntity : : AddComponentInternal ( std : : shared_ptr < IEntityComponent > pComponent , const CryGUID & componentTypeID , IEntityComponent : : SInitParams * pInitParams , const CEntityComponentClassDesc * pClassDescription ) <nl> + { <nl> + / / Initialize common component members <nl> + pComponent - > PreInit ( pInitParams ! = nullptr ? * pInitParams : IEntityComponent : : SInitParams ( this , CryGUID : : Create ( ) , " " , pClassDescription , EEntityComponentFlags : : None , nullptr , nullptr ) ) ; <nl> <nl> / / Initialize component entity pointer <nl> pComponent - > m_pEntity = this ; <nl> <nl> SEntityComponentRecord componentRecord ; <nl> componentRecord . pComponent = pComponent ; <nl> - componentRecord . typeId = typeId ; <nl> + componentRecord . typeId = componentTypeID ; <nl> componentRecord . registeredEventsMask = pComponent - > GetEventMask ( ) ; <nl> componentRecord . proxyType = ( int ) pComponent - > GetProxyType ( ) ; <nl> componentRecord . eventPriority = pComponent - > GetEventPriority ( ) ; <nl> IEntityComponent * CEntity : : AddComponent ( CryInterfaceID typeId , std : : shared_ptr < I <nl> <nl> / / Call initialization of the component <nl> pComponent - > Initialize ( ) ; <nl> - <nl> - return pComponent . get ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEntity : : RemoveAllComponents ( ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - IEntityComponent * CEntity : : GetComponentByTypeId ( const CryInterfaceID & interfaceID ) const <nl> + IEntityComponent * CEntity : : GetComponentByTypeId ( const CryInterfaceID & typeId ) const <nl> { <nl> - CRY_ASSERT ( ! interfaceID . IsNull ( ) ) ; <nl> - <nl> for ( const SEntityComponentRecord & componentRecord : m_components . GetVector ( ) ) <nl> { <nl> - if ( componentRecord . typeId = = interfaceID ) <nl> + if ( componentRecord . typeId = = typeId ) <nl> { <nl> return componentRecord . pComponent . get ( ) ; <nl> } <nl> IEntityComponent * CEntity : : GetComponentByTypeId ( const CryInterfaceID & interfaceI <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CEntity : : GetComponentsByTypeId ( const CryInterfaceID & interfaceID , DynArray < IEntityComponent * > & components ) const <nl> + void CEntity : : GetComponentsByTypeId ( const CryInterfaceID & typeId , DynArray < IEntityComponent * > & components ) const <nl> { <nl> - CRY_ASSERT ( ! interfaceID . IsNull ( ) ) ; <nl> - <nl> for ( const SEntityComponentRecord & componentRecord : m_components . GetVector ( ) ) <nl> { <nl> - if ( componentRecord . typeId = = interfaceID ) <nl> + if ( componentRecord . typeId = = typeId ) <nl> { <nl> components . push_back ( componentRecord . pComponent . get ( ) ) ; <nl> } <nl> void CEntity : : GetComponentsByTypeId ( const CryInterfaceID & interfaceID , DynArray < <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> IEntityComponent * CEntity : : GetComponentByGUID ( const CryGUID & guid ) const <nl> { <nl> - CRY_ASSERT ( ! guid . IsNull ( ) ) ; <nl> - <nl> for ( auto & record : m_components . GetVector ( ) ) <nl> { <nl> if ( record . pComponent ! = nullptr & & record . pComponent - > GetGUID ( ) = = guid ) <nl> IEntityComponent * CEntity : : GetComponentByGUID ( const CryGUID & guid ) const <nl> void CEntity : : QueryComponentsByInterfaceID ( const CryInterfaceID & interfaceID , DynArray < IEntityComponent * > & components ) const <nl> { <nl> CRY_ASSERT ( ! interfaceID . IsNull ( ) ) ; <nl> + CRY_ASSERT ( interfaceID ! = cryiidof < ICryUnknown > ( ) ) ; <nl> + CRY_ASSERT ( interfaceID ! = cryiidof < IEntityComponent > ( ) ) ; <nl> <nl> for ( const SEntityComponentRecord & record : m_components . GetVector ( ) ) <nl> { <nl> if ( record . pComponent = = nullptr ) <nl> continue ; <nl> <nl> - if ( record . pComponent - > GetClassDesc ( ) . FindBaseByTypeID ( interfaceID ) ! = nullptr ) <nl> + / / Check unified Schematyc / Entity class hierarchy <nl> + if ( record . pComponent - > GetClassDesc ( ) . GetGUID ( ) = = interfaceID | | record . pComponent - > GetClassDesc ( ) . FindBaseByTypeID ( interfaceID ) ! = nullptr ) <nl> { <nl> components . push_back ( record . pComponent . get ( ) ) ; <nl> continue ; <nl> } <nl> <nl> - / / Check legacy components <nl> + / / Check legacy component class hierarchy <nl> if ( ICryFactory * pFactory = record . pComponent - > GetFactory ( ) ) <nl> { <nl> - if ( pFactory - > ClassSupports ( interfaceID ) ) <nl> + if ( pFactory - > GetClassID ( ) = = interfaceID | | pFactory - > ClassSupports ( interfaceID ) ) <nl> { <nl> components . push_back ( record . pComponent . get ( ) ) ; <nl> continue ; <nl> IEntityComponent * CEntity : : QueryComponentByInterfaceID ( const CryInterfaceID & int <nl> { <nl> CRY_ASSERT ( ! interfaceID . IsNull ( ) ) ; <nl> <nl> + if ( interfaceID = = cryiidof < ICryUnknown > ( ) | | interfaceID = = cryiidof < IEntityComponent > ( ) ) <nl> + { <nl> + return nullptr ; <nl> + } <nl> + <nl> for ( const SEntityComponentRecord & record : m_components . GetVector ( ) ) <nl> { <nl> if ( record . pComponent = = nullptr ) <nl> continue ; <nl> <nl> - if ( record . pComponent - > GetClassDesc ( ) . FindBaseByTypeID ( interfaceID ) ! = nullptr ) <nl> + / / Check unified Schematyc / Entity class hierarchy <nl> + if ( record . pComponent - > GetClassDesc ( ) . GetGUID ( ) = = interfaceID | | record . pComponent - > GetClassDesc ( ) . FindBaseByTypeID ( interfaceID ) ! = nullptr ) <nl> { <nl> return record . pComponent . get ( ) ; <nl> } <nl> <nl> - / / Check legacy components <nl> + / / Check legacy component class hierarchy <nl> if ( ICryFactory * pFactory = record . pComponent - > GetFactory ( ) ) <nl> { <nl> - if ( pFactory - > ClassSupports ( interfaceID ) ) <nl> + if ( pFactory - > GetClassID ( ) = = interfaceID | | pFactory - > ClassSupports ( interfaceID ) ) <nl> { <nl> return record . pComponent . get ( ) ; <nl> } <nl> void CEntity : : CloneComponentsFrom ( IEntity & otherEntity ) <nl> <nl> / / Create a new component <nl> IEntityComponent : : SInitParams initParams ( this , CryGUID : : Create ( ) , pSourceComponent - > GetName ( ) , & pSourceComponent - > GetClassDesc ( ) , pSourceComponent - > GetComponentFlags ( ) , pSourceComponent - > GetParent ( ) , pSourceComponent - > GetTransform ( ) ) ; <nl> - IEntityComponent * pNewComponent = AddComponent ( componentRecord . typeId , std : : shared_ptr < IEntityComponent > ( ) , true , & initParams ) ; <nl> + IEntityComponent * pNewComponent = CreateComponentByInterfaceID ( componentRecord . typeId , & initParams ) ; <nl> <nl> DynArray < char > propertyBuffer ; <nl> / / Save properties from the source to buffer <nl> mmm a / Code / CryEngine / CryEntitySystem / Entity . h <nl> ppp b / Code / CryEngine / CryEntitySystem / Entity . h <nl> class CEntity : public IEntity <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - virtual IEntityComponent * AddComponent ( CryInterfaceID typeId , std : : shared_ptr < IEntityComponent > pComponent , bool bAllowDuplicate , IEntityComponent : : SInitParams * pInitParams ) final ; <nl> + virtual IEntityComponent * CreateComponentByInterfaceID ( const CryInterfaceID & interfaceId , IEntityComponent : : SInitParams * pInitParams ) final ; <nl> + virtual bool AddComponent ( std : : shared_ptr < IEntityComponent > pComponent , IEntityComponent : : SInitParams * pInitParams ) final ; <nl> virtual void RemoveComponent ( IEntityComponent * pComponent ) final ; <nl> virtual void RemoveAllComponents ( ) final ; <nl> virtual IEntityComponent * GetComponentByTypeId ( const CryInterfaceID & interfaceID ) const final ; <nl> class CEntity : public IEntity <nl> <nl> void CreateSchematycObject ( const SEntitySpawnParams & params ) ; <nl> <nl> + void AddComponentInternal ( std : : shared_ptr < IEntityComponent > pComponent , const CryGUID & componentTypeID , IEntityComponent : : SInitParams * pInitParams , const CEntityComponentClassDesc * pClassDescription ) ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Component Save / Load <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / Code / CryEngine / CryEntitySystem / EntityUnitTests . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / EntityUnitTests . cpp <nl> <nl> <nl> CRY_UNIT_TEST_SUITE ( EntityTestsSuit ) <nl> { <nl> - CRY_UNIT_TEST ( SpawnTest ) <nl> + struct IUnifiedEntityComponent : public IEntityComponent <nl> + { <nl> + static CryGUID & IID ( ) <nl> + { <nl> + static CryGUID id = " { C89DD0DD - 9850 - 43BA - BF52 - 86EFB7C9D0A5 } " _cry_guid ; <nl> + return id ; <nl> + } <nl> + <nl> + static void ReflectType ( Schematyc : : CTypeDesc < IUnifiedEntityComponent > & desc ) <nl> + { <nl> + desc . SetGUID ( cryiidof < IUnifiedEntityComponent > ( ) ) ; <nl> + } <nl> + } ; <nl> + <nl> + class CUnifiedEntityComponent : public IUnifiedEntityComponent <nl> + { <nl> + public : <nl> + static CryGUID & IID ( ) <nl> + { <nl> + static CryGUID id = " { C89DD0DD - 9850 - 43BA - BF52 - 86EFB7C9D0A5 } " _cry_guid ; <nl> + return id ; <nl> + } <nl> + <nl> + static void Register ( Schematyc : : CEnvRegistrationScope & componentScope ) <nl> + { <nl> + } <nl> + <nl> + static void ReflectType ( Schematyc : : CTypeDesc < CUnifiedEntityComponent > & desc ) <nl> + { <nl> + desc . AddBase < IUnifiedEntityComponent > ( ) ; <nl> + desc . SetGUID ( CUnifiedEntityComponent : : IID ( ) ) ; <nl> + desc . SetEditorCategory ( " Unit Tests " ) ; <nl> + desc . SetLabel ( " Unified Entity Component " ) ; <nl> + desc . SetDescription ( " Does stuff " ) ; <nl> + desc . SetIcon ( " icons : ObjectTypes / light . ico " ) ; <nl> + desc . SetComponentFlags ( { IEntityComponent : : EFlags : : Transform , IEntityComponent : : EFlags : : Socket , IEntityComponent : : EFlags : : Attach } ) ; <nl> + <nl> + desc . AddMember ( & CUnifiedEntityComponent : : m_bMyBool , ' bool ' , " Bool " , " Bool " , " Bool desc " , false ) ; <nl> + desc . AddMember ( & CUnifiedEntityComponent : : m_myFloat , ' floa ' , " Float " , " Float " , " Float desc " , 0 . f ) ; <nl> + } <nl> + <nl> + bool m_bMyBool = false ; <nl> + float m_myFloat = 0 . f ; <nl> + } ; <nl> + <nl> + IEntity * SpawnTestEntity ( const char * szName ) <nl> { <nl> SEntitySpawnParams params ; <nl> params . guid = CryGUID : : Create ( ) ; <nl> - params . sName = " TestEntity " ; <nl> + params . sName = szName ; <nl> params . nFlags = ENTITY_FLAG_CLIENT_ONLY ; <nl> params . pClass = gEnv - > pEntitySystem - > GetClassRegistry ( ) - > GetDefaultClass ( ) ; <nl> <nl> IEntity * pEntity = gEnv - > pEntitySystem - > SpawnEntity ( params ) ; <nl> - EntityId id = pEntity - > GetId ( ) ; <nl> CRY_UNIT_TEST_ASSERT ( pEntity ! = NULL ) ; <nl> + return pEntity ; <nl> + } <nl> + <nl> + CRY_UNIT_TEST ( SpawnTest ) <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " TestEntity " ) ; <nl> + EntityId id = pEntity - > GetId ( ) ; <nl> <nl> CRY_UNIT_TEST_ASSERT ( pEntity - > GetGuid ( ) ! = CryGUID : : Null ( ) ) ; <nl> <nl> CRY_UNIT_TEST_CHECK_EQUAL ( id , gEnv - > pEntitySystem - > FindEntityByGuid ( pEntity - > GetGuid ( ) ) ) ; <nl> - CRY_UNIT_TEST_CHECK_EQUAL ( pEntity , gEnv - > pEntitySystem - > FindEntityByName ( params . sName ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity , gEnv - > pEntitySystem - > FindEntityByName ( " TestEntity " ) ) ; <nl> <nl> / / Test Entity components <nl> IEntitySubstitutionComponent * pComponent = pEntity - > GetOrCreateComponent < IEntitySubstitutionComponent > ( ) ; <nl> CRY_UNIT_TEST_ASSERT ( nullptr ! = pComponent ) ; <nl> CRY_UNIT_TEST_ASSERT ( 1 = = pEntity - > GetComponentsCount ( ) ) ; <nl> } <nl> + <nl> + class CLegacyEntityComponent : public IEntityComponent <nl> + { <nl> + public : <nl> + CRY_ENTITY_COMPONENT_INTERFACE_AND_CLASS ( CLegacyEntityComponent , " LegacyEntityComponent " , 0xB1FEBCEEBE1246A9 , 0xB69ACC66D6C0D3E0 ) ; <nl> + } ; <nl> + <nl> + CRYREGISTER_CLASS ( CLegacyEntityComponent ) ; <nl> + <nl> + CRY_UNIT_TEST ( CreateLegacyComponent ) <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " LegacyComponentTestEntity " ) ; <nl> + <nl> + CLegacyEntityComponent * pComponent = pEntity - > GetOrCreateComponent < CLegacyEntityComponent > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 1 ) ; <nl> + <nl> + pEntity - > RemoveComponent ( pComponent ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 0 ) ; <nl> + } <nl> + <nl> + struct ILegacyComponentInterface : public IEntityComponent <nl> + { <nl> + CRY_ENTITY_COMPONENT_INTERFACE ( ILegacyComponentInterface , 0xD9A710128AF14426 , 0x883599C4F4EB987D ) <nl> + <nl> + virtual bool IsValid ( ) const { return false ; } <nl> + } ; <nl> + <nl> + class CLegacyEntityComponentWithInterface final : public ILegacyComponentInterface <nl> + { <nl> + public : <nl> + CRY_ENTITY_COMPONENT_CLASS ( CLegacyEntityComponentWithInterface , ILegacyComponentInterface , " LegacyEntityComponentWithInterface " , 0x34EE1B9221544BAD , 0xB69ACC66D6C0D3E0 ) ; <nl> + <nl> + virtual bool IsValid ( ) const final { return true ; } <nl> + } ; <nl> + <nl> + CRYREGISTER_CLASS ( CLegacyEntityComponentWithInterface ) ; <nl> + <nl> + CRY_UNIT_TEST ( CreateLegacyComponentWithInterface ) <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " LegacyComponentTestInterfaceEntity " ) ; <nl> + <nl> + ILegacyComponentInterface * pComponent = pEntity - > GetOrCreateComponent < ILegacyComponentInterface > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_ASSERT ( pComponent - > IsValid ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < CLegacyEntityComponentWithInterface > ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < ILegacyComponentInterface > ( ) ) ; <nl> + <nl> + pEntity - > RemoveComponent ( pComponent ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 0 ) ; <nl> + <nl> + pComponent = pEntity - > GetOrCreateComponent < CLegacyEntityComponentWithInterface > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_ASSERT ( pComponent - > IsValid ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < CLegacyEntityComponentWithInterface > ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < ILegacyComponentInterface > ( ) ) ; <nl> + <nl> + DynArray < CLegacyEntityComponentWithInterface * > components ; <nl> + pEntity - > GetComponents < CLegacyEntityComponentWithInterface > ( components ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( components . size ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( components . at ( 0 ) , static_cast < CLegacyEntityComponentWithInterface * > ( pComponent ) ) ; <nl> + <nl> + DynArray < ILegacyComponentInterface * > componentsbyInterface ; <nl> + pEntity - > GetComponents < ILegacyComponentInterface > ( componentsbyInterface ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( componentsbyInterface . size ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( componentsbyInterface . at ( 0 ) , static_cast < CLegacyEntityComponentWithInterface * > ( pComponent ) ) ; <nl> + } <nl> + <nl> + CRY_UNIT_TEST ( CreateUnifiedComponent ) <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " UnifiedComponentTestEntity " ) ; <nl> + <nl> + CUnifiedEntityComponent * pComponent = pEntity - > GetOrCreateComponent < CUnifiedEntityComponent > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_bMyBool , false ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_myFloat , 0 . f ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < CUnifiedEntityComponent > ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < IUnifiedEntityComponent > ( ) ) ; <nl> + <nl> + pEntity - > RemoveComponent ( pComponent ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 0 ) ; <nl> + <nl> + pComponent = static_cast < CUnifiedEntityComponent * > ( pEntity - > GetOrCreateComponent < IUnifiedEntityComponent > ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_bMyBool , false ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_myFloat , 0 . f ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < CUnifiedEntityComponent > ( ) ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent , pEntity - > GetComponent < IUnifiedEntityComponent > ( ) ) ; <nl> + <nl> + DynArray < CUnifiedEntityComponent * > components ; <nl> + pEntity - > GetComponents < CUnifiedEntityComponent > ( components ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( components . size ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( components . at ( 0 ) , static_cast < CUnifiedEntityComponent * > ( pComponent ) ) ; <nl> + <nl> + DynArray < IUnifiedEntityComponent * > componentsbyInterface ; <nl> + pEntity - > GetComponents < IUnifiedEntityComponent > ( componentsbyInterface ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( componentsbyInterface . size ( ) , 1 ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( componentsbyInterface . at ( 0 ) , static_cast < CUnifiedEntityComponent * > ( pComponent ) ) ; <nl> + } <nl> + <nl> + CRY_UNIT_TEST ( UnifiedComponentSerialization ) <nl> + { <nl> + XmlNodeRef node = gEnv - > pSystem - > CreateXmlNode ( ) ; <nl> + CryGUID instanceGUID ; <nl> + <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " UnifiedComponentSerializationTestEntity " ) ; <nl> + <nl> + CUnifiedEntityComponent * pComponent = pEntity - > GetOrCreateComponent < CUnifiedEntityComponent > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + / / Check default values <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_bMyBool , false ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_myFloat , 0 . f ) ; <nl> + <nl> + pComponent - > m_bMyBool = true ; <nl> + pComponent - > m_myFloat = 1337 . f ; <nl> + <nl> + instanceGUID = pComponent - > GetGUID ( ) ; <nl> + <nl> + / / Save to XML <nl> + pEntity - > SerializeXML ( node , false ) ; <nl> + } <nl> + <nl> + / / Create another entity for deserialization <nl> + IEntity * pDeserializedEntity = SpawnTestEntity ( " UnifiedComponentDeserializationTestEntity " ) ; <nl> + / / Deserialize <nl> + pDeserializedEntity - > SerializeXML ( node , true ) ; <nl> + <nl> + CUnifiedEntityComponent * pComponent = pDeserializedEntity - > GetComponent < CUnifiedEntityComponent > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_DIFFERENT ( pComponent , nullptr ) ; <nl> + / / Check deserialized values <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_bMyBool , true ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > m_myFloat , 1337 . f ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pComponent - > GetGUID ( ) , instanceGUID ) ; <nl> + } <nl> + <nl> + CRY_UNIT_TEST ( QueryInvalidGUID ) <nl> + { <nl> + IEntity * pEntity = SpawnTestEntity ( " UnifiedComponentTestEntity " ) ; <nl> + CUnifiedEntityComponent * pComponent = pEntity - > GetOrCreateComponent < CUnifiedEntityComponent > ( ) ; <nl> + CLegacyEntityComponentWithInterface * pLegacyComponent = pEntity - > GetOrCreateComponent < CLegacyEntityComponentWithInterface > ( ) ; <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponentsCount ( ) , 2 ) ; <nl> + / / Querying the lowest level GUIDs is disallowed <nl> + CRY_UNIT_TEST_CHECK_EQUAL ( pEntity - > GetComponent < IEntityComponent > ( ) , nullptr ) ; <nl> + } <nl> } <nl> + <nl> + static void RegisterUnitTestComponents ( Schematyc : : IEnvRegistrar & registrar ) <nl> + { <nl> + Schematyc : : CEnvRegistrationScope scope = registrar . Scope ( IEntity : : GetEntityScopeGUID ( ) ) ; <nl> + { <nl> + Schematyc : : CEnvRegistrationScope componentScope = scope . Register ( SCHEMATYC_MAKE_ENV_COMPONENT ( EntityTestsSuit : : CUnifiedEntityComponent ) ) ; <nl> + EntityTestsSuit : : CUnifiedEntityComponent : : Register ( componentScope ) ; <nl> + } <nl> + } <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 0000000000 . . 238f4fce17 <nl> mmm / dev / null <nl> ppp b / Code / CryEngine / CryEntitySystem / EntityUnitTests . h <nl> <nl> + / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # include " stdafx . h " <nl> + <nl> + # include < CrySchematyc / CoreAPI . h > <nl> + <nl> + static void RegisterUnitTestComponents ( Schematyc : : IEnvRegistrar & registrar ) ; <nl> \ No newline at end of file <nl> mmm a / Code / CryEngine / CryEntitySystem / PhysicsEventListener . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / PhysicsEventListener . cpp <nl> int CPhysicsEventListener : : OnPostStep ( const EventPhys * pEvent ) <nl> return 1 ; <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + int CPhysicsEventListener : : OnPostStepImmediate ( const EventPhys * pEvent ) <nl> + { <nl> + EventPhysPostStep * pPostStep = ( EventPhysPostStep * ) pEvent ; <nl> + if ( CEntity * pEntity = GetEntity ( pPostStep - > pForeignData , pPostStep - > iForeignData ) ) <nl> + { <nl> + SEntityEvent event ( ENTITY_EVENT_PHYS_POSTSTEP ) ; <nl> + event . fParam [ 0 ] = pPostStep - > dt ; <nl> + pEntity - > SendEvent ( event ) ; <nl> + } <nl> + <nl> + return 1 ; <nl> + } <nl> + <nl> int CPhysicsEventListener : : OnPostPump ( const EventPhys * pEvent ) <nl> { <nl> if ( gEnv - > p3DEngine - > GetWaterLevel ( ) ! = WATER_LEVEL_UNKNOWN ) <nl> void CPhysicsEventListener : : RegisterPhysicCallbacks ( ) <nl> m_pPhysics - > AddEventClient ( EventPhysStateChange : : id , OnStateChange , 1 ) ; <nl> m_pPhysics - > AddEventClient ( EventPhysBBoxOverlap : : id , OnBBoxOverlap , 1 ) ; <nl> m_pPhysics - > AddEventClient ( EventPhysPostStep : : id , OnPostStep , 1 ) ; <nl> + m_pPhysics - > AddEventClient ( EventPhysPostStep : : id , OnPostStepImmediate , 0 ) ; <nl> m_pPhysics - > AddEventClient ( EventPhysUpdateMesh : : id , OnUpdateMesh , 1 ) ; <nl> m_pPhysics - > AddEventClient ( EventPhysUpdateMesh : : id , OnUpdateMesh , 0 ) ; <nl> m_pPhysics - > AddEventClient ( EventPhysCreateEntityPart : : id , OnCreatePhysEntityPart , 1 ) ; <nl> void CPhysicsEventListener : : UnregisterPhysicCallbacks ( ) <nl> m_pPhysics - > RemoveEventClient ( EventPhysStateChange : : id , OnStateChange , 1 ) ; <nl> m_pPhysics - > RemoveEventClient ( EventPhysBBoxOverlap : : id , OnBBoxOverlap , 1 ) ; <nl> m_pPhysics - > RemoveEventClient ( EventPhysPostStep : : id , OnPostStep , 1 ) ; <nl> + m_pPhysics - > RemoveEventClient ( EventPhysPostStep : : id , OnPostStepImmediate , 0 ) ; <nl> m_pPhysics - > RemoveEventClient ( EventPhysUpdateMesh : : id , OnUpdateMesh , 1 ) ; <nl> m_pPhysics - > RemoveEventClient ( EventPhysUpdateMesh : : id , OnUpdateMesh , 0 ) ; <nl> m_pPhysics - > RemoveEventClient ( EventPhysCreateEntityPart : : id , OnCreatePhysEntityPart , 1 ) ; <nl> mmm a / Code / CryEngine / CryEntitySystem / PhysicsEventListener . h <nl> ppp b / Code / CryEngine / CryEntitySystem / PhysicsEventListener . h <nl> class CPhysicsEventListener <nl> static int OnBBoxOverlap ( const EventPhys * pEvent ) ; <nl> static int OnStateChange ( const EventPhys * pEvent ) ; <nl> static int OnPostStep ( const EventPhys * pEvent ) ; <nl> + static int OnPostStepImmediate ( const EventPhys * pEvent ) ; <nl> static int OnUpdateMesh ( const EventPhys * pEvent ) ; <nl> static int OnCreatePhysEntityPart ( const EventPhys * pEvent ) ; <nl> static int OnRemovePhysEntityParts ( const EventPhys * pEvent ) ; <nl> mmm a / Code / CryEngine / CrySchematyc / Core / Impl / Object . cpp <nl> ppp b / Code / CryEngine / CrySchematyc / Core / Impl / Object . cpp <nl> bool CObject : : CreateComponents ( ) <nl> transform <nl> ) ; <nl> <nl> - pEntity - > AddComponent ( component . classDesc . GetGUID ( ) , component . pComponent , true , & initParams ) ; <nl> + pEntity - > AddComponent ( component . pComponent , & initParams ) ; <nl> } <nl> } <nl> <nl> mmm a / Code / CryManaged / CryMonoBridge / NativeToManagedInterfaces / Entity . cpp <nl> ppp b / Code / CryManaged / CryMonoBridge / NativeToManagedInterfaces / Entity . cpp <nl> static void AddComponentBase ( MonoInternals : : MonoReflectionType * pType , MonoInter <nl> <nl> static IEntityComponent * CreateManagedComponent ( IEntity * pEntity , SEntitySpawnParams & params , void * pUserData ) <nl> { <nl> - return pEntity - > AddComponent ( * ( CryGUID * ) pUserData , std : : shared_ptr < IEntityComponent > ( ) , true , nullptr ) ; <nl> + return pEntity - > CreateComponentByInterfaceID ( * ( CryGUID * ) pUserData ) ; <nl> } <nl> <nl> static void RegisterManagedEntityWithDefaultComponent ( MonoInternals : : MonoString * pName , MonoInternals : : MonoString * pEditorCategory , MonoInternals : : MonoString * pEditorHelper , MonoInternals : : MonoString * pEditorIcon , bool bHide , MonoInternals : : MonoReflectionType * pComponentType ) <nl> static void GetComponents ( IEntity * pEntity , uint64 guidHipart , uint64 guidLopart <nl> <nl> static MonoInternals : : MonoObject * AddComponent ( IEntity * pEntity , uint64 guidHipart , uint64 guidLopart ) <nl> { <nl> - CManagedEntityComponent * pComponent = static_cast < CManagedEntityComponent * > ( pEntity - > AddComponent ( CryGUID : : Construct ( guidHipart , guidLopart ) , std : : shared_ptr < IEntityComponent > ( ) , true , nullptr ) ) ; <nl> + CManagedEntityComponent * pComponent = static_cast < CManagedEntityComponent * > ( pEntity - > CreateComponentByInterfaceID ( CryGUID : : Construct ( guidHipart , guidLopart ) ) ) ; <nl> <nl> if ( pComponent ! = nullptr ) <nl> { <nl> static MonoInternals : : MonoObject * GetOrCreateComponent ( IEntity * pEntity , uint64 <nl> CManagedEntityComponent * pComponent = static_cast < CManagedEntityComponent * > ( pEntity - > GetComponentByTypeId ( id ) ) ; <nl> if ( pComponent = = nullptr ) <nl> { <nl> - pComponent = static_cast < CManagedEntityComponent * > ( pEntity - > AddComponent ( id , std : : shared_ptr < IEntityComponent > ( ) , false , nullptr ) ) ; <nl> + pComponent = static_cast < CManagedEntityComponent * > ( pEntity - > CreateComponentByInterfaceID ( id , false ) ) ; <nl> } <nl> <nl> return pComponent - > GetObject ( ) - > GetManagedObject ( ) ; <nl> mmm a / Code / CryPlugins / CryDefaultEntities / Module / StdAfx . h <nl> ppp b / Code / CryPlugins / CryDefaultEntities / Module / StdAfx . h <nl> static IEntityClass * RegisterEntityWithDefaultComponent ( const char * name , const <nl> { <nl> static IEntityComponent * Create ( IEntity * pEntity , SEntitySpawnParams & params , void * pUserData ) <nl> { <nl> - return pEntity - > CreateComponentClass < T > ( ) ; <nl> + return pEntity - > GetOrCreateComponentClass < T > ( ) ; <nl> } <nl> } ; <nl> <nl> mmm a / Code / GameSDK / GameDll / Boids / Flock . cpp <nl> ppp b / Code / GameSDK / GameDll / Boids / Flock . cpp <nl> bool CFlock : : CreateEntities ( ) <nl> boid - > m_noentity = false ; <nl> boid - > m_entity = pBoidEntity - > GetId ( ) ; <nl> <nl> - auto pBoidObjectProxy = pBoidEntity - > CreateComponent < CBoidObjectProxy > ( ) ; <nl> + auto pBoidObjectProxy = pBoidEntity - > GetOrCreateComponent < CBoidObjectProxy > ( ) ; <nl> pBoidObjectProxy - > SetBoid ( boid ) ; <nl> <nl> / / check if character . <nl> mmm a / Code / GameSDK / GameDll / GameFactory . cpp <nl> ppp b / Code / GameSDK / GameDll / GameFactory . cpp <nl> struct C # # name # # Creator : public IGameObjectExtensionCreatorBase \ <nl> { \ <nl> IGameObjectExtension * Create ( IEntity * pEntity ) \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < C # # name > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < C # # name > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) \ <nl> { \ <nl> struct C # # name # # Creator : public IGameObjectExtensionCreatorBase \ <nl> { \ <nl> IGameObjectExtension * Create ( IEntity * pEntity ) \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < C # # impl > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < C # # impl > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) \ <nl> { \ <nl> struct C # # name # # Creator : public IGameObjectExtensionCreatorBase \ <nl> { \ <nl> IGameObjectExtension * Create ( IEntity * pEntity ) \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < C # # name > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < C # # name > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) \ <nl> { \ <nl> mmm a / Code / GameSDK / GameDll / ItemResource . cpp <nl> ppp b / Code / GameSDK / GameDll / ItemResource . cpp <nl> IEntityAudioComponent * CItem : : GetAudioProxy ( bool create ) <nl> IEntityAudioComponent * pIEntityAudioComponent = GetEntity ( ) - > GetComponent < IEntityAudioComponent > ( ) ; <nl> <nl> if ( ! pIEntityAudioComponent & & create ) <nl> - pIEntityAudioComponent = GetEntity ( ) - > CreateComponent < IEntityAudioComponent > ( ) ; <nl> + pIEntityAudioComponent = GetEntity ( ) - > GetOrCreateComponent < IEntityAudioComponent > ( ) ; <nl> <nl> return pIEntityAudioComponent ; <nl> } <nl> mmm a / Code / GameSDK / GameDll / WeaponSystem . cpp <nl> ppp b / Code / GameSDK / GameDll / WeaponSystem . cpp <nl> struct C # # name # # Creator : public IGameObjectExtensionCreatorBase \ <nl> { \ <nl> IGameObjectExtension * Create ( IEntity * pEntity ) \ <nl> { \ <nl> - return pEntity - > CreateComponentClass < T > ( ) ; \ <nl> + return pEntity - > GetOrCreateComponentClass < T > ( ) ; \ <nl> } \ <nl> void GetGameObjectExtensionRMIData ( void * * ppRMI , size_t * nCount ) \ <nl> { \ <nl> | ! T ( CryEntitySystem ) Implement component unit tests to avoid regressions of older bugs that keep popping up | CRYTEK/CRYENGINE | 5ac24508e73da5dfe4b4cf9cbf31a37ee6cdee2f | 2017-07-03T15:45:03Z |
mmm a / cores / esp8266 / Esp . cpp <nl> ppp b / cores / esp8266 / Esp . cpp <nl> EspClass ESP ; <nl> <nl> void EspClass : : wdtEnable ( uint32_t timeout_ms ) <nl> { <nl> + / / / This API can only be called if software watchdog is stopped <nl> + system_soft_wdt_restart ( ) ; <nl> } <nl> <nl> void EspClass : : wdtEnable ( WDTO_t timeout_ms ) <nl> { <nl> + wdtEnable ( ( uint32_t ) timeout_ms ) ; <nl> } <nl> <nl> void EspClass : : wdtDisable ( void ) <nl> { <nl> + / / / Please don ’ t stop software watchdog too long ( less than 6 seconds ) , <nl> + / / / otherwise it will trigger hardware watchdog reset . <nl> + system_soft_wdt_stop ( ) ; <nl> } <nl> <nl> void EspClass : : wdtFeed ( void ) <nl> { <nl> + <nl> } <nl> <nl> void EspClass : : deepSleep ( uint32_t time_us , WakeMode mode ) <nl> mmm a / libraries / ESP8266WiFi / src / ESP8266WiFi . cpp <nl> ppp b / libraries / ESP8266WiFi / src / ESP8266WiFi . cpp <nl> void ESP8266WiFiClass : : beginSmartConfig ( ) <nl> _smartConfigDone = false ; <nl> <nl> / / SC_TYPE_ESPTOUCH use ESPTOUCH for smartconfig , or use SC_TYPE_AIRKISS for AIRKISS <nl> - smartconfig_start ( SC_TYPE_ESPTOUCH , reinterpret_cast < sc_callback_t > ( & ESP8266WiFiClass : : _smartConfigCallback ) , 1 ) ; <nl> + smartconfig_start ( reinterpret_cast < sc_callback_t > ( & ESP8266WiFiClass : : _smartConfigCallback ) , 1 ) ; <nl> } <nl> <nl> void ESP8266WiFiClass : : stopSmartConfig ( ) <nl> mmm a / platform . txt <nl> ppp b / platform . txt <nl> compiler . S . flags = - c - g - x assembler - with - cpp - MMD <nl> compiler . c . elf . flags = - g - Os - nostdlib - Wl , - - no - check - sections - u call_user_start - Wl , - static " - L { compiler . sdk . path } / lib " " - L { compiler . sdk . path } / ld " " - T { build . flash_ld } " - Wl , - wrap , system_restart_local - Wl , - wrap , register_chipv6_phy <nl> <nl> compiler . c . elf . cmd = xtensa - lx106 - elf - gcc <nl> - compiler . c . elf . libs = - lm - lgcc - lhal - lphy - lnet80211 - llwip - lwpa - lmain - lpp - lsmartconfig <nl> + compiler . c . elf . libs = - lm - lgcc - lhal - lphy - lnet80211 - llwip - lwpa - lmain - lpp - lsmartconfig - lwps <nl> <nl> compiler . cpp . cmd = xtensa - lx106 - elf - g + + <nl> compiler . cpp . flags = - c - Os - g - mlongcalls - mtext - section - literals - fno - exceptions - fno - rtti - falign - functions = 4 - std = c + + 11 - MMD <nl> mmm a / tools / sdk / changelog . txt <nl> ppp b / tools / sdk / changelog . txt <nl> <nl> + esp_iot_sdk_v1 . 2 . 0_15_07_03 Release Note <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Resolved Issues(Bugs below are eligible for Bug Bounty Program ) : <nl> + 1 . TLS server disconnect to ESP8266 may cause crash . [ å ™ æ – ° è ™ Ž ] <nl> + <nl> + Optimization : <nl> + 1 . Update SmartConfig to version 2 . 4 , corresponding to ESPTOUCH APP v0 . 3 . 4 ( https : / / github . com / EspressifApp / ) , delete parameter " sc_type type " in smartconfig_start , SmartConfig type can be got automatically . <nl> + 2 . Add parameter " sint16 freq_offset ; " in structure " bss_info " to get AP ' s frequency offset . <nl> + 3 . Folder " ld " is updated , please use the latest one ( \ esp_iot_sdk_v1 . 2 . 0 \ ld ) <nl> + 4 . Add UDP transparent transmission example in documentation " 4B - ESP8266__AT Command Examples " <nl> + 5 . Revise the scan issue that may cause Wi - Fi connection break . <nl> + 6 . Add ESP - NOW function , more details in " Add APIs " <nl> + 7 . Add WPS function , more details in " Add APIs " <nl> + 8 . Fixed a DNS fail issue with special router <nl> + 9 . Optimize espconn , revise issues below : <nl> + ( 1 ) enter sent callback late in UDP transmission <nl> + ( 2 ) TCP shakehand may fail issue <nl> + ( 3 ) SSL connection fail may cause crash <nl> + ( 4 ) optimize SSL error handler <nl> + 10 . Memory optimization <nl> + <nl> + Add APIs : <nl> + 1 . ESP - NOW APIs <nl> + esp_now_init : init ESP - NOW function <nl> + esp_now_deinit : deinit ESP - NOW function <nl> + esp_now_register_recv_cb : register ESP - NOW receive callback <nl> + esp_now_unregister_recv_cb : unregister ESP - NOW receive callback <nl> + esp_now_send : send ESP - NOW packet <nl> + esp_now_add_peer : add an ESP - NOW peer <nl> + esp_now_del_peer : delete an ESP - NOW peer <nl> + esp_now_set_self_role : set ESP - NOW role of device itself <nl> + esp_now_get_self_role : get ESP - NOW role of device itself <nl> + esp_now_set_peer_role : set ESP - NOW role about another device <nl> + esp_now_get_peer_role : get ESP - NOW role about another device <nl> + esp_now_set_peer_key : set ESP - NOW key of a device <nl> + esp_now_get_peer_key : get ESP - NOW key of a device <nl> + <nl> + 2 . WPS APIs <nl> + wifi_wps_enable : enable WPS function <nl> + wifi_wps_disable : disable WPS function <nl> + wifi_wps_start : start WPS communication <nl> + wifi_set_wps_cb : set WPS callback <nl> + <nl> + 3 . software watchdog APIs <nl> + system_soft_wdt_stop : stop software watchdog <nl> + system_soft_wdt_restart : restart software watchdog <nl> + <nl> + 4 . sntp_get_timezone : get SNTP timezone <nl> + <nl> + AT_v0 . 30 Release Note : <nl> + Note : For AT firmware to support FOTA , flash size need to be 1024KB or more than that . <nl> + <nl> + 1 . Command " AT + CWSTARTSMART " need not parameter any more , SmartConfig type can be got automatically . <nl> + 2 . AP ' s frequency offset can be got by command " AT + CWLAP " <nl> + 3 . Memory optimization <nl> + <nl> + <nl> + <nl> + <nl> esp_iot_sdk_1 . 1 . 2_15_06_25_p2 Release Note <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> mmm a / tools / sdk / include / eagle_soc . h <nl> ppp b / tools / sdk / include / eagle_soc . h <nl> <nl> <nl> # define PIN_PULLUP_DIS ( PIN_NAME ) CLEAR_PERI_REG_MASK ( PIN_NAME , PERIPHS_IO_MUX_PULLUP ) <nl> # define PIN_PULLUP_EN ( PIN_NAME ) SET_PERI_REG_MASK ( PIN_NAME , PERIPHS_IO_MUX_PULLUP ) <nl> - # define PIN_PULLDWN_DIS ( PIN_NAME ) CLEAR_PERI_REG_MASK ( PIN_NAME , PERIPHS_IO_MUX_PULLDWN ) <nl> - # define PIN_PULLDWN_EN ( PIN_NAME ) SET_PERI_REG_MASK ( PIN_NAME , PERIPHS_IO_MUX_PULLDWN ) <nl> # define PIN_FUNC_SELECT ( PIN_NAME , FUNC ) do { \ <nl> - CLEAR_PERI_REG_MASK ( PIN_NAME , ( PERIPHS_IO_MUX_FUNC < < PERIPHS_IO_MUX_FUNC_S ) ) ; \ <nl> - SET_PERI_REG_MASK ( PIN_NAME , ( ( ( FUNC & BIT2 ) < < 2 ) | ( FUNC & 0x3 ) ) < < PERIPHS_IO_MUX_FUNC_S ) ; \ <nl> + WRITE_PERI_REG ( PIN_NAME , \ <nl> + READ_PERI_REG ( PIN_NAME ) \ <nl> + & ( ~ ( PERIPHS_IO_MUX_FUNC < < PERIPHS_IO_MUX_FUNC_S ) ) \ <nl> + | ( ( ( ( FUNC & BIT2 ) < < 2 ) | ( FUNC & 0x3 ) ) < < PERIPHS_IO_MUX_FUNC_S ) ) ; \ <nl> } while ( 0 ) <nl> <nl> / / } } <nl> new file mode 100644 <nl> index 0000000000 . . 8eeb65c121 <nl> mmm / dev / null <nl> ppp b / tools / sdk / include / espnow . h <nl> <nl> + / * <nl> + * Copyright ( C ) 2015 - 2018 Espressif System <nl> + * <nl> + * / <nl> + <nl> + # ifndef __ESPNOW_H__ <nl> + # define __ESPNOW_H__ <nl> + <nl> + enum esp_now_role { <nl> + ESP_NOW_ROLE_IDLE = 0 , <nl> + ESP_NOW_ROLE_CONTROLLER , <nl> + ESP_NOW_ROLE_SLAVE , <nl> + ESP_NOW_ROLE_MAX , <nl> + } ; <nl> + <nl> + typedef void ( * esp_now_cb_t ) ( u8 * mac_addr , u8 * data , u8 len ) ; <nl> + <nl> + int esp_now_init ( void ) ; <nl> + int esp_now_deinit ( void ) ; <nl> + <nl> + int esp_now_register_recv_cb ( esp_now_cb_t cb ) ; <nl> + int esp_now_unregister_recv_cb ( void ) ; <nl> + <nl> + int esp_now_send ( u8 * da , u8 * data , int len ) ; <nl> + <nl> + int esp_now_add_peer ( u8 * mac_addr , u8 role , u8 channel , u8 * key , u8 key_len ) ; <nl> + int esp_now_del_peer ( u8 * mac_addr ) ; <nl> + <nl> + int esp_now_set_self_role ( u8 role ) ; <nl> + int esp_now_get_self_role ( void ) ; <nl> + <nl> + int esp_now_set_peer_role ( u8 * mac_addr , u8 role ) ; <nl> + int esp_now_get_peer_role ( u8 * mac_addr ) ; <nl> + <nl> + int esp_now_set_peer_channel ( u8 * mac_addr , u8 channel ) ; <nl> + int esp_now_get_peer_channel ( u8 * mac_addr ) ; <nl> + <nl> + int esp_now_set_peer_key ( u8 * mac_addr , u8 * key , u8 key_len ) ; <nl> + int esp_now_get_peer_key ( u8 * mac_addr , u8 * key , u8 * key_len ) ; <nl> + <nl> + u8 * esp_now_fetch_peer ( bool restart ) ; <nl> + <nl> + int esp_now_is_peer_exist ( u8 * mac_addr ) ; <nl> + <nl> + int esp_now_get_cnt_info ( u8 * all_cnt , u8 * encrypt_cnt ) ; <nl> + <nl> + # endif <nl> mmm a / tools / sdk / include / ets_sys . h <nl> ppp b / tools / sdk / include / ets_sys . h <nl> inline uint32_t ETS_INTR_PENDING ( void ) <nl> # define ETS_FRC_TIMER1_NMI_INTR_ATTACH ( func ) \ <nl> NmiTimSetFunc ( func ) <nl> <nl> - # define ETS_FRC1_INTR_ENABLE ( ) \ <nl> - ETS_INTR_ENABLE ( ETS_FRC_TIMER1_INUM ) <nl> - <nl> - # define ETS_FRC1_INTR_DISABLE ( ) \ <nl> - ETS_INTR_DISABLE ( ETS_FRC_TIMER1_INUM ) <nl> - <nl> - <nl> # define ETS_GPIO_INTR_ATTACH ( func , arg ) \ <nl> ets_isr_attach ( ETS_GPIO_INUM , ( int_handler_t ) ( func ) , ( void * ) ( arg ) ) <nl> <nl> inline uint32_t ETS_INTR_PENDING ( void ) <nl> # define ETS_UART_INTR_DISABLE ( ) \ <nl> ETS_INTR_DISABLE ( ETS_UART_INUM ) <nl> <nl> + # define ETS_FRC1_INTR_ENABLE ( ) \ <nl> + ETS_INTR_ENABLE ( ETS_FRC_TIMER1_INUM ) <nl> + <nl> + # define ETS_FRC1_INTR_DISABLE ( ) \ <nl> + ETS_INTR_DISABLE ( ETS_FRC_TIMER1_INUM ) <nl> + <nl> <nl> # define ETS_SPI_INTR_ATTACH ( func , arg ) \ <nl> ets_isr_attach ( ETS_SPI_INUM , ( int_handler_t ) ( func ) , ( void * ) ( arg ) ) <nl> new file mode 100644 <nl> index 0000000000 . . 501a5fe7fb <nl> mmm / dev / null <nl> ppp b / tools / sdk / include / pwm . h <nl> <nl> + # ifndef __PWM_H__ <nl> + # define __PWM_H__ <nl> + <nl> + / * pwm . h : function and macro definition of PWM API , driver level * / <nl> + / * user_light . h : user interface for light API , user level * / <nl> + / * user_light_adj : API for color changing and lighting effects , user level * / <nl> + <nl> + <nl> + / * NOTE ! ! : DO NOT CHANGE THIS FILE * / <nl> + <nl> + / * SUPPORT UP TO 8 PWM CHANNEL * / <nl> + # define PWM_CHANNEL_NUM_MAX 8 <nl> + <nl> + struct pwm_param { <nl> + uint32 period ; <nl> + uint32 freq ; <nl> + uint32 duty [ PWM_CHANNEL_NUM_MAX ] ; / / PWM_CHANNEL < = 8 <nl> + } ; <nl> + <nl> + <nl> + / * pwm_init should be called only once , for now * / <nl> + void pwm_init ( uint32 period , uint32 * duty , uint32 pwm_channel_num , uint32 ( * pin_info_list ) [ 3 ] ) ; <nl> + void pwm_start ( void ) ; <nl> + <nl> + void pwm_set_duty ( uint32 duty , uint8 channel ) ; <nl> + uint32 pwm_get_duty ( uint8 channel ) ; <nl> + void pwm_set_period ( uint32 period ) ; <nl> + uint32 pwm_get_period ( void ) ; <nl> + <nl> + uint32 get_pwm_version ( void ) ; <nl> + void set_pwm_debug_en ( uint8 print_en ) ; <nl> + <nl> + # endif <nl> + <nl> mmm a / tools / sdk / include / smartconfig . h <nl> ppp b / tools / sdk / include / smartconfig . h <nl> typedef enum { <nl> typedef void ( * sc_callback_t ) ( sc_status status , void * pdata ) ; <nl> <nl> const char * smartconfig_get_version ( void ) ; <nl> - bool smartconfig_start ( sc_type type , sc_callback_t cb , . . . ) ; <nl> + bool smartconfig_start ( sc_callback_t cb , . . . ) ; <nl> bool smartconfig_stop ( void ) ; <nl> bool esptouch_set_timeout ( uint8 time_s ) ; / / 15s ~ 255s , offset : 45s <nl> <nl> mmm a / tools / sdk / include / sntp . h <nl> ppp b / tools / sdk / include / sntp . h <nl> uint32 sntp_get_current_timestamp ( ) ; <nl> * get real time ( GTM + 8 time zone ) <nl> * / <nl> char * sntp_get_real_time ( long t ) ; <nl> + / * * <nl> + * SNTP get time_zone default GMT + 8 <nl> + * / <nl> + sint8 sntp_get_timezone ( void ) ; <nl> / * * <nl> * SNTP set time_zone ( default GMT + 8 ) <nl> * / <nl> mmm a / tools / sdk / include / user_interface . h <nl> ppp b / tools / sdk / include / user_interface . h <nl> void system_phy_set_rfoption ( uint8 option ) ; <nl> bool system_param_save_with_protect ( uint16 start_sec , void * param , uint16 len ) ; <nl> bool system_param_load ( uint16 start_sec , uint16 offset , void * param , uint16 len ) ; <nl> <nl> + void system_soft_wdt_stop ( void ) ; <nl> + void system_soft_wdt_restart ( void ) ; <nl> + <nl> # define NULL_MODE 0x00 <nl> # define STATION_MODE 0x01 <nl> # define SOFTAP_MODE 0x02 <nl> struct bss_info { <nl> sint8 rssi ; <nl> AUTH_MODE authmode ; <nl> uint8 is_hidden ; <nl> + sint16 freq_offset ; <nl> } ; <nl> <nl> typedef struct _scaninfo { <nl> bool wifi_station_dhcpc_start ( void ) ; <nl> bool wifi_station_dhcpc_stop ( void ) ; <nl> enum dhcp_status wifi_station_dhcpc_status ( void ) ; <nl> <nl> + char * wifi_station_get_hostname ( void ) ; <nl> + bool wifi_station_set_hostname ( char * name ) ; <nl> + <nl> struct softap_config { <nl> uint8 ssid [ 32 ] ; <nl> uint8 password [ 64 ] ; <nl> typedef void ( * wifi_event_handler_cb_t ) ( System_Event_t * event ) ; <nl> <nl> void wifi_set_event_handler_cb ( wifi_event_handler_cb_t cb ) ; <nl> <nl> + typedef enum wps_type { <nl> + WPS_TYPE_DISABLE = 0 , <nl> + WPS_TYPE_PBC , <nl> + WPS_TYPE_PIN , <nl> + WPS_TYPE_DISPLAY , <nl> + WPS_TYPE_MAX , <nl> + } WPS_TYPE_t ; <nl> + <nl> + enum wps_cb_status { <nl> + WPS_CB_ST_SUCCESS = 0 , <nl> + WPS_CB_ST_FAILED , <nl> + WPS_CB_ST_TIMEOUT , <nl> + } ; <nl> + <nl> + bool wifi_wps_enable ( WPS_TYPE_t wps_type ) ; <nl> + bool wifi_wps_disable ( void ) ; <nl> + bool wifi_wps_start ( void ) ; <nl> + <nl> + typedef void ( * wps_st_cb_t ) ( int status ) ; <nl> + bool wifi_set_wps_cb ( wps_st_cb_t cb ) ; <nl> + <nl> # endif <nl> new file mode 100644 <nl> index 0000000000 . . f37884c3ef <nl> Binary files / dev / null and b / tools / sdk / lib / libat . a differ <nl> new file mode 100644 <nl> index 0000000000 . . 5e2b7e31ed <nl> Binary files / dev / null and b / tools / sdk / lib / libcrypto . a differ <nl> new file mode 100644 <nl> index 0000000000 . . ffa483b9e6 <nl> Binary files / dev / null and b / tools / sdk / lib / libespnow . a differ <nl> Binary files a / tools / sdk / lib / libjson . a and b / tools / sdk / lib / libjson . a differ <nl> Binary files a / tools / sdk / lib / liblwip . a and b / tools / sdk / lib / liblwip . a differ <nl> new file mode 100644 <nl> index 0000000000 . . 7d8b56536a <nl> Binary files / dev / null and b / tools / sdk / lib / liblwip_536 . a differ <nl> Binary files a / tools / sdk / lib / libmain . a and b / tools / sdk / lib / libmain . a differ <nl> Binary files a / tools / sdk / lib / libnet80211 . a and b / tools / sdk / lib / libnet80211 . a differ <nl> Binary files a / tools / sdk / lib / libpp . a and b / tools / sdk / lib / libpp . a differ <nl> new file mode 100644 <nl> index 0000000000 . . 1913f1604e <nl> Binary files / dev / null and b / tools / sdk / lib / libpwm . a differ <nl> Binary files a / tools / sdk / lib / libsmartconfig . a and b / tools / sdk / lib / libsmartconfig . a differ <nl> Binary files a / tools / sdk / lib / libssl . a and b / tools / sdk / lib / libssl . a differ <nl> Binary files a / tools / sdk / lib / libupgrade . a and b / tools / sdk / lib / libupgrade . a differ <nl> Binary files a / tools / sdk / lib / libwpa . a and b / tools / sdk / lib / libwpa . a differ <nl> new file mode 100644 <nl> index 0000000000 . . 37e21ab97d <nl> Binary files / dev / null and b / tools / sdk / lib / libwps . a differ <nl> mmm a / tools / sdk / version <nl> ppp b / tools / sdk / version <nl> @ @ - 1 + 1 @ @ <nl> - 1 . 1 . 2_15_06_25_p2 <nl> \ No newline at end of file <nl> + 1 . 2 . 0_15_07_03 <nl> \ No newline at end of file <nl> | update SDK to v1 . 2 . 0_15_07_03 | esp8266/Arduino | c77fbb23831de303bdf46c5e461504bed5bdffdb | 2015-07-04T07:45:05Z |
mmm a / utils / GYBUnicodeDataUtils . py <nl> ppp b / utils / GYBUnicodeDataUtils . py <nl> class GraphemeClusterBreakPropertyTable ( UnicodeProperty ) : <nl> ' LVT ' : 12 , <nl> } <nl> <nl> - symbolic_values = [ <nl> - ' Other ' , ' CR ' , ' LF ' , ' Control ' , ' Extend ' , ' Regional_Indicator ' , <nl> - ' Prepend ' , ' SpacingMark ' , ' L ' , ' V ' , ' T ' , ' LV ' , ' LVT ' , <nl> - ] <nl> - <nl> def __init__ ( self , grapheme_break_property_file_name ) : <nl> + # Build ' self . symbolic_values ' - - an array that maps numeric property <nl> + # values to symbolic values . <nl> + self . symbolic_values = \ <nl> + [ None ] * ( max ( self . numeric_value_table . values ( ) ) + 1 ) <nl> + for k , v in self . numeric_value_table . iteritems ( ) : <nl> + self . symbolic_values [ v ] = k <nl> + <nl> # Load the data file . <nl> with open ( grapheme_break_property_file_name , ' rb ' ) as f : <nl> for line in f : <nl> | Unicode tables : DRY in GraphemeClusterBreakPropertyTable . symbolic_values | apple/swift | ff37a42920db06f9853dd2c188cd9b35bd869242 | 2014-07-01T13:18:24Z |
mmm a / pycaffe2 / caffe2_python . cc <nl> ppp b / pycaffe2 / caffe2_python . cc <nl> <nl> # include < memory > <nl> # include < set > <nl> # include < string > <nl> + # include < sstream > <nl> # include < vector > <nl> <nl> # include " caffe2 / core / context . h " <nl> PyObject * FetchBlob ( PyObject * self , PyObject * args ) { <nl> } <nl> } <nl> # endif / / ! PYCAFFE2_CPU_ONLY <nl> - <nl> - / / If all branches failed , we should throw an error . <nl> - CAFFE_LOG_ERROR < < " Blob " < < caffe2 : : string ( name ) <nl> - < < " has unsupported data type : " <nl> - < < blob . TypeName ( ) ; <nl> - PyErr_SetString ( PyExc_TypeError , " Unsupported data type . " ) ; <nl> - return NULL ; <nl> + / / If all branches failed , we will return a metainfo string . <nl> + std : : stringstream ss ; <nl> + ss < < caffe2 : : string ( name ) < < " , a C + + native class of type " <nl> + < < blob . TypeName ( ) < < " . " ; <nl> + return StdStringToPyString ( ss . str ( ) ) ; <nl> } <nl> <nl> PyObject * FeedBlob ( PyObject * self , PyObject * args ) { <nl> | elegant fetchblob | pytorch/pytorch | 457ef79c70034b304022f4747c96db9b8fa272c6 | 2015-10-31T16:55:29Z |
mmm a / flow / ActorCollection . actor . cpp <nl> ppp b / flow / ActorCollection . actor . cpp <nl> TEST_CASE ( " / flow / TraceEvent " ) { <nl> wait ( delay ( 0 ) ) ; <nl> } <nl> TraceEvent ( " TraceDuration " ) <nl> - . detail ( " Time " , g_network - > now ( ) - startTime ) ; <nl> + . detail ( " Duration " , g_network - > now ( ) - startTime ) ; <nl> startTime = g_network - > now ( ) ; <nl> for ( i = 0 ; i < 1000000 ; + + i ) { <nl> for ( unsigned j = 0 ; j < 100 ; + + j ) { <nl> TEST_CASE ( " / flow / TraceEvent " ) { <nl> wait ( delay ( 0 ) ) ; <nl> } <nl> TraceEvent ( " TraceDuration " ) <nl> - . detail ( " Time " , g_network - > now ( ) - startTime ) ; <nl> + . detail ( " Duration " , g_network - > now ( ) - startTime ) ; <nl> printf ( " benchmark done \ n " ) ; <nl> wait ( delay ( 10 ) ) ; <nl> return Void ( ) ; <nl> | Rename trace event field to avoid duplicating ' Time ' field . | apple/foundationdb | 8e1927a5cba9f7c7317f89cba0960d9b2ff400d8 | 2019-05-13T20:25:01Z |
mmm a / examples / Linalg / Linalg1 / Conversion . cpp <nl> ppp b / examples / Linalg / Linalg1 / Conversion . cpp <nl> TEST_FUNC ( viewRangeConversion ) { <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 2 = llvm . insertvalue % 1 , % 0 [ 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 3 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 4 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 3 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 6 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 4 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 3 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 6 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 7 = llvm . extractvalue % arg1 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 8 = llvm . mul % 7 , % 5 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 9 = llvm . add % 6 , % 8 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 8 = llvm . mul % 7 , % 5 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 9 = llvm . add % 6 , % 8 : ! llvm . i64 <nl> / / CHECK - NEXT : % 10 = llvm . extractvalue % arg2 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 11 = llvm . mul % 10 , % 4 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 12 = llvm . add % 9 , % 11 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 11 = llvm . mul % 10 , % 4 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 12 = llvm . add % 9 , % 11 : ! llvm . i64 <nl> / / CHECK - NEXT : % 13 = llvm . insertvalue % 12 , % 2 [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 14 = llvm . extractvalue % arg1 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> / / CHECK - NEXT : % 15 = llvm . extractvalue % arg1 [ 1 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 16 = llvm . sub % 15 , % 14 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 16 = llvm . sub % 15 , % 14 : ! llvm . i64 <nl> / / CHECK - NEXT : % 17 = llvm . insertvalue % 16 , % 13 [ 2 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 18 = llvm . extractvalue % arg2 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> / / CHECK - NEXT : % 19 = llvm . extractvalue % arg2 [ 1 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 20 = llvm . sub % 19 , % 18 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 20 = llvm . sub % 19 , % 18 : ! llvm . i64 <nl> / / CHECK - NEXT : % 21 = llvm . insertvalue % 20 , % 17 [ 2 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 22 = llvm . extractvalue % arg1 [ 2 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 23 = llvm . mul % 5 , % 22 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 23 = llvm . mul % 5 , % 22 : ! llvm . i64 <nl> / / CHECK - NEXT : % 24 = llvm . insertvalue % 23 , % 21 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 25 = llvm . extractvalue % arg2 [ 2 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 26 = llvm . mul % 4 , % 25 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 26 = llvm . mul % 4 , % 25 : ! llvm . i64 <nl> / / CHECK - NEXT : % 27 = llvm . insertvalue % 26 , % 24 [ 3 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / clang - format on <nl> convertToLLVM ( module ) ; <nl> TEST_FUNC ( viewNonRangeConversion ) { <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 2 = llvm . insertvalue % 1 , % 0 [ 0 ] : ! llvm < " { float * , i64 , [ 1 x i64 ] , [ 1 x i64 ] } " > <nl> / / CHECK - NEXT : % 3 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 4 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 3 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 6 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 4 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 3 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 6 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 7 = llvm . extractvalue % arg1 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 8 = llvm . mul % 7 , % 5 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 9 = llvm . add % 6 , % 8 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 10 = llvm . mul % arg2 , % 4 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 11 = llvm . add % 9 , % 10 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 8 = llvm . mul % 7 , % 5 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 9 = llvm . add % 6 , % 8 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 10 = llvm . mul % arg2 , % 4 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 11 = llvm . add % 9 , % 10 : ! llvm . i64 <nl> / / CHECK - NEXT : % 12 = llvm . insertvalue % 11 , % 2 [ 1 ] : ! llvm < " { float * , i64 , [ 1 x i64 ] , [ 1 x i64 ] } " > <nl> / / CHECK - NEXT : % 13 = llvm . extractvalue % arg1 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> / / CHECK - NEXT : % 14 = llvm . extractvalue % arg1 [ 1 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 15 = llvm . sub % 14 , % 13 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 15 = llvm . sub % 14 , % 13 : ! llvm . i64 <nl> / / CHECK - NEXT : % 16 = llvm . insertvalue % 15 , % 12 [ 2 , 0 ] : ! llvm < " { float * , i64 , [ 1 x i64 ] , [ 1 x i64 ] } " > <nl> / / CHECK - NEXT : % 17 = llvm . extractvalue % arg1 [ 2 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 18 = llvm . mul % 5 , % 17 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 18 = llvm . mul % 5 , % 17 : ! llvm . i64 <nl> / / CHECK - NEXT : % 19 = llvm . insertvalue % 18 , % 16 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 1 x i64 ] , [ 1 x i64 ] } " > <nl> / / clang - format on <nl> convertToLLVM ( module ) ; <nl> TEST_FUNC ( sliceRangeConversion ) { <nl> / / CHECK - NEXT : % 31 = llvm . extractvalue % 27 [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 32 = llvm . extractvalue % arg3 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> / / CHECK - NEXT : % 33 = llvm . extractvalue % 27 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : % 34 = llvm . mul % 32 , % 33 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 35 = llvm . add % 31 , % 34 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 34 = llvm . mul % 32 , % 33 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 35 = llvm . add % 31 , % 34 : ! llvm . i64 <nl> / / CHECK - NEXT : % 36 = llvm . insertvalue % 35 , % 30 [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 37 = llvm . extractvalue % arg3 [ 1 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> / / CHECK - NEXT : % 38 = llvm . extractvalue % arg3 [ 0 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 39 = llvm . sub % 37 , % 38 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 39 = llvm . sub % 37 , % 38 : ! llvm . i64 <nl> / / CHECK - NEXT : % 40 = llvm . extractvalue % 27 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 41 = llvm . extractvalue % arg3 [ 2 ] : ! llvm < " { i64 , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 42 = llvm . mul % 40 , % 41 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 42 = llvm . mul % 40 , % 41 : ! llvm . i64 <nl> / / CHECK - NEXT : % 43 = llvm . insertvalue % 39 , % 36 [ 2 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 44 = llvm . insertvalue % 42 , % 43 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 45 = llvm . extractvalue % 27 [ 2 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> TEST_FUNC ( sliceNonRangeConversion ) { <nl> / / ! llvm < " { float * , i64 , [ 1 x i64 ] , [ 1 x i64 ] } " > CHECK - NEXT : % 31 = <nl> / / llvm . extractvalue % 27 [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : % 32 = llvm . extractvalue % 27 [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x <nl> - / / i64 ] , [ 2 x i64 ] } " > CHECK - NEXT : % 33 = llvm . mul % arg3 , % 32 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 34 = llvm . add % 31 , % 33 : ! llvm < " i64 " > <nl> + / / i64 ] , [ 2 x i64 ] } " > CHECK - NEXT : % 33 = llvm . mul % arg3 , % 32 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 34 = llvm . add % 31 , % 33 : ! llvm . i64 <nl> / / CHECK - NEXT : % 35 = llvm . insertvalue % 34 , % 30 [ 1 ] : ! llvm < " { float * , i64 , [ 1 x <nl> / / i64 ] , [ 1 x i64 ] } " > CHECK - NEXT : % 36 = llvm . extractvalue % 27 [ 2 , 1 ] : <nl> / / ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > CHECK - NEXT : % 37 = <nl> mmm a / examples / Linalg / Linalg1 / Example . cpp <nl> ppp b / examples / Linalg / Linalg1 / Example . cpp <nl> TEST_FUNC ( view_op ) { <nl> some_consumer ( { v0 , v1 , v2 } ) ; <nl> ret ( ) ; <nl> / / CHECK - LABEL : func @ view_op <nl> - / / CHECK : % [ [ R : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg < " range " > <nl> - / / CHECK - NEXT : { { . * } } = linalg . view { { . * } } [ ] : ! linalg < " view < f32 > " > <nl> + / / CHECK : % [ [ R : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg . range <nl> + / / CHECK - NEXT : { { . * } } = linalg . view { { . * } } [ ] : ! linalg . view < f32 > <nl> / / CHECK - NEXT : { { . * } } = linalg . view { { . * } } [ % [ [ R ] ] ] : ! linalg < " view < ? xf32 > " > <nl> / / CHECK - NEXT : { { . * } } = linalg . view { { . * } } [ % [ [ R ] ] , % [ [ R ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / clang - format on <nl> TEST_FUNC ( slice_op ) { <nl> / / CHECK : % [ [ ALLOC : . * ] ] = alloc ( % arg0 , % arg1 ) : memref < ? x ? xf32 > <nl> / / CHECK - NEXT : % [ [ M : . * ] ] = dim % 0 , 0 : memref < ? x ? xf32 > <nl> / / CHECK - NEXT : % [ [ N : . * ] ] = dim % 0 , 1 : memref < ? x ? xf32 > <nl> - / / CHECK - NEXT : % [ [ R1 : . * ] ] = linalg . range { { . * } } : % [ [ M ] ] : { { . * } } : ! linalg < " range " > <nl> - / / CHECK - NEXT : % [ [ R2 : . * ] ] = linalg . range { { . * } } : % [ [ N ] ] : { { . * } } : ! linalg < " range " > <nl> + / / CHECK - NEXT : % [ [ R1 : . * ] ] = linalg . range { { . * } } : % [ [ M ] ] : { { . * } } : ! linalg . range <nl> + / / CHECK - NEXT : % [ [ R2 : . * ] ] = linalg . range { { . * } } : % [ [ N ] ] : { { . * } } : ! linalg . range <nl> / / CHECK - NEXT : % [ [ V : . * ] ] = linalg . view % 0 [ % [ [ R1 ] ] , % [ [ R2 ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : for % i0 = 0 to ( d0 ) - > ( d0 ) ( % [ [ M ] ] ) { <nl> / / CHECK - NEXT : for % i1 = 0 to ( d0 ) - > ( d0 ) ( % [ [ N ] ] ) { <nl> / / CHECK - NEXT : % [ [ S1 : . * ] ] = linalg . slice % [ [ V ] ] [ * , % i0 ] : ! linalg < " view < ? xf32 > " > <nl> / / CHECK - NEXT : " some_consumer " ( % [ [ S1 ] ] ) : ( ! linalg < " view < ? xf32 > " > ) - > ( ) <nl> / / CHECK - NEXT : % [ [ S2 : . * ] ] = linalg . slice % [ [ V ] ] [ % i1 , * ] : ! linalg < " view < ? xf32 > " > <nl> - / / CHECK - NEXT : % [ [ S3 : . * ] ] = linalg . slice % [ [ S2 ] ] [ % i0 ] : ! linalg < " view < f32 > " > <nl> - / / CHECK - NEXT : " some_consumer " ( % [ [ S3 ] ] ) : ( ! linalg < " view < f32 > " > ) - > ( ) <nl> + / / CHECK - NEXT : % [ [ S3 : . * ] ] = linalg . slice % [ [ S2 ] ] [ % i0 ] : ! linalg . view < f32 > <nl> + / / CHECK - NEXT : " some_consumer " ( % [ [ S3 ] ] ) : ( ! linalg . view < f32 > ) - > ( ) <nl> / / clang - format on <nl> <nl> cleanupAndPrintFunction ( f ) ; <nl> mmm a / examples / Linalg / Linalg1 / lib / RangeOp . cpp <nl> ppp b / examples / Linalg / Linalg1 / lib / RangeOp . cpp <nl> bool linalg : : RangeOp : : parse ( OpAsmParser * parser , OperationState * result ) { <nl> / / A RangeOp prints as : <nl> / / <nl> / / ` ` ` { . mlir } <nl> - / / linalg . range % arg0 : % arg1 : % c42 : ! linalg < " range " > <nl> + / / linalg . range % arg0 : % arg1 : % c42 : ! linalg . range <nl> / / ` ` ` <nl> void linalg : : RangeOp : : print ( OpAsmPrinter * p ) { <nl> * p < < getOperationName ( ) < < " " < < * getMin ( ) < < " : " < < * getMax ( ) < < " : " <nl> mmm a / examples / Linalg / Linalg2 / Example . cpp <nl> ppp b / examples / Linalg / Linalg2 / Example . cpp <nl> TEST_FUNC ( linalg_ops ) { <nl> / / CHECK : { { . * } } = linalg . slice { { . * } } [ * , { { . * } } ] : ! linalg < " view < ? xf32 > " > <nl> / / CHECK - NEXT : { { . * } } = linalg . slice { { . * } } [ * , { { . * } } ] : ! linalg < " view < ? xf32 > " > <nl> / / CHECK - NEXT : { { . * } } = linalg . slice { { . * } } [ { { . * } } , * ] : ! linalg < " view < ? xf32 > " > <nl> - / / CHECK - NEXT : { { . * } } = linalg . slice { { . * } } [ { { . * } } ] : ! linalg < " view < f32 > " > <nl> + / / CHECK - NEXT : { { . * } } = linalg . slice { { . * } } [ { { . * } } ] : ! linalg . view < f32 > <nl> / / CHECK : linalg . matmul ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : linalg . matvec ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < ? xf32 > " > <nl> - / / CHECK - NEXT : linalg . dot ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < f32 > " > <nl> + / / CHECK - NEXT : linalg . dot ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg . view < f32 > <nl> / / clang - format on <nl> <nl> cleanupAndPrintFunction ( f ) ; <nl> TEST_FUNC ( linalg_ops_folded_slices ) { <nl> / / CHECK - NOT : linalg . slice <nl> / / CHECK : linalg . matmul ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : linalg . matvec ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < ? xf32 > " > <nl> - / / CHECK - NEXT : linalg . dot ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg < " view < f32 > " > <nl> + / / CHECK - NEXT : linalg . dot ( { { . * } } , { { . * } } , { { . * } } ) : ! linalg . view < f32 > <nl> / / clang - format on <nl> <nl> f - > walk < SliceOp > ( [ ] ( SliceOp slice ) { <nl> mmm a / examples / Linalg / Linalg3 / Conversion . cpp <nl> ppp b / examples / Linalg / Linalg3 / Conversion . cpp <nl> TEST_FUNC ( foo ) { <nl> / / clang - format off <nl> / / CHECK : { { . * } } = llvm . extractvalue { { . * } } [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : { { . * } } = llvm . load { { . * } } : ! llvm < " float * " > <nl> / / CHECK : { { . * } } = llvm . extractvalue { { . * } } [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : { { . * } } = llvm . load { { . * } } : ! llvm < " float * " > <nl> / / CHECK : % 159 = llvm . extractvalue { { . * } } [ 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 3 , 1 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . mul { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 0 ] : ! llvm < " { float * , i64 , [ 2 x i64 ] , [ 2 x i64 ] } " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . getelementptr { { . * } } [ { { . * } } ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : llvm . store { { . * } } , { { . * } } : ! llvm < " float * " > <nl> / / clang - format on <nl> module . print ( llvm : : outs ( ) ) ; <nl> mmm a / examples / Linalg / Linalg3 / Example . cpp <nl> ppp b / examples / Linalg / Linalg3 / Example . cpp <nl> TEST_FUNC ( matmul_as_dot ) { <nl> / / CHECK : % [ [ vB : . * ] ] = linalg . view % arg1 [ % { { . * } } , % { { . * } } ] : ! linalg < " view < ? xf32 > " > <nl> / / CHECK - NEXT : affine . for % i1 = 0 to ( d0 ) - > ( d0 ) ( % [ [ M ] ] ) { <nl> / / CHECK : % [ [ vA : . * ] ] = linalg . view % arg0 [ % { { . * } } , % { { . * } } ] : ! linalg < " view < ? xf32 > " > <nl> - / / CHECK - NEXT : % [ [ vC : . * ] ] = linalg . view % arg2 [ % { { . * } } , % { { . * } } ] : ! linalg < " view < f32 > " > <nl> - / / CHECK - NEXT : linalg . dot ( % [ [ vA ] ] , % [ [ vB ] ] , % [ [ vC ] ] ) : ! linalg < " view < f32 > " > <nl> + / / CHECK - NEXT : % [ [ vC : . * ] ] = linalg . view % arg2 [ % { { . * } } , % { { . * } } ] : ! linalg . view < f32 > <nl> + / / CHECK - NEXT : linalg . dot ( % [ [ vA ] ] , % [ [ vB ] ] , % [ [ vC ] ] ) : ! linalg . view < f32 > <nl> / / clang - format on <nl> cleanupAndPrintFunction ( f ) ; <nl> } <nl> TEST_FUNC ( matmul_as_loops ) { <nl> / / CHECK : % [ [ M : . * ] ] = dim % arg0 , 0 : memref < ? x ? xf32 > <nl> / / CHECK : % [ [ N : . * ] ] = dim % arg2 , 1 : memref < ? x ? xf32 > <nl> / / CHECK : % [ [ K : . * ] ] = dim % arg0 , 1 : memref < ? x ? xf32 > <nl> - / / CHECK : % [ [ rM : . * ] ] = linalg . range % c0 : % [ [ M ] ] : % c1 : ! linalg < " range " > <nl> - / / CHECK : % [ [ rN : . * ] ] = linalg . range % c0 : % [ [ N ] ] : % c1 : ! linalg < " range " > <nl> - / / CHECK : % [ [ rK : . * ] ] = linalg . range % c0 : % [ [ K ] ] : % c1 : ! linalg < " range " > <nl> + / / CHECK : % [ [ rM : . * ] ] = linalg . range % c0 : % [ [ M ] ] : % c1 : ! linalg . range <nl> + / / CHECK : % [ [ rN : . * ] ] = linalg . range % c0 : % [ [ N ] ] : % c1 : ! linalg . range <nl> + / / CHECK : % [ [ rK : . * ] ] = linalg . range % c0 : % [ [ K ] ] : % c1 : ! linalg . range <nl> / / CHECK : % [ [ vA : . * ] ] = linalg . view % arg0 [ % [ [ rM ] ] , % [ [ rK ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK : % [ [ vB : . * ] ] = linalg . view % arg1 [ % [ [ rK ] ] , % [ [ rN ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK : % [ [ vC : . * ] ] = linalg . view % arg2 [ % [ [ rM ] ] , % [ [ rN ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> mmm a / examples / Linalg / Linalg4 / Example . cpp <nl> ppp b / examples / Linalg / Linalg4 / Example . cpp <nl> TEST_FUNC ( matmul_tiled_views ) { <nl> / / CHECK - NEXT : affine . for % i1 = 0 to ( d0 ) - > ( d0 ) ( % [ [ N ] ] ) step 9 { <nl> / / CHECK - NEXT : % [ [ i0min : . * ] ] = affine . apply ( d0 ) - > ( d0 ) ( % i0 ) <nl> / / CHECK - NEXT : % [ [ i0max : . * ] ] = affine . apply ( d0 ) - > ( d0 + 8 ) ( % i0 ) <nl> - / / CHECK - NEXT : % [ [ ri0 : . * ] ] = linalg . range % [ [ i0min ] ] : % [ [ i0max ] ] : { { . * } } : ! linalg < " range " > <nl> - / / CHECK : % [ [ rK : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg < " range " > <nl> + / / CHECK - NEXT : % [ [ ri0 : . * ] ] = linalg . range % [ [ i0min ] ] : % [ [ i0max ] ] : { { . * } } : ! linalg . range <nl> + / / CHECK : % [ [ rK : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg . range <nl> / / CHECK : % [ [ vA : . * ] ] = linalg . view % arg0 [ % [ [ ri0 ] ] , % [ [ rK ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK : % [ [ i1min : . * ] ] = affine . apply ( d0 ) - > ( d0 ) ( % i1 ) <nl> / / CHECK - NEXT : % [ [ i1max : . * ] ] = affine . apply ( d0 ) - > ( d0 + 9 ) ( % i1 ) <nl> - / / CHECK - NEXT : % [ [ ri1 : . * ] ] = linalg . range % [ [ i1min ] ] : % [ [ i1max ] ] : % { { . * } } : ! linalg < " range " > <nl> + / / CHECK - NEXT : % [ [ ri1 : . * ] ] = linalg . range % [ [ i1min ] ] : % [ [ i1max ] ] : % { { . * } } : ! linalg . range <nl> / / CHECK - NEXT : % [ [ vB : . * ] ] = linalg . view % arg1 [ % 10 , % 13 ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : % [ [ vC : . * ] ] = linalg . view % arg2 [ % 5 , % 13 ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : linalg . matmul ( % [ [ vA ] ] , % [ [ vB ] ] , % [ [ vC ] ] ) : ! linalg < " view < ? x ? xf32 > " > <nl> TEST_FUNC ( matmul_tiled_views_as_loops ) { <nl> / / CHECK - NEXT : affine . for % i1 = 0 to ( d0 ) - > ( d0 ) ( % [ [ N ] ] ) step 9 { <nl> / / CHECK - NEXT : % [ [ i0min : . * ] ] = affine . apply ( d0 ) - > ( d0 ) ( % i0 ) <nl> / / CHECK - NEXT : % [ [ i0max : . * ] ] = affine . apply ( d0 ) - > ( d0 + 8 ) ( % i0 ) <nl> - / / CHECK - NEXT : % [ [ ri0 : . * ] ] = linalg . range % [ [ i0min ] ] : % [ [ i0max ] ] : { { . * } } : ! linalg < " range " > <nl> - / / CHECK : % [ [ rK : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg < " range " > <nl> + / / CHECK - NEXT : % [ [ ri0 : . * ] ] = linalg . range % [ [ i0min ] ] : % [ [ i0max ] ] : { { . * } } : ! linalg . range <nl> + / / CHECK : % [ [ rK : . * ] ] = linalg . range % { { . * } } : % { { . * } } : % { { . * } } : ! linalg . range <nl> / / CHECK : % [ [ vA : . * ] ] = linalg . view % arg0 [ % [ [ ri0 ] ] , % [ [ rK ] ] ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK : % [ [ i1min : . * ] ] = affine . apply ( d0 ) - > ( d0 ) ( % i1 ) <nl> / / CHECK - NEXT : % [ [ i1max : . * ] ] = affine . apply ( d0 ) - > ( d0 + 9 ) ( % i1 ) <nl> - / / CHECK - NEXT : % [ [ ri1 : . * ] ] = linalg . range % [ [ i1min ] ] : % [ [ i1max ] ] : % { { . * } } : ! linalg < " range " > <nl> + / / CHECK - NEXT : % [ [ ri1 : . * ] ] = linalg . range % [ [ i1min ] ] : % [ [ i1max ] ] : % { { . * } } : ! linalg . range <nl> / / CHECK - NEXT : % [ [ vB : . * ] ] = linalg . view % arg1 [ % 10 , % 13 ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : % [ [ vC : . * ] ] = linalg . view % arg2 [ % 5 , % 13 ] : ! linalg < " view < ? x ? xf32 > " > <nl> / / CHECK - NEXT : affine . for % i2 = ( d0 ) - > ( d0 ) ( % i0 ) to ( d0 ) - > ( d0 ) ( % [ [ i0max ] ] ) { <nl> mmm a / examples / toy / Ch2 / mlir / MLIRGen . cpp <nl> ppp b / examples / toy / Ch2 / mlir / MLIRGen . cpp <nl> class MLIRGenImpl { <nl> / / / Build a type from a list of shape dimensions . Types are ` array ` followed <nl> / / / by an optional dimension list , example : array < 2 , 2 > <nl> / / / They are wrapped in a ` toy ` dialect ( see next chapter ) and get printed : <nl> - / / / ! toy < " array < 2 , 2 > " > <nl> + / / / ! toy . array < 2 , 2 > <nl> template < typename T > mlir : : Type getType ( T shape ) { <nl> mlir : : Type elementType = mlir : : FloatType : : getF64 ( & context ) ; <nl> std : : string typeName = " array " ; <nl> mmm a / examples / toy / Ch3 / include / toy / Dialect . h <nl> ppp b / examples / toy / Ch3 / include / toy / Dialect . h <nl> class ToyArrayType : public mlir : : Type : : TypeBase < ToyArrayType , mlir : : Type , <nl> / / / <nl> / / / % 0 = " toy . constant " ( ) <nl> / / / { value : dense < tensor < 2x3xf64 > , [ [ 1 . 0 , 2 . 0 , 3 . 0 ] , [ 4 . 0 , 5 . 0 , 6 . 0 ] ] > } <nl> - / / / : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + / / / : ( ) - > ! toy . array < 2 , 3 > <nl> / / / <nl> / / / An operation inherits from ` class Op ` and specifies optional traits . Here we <nl> / / / indicate that ` toy . constant ` does not have any operands and returns a single <nl> class ConstantOp : public mlir : : Op < ConstantOp , mlir : : OpTrait : : ZeroOperands , <nl> mlir : : DenseElementsAttr value ) ; <nl> <nl> / / / Similar to the one above , but takes a single float and returns a <nl> - / / / ! toy < " array < 1 > " > . <nl> + / / / ! toy . array < 1 > . <nl> static void build ( mlir : : Builder * builder , mlir : : OperationState * state , <nl> mlir : : FloatAttr value ) ; <nl> <nl> class ConstantOp : public mlir : : Op < ConstantOp , mlir : : OpTrait : : ZeroOperands , <nl> / / / arguments expected by the callee . For example : <nl> / / / <nl> / / / % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " my_func " } <nl> - / / / : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> + / / / : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > <nl> / / / <nl> / / / This is only valid if a function named " my_func " exists and takes two <nl> / / / arguments . <nl> class TransposeOp : public mlir : : Op < TransposeOp , mlir : : OpTrait : : OneOperand , <nl> / / / Reshape operation is transforming its input array into a new array with the <nl> / / / same number of elements but different shapes . For example : <nl> / / / <nl> - / / / % 0 = " toy . transpose " ( % arg1 ) : ( ! toy < " array < 10 > " > ) - > ! toy < " array < 5 , 2 > " > <nl> + / / / % 0 = " toy . transpose " ( % arg1 ) : ( ! toy . array < 10 > ) - > ! toy . array < 5 , 2 > <nl> / / / <nl> class ReshapeOp : public mlir : : Op < ReshapeOp , mlir : : OpTrait : : OneOperand , <nl> mlir : : OpTrait : : OneResult > { <nl> mmm a / examples / toy / Ch3 / mlir / MLIRGen . cpp <nl> ppp b / examples / toy / Ch3 / mlir / MLIRGen . cpp <nl> class MLIRGenImpl { <nl> / / / Build a type from a list of shape dimensions . Types are ` array ` followed <nl> / / / by an optional dimension list , example : array < 2 , 2 > <nl> / / / They are wrapped in a ` toy ` dialect ( see next chapter ) and get printed : <nl> - / / / ! toy < " array < 2 , 2 > " > <nl> + / / / ! toy . array < 2 , 2 > <nl> template < typename T > mlir : : Type getType ( T shape ) { <nl> SmallVector < int64_t , 8 > shape64 ( shape . begin ( ) , shape . end ( ) ) ; <nl> return ToyArrayType : : get ( & context , shape64 ) ; <nl> mmm a / examples / toy / Ch4 / include / toy / Dialect . h <nl> ppp b / examples / toy / Ch4 / include / toy / Dialect . h <nl> class ToyArrayType : public mlir : : Type : : TypeBase < ToyArrayType , mlir : : Type , <nl> / / / <nl> / / / % 0 = " toy . constant " ( ) <nl> / / / { value : dense < tensor < 2x3xf64 > , [ [ 1 . 0 , 2 . 0 , 3 . 0 ] , [ 4 . 0 , 5 . 0 , 6 . 0 ] ] > } <nl> - / / / : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + / / / : ( ) - > ! toy . array < 2 , 3 > <nl> / / / <nl> / / / An operation inherits from ` class Op ` and specifies optional traits . Here we <nl> / / / indicate that ` toy . constant ` does not have any operands and returns a single <nl> class ConstantOp : public mlir : : Op < ConstantOp , mlir : : OpTrait : : ZeroOperands , <nl> mlir : : DenseElementsAttr value ) ; <nl> <nl> / / / Similar to the one above , but takes a single float and returns a <nl> - / / / ! toy < " array < 1 > " > . <nl> + / / / ! toy . array < 1 > . <nl> static void build ( mlir : : Builder * builder , mlir : : OperationState * state , <nl> mlir : : FloatAttr value ) ; <nl> <nl> class ConstantOp : public mlir : : Op < ConstantOp , mlir : : OpTrait : : ZeroOperands , <nl> / / / arguments expected by the callee . For example : <nl> / / / <nl> / / / % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " my_func " } <nl> - / / / : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> + / / / : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > <nl> / / / <nl> / / / This is only valid if a function named " my_func " exists and takes two <nl> / / / arguments . <nl> class TransposeOp : public mlir : : Op < TransposeOp , mlir : : OpTrait : : OneOperand , <nl> / / / Reshape operation is transforming its input array into a new array with the <nl> / / / same number of elements but different shapes . For example : <nl> / / / <nl> - / / / % 0 = " toy . transpose " ( % arg1 ) : ( ! toy < " array < 10 > " > ) - > ! toy < " array < 5 , 2 > " > <nl> + / / / % 0 = " toy . transpose " ( % arg1 ) : ( ! toy . array < 10 > ) - > ! toy . array < 5 , 2 > <nl> / / / <nl> class ReshapeOp : public mlir : : Op < ReshapeOp , mlir : : OpTrait : : OneOperand , <nl> mlir : : OpTrait : : OneResult , <nl> mmm a / examples / toy / Ch4 / mlir / MLIRGen . cpp <nl> ppp b / examples / toy / Ch4 / mlir / MLIRGen . cpp <nl> class MLIRGenImpl { <nl> / / / Build a type from a list of shape dimensions . Types are ` array ` followed <nl> / / / by an optional dimension list , example : array < 2 , 2 > <nl> / / / They are wrapped in a ` toy ` dialect ( see next chapter ) and get printed : <nl> - / / / ! toy < " array < 2 , 2 > " > <nl> + / / / ! toy . array < 2 , 2 > <nl> template < typename T > mlir : : Type getType ( T shape ) { <nl> SmallVector < int64_t , 8 > shape64 ( shape . begin ( ) , shape . end ( ) ) ; <nl> return ToyArrayType : : get ( & context , shape64 ) ; <nl> mmm a / examples / toy / Ch4 / mlir / ShapeInferencePass . cpp <nl> ppp b / examples / toy / Ch4 / mlir / ShapeInferencePass . cpp <nl> using llvm : : Twine ; <nl> / / / shape of the arguments to the function name . For example , calling <nl> / / / <nl> / / / " toy . generic_call " ( % 1 , % 3 ) { callee : " foo " } <nl> - / / / : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> + / / / : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > <nl> / / / <nl> / / / would be mangled foo_2x3_2x3 . This mangling isn ' t robust as the user could <nl> / / / have provided a function with a similar name , but we will claim this as a <nl> mmm a / g3doc / Dialects / LLVM . md <nl> ppp b / g3doc / Dialects / LLVM . md <nl> type : : = ` ! llvm < " ` llvm - canonical - type ` " > <nl> llvm - canonical - type : : = < canonical textual representation defined by LLVM > <nl> ` ` ` <nl> <nl> - For example , one can use primitive types ` ! llvm < " i32 " > ` , pointer types <nl> + For example , one can use primitive types ` ! llvm . i32 ` , pointer types <nl> ` ! llvm < " i8 * " > ` , vector types ` ! llvm < " < 4 x float > " > ` or structure types <nl> ` ! llvm < " { i32 , float } " > ` . The parsing and printing of the canonical form is <nl> delegated to the LLVM assembly parser and printer . <nl> Examples : <nl> <nl> ` ` ` mlir { . mlir } <nl> / / Integer addition . <nl> - % 0 = llvm . add % a , % b : ! llvm < " i32 " > <nl> + % 0 = llvm . add % a , % b : ! llvm . i32 <nl> <nl> / / Unsigned integer division . <nl> - % 1 = llvm . udiv % a , % b : ! llvm < " i32 " > <nl> + % 1 = llvm . udiv % a , % b : ! llvm . i32 <nl> ` ` ` <nl> <nl> # # # # Floating point binary arithmetic operations <nl> Examples : <nl> <nl> ` ` ` mlir { . mlir } <nl> / / Float addition . <nl> - % 0 = llvm . fadd % a , % b : ! llvm < " float " > <nl> + % 0 = llvm . fadd % a , % b : ! llvm . float <nl> <nl> / / Float division . <nl> - % 1 = llvm . fdiv % a , % b : ! llvm < " float " > <nl> + % 1 = llvm . fdiv % a , % b : ! llvm . float <nl> ` ` ` <nl> <nl> # # # # Memory - related operations <nl> Examples : <nl> <nl> ` ` ` mlir { . mlir } <nl> / / Allocate an array of 4 floats on stack <nl> - % c4 = llvm . constant ( 4 ) : ! llvm < " i64 " > <nl> - % 0 = llvm . alloca % c4 x ! llvm < " float " > : ( ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % c4 = llvm . constant ( 4 ) : ! llvm . i64 <nl> + % 0 = llvm . alloca % c4 x ! llvm . float : ( ! llvm . i64 ) - > ! llvm < " float * " > <nl> <nl> / / Get the second element of the array ( note 0 - based indexing ) . <nl> - % c1 = llvm . constant ( 1 ) : ! llvm < " i64 " > <nl> - % 1 = llvm . getelementptr % 0 [ % c1 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) <nl> + % c1 = llvm . constant ( 1 ) : ! llvm . i64 <nl> + % 1 = llvm . getelementptr % 0 [ % c1 ] : ( ! llvm < " float * " > , ! llvm . i64 ) <nl> - > ! llvm < " float * " > <nl> <nl> / / Store a constant into this element . <nl> - % cf = llvm . constant ( 42 . 0 : f32 ) : ! llvm < " float " > <nl> + % cf = llvm . constant ( 42 . 0 : f32 ) : ! llvm . float <nl> llvm . store % cf , % 1 : ! llvm < " float * " > <nl> <nl> / / Load the value from this element . <nl> Examples : <nl> llvm . br ^ bb0 <nl> <nl> / / Branch and pass arguments . <nl> - ^ bb1 ( % arg : ! llvm < " i32 " > ) : <nl> - llvm . br ^ bb1 ( % arg : ! llvm < " i32 " > ) <nl> + ^ bb1 ( % arg : ! llvm . i32 ) : <nl> + llvm . br ^ bb1 ( % arg : ! llvm . i32 ) <nl> <nl> / / Conditionally branch and pass arguments to one of the blocks . <nl> - llvm . cond_br % cond , ^ bb0 , % bb1 ( % arg : ! llvm < " i32 " > ) <nl> + llvm . cond_br % cond , ^ bb0 , % bb1 ( % arg : ! llvm . i32 ) <nl> <nl> / / It ' s okay to use the same block without arguments , but probably useless . <nl> llvm . cond_br % cond , ^ bb0 , ^ bb0 <nl> <nl> / / ERROR : Passing different arguments to the same block in a conditional branch . <nl> - llvm . cond_br % cond , ^ bb1 ( % 0 : ! llvm < " i32 " > ) , ^ bb1 ( % 1 : ! llvm < " i32 " > ) <nl> + llvm . cond_br % cond , ^ bb1 ( % 0 : ! llvm . i32 ) , ^ bb1 ( % 1 : ! llvm . i32 ) <nl> <nl> ` ` ` <nl> <nl> Examples : <nl> <nl> ` ` ` mlir { . mlir } <nl> / / Direct call without arguments and with one result . <nl> - % 0 = llvm . call @ foo ( ) : ( ) - > ( ! llvm < " float " > ) <nl> + % 0 = llvm . call @ foo ( ) : ( ) - > ( ! llvm . float ) <nl> <nl> / / Direct call with arguments and without a result . <nl> - llvm . call @ bar ( % 0 ) : ( ! llvm < " float " > ) - > ( ) <nl> + llvm . call @ bar ( % 0 ) : ( ! llvm . float ) - > ( ) <nl> <nl> / / Indirect call with an argument and without a result . <nl> - llvm . call % 1 ( % 0 ) : ( ! llvm < " float " > ) - > ( ) <nl> + llvm . call % 1 ( % 0 ) : ( ! llvm . float ) - > ( ) <nl> ` ` ` <nl> <nl> # # # # Miscellaneous operations . <nl> Examples : <nl> <nl> ` ` ` mlir { . mlir } <nl> / / Integer constant , internal i32 is mandatory <nl> - % 0 = llvm . constant ( 42 : i32 ) : ! llvm < " i32 " > <nl> + % 0 = llvm . constant ( 42 : i32 ) : ! llvm . i32 <nl> <nl> / / It ' s okay to omit i64 . <nl> - % 1 = llvm . constant ( 42 ) : ! llvm < " i64 " > <nl> + % 1 = llvm . constant ( 42 ) : ! llvm . i64 <nl> <nl> / / Floating point constant . <nl> - % 2 = llvm . constant ( 42 . 0 : f32 ) : ! llvm < " float " > <nl> + % 2 = llvm . constant ( 42 . 0 : f32 ) : ! llvm . float <nl> <nl> / / Splat vector constant , . <nl> % 3 = llvm . constant ( splat < vector < 4xf32 > , 1 . 0 > ) : ! llvm < " < 4 x float > " > <nl> mmm a / g3doc / LangRef . md <nl> ppp b / g3doc / LangRef . md <nl> Dialect types can be specified in a verbose form , e . g . like this : <nl> ! llvm < " i32 * " > <nl> <nl> / / Tensor flow string type . <nl> - ! tf < " string " > <nl> + ! tf . string <nl> <nl> / / Complex type <nl> ! foo < " something < abcd > " > <nl> mmm a / g3doc / Tutorials / Toy / Ch - 2 . md <nl> ppp b / g3doc / Tutorials / Toy / Ch - 2 . md <nl> and can have application - specific semantics . <nl> Here is the MLIR assembly for the Toy ' transpose ' operations : <nl> <nl> ` ` ` MLIR ( . mlir ) <nl> - % t_array = " toy . transpose " ( % array ) { inplace : true } : ( ! toy < " array < 2 , 3 > " > ) - > ! toy < " array < 3 , 2 > " > <nl> + % t_array = " toy . transpose " ( % array ) { inplace : true } : ( ! toy . array < 2 , 3 > ) - > ! toy . array < 3 , 2 > <nl> ` ` ` <nl> <nl> Let ' s look at the anatomy of this MLIR operation : <nl> mlir : : Operation * createTransposeOp ( FuncBuilder * builder , <nl> mlir : : Value * input_array ) { <nl> / / We bundle our custom type in a ` toy ` dialect . <nl> auto toyDialect = mlir : : Identifier : : get ( " toy " , builder - > getContext ( ) ) ; <nl> - / / Create a custom type , in the MLIR assembly it is : ! toy < " array < 2 , 2 > " > <nl> + / / Create a custom type , in the MLIR assembly it is : ! toy . array < 2 , 2 > <nl> auto type = mlir : : OpaqueType : : get ( toyDialect , " array < 2 , 2 > " , builder - > getContext ( ) ) ; <nl> <nl> / / Fill the ` OperationState ` with the required fields <nl> func @ multiply_transpose ( % arg0 : ! toy < " array " > , % arg1 : ! toy < " array " > ) <nl> } <nl> <nl> func @ main ( ) loc ( " test / codegen . toy " : 6 : 1 ) { <nl> - % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , [ [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy < " array < 2 , 3 > " > loc ( " test / codegen . toy " : 7 : 17 ) <nl> - % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 2 , 3 > " > ) - > ! toy < " array < 2 , 3 > " > loc ( " test / codegen . toy " : 7 : 3 ) <nl> - % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy < " array < 6 > " > loc ( " test / codegen . toy " : 8 : 17 ) <nl> - % 3 = " toy . reshape " ( % 2 ) : ( ! toy < " array < 6 > " > ) - > ! toy < " array < 2 , 3 > " > loc ( " test / codegen . toy " : 8 : 3 ) <nl> - % 4 = " toy . generic_call " ( % 1 , % 3 , % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > loc ( " test / codegen . toy " : 9 : 11 ) <nl> - % 5 = " toy . generic_call " ( % 3 , % 1 , % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > loc ( " test / codegen . toy " : 10 : 11 ) <nl> + % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , [ [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy . array < 2 , 3 > loc ( " test / codegen . toy " : 7 : 17 ) <nl> + % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 2 , 3 > ) - > ! toy . array < 2 , 3 > loc ( " test / codegen . toy " : 7 : 3 ) <nl> + % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy . array < 6 > loc ( " test / codegen . toy " : 8 : 17 ) <nl> + % 3 = " toy . reshape " ( % 2 ) : ( ! toy . array < 6 > ) - > ! toy . array < 2 , 3 > loc ( " test / codegen . toy " : 8 : 3 ) <nl> + % 4 = " toy . generic_call " ( % 1 , % 3 , % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > loc ( " test / codegen . toy " : 9 : 11 ) <nl> + % 5 = " toy . generic_call " ( % 3 , % 1 , % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > loc ( " test / codegen . toy " : 10 : 11 ) <nl> " toy . print " ( % 5 ) : ( ! toy < " array " > ) - > ( ) loc ( " test / codegen . toy " : 11 : 3 ) <nl> " toy . return " ( ) : ( ) - > ( ) loc ( " test / codegen . toy " : 6 : 1 ) <nl> } <nl> round - trip without tripping the verifier : <nl> ` ` ` MLIR ( . mlir ) <nl> / / RUN : toyc % s - emit = mlir <nl> func @ main ( ) { <nl> - % 0 = " toy . print " ( ) : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + % 0 = " toy . print " ( ) : ( ) - > ! toy . array < 2 , 3 > <nl> } <nl> ` ` ` <nl> <nl> mmm a / g3doc / Tutorials / Toy / Ch - 3 . md <nl> ppp b / g3doc / Tutorials / Toy / Ch - 3 . md <nl> arrays . <nl> <nl> As you may have noticed in the previous chapter , dialect specific types in MLIR <nl> are serialized as strings . In the case of Toy , an example would be <nl> - ` ! toy < " array < 2 , 3 > " > ` . MLIR will find the ToyDialect from the ` ! toy ` prefix but <nl> - it is up to the dialect itself to translate the content of the string into a <nl> - proper type . <nl> + ` ! toy . array < 2 , 3 > ` . MLIR will find the ToyDialect from the ` ! toy ` prefix but it <nl> + is up to the dialect itself to translate the content of the string into a proper <nl> + type . <nl> <nl> First we need to define the class representing our type . In MLIR , types are <nl> references to immutable and uniqued objects owned by the MLIRContext . As such , <nl> language . Let ' s walk through the creation of the ` toy . generic_call ` operation : <nl> <nl> ` ` ` MLIR ( . mlir ) <nl> % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " my_func " } <nl> - : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> + : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy < " array " > <nl> ` ` ` <nl> <nl> This operation takes a variable number of operands , all of which are expected to <nl> verifier , we try again the same example of invalid IR from the previous chapter : <nl> ` ` ` bash ( . sh ) <nl> $ cat test / invalid . mlir <nl> func @ main ( ) { <nl> - % 0 = " toy . print " ( ) : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + % 0 = " toy . print " ( ) : ( ) - > ! toy . array < 2 , 3 > <nl> } <nl> $ toyc test / invalid . mlir - emit = mlir <nl> loc ( " test / invalid . mlir " : 2 : 8 ) : error : ' toy . print ' op requires a single operand <nl> mmm a / lib / IR / AsmPrinter . cpp <nl> ppp b / lib / IR / AsmPrinter . cpp <nl> void ModulePrinter : : printDenseElementsAttr ( DenseElementsAttr attr ) { <nl> os < < ' ] ' ; <nl> } <nl> <nl> + static bool isDialectTypeSimpleEnoughForPrettyForm ( StringRef typeName ) { <nl> + / / The type name must start with an identifier . <nl> + if ( typeName . empty ( ) | | ! isalpha ( typeName . front ( ) ) ) <nl> + return false ; <nl> + <nl> + / / Ignore all the characters that are valid in an identifier in the type <nl> + / / name . <nl> + while ( isalpha ( typeName . front ( ) ) | | isdigit ( typeName . front ( ) ) | | <nl> + typeName . front ( ) = = ' . ' ) { <nl> + typeName = typeName . drop_front ( ) ; <nl> + if ( typeName . empty ( ) ) <nl> + return true ; <nl> + } <nl> + <nl> + / / If we got to an unexpected character , then it must be a < > . Check those <nl> + / / recursively . <nl> + if ( typeName . front ( ) ! = ' < ' | | typeName . back ( ) ! = ' > ' ) <nl> + return false ; <nl> + <nl> + unsigned bracketDepth = 0 ; <nl> + while ( ! typeName . empty ( ) ) { <nl> + auto c = typeName . front ( ) ; <nl> + switch ( c ) { <nl> + case ' < ' : <nl> + + + bracketDepth ; <nl> + break ; <nl> + case ' > ' : <nl> + / / Reject types with mismatched brackets . <nl> + if ( bracketDepth = = 0 ) <nl> + return false ; <nl> + - - bracketDepth ; <nl> + break ; <nl> + <nl> + case ' . ' : <nl> + case ' - ' : <nl> + case ' ' : <nl> + case ' , ' : <nl> + / / These are all ok . <nl> + break ; <nl> + <nl> + default : <nl> + if ( isalpha ( c ) | | isdigit ( c ) ) <nl> + break ; <nl> + / / Unknown character abort . <nl> + return false ; <nl> + } <nl> + <nl> + typeName = typeName . drop_front ( ) ; <nl> + } <nl> + <nl> + return bracketDepth = = 0 ; <nl> + } <nl> + <nl> void ModulePrinter : : printType ( Type type ) { <nl> / / Check for an alias for this type . <nl> StringRef alias = state . getTypeAlias ( type ) ; <nl> void ModulePrinter : : printType ( Type type ) { <nl> return ; <nl> } <nl> <nl> + auto printDialectType = [ & ] ( StringRef dialectName , StringRef typeString ) { <nl> + os < < ' ! ' < < dialectName ; <nl> + <nl> + / / If this type name is simple enough , print it directly in pretty form , <nl> + / / otherwise , we print it as an escaped string . <nl> + if ( isDialectTypeSimpleEnoughForPrettyForm ( typeString ) ) { <nl> + os < < ' . ' < < typeString ; <nl> + return ; <nl> + } <nl> + <nl> + / / TODO : escape the type name , it could contain " characters . <nl> + os < < " < \ " " < < typeString < < " \ " > " ; <nl> + } ; <nl> + <nl> switch ( type . getKind ( ) ) { <nl> default : { <nl> auto & dialect = type . getDialect ( ) ; <nl> - os < < ' ! ' < < dialect . getNamespace ( ) < < " < \ " " ; <nl> - dialect . printType ( type , os ) ; <nl> - os < < " \ " > " ; <nl> + <nl> + / / Ask the dialect to serialize the type to a string . <nl> + std : : string typeName ; <nl> + { <nl> + llvm : : raw_string_ostream typeNameStr ( typeName ) ; <nl> + dialect . printType ( type , typeNameStr ) ; <nl> + } <nl> + <nl> + printDialectType ( dialect . getNamespace ( ) , typeName ) ; <nl> return ; <nl> } <nl> case Type : : Kind : : Opaque : { <nl> auto opaqueTy = type . cast < OpaqueType > ( ) ; <nl> - os < < ' ! ' < < opaqueTy . getDialectNamespace ( ) < < " < \ " " <nl> - < < opaqueTy . getTypeData ( ) < < " \ " > " ; <nl> + printDialectType ( opaqueTy . getDialectNamespace ( ) , opaqueTy . getTypeData ( ) ) ; <nl> return ; <nl> } <nl> case StandardTypes : : Index : <nl> mmm a / lib / LLVMIR / Transforms / ConvertToLLVMDialect . cpp <nl> ppp b / lib / LLVMIR / Transforms / ConvertToLLVMDialect . cpp <nl> class TypeConverter { <nl> / / Convert an integer type ` i * ` to ` ! llvm < " i * " > ` . <nl> Type convertIntegerType ( IntegerType type ) ; <nl> <nl> - / / Convert a floating point type : ` f16 ` to ` ! llvm < " half " > ` , ` f32 ` to <nl> - / / ` ! llvm < " float " > ` and ` f64 ` to ` ! llvm < " double " > ` . ` bf16 ` is not supported <nl> + / / Convert a floating point type : ` f16 ` to ` ! llvm . half ` , ` f32 ` to <nl> + / / ` ! llvm . float ` and ` f64 ` to ` ! llvm . double ` . ` bf16 ` is not supported <nl> / / by LLVM . <nl> Type convertFloatType ( FloatType type ) ; <nl> <nl> mmm a / lib / Parser / Parser . cpp <nl> ppp b / lib / Parser / Parser . cpp <nl> Parser : : parseDimensionListRanked ( SmallVectorImpl < int64_t > & dimensions , <nl> / / / <nl> / / / pretty - dialect - type - body : : = ' < ' pretty - dialect - type - contents + ' > ' <nl> / / / pretty - dialect - type - contents : : = pretty - dialect - type - body <nl> - / / / | ' [ 0 - 9a - zA - Z . - ] + ' <nl> + / / / | ' [ 0 - 9a - zA - Z . , - ] + ' <nl> / / / <nl> ParseResult Parser : : parsePrettyDialectTypeName ( StringRef & prettyName ) { <nl> consumeToken ( Token : : less ) ; <nl> ParseResult Parser : : parsePrettyDialectTypeName ( StringRef & prettyName ) { <nl> / / Check to see if the token contains simple characters . <nl> bool isSimple = true ; <nl> for ( auto c : getTokenSpelling ( ) ) <nl> - isSimple & = ( isalpha ( c ) | | isdigit ( c ) | | c = = ' . ' | | c = = ' - ' ) ; <nl> + isSimple & = <nl> + ( isalpha ( c ) | | isdigit ( c ) | | c = = ' . ' | | c = = ' - ' | | c = = ' , ' ) ; <nl> <nl> if ( ! isSimple | | getToken ( ) . is ( Token : : eof ) ) <nl> return emitError ( " expected simple name in pretty dialect type " ) ; <nl> mmm a / test / Examples / Toy / Ch2 / codegen . toy <nl> ppp b / test / Examples / Toy / Ch2 / codegen . toy <nl> def main ( ) { <nl> print ( d ) ; <nl> } <nl> <nl> - # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy < " array " > , % arg1 : ! toy < " array " > ) <nl> + # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy . array , % arg1 : ! toy . array ) <nl> # CHECK - NEXT : attributes { toy . generic : true } { <nl> - # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy < " array " > , ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy . array , ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : } <nl> <nl> # CHECK - LABEL : func @ main ( ) { <nl> - # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 2 , 3 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy < " array < 6 > " > <nl> - # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy < " array < 6 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 2 , 3 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy . array < 6 > <nl> + # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy . array < 6 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : " toy . return " ( ) : ( ) - > ( ) <nl> <nl> mmm a / test / Examples / Toy / Ch2 / invalid . mlir <nl> ppp b / test / Examples / Toy / Ch2 / invalid . mlir <nl> <nl> / / - There should be a block terminator . <nl> / / This all round - trip since this is opaque for MLIR . <nl> func @ main ( ) { <nl> - % 0 = " toy . print " ( ) : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + % 0 = " toy . print " ( ) : ( ) - > ! toy . array < 2 , 3 > <nl> } <nl> mmm a / test / Examples / Toy / Ch3 / codegen . toy <nl> ppp b / test / Examples / Toy / Ch3 / codegen . toy <nl> def main ( ) { <nl> print ( d ) ; <nl> } <nl> <nl> - # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy < " array " > , % arg1 : ! toy < " array " > ) <nl> + # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy . array , % arg1 : ! toy . array ) <nl> # CHECK - NEXT : attributes { toy . generic : true } { <nl> - # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy < " array " > , ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy . array , ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : } <nl> <nl> # CHECK - LABEL : func @ main ( ) { <nl> - # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 2 , 3 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy < " array < 6 > " > <nl> - # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy < " array < 6 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 2 , 3 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy . array < 6 > <nl> + # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy . array < 6 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : " toy . return " ( ) : ( ) - > ( ) <nl> <nl> mmm a / test / Examples / Toy / Ch3 / invalid . mlir <nl> ppp b / test / Examples / Toy / Ch3 / invalid . mlir <nl> <nl> / / - There should be a block terminator . <nl> / / This all round - trip since this is opaque for MLIR . <nl> func @ main ( ) { <nl> - % 0 = " toy . print " ( ) : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + % 0 = " toy . print " ( ) : ( ) - > ! toy . array < 2 , 3 > <nl> } <nl> mmm a / test / Examples / Toy / Ch3 / scalar . toy <nl> ppp b / test / Examples / Toy / Ch3 / scalar . toy <nl> def main ( ) { <nl> } <nl> <nl> # CHECK - LABEL : func @ main ( ) { <nl> - # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 1xf64 > , [ 5 . 500000e + 00 ] > } : ( ) - > ! toy < " array < 1 > " > <nl> - # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 1 > " > ) - > ! toy < " array < 2 , 2 > " > <nl> - # CHECK - NEXT : " toy . print " ( % 1 ) : ( ! toy < " array < 2 , 2 > " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 1xf64 > , [ 5 . 500000e + 00 ] > } : ( ) - > ! toy . array < 1 > <nl> + # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 1 > ) - > ! toy . array < 2 , 2 > <nl> + # CHECK - NEXT : " toy . print " ( % 1 ) : ( ! toy . array < 2 , 2 > ) - > ( ) <nl> # CHECK - NEXT : " toy . return " ( ) : ( ) - > ( ) <nl> # CHECK - NEXT : } <nl> <nl> mmm a / test / Examples / Toy / Ch4 / codegen . toy <nl> ppp b / test / Examples / Toy / Ch4 / codegen . toy <nl> def main ( ) { <nl> print ( d ) ; <nl> } <nl> <nl> - # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy < " array " > , % arg1 : ! toy < " array " > ) <nl> + # CHECK - LABEL : func @ multiply_transpose ( % arg0 : ! toy . array , % arg1 : ! toy . array ) <nl> # CHECK - NEXT : attributes { toy . generic : true } { <nl> - # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy < " array " > , ! toy < " array " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . transpose " ( % arg1 ) : ( ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : % 1 = " toy . mul " ( % arg0 , % 0 ) : ( ! toy . array , ! toy . array ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . return " ( % 1 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : } <nl> <nl> # CHECK - LABEL : func @ main ( ) { <nl> - # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 2 , 3 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy < " array < 6 > " > <nl> - # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy < " array < 6 > " > ) - > ! toy < " array < 2 , 3 > " > <nl> - # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy < " array < 2 , 3 > " > , ! toy < " array < 2 , 3 > " > ) - > ! toy < " array " > <nl> - # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy < " array " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 2x3xf64 > , { { \ [ \ [ } } 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 ] , [ 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] ] > } : ( ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 2 , 3 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 2 = " toy . constant " ( ) { value : dense < tensor < 6xf64 > , [ 1 . 000000e + 00 , 2 . 000000e + 00 , 3 . 000000e + 00 , 4 . 000000e + 00 , 5 . 000000e + 00 , 6 . 000000e + 00 ] > } : ( ) - > ! toy . array < 6 > <nl> + # CHECK - NEXT : % 3 = " toy . reshape " ( % 2 ) : ( ! toy . array < 6 > ) - > ! toy . array < 2 , 3 > <nl> + # CHECK - NEXT : % 4 = " toy . generic_call " ( % 1 , % 3 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : % 5 = " toy . generic_call " ( % 3 , % 1 ) { callee : " multiply_transpose " } : ( ! toy . array < 2 , 3 > , ! toy . array < 2 , 3 > ) - > ! toy . array <nl> + # CHECK - NEXT : " toy . print " ( % 5 ) : ( ! toy . array ) - > ( ) <nl> # CHECK - NEXT : " toy . return " ( ) : ( ) - > ( ) <nl> <nl> mmm a / test / Examples / Toy / Ch4 / invalid . mlir <nl> ppp b / test / Examples / Toy / Ch4 / invalid . mlir <nl> <nl> / / - There should be a block terminator . <nl> / / This all round - trip since this is opaque for MLIR . <nl> func @ main ( ) { <nl> - % 0 = " toy . print " ( ) : ( ) - > ! toy < " array < 2 , 3 > " > <nl> + % 0 = " toy . print " ( ) : ( ) - > ! toy . array < 2 , 3 > <nl> } <nl> mmm a / test / Examples / Toy / Ch4 / scalar . toy <nl> ppp b / test / Examples / Toy / Ch4 / scalar . toy <nl> def main ( ) { <nl> } <nl> <nl> # CHECK - LABEL : func @ main ( ) { <nl> - # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 1xf64 > , [ 5 . 500000e + 00 ] > } : ( ) - > ! toy < " array < 1 > " > <nl> - # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy < " array < 1 > " > ) - > ! toy < " array < 2 , 2 > " > <nl> - # CHECK - NEXT : " toy . print " ( % 1 ) : ( ! toy < " array < 2 , 2 > " > ) - > ( ) <nl> + # CHECK - NEXT : % 0 = " toy . constant " ( ) { value : dense < tensor < 1xf64 > , [ 5 . 500000e + 00 ] > } : ( ) - > ! toy . array < 1 > <nl> + # CHECK - NEXT : % 1 = " toy . reshape " ( % 0 ) : ( ! toy . array < 1 > ) - > ! toy . array < 2 , 2 > <nl> + # CHECK - NEXT : " toy . print " ( % 1 ) : ( ! toy . array < 2 , 2 > ) - > ( ) <nl> # CHECK - NEXT : " toy . return " ( ) : ( ) - > ( ) <nl> # CHECK - NEXT : } <nl> <nl> mmm a / test / IR / parser . mlir <nl> ppp b / test / IR / parser . mlir <nl> func @ unknown_dialect_type ( ) - > ! bar < " " > { <nl> / / CHECK : " foo " ( ) : ( ) - > ! bar < " " > <nl> % 0 = " foo " ( ) : ( ) - > ! bar < " " > <nl> <nl> - / / CHECK : " foo " ( ) : ( ) - > ! bar < " baz " > <nl> + / / CHECK : " foo " ( ) : ( ) - > ! bar . baz <nl> % 1 = " foo " ( ) : ( ) - > ! bar < " baz " > <nl> <nl> return % 0 : ! bar < " " > <nl> func @ pretty_form_multi_result ( ) - > ( i16 , i16 ) { <nl> / / CHECK - LABEL : func @ pretty_dialect_type ( ) <nl> func @ pretty_dialect_type ( ) { <nl> <nl> - / / CHECK : % 0 = " foo . unknown_op " ( ) : ( ) - > ! foo < " simpletype " > <nl> + / / CHECK : % 0 = " foo . unknown_op " ( ) : ( ) - > ! foo . simpletype <nl> % 0 = " foo . unknown_op " ( ) : ( ) - > ! foo . simpletype <nl> <nl> - / / CHECK : % 1 = " foo . unknown_op " ( ) : ( ) - > ! foo < " complextype < abcd > " > <nl> + / / CHECK : % 1 = " foo . unknown_op " ( ) : ( ) - > ! foo . complextype < abcd > <nl> % 1 = " foo . unknown_op " ( ) : ( ) - > ! foo . complextype < abcd > <nl> <nl> - / / CHECK : % 2 = " foo . unknown_op " ( ) : ( ) - > ! foo < " complextype < abcd < f32 > > " > <nl> + / / CHECK : % 2 = " foo . unknown_op " ( ) : ( ) - > ! foo . complextype < abcd < f32 > > <nl> % 2 = " foo . unknown_op " ( ) : ( ) - > ! foo . complextype < abcd < f32 > > <nl> return <nl> } <nl> mmm a / test / LLVMIR / convert - funcs . mlir <nl> ppp b / test / LLVMIR / convert - funcs . mlir <nl> func @ pass_through ( % arg0 : ( ) - > ( ) ) - > ( ( ) - > ( ) ) { <nl> return % bbarg : ( ) - > ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : func @ body ( ! llvm < " i32 " > ) <nl> + / / CHECK - LABEL : func @ body ( ! llvm . i32 ) <nl> func @ body ( i32 ) <nl> <nl> - / / CHECK - LABEL : func @ indirect_const_call ( % arg0 : ! llvm < " i32 " > ) { <nl> + / / CHECK - LABEL : func @ indirect_const_call ( % arg0 : ! llvm . i32 ) { <nl> func @ indirect_const_call ( % arg0 : i32 ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( @ body : ( ! llvm < " i32 " > ) - > ( ) ) : ! llvm < " void ( i32 ) * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( @ body : ( ! llvm . i32 ) - > ( ) ) : ! llvm < " void ( i32 ) * " > <nl> % 0 = constant @ body : ( i32 ) - > ( ) <nl> - / / CHECK - NEXT : llvm . call % 0 ( % arg0 ) : ( ! llvm < " i32 " > ) - > ( ) <nl> + / / CHECK - NEXT : llvm . call % 0 ( % arg0 ) : ( ! llvm . i32 ) - > ( ) <nl> call_indirect % 0 ( % arg0 ) : ( i32 ) - > ( ) <nl> / / CHECK - NEXT : llvm . return <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ indirect_call ( % arg0 : ! llvm < " i32 ( float ) * " > , % arg1 : ! llvm < " float " > ) - > ! llvm < " i32 " > { <nl> + / / CHECK - LABEL : func @ indirect_call ( % arg0 : ! llvm < " i32 ( float ) * " > , % arg1 : ! llvm . float ) - > ! llvm . i32 { <nl> func @ indirect_call ( % arg0 : ( f32 ) - > i32 , % arg1 : f32 ) - > i32 { <nl> - / / CHECK - NEXT : % 0 = llvm . call % arg0 ( % arg1 ) : ( ! llvm < " float " > ) - > ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 0 = llvm . call % arg0 ( % arg1 ) : ( ! llvm . float ) - > ! llvm . i32 <nl> % 0 = call_indirect % arg0 ( % arg1 ) : ( f32 ) - > i32 <nl> - / / CHECK - NEXT : llvm . return % 0 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : llvm . return % 0 : ! llvm . i32 <nl> return % 0 : i32 <nl> } <nl> <nl> mmm a / test / LLVMIR / convert - memref - ops . mlir <nl> ppp b / test / LLVMIR / convert - memref - ops . mlir <nl> func @ check_static_return ( % static : memref < 32x18xf32 > ) - > memref < 32x18xf32 > { <nl> <nl> / / CHECK - LABEL : func @ zero_d_alloc ( ) - > ! llvm < " float * " > { <nl> func @ zero_d_alloc ( ) - > memref < f32 > { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> / / CHECK - NEXT : % 4 = llvm . bitcast % 3 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 0 = alloc ( ) : memref < f32 > <nl> return % 0 : memref < f32 > <nl> func @ zero_d_dealloc ( % arg0 : memref < f32 > ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ mixed_alloc ( % arg0 : ! llvm < " i64 " > , % arg1 : ! llvm < " i64 " > ) - > ! llvm < " { float * , i64 , i64 } " > { <nl> + / / CHECK - LABEL : func @ mixed_alloc ( % arg0 : ! llvm . i64 , % arg1 : ! llvm . i64 ) - > ! llvm < " { float * , i64 , i64 } " > { <nl> func @ mixed_alloc ( % arg0 : index , % arg1 : index ) - > memref < ? x42x ? xf32 > { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . mul % arg0 , % 0 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % 1 , % arg1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 4 = llvm . mul % 2 , % 3 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 5 = llvm . call @ malloc ( % 4 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . mul % arg0 , % 0 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % 1 , % arg1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 4 = llvm . mul % 2 , % 3 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 5 = llvm . call @ malloc ( % 4 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> / / CHECK - NEXT : % 6 = llvm . bitcast % 5 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> / / CHECK - NEXT : % 7 = llvm . undef : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 8 = llvm . insertvalue % 6 , % 7 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> func @ mixed_dealloc ( % arg0 : memref < ? x42x ? xf32 > ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ dynamic_alloc ( % arg0 : ! llvm < " i64 " > , % arg1 : ! llvm < " i64 " > ) - > ! llvm < " { float * , i64 , i64 } " > { <nl> + / / CHECK - LABEL : func @ dynamic_alloc ( % arg0 : ! llvm . i64 , % arg1 : ! llvm . i64 ) - > ! llvm < " { float * , i64 , i64 } " > { <nl> func @ dynamic_alloc ( % arg0 : index , % arg1 : index ) - > memref < ? x ? xf32 > { <nl> - / / CHECK - NEXT : % 0 = llvm . mul % arg0 , % arg1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + / / CHECK - NEXT : % 0 = llvm . mul % arg0 , % arg1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> / / CHECK - NEXT : % 4 = llvm . bitcast % 3 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> / / CHECK - NEXT : % 5 = llvm . undef : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 6 = llvm . insertvalue % 4 , % 5 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> func @ dynamic_dealloc ( % arg0 : memref < ? x ? xf32 > ) { <nl> <nl> / / CHECK - LABEL : func @ static_alloc ( ) - > ! llvm < " float * " > { <nl> func @ static_alloc ( ) - > memref < 32x18xf32 > { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 32 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 18 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 4 = llvm . mul % 2 , % 3 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 5 = llvm . call @ malloc ( % 4 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 32 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 18 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % 0 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 4 = llvm . mul % 2 , % 3 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 5 = llvm . call @ malloc ( % 4 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> / / CHECK - NEXT : % 6 = llvm . bitcast % 5 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 0 = alloc ( ) : memref < 32x18xf32 > <nl> return % 0 : memref < 32x18xf32 > <nl> func @ static_dealloc ( % static : memref < 10x8xf32 > ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ zero_d_load ( % arg0 : ! llvm < " float * " > ) - > ! llvm < " float " > { <nl> + / / CHECK - LABEL : func @ zero_d_load ( % arg0 : ! llvm < " float * " > ) - > ! llvm . float { <nl> func @ zero_d_load ( % arg0 : memref < f32 > ) - > f32 { <nl> / / CHECK - NEXT : % 0 = llvm . load % arg0 : ! llvm < " float * " > <nl> % 0 = load % arg0 [ ] : memref < f32 > <nl> func @ zero_d_load ( % arg0 : memref < f32 > ) - > f32 { <nl> <nl> / / CHECK - LABEL : func @ static_load <nl> func @ static_load ( % static : memref < 10x42xf32 > , % i : index , % j : index ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 4 = llvm . getelementptr % arg0 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 4 = llvm . getelementptr % arg0 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : % 5 = llvm . load % 4 : ! llvm < " float * " > <nl> % 0 = load % static [ % i , % j ] : memref < 10x42xf32 > <nl> return <nl> func @ static_load ( % static : memref < 10x42xf32 > , % i : index , % j : index ) { <nl> <nl> / / CHECK - LABEL : func @ mixed_load <nl> func @ mixed_load ( % mixed : memref < 42x ? xf32 > , % i : index , % j : index ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : % 6 = llvm . load % 5 : ! llvm < " float * " > <nl> % 0 = load % mixed [ % i , % j ] : memref < 42x ? xf32 > <nl> return <nl> func @ mixed_load ( % mixed : memref < 42x ? xf32 > , % i : index , % j : index ) { <nl> func @ dynamic_load ( % dynamic : memref < ? x ? xf32 > , % i : index , % j : index ) { <nl> / / CHECK - NEXT : % 0 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : % 6 = llvm . load % 5 : ! llvm < " float * " > <nl> % 0 = load % dynamic [ % i , % j ] : memref < ? x ? xf32 > <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ zero_d_store ( % arg0 : ! llvm < " float * " > , % arg1 : ! llvm < " float " > ) { <nl> + / / CHECK - LABEL : func @ zero_d_store ( % arg0 : ! llvm < " float * " > , % arg1 : ! llvm . float ) { <nl> func @ zero_d_store ( % arg0 : memref < f32 > , % arg1 : f32 ) { <nl> / / CHECK - NEXT : llvm . store % arg1 , % arg0 : ! llvm < " float * " > <nl> store % arg1 , % arg0 [ ] : memref < f32 > <nl> func @ zero_d_store ( % arg0 : memref < f32 > , % arg1 : f32 ) { <nl> <nl> / / CHECK - LABEL : func @ static_store <nl> func @ static_store ( % static : memref < 10x42xf32 > , % i : index , % j : index , % val : f32 ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 4 = llvm . getelementptr % arg0 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 4 = llvm . getelementptr % arg0 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : llvm . store % arg3 , % 4 : ! llvm < " float * " > <nl> store % val , % static [ % i , % j ] : memref < 10x42xf32 > <nl> return <nl> func @ static_store ( % static : memref < 10x42xf32 > , % i : index , % j : index , % val : f <nl> func @ dynamic_store ( % dynamic : memref < ? x ? xf32 > , % i : index , % j : index , % val : f32 ) { <nl> / / CHECK - NEXT : % 0 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : llvm . store % arg3 , % 5 : ! llvm < " float * " > <nl> store % val , % dynamic [ % i , % j ] : memref < ? x ? xf32 > <nl> return <nl> func @ dynamic_store ( % dynamic : memref < ? x ? xf32 > , % i : index , % j : index , % val : f <nl> <nl> / / CHECK - LABEL : func @ mixed_store <nl> func @ mixed_store ( % mixed : memref < 42x ? xf32 > , % i : index , % j : index , % val : f32 ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg1 , % 1 : ! llvm . i64 <nl> + / / CHECK - NEXT : % 3 = llvm . add % 2 , % arg2 : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + / / CHECK - NEXT : % 5 = llvm . getelementptr % 4 [ % 3 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> / / CHECK - NEXT : llvm . store % arg3 , % 5 : ! llvm < " float * " > <nl> store % val , % mixed [ % i , % j ] : memref < 42x ? xf32 > <nl> return <nl> func @ mixed_store ( % mixed : memref < 42x ? xf32 > , % i : index , % j : index , % val : f32 ) <nl> func @ memref_cast_static_to_dynamic ( % static : memref < 10x42xf32 > ) { <nl> / / CHECK - NEXT : % 0 = llvm . undef : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . insertvalue % arg0 , % 0 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 3 = llvm . insertvalue % 2 , % 1 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 4 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 4 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 5 = llvm . insertvalue % 4 , % 3 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> % 0 = memref_cast % static : memref < 10x42xf32 > to memref < ? x ? xf32 > <nl> return <nl> func @ memref_cast_static_to_dynamic ( % static : memref < 10x42xf32 > ) { <nl> func @ memref_cast_static_to_mixed ( % static : memref < 10x42xf32 > ) { <nl> / / CHECK - NEXT : % 0 = llvm . undef : ! llvm < " { float * , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . insertvalue % arg0 , % 0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 2 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 3 = llvm . insertvalue % 2 , % 1 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> % 0 = memref_cast % static : memref < 10x42xf32 > to memref < ? x42xf32 > <nl> return <nl> func @ memref_cast_mixed_to_dynamic ( % mixed : memref < 42x ? xf32 > ) { <nl> / / CHECK - NEXT : % 0 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . undef : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 2 = llvm . insertvalue % 0 , % 1 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . insertvalue % 3 , % 2 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK - NEXT : % 5 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> / / CHECK - NEXT : % 6 = llvm . insertvalue % 5 , % 4 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> func @ memref_cast_mixed_to_mixed ( % mixed : memref < 42x ? xf32 > ) { <nl> / / CHECK - NEXT : % 0 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> / / CHECK - NEXT : % 1 = llvm . undef : ! llvm < " { float * , i64 } " > <nl> / / CHECK - NEXT : % 2 = llvm . insertvalue % 0 , % 1 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 4 = llvm . insertvalue % 3 , % 2 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> % 0 = memref_cast % mixed : memref < 42x ? xf32 > to memref < ? x1xf32 > <nl> return <nl> func @ memref_cast_mixed_to_mixed ( % mixed : memref < 42x ? xf32 > ) { <nl> <nl> / / CHECK - LABEL : func @ mixed_memref_dim ( % arg0 : ! llvm < " { float * , i64 , i64 , i64 } " > ) <nl> func @ mixed_memref_dim ( % mixed : memref < 42x ? x ? x13x ? xf32 > ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> % 0 = dim % mixed , 0 : memref < 42x ? x ? x13x ? xf32 > <nl> / / CHECK - NEXT : % 1 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 , i64 , i64 } " > <nl> % 1 = dim % mixed , 1 : memref < 42x ? x ? x13x ? xf32 > <nl> / / CHECK - NEXT : % 2 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 , i64 } " > <nl> % 2 = dim % mixed , 2 : memref < 42x ? x ? x13x ? xf32 > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 13 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 13 : index ) : ! llvm . i64 <nl> % 3 = dim % mixed , 3 : memref < 42x ? x ? x13x ? xf32 > <nl> / / CHECK - NEXT : % 4 = llvm . extractvalue % arg0 [ 3 ] : ! llvm < " { float * , i64 , i64 , i64 } " > <nl> % 4 = dim % mixed , 4 : memref < 42x ? x ? x13x ? xf32 > <nl> func @ mixed_memref_dim ( % mixed : memref < 42x ? x ? x13x ? xf32 > ) { <nl> <nl> / / CHECK - LABEL : func @ static_memref_dim ( % arg0 : ! llvm < " float * " > ) <nl> func @ static_memref_dim ( % static : memref < 42x32x15x13x27xf32 > ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> % 0 = dim % static , 0 : memref < 42x32x15x13x27xf32 > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 32 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 32 : index ) : ! llvm . i64 <nl> % 1 = dim % static , 1 : memref < 42x32x15x13x27xf32 > <nl> - / / CHECK - NEXT : % 2 = llvm . constant ( 15 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 2 = llvm . constant ( 15 : index ) : ! llvm . i64 <nl> % 2 = dim % static , 2 : memref < 42x32x15x13x27xf32 > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 13 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 13 : index ) : ! llvm . i64 <nl> % 3 = dim % static , 3 : memref < 42x32x15x13x27xf32 > <nl> - / / CHECK - NEXT : % 4 = llvm . constant ( 27 : index ) : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : % 4 = llvm . constant ( 27 : index ) : ! llvm . i64 <nl> % 4 = dim % static , 4 : memref < 42x32x15x13x27xf32 > <nl> return <nl> } <nl> mmm a / test / LLVMIR / convert - to - llvmir . mlir <nl> ppp b / test / LLVMIR / convert - to - llvmir . mlir <nl> func @ empty ( ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ body ( ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ body ( ! llvm . i64 ) <nl> func @ body ( index ) <nl> <nl> / / CHECK - LABEL : func @ simple_loop ( ) { <nl> func @ simple_loop ( ) { <nl> br ^ bb1 <nl> <nl> / / CHECK - NEXT : ^ bb1 : / / pred : ^ bb0 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb1 : / / pred : ^ bb0 <nl> % c1 = constant 1 : index <nl> % c42 = constant 42 : index <nl> br ^ bb2 ( % c1 : index ) <nl> <nl> - / / CHECK : ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK : ^ bb2 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb3 , ^ bb4 <nl> ^ bb2 ( % 0 : index ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> % 1 = cmpi " slt " , % 0 , % c42 : index <nl> cond_br % 1 , ^ bb3 , ^ bb4 <nl> <nl> / / CHECK : ^ bb3 : / / pred : ^ bb2 <nl> - / / CHECK - NEXT : llvm . call @ body ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ body ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb3 : / / pred : ^ bb2 <nl> call @ body ( % 0 ) : ( index ) - > ( ) <nl> % c1_0 = constant 1 : index <nl> func @ ml_caller ( ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ body_args ( ! llvm < " i64 " > ) - > ! llvm < " i64 " > <nl> + / / CHECK - LABEL : func @ body_args ( ! llvm . i64 ) - > ! llvm . i64 <nl> func @ body_args ( index ) - > index <nl> - / / CHECK - LABEL : func @ other ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> + / / CHECK - LABEL : func @ other ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> func @ other ( index , i32 ) - > i32 <nl> <nl> - / / CHECK - LABEL : func @ func_args ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " i32 " > ) - > ! llvm < " i32 " > { <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : i32 ) : ! llvm < " i32 " > <nl> + / / CHECK - LABEL : func @ func_args ( % arg0 : ! llvm . i32 , % arg1 : ! llvm . i32 ) - > ! llvm . i32 { <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : i32 ) : ! llvm . i32 <nl> / / CHECK - NEXT : llvm . br ^ bb1 <nl> func @ func_args ( i32 , i32 ) - > i32 { <nl> ^ bb0 ( % arg0 : i32 , % arg1 : i32 ) : <nl> func @ func_args ( i32 , i32 ) - > i32 { <nl> br ^ bb1 <nl> <nl> / / CHECK - NEXT : ^ bb1 : / / pred : ^ bb0 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb1 : / / pred : ^ bb0 <nl> % c0 = constant 0 : index <nl> % c42 = constant 42 : index <nl> br ^ bb2 ( % c0 : index ) <nl> <nl> - / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb3 , ^ bb4 <nl> ^ bb2 ( % 0 : index ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> % 1 = cmpi " slt " , % 0 , % c42 : index <nl> cond_br % 1 , ^ bb3 , ^ bb4 <nl> <nl> / / CHECK - NEXT : ^ bb3 : / / pred : ^ bb2 <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ body_args ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , % arg0 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , { { . * } } ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , % arg1 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ body_args ( { { . * } } ) : ( ! llvm . i64 ) - > ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , % arg0 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , { { . * } } ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , % arg1 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb3 : / / pred : ^ bb2 <nl> % 2 = call @ body_args ( % 0 ) : ( index ) - > index <nl> % 3 = call @ other ( % 2 , % arg0 ) : ( index , i32 ) - > i32 <nl> func @ func_args ( i32 , i32 ) - > i32 { <nl> br ^ bb2 ( % 6 : index ) <nl> <nl> / / CHECK - NEXT : ^ bb4 : / / pred : ^ bb2 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , { { . * } } ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - / / CHECK - NEXT : llvm . return { { . * } } : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ other ( { { . * } } , { { . * } } ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + / / CHECK - NEXT : llvm . return { { . * } } : ! llvm . i32 <nl> ^ bb4 : / / pred : ^ bb2 <nl> % c0_0 = constant 0 : index <nl> % 7 = call @ other ( % c0_0 , % c0_i32 ) : ( index , i32 ) - > i32 <nl> return % 7 : i32 <nl> } <nl> <nl> - / / CHECK - LABEL : func @ pre ( ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ pre ( ! llvm . i64 ) <nl> func @ pre ( index ) <nl> <nl> - / / CHECK - LABEL : func @ body2 ( ! llvm < " i64 " > , ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ body2 ( ! llvm . i64 , ! llvm . i64 ) <nl> func @ body2 ( index , index ) <nl> <nl> - / / CHECK - LABEL : func @ post ( ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ post ( ! llvm . i64 ) <nl> func @ post ( index ) <nl> <nl> / / CHECK - LABEL : func @ imperfectly_nested_loops ( ) { <nl> func @ imperfectly_nested_loops ( ) { <nl> br ^ bb1 <nl> <nl> / / CHECK - NEXT : ^ bb1 : / / pred : ^ bb0 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb1 : / / pred : ^ bb0 <nl> % c0 = constant 0 : index <nl> % c42 = constant 42 : index <nl> br ^ bb2 ( % c0 : index ) <nl> <nl> - / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb7 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb7 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb3 , ^ bb8 <nl> ^ bb2 ( % 0 : index ) : / / 2 preds : ^ bb1 , ^ bb7 <nl> % 1 = cmpi " slt " , % 0 , % c42 : index <nl> cond_br % 1 , ^ bb3 , ^ bb8 <nl> <nl> / / CHECK - NEXT : ^ bb3 : <nl> - / / CHECK - NEXT : llvm . call @ pre ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + / / CHECK - NEXT : llvm . call @ pre ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> / / CHECK - NEXT : llvm . br ^ bb4 <nl> ^ bb3 : / / pred : ^ bb2 <nl> call @ pre ( % 0 ) : ( index ) - > ( ) <nl> br ^ bb4 <nl> <nl> / / CHECK - NEXT : ^ bb4 : / / pred : ^ bb3 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 7 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 56 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 7 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 56 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb4 : / / pred : ^ bb3 <nl> % c7 = constant 7 : index <nl> % c56 = constant 56 : index <nl> br ^ bb5 ( % c7 : index ) <nl> <nl> - / / CHECK - NEXT : ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : ^ bb5 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb6 , ^ bb7 <nl> ^ bb5 ( % 2 : index ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> % 3 = cmpi " slt " , % 2 , % c56 : index <nl> cond_br % 3 , ^ bb6 , ^ bb7 <nl> <nl> / / CHECK - NEXT : ^ bb6 : / / pred : ^ bb5 <nl> - / / CHECK - NEXT : llvm . call @ body2 ( { { . * } } , { { . * } } ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ body2 ( { { . * } } , { { . * } } ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb6 : / / pred : ^ bb5 <nl> call @ body2 ( % 0 , % 2 ) : ( index , index ) - > ( ) <nl> % c2 = constant 2 : index <nl> func @ imperfectly_nested_loops ( ) { <nl> br ^ bb5 ( % 4 : index ) <nl> <nl> / / CHECK - NEXT : ^ bb7 : / / pred : ^ bb5 <nl> - / / CHECK - NEXT : llvm . call @ post ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ post ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> ^ bb7 : / / pred : ^ bb5 <nl> call @ post ( % 0 ) : ( index ) - > ( ) <nl> % c1 = constant 1 : index <nl> func @ imperfectly_nested_loops ( ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ mid ( ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ mid ( ! llvm . i64 ) <nl> func @ mid ( index ) <nl> <nl> - / / CHECK - LABEL : func @ body3 ( ! llvm < " i64 " > , ! llvm < " i64 " > ) <nl> + / / CHECK - LABEL : func @ body3 ( ! llvm . i64 , ! llvm . i64 ) <nl> func @ body3 ( index , index ) <nl> <nl> / / A complete function transformation check . <nl> / / CHECK - LABEL : func @ more_imperfectly_nested_loops ( ) { <nl> / / CHECK - NEXT : llvm . br ^ bb1 <nl> / / CHECK - NEXT : ^ bb1 : / / pred : ^ bb0 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> - / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb11 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> + / / CHECK - NEXT : ^ bb2 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb11 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb3 , ^ bb12 <nl> / / CHECK - NEXT : ^ bb3 : / / pred : ^ bb2 <nl> - / / CHECK - NEXT : llvm . call @ pre ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + / / CHECK - NEXT : llvm . call @ pre ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> / / CHECK - NEXT : llvm . br ^ bb4 <nl> / / CHECK - NEXT : ^ bb4 : / / pred : ^ bb3 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 7 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 56 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) <nl> - / / CHECK - NEXT : ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 7 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 56 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm . i64 ) <nl> + / / CHECK - NEXT : ^ bb5 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb6 , ^ bb7 <nl> / / CHECK - NEXT : ^ bb6 : / / pred : ^ bb5 <nl> - / / CHECK - NEXT : llvm . call @ body2 ( { { . * } } , { { . * } } ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ body2 ( { { . * } } , { { . * } } ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb5 ( { { . * } } : ! llvm . i64 ) <nl> / / CHECK - NEXT : ^ bb7 : / / pred : ^ bb5 <nl> - / / CHECK - NEXT : llvm . call @ mid ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + / / CHECK - NEXT : llvm . call @ mid ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> / / CHECK - NEXT : llvm . br ^ bb8 <nl> / / CHECK - NEXT : ^ bb8 : / / pred : ^ bb7 <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 18 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 37 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb9 ( { { . * } } : ! llvm < " i64 " > ) <nl> - / / CHECK - NEXT : ^ bb9 ( { { . * } } : ! llvm < " i64 " > ) : / / 2 preds : ^ bb8 , ^ bb10 <nl> - / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 18 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 37 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb9 ( { { . * } } : ! llvm . i64 ) <nl> + / / CHECK - NEXT : ^ bb9 ( { { . * } } : ! llvm . i64 ) : / / 2 preds : ^ bb8 , ^ bb10 <nl> + / / CHECK - NEXT : { { . * } } = llvm . icmp " slt " { { . * } } , { { . * } } : ! llvm . i64 <nl> / / CHECK - NEXT : llvm . cond_br { { . * } } , ^ bb10 , ^ bb11 <nl> / / CHECK - NEXT : ^ bb10 : / / pred : ^ bb9 <nl> - / / CHECK - NEXT : llvm . call @ body3 ( { { . * } } , { { . * } } ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 3 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb9 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ body3 ( { { . * } } , { { . * } } ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 3 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb9 ( { { . * } } : ! llvm . i64 ) <nl> / / CHECK - NEXT : ^ bb11 : / / pred : ^ bb9 <nl> - / / CHECK - NEXT : llvm . call @ post ( { { . * } } ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> - / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm < " i64 " > ) <nl> + / / CHECK - NEXT : llvm . call @ post ( { { . * } } ) : ( ! llvm . i64 ) - > ( ) <nl> + / / CHECK - NEXT : { { . * } } = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> + / / CHECK - NEXT : llvm . br ^ bb2 ( { { . * } } : ! llvm . i64 ) <nl> / / CHECK - NEXT : ^ bb12 : / / pred : ^ bb2 <nl> / / CHECK - NEXT : llvm . return <nl> / / CHECK - NEXT : } <nl> func @ more_imperfectly_nested_loops ( ) { <nl> return <nl> } <nl> <nl> - / / CHECK - LABEL : func @ get_i64 ( ) - > ! llvm < " i64 " > <nl> + / / CHECK - LABEL : func @ get_i64 ( ) - > ! llvm . i64 <nl> func @ get_i64 ( ) - > ( i64 ) <nl> - / / CHECK - LABEL : func @ get_f32 ( ) - > ! llvm < " float " > <nl> + / / CHECK - LABEL : func @ get_f32 ( ) - > ! llvm . float <nl> func @ get_f32 ( ) - > ( f32 ) <nl> / / CHECK - LABEL : func @ get_memref ( ) - > ! llvm < " { float * , i64 , i64 } " > <nl> func @ get_memref ( ) - > ( memref < 42x ? x10x ? xf32 > ) <nl> func @ get_memref ( ) - > ( memref < 42x ? x10x ? xf32 > ) <nl> / / CHECK - LABEL : func @ multireturn ( ) - > ! llvm < " { i64 , float , { float * , i64 , i64 } } " > { <nl> func @ multireturn ( ) - > ( i64 , f32 , memref < 42x ? x10x ? xf32 > ) { <nl> ^ bb0 : <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ get_i64 ( ) : ( ) - > ! llvm < " i64 " > <nl> - / / CHECK - NEXT : { { . * } } = llvm . call @ get_f32 ( ) : ( ) - > ! llvm < " float " > <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ get_i64 ( ) : ( ) - > ! llvm . i64 <nl> + / / CHECK - NEXT : { { . * } } = llvm . call @ get_f32 ( ) : ( ) - > ! llvm . float <nl> / / CHECK - NEXT : { { . * } } = llvm . call @ get_memref ( ) : ( ) - > ! llvm < " { float * , i64 , i64 } " > <nl> % 0 = call @ get_i64 ( ) : ( ) - > ( i64 ) <nl> % 1 = call @ get_f32 ( ) : ( ) - > ( f32 ) <nl> func @ multireturn_caller ( ) { <nl> / / CHECK - NEXT : { { . * } } = llvm . extractvalue { { . * } } [ 2 ] : ! llvm < " { i64 , float , { float * , i64 , i64 } } " > <nl> % 0 : 3 = call @ multireturn ( ) : ( ) - > ( i64 , f32 , memref < 42x ? x10x ? xf32 > ) <nl> % 1 = constant 42 : i64 <nl> - / / CHECK : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm < " i64 " > <nl> + / / CHECK : { { . * } } = llvm . add { { . * } } , { { . * } } : ! llvm . i64 <nl> % 2 = addi % 0 # 0 , % 1 : i64 <nl> % 3 = constant 42 . 0 : f32 <nl> - / / CHECK : { { . * } } = llvm . fadd { { . * } } , { { . * } } : ! llvm < " float " > <nl> + / / CHECK : { { . * } } = llvm . fadd { { . * } } , { { . * } } : ! llvm . float <nl> % 4 = addf % 0 # 1 , % 3 : f32 <nl> % 5 = constant 0 : index <nl> return <nl> func @ vector_ops ( vector < 4xf32 > , vector < 4xi1 > , vector < 4xi64 > ) - > vector < 4xf32 > { <nl> / / CHECK - LABEL : @ ops <nl> func @ ops ( f32 , f32 , i32 , i32 ) - > ( f32 , i32 ) { <nl> ^ bb0 ( % arg0 : f32 , % arg1 : f32 , % arg2 : i32 , % arg3 : i32 ) : <nl> - / / CHECK - NEXT : % 0 = llvm . fsub % arg0 , % arg1 : ! llvm < " float " > <nl> + / / CHECK - NEXT : % 0 = llvm . fsub % arg0 , % arg1 : ! llvm . float <nl> % 0 = subf % arg0 , % arg1 : f32 <nl> - / / CHECK - NEXT : % 1 = llvm . sub % arg2 , % arg3 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 1 = llvm . sub % arg2 , % arg3 : ! llvm . i32 <nl> % 1 = subi % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 2 = llvm . icmp " slt " % arg2 , % 1 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 2 = llvm . icmp " slt " % arg2 , % 1 : ! llvm . i32 <nl> % 2 = cmpi " slt " , % arg2 , % 1 : i32 <nl> - / / CHECK - NEXT : % 3 = llvm . sdiv % arg2 , % arg3 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 3 = llvm . sdiv % arg2 , % arg3 : ! llvm . i32 <nl> % 4 = divis % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 4 = llvm . udiv % arg2 , % arg3 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 4 = llvm . udiv % arg2 , % arg3 : ! llvm . i32 <nl> % 5 = diviu % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 5 = llvm . srem % arg2 , % arg3 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 5 = llvm . srem % arg2 , % arg3 : ! llvm . i32 <nl> % 6 = remis % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 6 = llvm . urem % arg2 , % arg3 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 6 = llvm . urem % arg2 , % arg3 : ! llvm . i32 <nl> % 7 = remiu % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 7 = llvm . select % 2 , % arg2 , % arg3 : ! llvm < " i1 " > , ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 7 = llvm . select % 2 , % arg2 , % arg3 : ! llvm . i1 , ! llvm . i32 <nl> % 8 = select % 2 , % arg2 , % arg3 : i32 <nl> - / / CHECK - NEXT : % 8 = llvm . fdiv % arg0 , % arg1 : ! llvm < " float " > <nl> + / / CHECK - NEXT : % 8 = llvm . fdiv % arg0 , % arg1 : ! llvm . float <nl> % 9 = divf % arg0 , % arg1 : f32 <nl> - / / CHECK - NEXT : % 9 = llvm . frem % arg0 , % arg1 : ! llvm < " float " > <nl> + / / CHECK - NEXT : % 9 = llvm . frem % arg0 , % arg1 : ! llvm . float <nl> % 10 = remf % arg0 , % arg1 : f32 <nl> <nl> return % 0 , % 4 : f32 , i32 <nl> func @ ops ( f32 , f32 , i32 , i32 ) - > ( f32 , i32 ) { <nl> <nl> / / CHECK - LABEL : @ dfs_block_order <nl> func @ dfs_block_order ( ) - > ( i32 ) { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 42 : i32 ) : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 42 : i32 ) : ! llvm . i32 <nl> % 0 = constant 42 : i32 <nl> / / CHECK - NEXT : llvm . br ^ bb2 <nl> br ^ bb2 <nl> <nl> / / CHECK - NEXT : ^ bb1 : <nl> - / / CHECK - NEXT : % 1 = llvm . add % 0 , % 2 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : llvm . return % 1 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 1 = llvm . add % 0 , % 2 : ! llvm . i32 <nl> + / / CHECK - NEXT : llvm . return % 1 : ! llvm . i32 <nl> ^ bb1 : <nl> % 2 = addi % 0 , % 1 : i32 <nl> return % 2 : i32 <nl> <nl> / / CHECK - NEXT : ^ bb2 : <nl> ^ bb2 : <nl> - / / CHECK - NEXT : % 2 = llvm . constant ( 55 : i32 ) : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 2 = llvm . constant ( 55 : i32 ) : ! llvm . i32 <nl> % 1 = constant 55 : i32 <nl> / / CHECK - NEXT : llvm . br ^ bb1 <nl> br ^ bb1 <nl> } <nl> - / / CHECK - LABEL : func @ cond_br_same_target ( % arg0 : ! llvm < " i1 " > , % arg1 : ! llvm < " i32 " > , % arg2 : ! llvm < " i32 " > ) <nl> + / / CHECK - LABEL : func @ cond_br_same_target ( % arg0 : ! llvm . i1 , % arg1 : ! llvm . i32 , % arg2 : ! llvm . i32 ) <nl> func @ cond_br_same_target ( % arg0 : i1 , % arg1 : i32 , % arg2 : i32 ) - > ( i32 ) { <nl> - / / CHECK - NEXT : llvm . cond_br % arg0 , ^ [ [ origBlock : bb [ 0 - 9 ] + ] ] ( % arg1 : ! llvm < " i32 " > ) , ^ [ [ dummyBlock : bb [ 0 - 9 ] + ] ] <nl> + / / CHECK - NEXT : llvm . cond_br % arg0 , ^ [ [ origBlock : bb [ 0 - 9 ] + ] ] ( % arg1 : ! llvm . i32 ) , ^ [ [ dummyBlock : bb [ 0 - 9 ] + ] ] <nl> cond_br % arg0 , ^ bb1 ( % arg1 : i32 ) , ^ bb1 ( % arg2 : i32 ) <nl> <nl> - / / CHECK : ^ [ [ origBlock ] ] ( % 0 : ! llvm < " i32 " > ) : <nl> - / / CHECK - NEXT : llvm . return % 0 : ! llvm < " i32 " > <nl> + / / CHECK : ^ [ [ origBlock ] ] ( % 0 : ! llvm . i32 ) : <nl> + / / CHECK - NEXT : llvm . return % 0 : ! llvm . i32 <nl> ^ bb1 ( % 0 : i32 ) : <nl> return % 0 : i32 <nl> <nl> / / CHECK : ^ [ [ dummyBlock ] ] : <nl> - / / CHECK - NEXT : llvm . br ^ [ [ origBlock ] ] ( % arg2 : ! llvm < " i32 " > ) <nl> + / / CHECK - NEXT : llvm . br ^ [ [ origBlock ] ] ( % arg2 : ! llvm . i32 ) <nl> } <nl> mmm a / test / LLVMIR / invalid . mlir <nl> ppp b / test / LLVMIR / invalid . mlir <nl> <nl> / / RUN : mlir - opt % s - split - input - file - verify <nl> <nl> / / expected - error @ + 1 { { llvm . noalias argument attribute of non boolean type } } <nl> - func @ invalid_noalias ( % arg0 : ! llvm < " i32 " > { llvm . noalias : 3 } ) { <nl> + func @ invalid_noalias ( % arg0 : ! llvm . i32 { llvm . noalias : 3 } ) { <nl> " llvm . return " ( ) : ( ) - > ( ) <nl> } <nl> <nl> func @ invalid_noalias ( % arg0 : ! llvm < " i32 " > { llvm . noalias : 3 } ) { <nl> <nl> / / mmm - - <nl> <nl> - func @ icmp_non_string ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " i16 " > ) { <nl> + func @ icmp_non_string ( % arg0 : ! llvm . i32 , % arg1 : ! llvm < " i16 " > ) { <nl> / / expected - error @ + 1 { { expected ' predicate ' attribute of string type } } <nl> - llvm . icmp 42 % arg0 , % arg0 : ! llvm < " i32 " > <nl> + llvm . icmp 42 % arg0 , % arg0 : ! llvm . i32 <nl> return <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ icmp_wrong_string ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " i16 " > ) { <nl> + func @ icmp_wrong_string ( % arg0 : ! llvm . i32 , % arg1 : ! llvm < " i16 " > ) { <nl> / / expected - error @ + 1 { { ' foo ' is an incorrect value of the ' predicate ' attribute } } <nl> - llvm . icmp " foo " % arg0 , % arg0 : ! llvm < " i32 " > <nl> + llvm . icmp " foo " % arg0 , % arg0 : ! llvm . i32 <nl> return <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ alloca_missing_input_result_type ( % size : ! llvm < " i64 " > ) { <nl> + func @ alloca_missing_input_result_type ( % size : ! llvm . i64 ) { <nl> / / expected - error @ + 1 { { expected trailing function type with one argument and one result } } <nl> - llvm . alloca % size x ! llvm < " i32 " > : ( ) - > ( ) <nl> + llvm . alloca % size x ! llvm . i32 : ( ) - > ( ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> func @ alloca_missing_input_type ( ) { <nl> / / expected - error @ + 1 { { expected trailing function type with one argument and one result } } <nl> - llvm . alloca % size x ! llvm < " i32 " > : ( ) - > ( ! llvm < " i32 * " > ) <nl> + llvm . alloca % size x ! llvm . i32 : ( ) - > ( ! llvm < " i32 * " > ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> func @ alloca_mising_result_type ( ) { <nl> / / expected - error @ + 1 { { expected trailing function type with one argument and one result } } <nl> - llvm . alloca % size x ! llvm < " i32 " > : ( ! llvm < " i64 " > ) - > ( ) <nl> + llvm . alloca % size x ! llvm . i32 : ( ! llvm . i64 ) - > ( ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> func @ alloca_non_function_type ( ) { <nl> / / expected - error @ + 1 { { expected trailing function type with one argument and one result } } <nl> - llvm . alloca % size x ! llvm < " i32 " > : ! llvm < " i32 * " > <nl> + llvm . alloca % size x ! llvm . i32 : ! llvm < " i32 * " > <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ gep_missing_input_result_type ( % pos : ! llvm < " i64 " > , % base : ! llvm < " float * " > ) { <nl> + func @ gep_missing_input_result_type ( % pos : ! llvm . i64 , % base : ! llvm < " float * " > ) { <nl> / / expected - error @ + 1 { { expected trailing function type with at least one argument and one result } } <nl> llvm . getelementptr % base [ % pos ] : ( ) - > ( ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ gep_missing_input_type ( % pos : ! llvm < " i64 " > , % base : ! llvm < " float * " > ) { <nl> + func @ gep_missing_input_type ( % pos : ! llvm . i64 , % base : ! llvm < " float * " > ) { <nl> / / expected - error @ + 1 { { expected trailing function type with at least one argument and one result } } <nl> llvm . getelementptr % base [ % pos ] : ( ) - > ( ! llvm < " float * " > ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ gep_missing_result_type ( % pos : ! llvm < " i64 " > , % base : ! llvm < " float * " > ) { <nl> + func @ gep_missing_result_type ( % pos : ! llvm . i64 , % base : ! llvm < " float * " > ) { <nl> / / expected - error @ + 1 { { expected trailing function type with at least one argument and one result } } <nl> - llvm . getelementptr % base [ % pos ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ( ) <nl> + llvm . getelementptr % base [ % pos ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ( ) <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ gep_non_function_type ( % pos : ! llvm < " i64 " > , % base : ! llvm < " float * " > ) { <nl> + func @ gep_non_function_type ( % pos : ! llvm . i64 , % base : ! llvm < " float * " > ) { <nl> / / expected - error @ + 1 { { expected trailing function type with at least one argument and one result } } <nl> llvm . getelementptr % base [ % pos ] : ! llvm < " float * " > <nl> } <nl> func @ load_non_llvm_type ( % foo : memref < f32 > ) { <nl> <nl> / / mmm - - <nl> <nl> - func @ load_non_ptr_type ( % foo : ! llvm < " float " > ) { <nl> + func @ load_non_ptr_type ( % foo : ! llvm . float ) { <nl> / / expected - error @ + 1 { { expected LLVM pointer type } } <nl> - llvm . load % foo : ! llvm < " float " > <nl> + llvm . load % foo : ! llvm . float <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ store_non_llvm_type ( % foo : memref < f32 > , % bar : ! llvm < " float " > ) { <nl> + func @ store_non_llvm_type ( % foo : memref < f32 > , % bar : ! llvm . float ) { <nl> / / expected - error @ + 1 { { expected LLVM IR dialect type } } <nl> llvm . store % bar , % foo : memref < f32 > <nl> } <nl> <nl> / / mmm - - <nl> <nl> - func @ store_non_ptr_type ( % foo : ! llvm < " float " > , % bar : ! llvm < " float " > ) { <nl> + func @ store_non_ptr_type ( % foo : ! llvm . float , % bar : ! llvm . float ) { <nl> / / expected - error @ + 1 { { expected LLVM pointer type } } <nl> - llvm . store % bar , % foo : ! llvm < " float " > <nl> + llvm . store % bar , % foo : ! llvm . float <nl> } <nl> <nl> / / mmm - - <nl> mmm a / test / LLVMIR / roundtrip . mlir <nl> ppp b / test / LLVMIR / roundtrip . mlir <nl> <nl> / / RUN : mlir - opt % s | FileCheck % s <nl> <nl> - / / CHECK - LABEL : func @ ops ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " float " > ) <nl> - func @ ops ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " float " > ) { <nl> + / / CHECK - LABEL : func @ ops ( % arg0 : ! llvm . i32 , % arg1 : ! llvm . float ) <nl> + func @ ops ( % arg0 : ! llvm . i32 , % arg1 : ! llvm . float ) { <nl> / / Integer artithmetics binary operations . <nl> / / <nl> - / / CHECK - NEXT : % 0 = llvm . add % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 1 = llvm . sub % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 2 = llvm . mul % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 3 = llvm . udiv % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 4 = llvm . sdiv % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 5 = llvm . urem % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 6 = llvm . srem % arg0 , % arg0 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 7 = llvm . icmp " ne " % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 0 = llvm . add % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 1 = llvm . sub % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 2 = llvm . mul % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 3 = llvm . udiv % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 4 = llvm . sdiv % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 5 = llvm . urem % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 6 = llvm . srem % arg0 , % arg0 : ! llvm < " i32 " > <nl> - % 7 = llvm . icmp " ne " % arg0 , % arg0 : ! llvm < " i32 " > <nl> + / / CHECK - NEXT : % 0 = llvm . add % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 1 = llvm . sub % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 2 = llvm . mul % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 3 = llvm . udiv % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 4 = llvm . sdiv % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 5 = llvm . urem % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 6 = llvm . srem % arg0 , % arg0 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 7 = llvm . icmp " ne " % arg0 , % arg0 : ! llvm . i32 <nl> + % 0 = llvm . add % arg0 , % arg0 : ! llvm . i32 <nl> + % 1 = llvm . sub % arg0 , % arg0 : ! llvm . i32 <nl> + % 2 = llvm . mul % arg0 , % arg0 : ! llvm . i32 <nl> + % 3 = llvm . udiv % arg0 , % arg0 : ! llvm . i32 <nl> + % 4 = llvm . sdiv % arg0 , % arg0 : ! llvm . i32 <nl> + % 5 = llvm . urem % arg0 , % arg0 : ! llvm . i32 <nl> + % 6 = llvm . srem % arg0 , % arg0 : ! llvm . i32 <nl> + % 7 = llvm . icmp " ne " % arg0 , % arg0 : ! llvm . i32 <nl> <nl> / / Floating point binary operations . <nl> / / <nl> - / / CHECK - NEXT : % 8 = llvm . fadd % arg1 , % arg1 : ! llvm < " float " > <nl> - / / CHECK - NEXT : % 9 = llvm . fsub % arg1 , % arg1 : ! llvm < " float " > <nl> - / / CHECK - NEXT : % 10 = llvm . fmul % arg1 , % arg1 : ! llvm < " float " > <nl> - / / CHECK - NEXT : % 11 = llvm . fdiv % arg1 , % arg1 : ! llvm < " float " > <nl> - / / CHECK - NEXT : % 12 = llvm . frem % arg1 , % arg1 : ! llvm < " float " > <nl> - % 8 = llvm . fadd % arg1 , % arg1 : ! llvm < " float " > <nl> - % 9 = llvm . fsub % arg1 , % arg1 : ! llvm < " float " > <nl> - % 10 = llvm . fmul % arg1 , % arg1 : ! llvm < " float " > <nl> - % 11 = llvm . fdiv % arg1 , % arg1 : ! llvm < " float " > <nl> - % 12 = llvm . frem % arg1 , % arg1 : ! llvm < " float " > <nl> + / / CHECK - NEXT : % 8 = llvm . fadd % arg1 , % arg1 : ! llvm . float <nl> + / / CHECK - NEXT : % 9 = llvm . fsub % arg1 , % arg1 : ! llvm . float <nl> + / / CHECK - NEXT : % 10 = llvm . fmul % arg1 , % arg1 : ! llvm . float <nl> + / / CHECK - NEXT : % 11 = llvm . fdiv % arg1 , % arg1 : ! llvm . float <nl> + / / CHECK - NEXT : % 12 = llvm . frem % arg1 , % arg1 : ! llvm . float <nl> + % 8 = llvm . fadd % arg1 , % arg1 : ! llvm . float <nl> + % 9 = llvm . fsub % arg1 , % arg1 : ! llvm . float <nl> + % 10 = llvm . fmul % arg1 , % arg1 : ! llvm . float <nl> + % 11 = llvm . fdiv % arg1 , % arg1 : ! llvm . float <nl> + % 12 = llvm . frem % arg1 , % arg1 : ! llvm . float <nl> <nl> / / Memory - related operations . <nl> / / <nl> - / / CHECK - NEXT : % 13 = llvm . alloca % arg0 x ! llvm < " double " > : ( ! llvm < " i32 " > ) - > ! llvm < " double * " > <nl> - / / CHECK - NEXT : % 14 = llvm . getelementptr % 13 [ % arg0 , % arg0 ] : ( ! llvm < " double * " > , ! llvm < " i32 " > , ! llvm < " i32 " > ) - > ! llvm < " double * " > <nl> + / / CHECK - NEXT : % 13 = llvm . alloca % arg0 x ! llvm . double : ( ! llvm . i32 ) - > ! llvm < " double * " > <nl> + / / CHECK - NEXT : % 14 = llvm . getelementptr % 13 [ % arg0 , % arg0 ] : ( ! llvm < " double * " > , ! llvm . i32 , ! llvm . i32 ) - > ! llvm < " double * " > <nl> / / CHECK - NEXT : % 15 = llvm . load % 14 : ! llvm < " double * " > <nl> / / CHECK - NEXT : llvm . store % 15 , % 13 : ! llvm < " double * " > <nl> / / CHECK - NEXT : % 16 = llvm . bitcast % 13 : ! llvm < " double * " > to ! llvm < " i64 * " > <nl> - % 13 = llvm . alloca % arg0 x ! llvm < " double " > : ( ! llvm < " i32 " > ) - > ! llvm < " double * " > <nl> - % 14 = llvm . getelementptr % 13 [ % arg0 , % arg0 ] : ( ! llvm < " double * " > , ! llvm < " i32 " > , ! llvm < " i32 " > ) - > ! llvm < " double * " > <nl> + % 13 = llvm . alloca % arg0 x ! llvm . double : ( ! llvm . i32 ) - > ! llvm < " double * " > <nl> + % 14 = llvm . getelementptr % 13 [ % arg0 , % arg0 ] : ( ! llvm < " double * " > , ! llvm . i32 , ! llvm . i32 ) - > ! llvm < " double * " > <nl> % 15 = llvm . load % 14 : ! llvm < " double * " > <nl> llvm . store % 15 , % 13 : ! llvm < " double * " > <nl> % 16 = llvm . bitcast % 13 : ! llvm < " double * " > to ! llvm < " i64 * " > <nl> <nl> / / Function call - related operations . <nl> / / <nl> - / / CHECK - NEXT : % 17 = llvm . call @ foo ( % arg0 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> + / / CHECK - NEXT : % 17 = llvm . call @ foo ( % arg0 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 18 = llvm . extractvalue % 17 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 19 = llvm . insertvalue % 18 , % 17 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> - / / CHECK - NEXT : % 20 = llvm . constant ( @ foo : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > ) : ! llvm < " { i32 , double , i32 } ( i32 ) * " > <nl> - / / CHECK - NEXT : % 21 = llvm . call % 20 ( % arg0 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> - % 17 = llvm . call @ foo ( % arg0 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> + / / CHECK - NEXT : % 20 = llvm . constant ( @ foo : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > ) : ! llvm < " { i32 , double , i32 } ( i32 ) * " > <nl> + / / CHECK - NEXT : % 21 = llvm . call % 20 ( % arg0 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> + % 17 = llvm . call @ foo ( % arg0 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> % 18 = llvm . extractvalue % 17 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> % 19 = llvm . insertvalue % 18 , % 17 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> - % 20 = llvm . constant ( @ foo : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > ) : ! llvm < " { i32 , double , i32 } ( i32 ) * " > <nl> - % 21 = llvm . call % 20 ( % arg0 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> + % 20 = llvm . constant ( @ foo : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > ) : ! llvm < " { i32 , double , i32 } ( i32 ) * " > <nl> + % 21 = llvm . call % 20 ( % arg0 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> <nl> <nl> / / Terminator operations and their successors . <nl> func @ ops ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " float " > ) { <nl> <nl> ^ bb2 : <nl> / / CHECK : % 22 = llvm . undef : ! llvm < " { i32 , double , i32 } " > <nl> - / / CHECK - NEXT : % 23 = llvm . constant ( 42 ) : ! llvm < " i47 " > <nl> + / / CHECK - NEXT : % 23 = llvm . constant ( 42 ) : ! llvm . i47 <nl> % 22 = llvm . undef : ! llvm < " { i32 , double , i32 } " > <nl> - % 23 = llvm . constant ( 42 ) : ! llvm < " i47 " > <nl> + % 23 = llvm . constant ( 42 ) : ! llvm . i47 <nl> <nl> / / Misc operations . <nl> - / / CHECK : % 24 = llvm . select % 7 , % 0 , % 1 : ! llvm < " i1 " > , ! llvm < " i32 " > <nl> + / / CHECK : % 24 = llvm . select % 7 , % 0 , % 1 : ! llvm . i1 , ! llvm . i32 <nl> / / CHECK - NEXT : llvm . return <nl> - % 24 = llvm . select % 7 , % 0 , % 1 : ! llvm < " i1 " > , ! llvm < " i32 " > <nl> + % 24 = llvm . select % 7 , % 0 , % 1 : ! llvm . i1 , ! llvm . i32 <nl> llvm . return <nl> } <nl> <nl> / / An larger self - contained function . <nl> - / / CHECK - LABEL : func @ foo ( % arg0 : ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > { <nl> - func @ foo ( % arg0 : ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > { <nl> - / / CHECK - NEXT : % 0 = llvm . constant ( 3 ) : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 1 = llvm . constant ( 3 ) : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 2 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm < " double " > <nl> - / / CHECK - NEXT : % 3 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm < " double " > <nl> - / / CHECK - NEXT : % 4 = llvm . add % 0 , % 1 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 1 : ! llvm < " i32 " > <nl> - / / CHECK - NEXT : % 6 = llvm . fadd % 2 , % 3 : ! llvm < " double " > <nl> - / / CHECK - NEXT : % 7 = llvm . fsub % 3 , % 6 : ! llvm < " double " > <nl> - / / CHECK - NEXT : % 8 = llvm . constant ( 1 ) : ! llvm < " i1 " > <nl> - / / CHECK - NEXT : llvm . cond_br % 8 , ^ bb1 ( % 4 : ! llvm < " i32 " > ) , ^ bb2 ( % 4 : ! llvm < " i32 " > ) <nl> - % 0 = llvm . constant ( 3 ) : ! llvm < " i32 " > <nl> - % 1 = llvm . constant ( 3 ) : ! llvm < " i32 " > <nl> - % 2 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm < " double " > <nl> - % 3 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm < " double " > <nl> - % 4 = llvm . add % 0 , % 1 : ! llvm < " i32 " > <nl> - % 5 = llvm . mul % 4 , % 1 : ! llvm < " i32 " > <nl> - % 6 = llvm . fadd % 2 , % 3 : ! llvm < " double " > <nl> - % 7 = llvm . fsub % 3 , % 6 : ! llvm < " double " > <nl> - % 8 = llvm . constant ( 1 ) : ! llvm < " i1 " > <nl> - llvm . cond_br % 8 , ^ bb1 ( % 4 : ! llvm < " i32 " > ) , ^ bb2 ( % 4 : ! llvm < " i32 " > ) <nl> + / / CHECK - LABEL : func @ foo ( % arg0 : ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > { <nl> + func @ foo ( % arg0 : ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > { <nl> + / / CHECK - NEXT : % 0 = llvm . constant ( 3 ) : ! llvm . i32 <nl> + / / CHECK - NEXT : % 1 = llvm . constant ( 3 ) : ! llvm . i32 <nl> + / / CHECK - NEXT : % 2 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm . double <nl> + / / CHECK - NEXT : % 3 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm . double <nl> + / / CHECK - NEXT : % 4 = llvm . add % 0 , % 1 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 5 = llvm . mul % 4 , % 1 : ! llvm . i32 <nl> + / / CHECK - NEXT : % 6 = llvm . fadd % 2 , % 3 : ! llvm . double <nl> + / / CHECK - NEXT : % 7 = llvm . fsub % 3 , % 6 : ! llvm . double <nl> + / / CHECK - NEXT : % 8 = llvm . constant ( 1 ) : ! llvm . i1 <nl> + / / CHECK - NEXT : llvm . cond_br % 8 , ^ bb1 ( % 4 : ! llvm . i32 ) , ^ bb2 ( % 4 : ! llvm . i32 ) <nl> + % 0 = llvm . constant ( 3 ) : ! llvm . i32 <nl> + % 1 = llvm . constant ( 3 ) : ! llvm . i32 <nl> + % 2 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm . double <nl> + % 3 = llvm . constant ( 4 . 200000e + 01 ) : ! llvm . double <nl> + % 4 = llvm . add % 0 , % 1 : ! llvm . i32 <nl> + % 5 = llvm . mul % 4 , % 1 : ! llvm . i32 <nl> + % 6 = llvm . fadd % 2 , % 3 : ! llvm . double <nl> + % 7 = llvm . fsub % 3 , % 6 : ! llvm . double <nl> + % 8 = llvm . constant ( 1 ) : ! llvm . i1 <nl> + llvm . cond_br % 8 , ^ bb1 ( % 4 : ! llvm . i32 ) , ^ bb2 ( % 4 : ! llvm . i32 ) <nl> <nl> - / / CHECK - NEXT : ^ bb1 ( % 9 : ! llvm < " i32 " > ) : <nl> - / / CHECK - NEXT : % 10 = llvm . call @ foo ( % 9 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> + / / CHECK - NEXT : ^ bb1 ( % 9 : ! llvm . i32 ) : <nl> + / / CHECK - NEXT : % 10 = llvm . call @ foo ( % 9 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 11 = llvm . extractvalue % 10 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 12 = llvm . extractvalue % 10 [ 1 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 13 = llvm . extractvalue % 10 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> func @ foo ( % arg0 : ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > { <nl> / / CHECK - NEXT : % 16 = llvm . insertvalue % 7 , % 15 [ 1 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 17 = llvm . insertvalue % 11 , % 16 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : llvm . return % 17 : ! llvm < " { i32 , double , i32 } " > <nl> - ^ bb1 ( % 9 : ! llvm < " i32 " > ) : <nl> - % 10 = llvm . call @ foo ( % 9 ) : ( ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > <nl> + ^ bb1 ( % 9 : ! llvm . i32 ) : <nl> + % 10 = llvm . call @ foo ( % 9 ) : ( ! llvm . i32 ) - > ! llvm < " { i32 , double , i32 } " > <nl> % 11 = llvm . extractvalue % 10 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> % 12 = llvm . extractvalue % 10 [ 1 ] : ! llvm < " { i32 , double , i32 } " > <nl> % 13 = llvm . extractvalue % 10 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> func @ foo ( % arg0 : ! llvm < " i32 " > ) - > ! llvm < " { i32 , double , i32 } " > { <nl> % 17 = llvm . insertvalue % 11 , % 16 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> llvm . return % 17 : ! llvm < " { i32 , double , i32 } " > <nl> <nl> - / / CHECK - NEXT : ^ bb2 ( % 18 : ! llvm < " i32 " > ) : / / pred : ^ bb0 <nl> + / / CHECK - NEXT : ^ bb2 ( % 18 : ! llvm . i32 ) : / / pred : ^ bb0 <nl> / / CHECK - NEXT : % 19 = llvm . undef : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 20 = llvm . insertvalue % 18 , % 19 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 21 = llvm . insertvalue % 7 , % 20 [ 1 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : % 22 = llvm . insertvalue % 5 , % 21 [ 2 ] : ! llvm < " { i32 , double , i32 } " > <nl> / / CHECK - NEXT : llvm . return % 22 : ! llvm < " { i32 , double , i32 } " > <nl> - ^ bb2 ( % 18 : ! llvm < " i32 " > ) : / / pred : ^ bb0 <nl> + ^ bb2 ( % 18 : ! llvm . i32 ) : / / pred : ^ bb0 <nl> % 19 = llvm . undef : ! llvm < " { i32 , double , i32 } " > <nl> % 20 = llvm . insertvalue % 18 , % 19 [ 0 ] : ! llvm < " { i32 , double , i32 } " > <nl> % 21 = llvm . insertvalue % 7 , % 20 [ 1 ] : ! llvm < " { i32 , double , i32 } " > <nl> mmm a / test / Target / llvmir . mlir <nl> ppp b / test / Target / llvmir . mlir <nl> <nl> / / <nl> <nl> / / CHECK : declare i8 * @ malloc ( i64 ) <nl> - func @ malloc ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + func @ malloc ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> / / CHECK : declare void @ free ( i8 * ) <nl> <nl> <nl> func @ empty ( ) { <nl> } <nl> <nl> / / CHECK - LABEL : declare void @ body ( i64 ) <nl> - func @ body ( ! llvm < " i64 " > ) <nl> + func @ body ( ! llvm . i64 ) <nl> <nl> <nl> / / CHECK - LABEL : define void @ simple_loop ( ) { <nl> func @ simple_loop ( ) { <nl> / / CHECK : [ [ SIMPLE_bb1 ] ] : <nl> / / CHECK - NEXT : br label % [ [ SIMPLE_bb2 : [ 0 - 9 ] + ] ] <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 0 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 1 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 0 : ! llvm < " i64 " > ) <nl> + % 0 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 1 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 0 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ SIMPLE_bb2 ] ] : <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = phi i64 [ % { { [ 0 - 9 ] + } } , % [ [ SIMPLE_bb3 : [ 0 - 9 ] + ] ] ] , [ 1 , % [ [ SIMPLE_bb1 ] ] ] <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = icmp slt i64 % { { [ 0 - 9 ] + } } , 42 <nl> / / CHECK - NEXT : br i1 % { { [ 0 - 9 ] + } } , label % [ [ SIMPLE_bb3 ] ] , label % [ [ SIMPLE_bb4 : [ 0 - 9 ] + ] ] <nl> - ^ bb2 ( % 2 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> - % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm < " i64 " > <nl> + ^ bb2 ( % 2 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm . i64 <nl> llvm . cond_br % 3 , ^ bb3 , ^ bb4 <nl> <nl> / / CHECK : [ [ SIMPLE_bb3 ] ] : <nl> func @ simple_loop ( ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = add i64 % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : br label % [ [ SIMPLE_bb2 ] ] <nl> ^ bb3 : / / pred : ^ bb2 <nl> - llvm . call @ body ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - % 4 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 5 = llvm . add % 2 , % 4 : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 5 : ! llvm < " i64 " > ) <nl> + llvm . call @ body ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> + % 4 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 5 = llvm . add % 2 , % 4 : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 5 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ SIMPLE_bb4 ] ] : <nl> / / CHECK - NEXT : ret void <nl> func @ ml_caller ( ) { <nl> } <nl> <nl> / / CHECK - LABEL : declare i64 @ body_args ( i64 ) <nl> - func @ body_args ( ! llvm < " i64 " > ) - > ! llvm < " i64 " > <nl> + func @ body_args ( ! llvm . i64 ) - > ! llvm . i64 <nl> / / CHECK - LABEL : declare i32 @ other ( i64 , i32 ) <nl> - func @ other ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> + func @ other ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> <nl> / / CHECK - LABEL : define i32 @ func_args ( i32 , i32 ) { <nl> / / CHECK - NEXT : br label % [ [ ARGS_bb1 : [ 0 - 9 ] + ] ] <nl> - func @ func_args ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " i32 " > ) - > ! llvm < " i32 " > { <nl> - % 0 = llvm . constant ( 0 : i32 ) : ! llvm < " i32 " > <nl> + func @ func_args ( % arg0 : ! llvm . i32 , % arg1 : ! llvm . i32 ) - > ! llvm . i32 { <nl> + % 0 = llvm . constant ( 0 : i32 ) : ! llvm . i32 <nl> llvm . br ^ bb1 <nl> <nl> / / CHECK : [ [ ARGS_bb1 ] ] : <nl> / / CHECK - NEXT : br label % [ [ ARGS_bb2 : [ 0 - 9 ] + ] ] <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 1 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 2 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 1 : ! llvm < " i64 " > ) <nl> + % 1 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 2 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 1 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ ARGS_bb2 ] ] : <nl> / / CHECK - NEXT : % 5 = phi i64 [ % 12 , % [ [ ARGS_bb3 : [ 0 - 9 ] + ] ] ] , [ 0 , % [ [ ARGS_bb1 ] ] ] <nl> / / CHECK - NEXT : % 6 = icmp slt i64 % 5 , 42 <nl> / / CHECK - NEXT : br i1 % 6 , label % [ [ ARGS_bb3 ] ] , label % [ [ ARGS_bb4 : [ 0 - 9 ] + ] ] <nl> - ^ bb2 ( % 3 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> - % 4 = llvm . icmp " slt " % 3 , % 2 : ! llvm < " i64 " > <nl> + ^ bb2 ( % 3 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + % 4 = llvm . icmp " slt " % 3 , % 2 : ! llvm . i64 <nl> llvm . cond_br % 4 , ^ bb3 , ^ bb4 <nl> <nl> / / CHECK : [ [ ARGS_bb3 ] ] : <nl> func @ func_args ( % arg0 : ! llvm < " i32 " > , % arg1 : ! llvm < " i32 " > ) - > ! llvm < " i32 " > { <nl> / / CHECK - NEXT : % 12 = add i64 % 5 , 1 <nl> / / CHECK - NEXT : br label % [ [ ARGS_bb2 ] ] <nl> ^ bb3 : / / pred : ^ bb2 <nl> - % 5 = llvm . call @ body_args ( % 3 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i64 " > <nl> - % 6 = llvm . call @ other ( % 5 , % arg0 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - % 7 = llvm . call @ other ( % 5 , % 6 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - % 8 = llvm . call @ other ( % 5 , % arg1 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - % 9 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 10 = llvm . add % 3 , % 9 : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 10 : ! llvm < " i64 " > ) <nl> + % 5 = llvm . call @ body_args ( % 3 ) : ( ! llvm . i64 ) - > ! llvm . i64 <nl> + % 6 = llvm . call @ other ( % 5 , % arg0 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + % 7 = llvm . call @ other ( % 5 , % 6 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + % 8 = llvm . call @ other ( % 5 , % arg1 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + % 9 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 10 = llvm . add % 3 , % 9 : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 10 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ ARGS_bb4 ] ] : <nl> / / CHECK - NEXT : % 14 = call i32 @ other ( i64 0 , i32 0 ) <nl> / / CHECK - NEXT : ret i32 % 14 <nl> ^ bb4 : / / pred : ^ bb2 <nl> - % 11 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 12 = llvm . call @ other ( % 11 , % 0 ) : ( ! llvm < " i64 " > , ! llvm < " i32 " > ) - > ! llvm < " i32 " > <nl> - llvm . return % 12 : ! llvm < " i32 " > <nl> + % 11 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 12 = llvm . call @ other ( % 11 , % 0 ) : ( ! llvm . i64 , ! llvm . i32 ) - > ! llvm . i32 <nl> + llvm . return % 12 : ! llvm . i32 <nl> } <nl> <nl> / / CHECK : declare void @ pre ( i64 ) <nl> - func @ pre ( ! llvm < " i64 " > ) <nl> + func @ pre ( ! llvm . i64 ) <nl> <nl> / / CHECK : declare void @ body2 ( i64 , i64 ) <nl> - func @ body2 ( ! llvm < " i64 " > , ! llvm < " i64 " > ) <nl> + func @ body2 ( ! llvm . i64 , ! llvm . i64 ) <nl> <nl> / / CHECK : declare void @ post ( i64 ) <nl> - func @ post ( ! llvm < " i64 " > ) <nl> + func @ post ( ! llvm . i64 ) <nl> <nl> / / CHECK - LABEL : define void @ imperfectly_nested_loops ( ) { <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb1 : [ 0 - 9 ] + ] ] <nl> func @ imperfectly_nested_loops ( ) { <nl> / / CHECK : [ [ IMPER_bb1 ] ] : <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb2 : [ 0 - 9 ] + ] ] <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 0 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 1 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 0 : ! llvm < " i64 " > ) <nl> + % 0 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 1 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 0 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ IMPER_bb2 ] ] : <nl> / / CHECK - NEXT : % 3 = phi i64 [ % 13 , % [ [ IMPER_bb7 : [ 0 - 9 ] + ] ] ] , [ 0 , % [ [ IMPER_bb1 ] ] ] <nl> / / CHECK - NEXT : % 4 = icmp slt i64 % 3 , 42 <nl> / / CHECK - NEXT : br i1 % 4 , label % [ [ IMPER_bb3 : [ 0 - 9 ] + ] ] , label % [ [ IMPER_bb8 : [ 0 - 9 ] + ] ] <nl> - ^ bb2 ( % 2 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb7 <nl> - % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm < " i64 " > <nl> + ^ bb2 ( % 2 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb7 <nl> + % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm . i64 <nl> llvm . cond_br % 3 , ^ bb3 , ^ bb8 <nl> <nl> / / CHECK : [ [ IMPER_bb3 ] ] : <nl> / / CHECK - NEXT : call void @ pre ( i64 % 3 ) <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb4 : [ 0 - 9 ] + ] ] <nl> ^ bb3 : / / pred : ^ bb2 <nl> - llvm . call @ pre ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + llvm . call @ pre ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> llvm . br ^ bb4 <nl> <nl> / / CHECK : [ [ IMPER_bb4 ] ] : <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb5 : [ 0 - 9 ] + ] ] <nl> ^ bb4 : / / pred : ^ bb3 <nl> - % 4 = llvm . constant ( 7 : index ) : ! llvm < " i64 " > <nl> - % 5 = llvm . constant ( 56 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb5 ( % 4 : ! llvm < " i64 " > ) <nl> + % 4 = llvm . constant ( 7 : index ) : ! llvm . i64 <nl> + % 5 = llvm . constant ( 56 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb5 ( % 4 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ IMPER_bb5 ] ] : <nl> / / CHECK - NEXT : % 8 = phi i64 [ % 11 , % [ [ IMPER_bb6 : [ 0 - 9 ] + ] ] ] , [ 7 , % [ [ IMPER_bb4 ] ] ] <nl> / / CHECK - NEXT : % 9 = icmp slt i64 % 8 , 56 <nl> / / CHECK - NEXT : br i1 % 9 , label % [ [ IMPER_bb6 ] ] , label % [ [ IMPER_bb7 ] ] <nl> - ^ bb5 ( % 6 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> - % 7 = llvm . icmp " slt " % 6 , % 5 : ! llvm < " i64 " > <nl> + ^ bb5 ( % 6 : ! llvm . i64 ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> + % 7 = llvm . icmp " slt " % 6 , % 5 : ! llvm . i64 <nl> llvm . cond_br % 7 , ^ bb6 , ^ bb7 <nl> <nl> / / CHECK : [ [ IMPER_bb6 ] ] : <nl> func @ imperfectly_nested_loops ( ) { <nl> / / CHECK - NEXT : % 11 = add i64 % 8 , 2 <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb5 ] ] <nl> ^ bb6 : / / pred : ^ bb5 <nl> - llvm . call @ body2 ( % 2 , % 6 ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - % 8 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - % 9 = llvm . add % 6 , % 8 : ! llvm < " i64 " > <nl> - llvm . br ^ bb5 ( % 9 : ! llvm < " i64 " > ) <nl> + llvm . call @ body2 ( % 2 , % 6 ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + % 8 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + % 9 = llvm . add % 6 , % 8 : ! llvm . i64 <nl> + llvm . br ^ bb5 ( % 9 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ IMPER_bb7 ] ] : <nl> / / CHECK - NEXT : call void @ post ( i64 % 3 ) <nl> / / CHECK - NEXT : % 13 = add i64 % 3 , 1 <nl> / / CHECK - NEXT : br label % [ [ IMPER_bb2 ] ] <nl> ^ bb7 : / / pred : ^ bb5 <nl> - llvm . call @ post ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - % 10 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 11 = llvm . add % 2 , % 10 : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 11 : ! llvm < " i64 " > ) <nl> + llvm . call @ post ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> + % 10 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 11 = llvm . add % 2 , % 10 : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 11 : ! llvm . i64 ) <nl> <nl> / / CHECK : [ [ IMPER_bb8 ] ] : <nl> / / CHECK - NEXT : ret void <nl> func @ imperfectly_nested_loops ( ) { <nl> } <nl> <nl> / / CHECK : declare void @ mid ( i64 ) <nl> - func @ mid ( ! llvm < " i64 " > ) <nl> + func @ mid ( ! llvm . i64 ) <nl> <nl> / / CHECK : declare void @ body3 ( i64 , i64 ) <nl> - func @ body3 ( ! llvm < " i64 " > , ! llvm < " i64 " > ) <nl> + func @ body3 ( ! llvm . i64 , ! llvm . i64 ) <nl> <nl> / / A complete function transformation check . <nl> / / CHECK - LABEL : define void @ more_imperfectly_nested_loops ( ) { <nl> func @ body3 ( ! llvm < " i64 " > , ! llvm < " i64 " > ) <nl> func @ more_imperfectly_nested_loops ( ) { <nl> llvm . br ^ bb1 <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 0 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 1 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 0 : ! llvm < " i64 " > ) <nl> - ^ bb2 ( % 2 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb11 <nl> - % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm < " i64 " > <nl> + % 0 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 1 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 0 : ! llvm . i64 ) <nl> + ^ bb2 ( % 2 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb11 <nl> + % 3 = llvm . icmp " slt " % 2 , % 1 : ! llvm . i64 <nl> llvm . cond_br % 3 , ^ bb3 , ^ bb12 <nl> ^ bb3 : / / pred : ^ bb2 <nl> - llvm . call @ pre ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + llvm . call @ pre ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> llvm . br ^ bb4 <nl> ^ bb4 : / / pred : ^ bb3 <nl> - % 4 = llvm . constant ( 7 : index ) : ! llvm < " i64 " > <nl> - % 5 = llvm . constant ( 56 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb5 ( % 4 : ! llvm < " i64 " > ) <nl> - ^ bb5 ( % 6 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> - % 7 = llvm . icmp " slt " % 6 , % 5 : ! llvm < " i64 " > <nl> + % 4 = llvm . constant ( 7 : index ) : ! llvm . i64 <nl> + % 5 = llvm . constant ( 56 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb5 ( % 4 : ! llvm . i64 ) <nl> + ^ bb5 ( % 6 : ! llvm . i64 ) : / / 2 preds : ^ bb4 , ^ bb6 <nl> + % 7 = llvm . icmp " slt " % 6 , % 5 : ! llvm . i64 <nl> llvm . cond_br % 7 , ^ bb6 , ^ bb7 <nl> ^ bb6 : / / pred : ^ bb5 <nl> - llvm . call @ body2 ( % 2 , % 6 ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - % 8 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - % 9 = llvm . add % 6 , % 8 : ! llvm < " i64 " > <nl> - llvm . br ^ bb5 ( % 9 : ! llvm < " i64 " > ) <nl> + llvm . call @ body2 ( % 2 , % 6 ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + % 8 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + % 9 = llvm . add % 6 , % 8 : ! llvm . i64 <nl> + llvm . br ^ bb5 ( % 9 : ! llvm . i64 ) <nl> ^ bb7 : / / pred : ^ bb5 <nl> - llvm . call @ mid ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + llvm . call @ mid ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> llvm . br ^ bb8 <nl> ^ bb8 : / / pred : ^ bb7 <nl> - % 10 = llvm . constant ( 18 : index ) : ! llvm < " i64 " > <nl> - % 11 = llvm . constant ( 37 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb9 ( % 10 : ! llvm < " i64 " > ) <nl> - ^ bb9 ( % 12 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb8 , ^ bb10 <nl> - % 13 = llvm . icmp " slt " % 12 , % 11 : ! llvm < " i64 " > <nl> + % 10 = llvm . constant ( 18 : index ) : ! llvm . i64 <nl> + % 11 = llvm . constant ( 37 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb9 ( % 10 : ! llvm . i64 ) <nl> + ^ bb9 ( % 12 : ! llvm . i64 ) : / / 2 preds : ^ bb8 , ^ bb10 <nl> + % 13 = llvm . icmp " slt " % 12 , % 11 : ! llvm . i64 <nl> llvm . cond_br % 13 , ^ bb10 , ^ bb11 <nl> ^ bb10 : / / pred : ^ bb9 <nl> - llvm . call @ body3 ( % 2 , % 12 ) : ( ! llvm < " i64 " > , ! llvm < " i64 " > ) - > ( ) <nl> - % 14 = llvm . constant ( 3 : index ) : ! llvm < " i64 " > <nl> - % 15 = llvm . add % 12 , % 14 : ! llvm < " i64 " > <nl> - llvm . br ^ bb9 ( % 15 : ! llvm < " i64 " > ) <nl> + llvm . call @ body3 ( % 2 , % 12 ) : ( ! llvm . i64 , ! llvm . i64 ) - > ( ) <nl> + % 14 = llvm . constant ( 3 : index ) : ! llvm . i64 <nl> + % 15 = llvm . add % 12 , % 14 : ! llvm . i64 <nl> + llvm . br ^ bb9 ( % 15 : ! llvm . i64 ) <nl> ^ bb11 : / / pred : ^ bb9 <nl> - llvm . call @ post ( % 2 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> - % 16 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 17 = llvm . add % 2 , % 16 : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 17 : ! llvm < " i64 " > ) <nl> + llvm . call @ post ( % 2 ) : ( ! llvm . i64 ) - > ( ) <nl> + % 16 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 17 = llvm . add % 2 , % 16 : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 17 : ! llvm . i64 ) <nl> ^ bb12 : / / pred : ^ bb2 <nl> llvm . return <nl> } <nl> func @ memref_alloc ( ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i8 * @ malloc ( i64 400 ) <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = bitcast i8 * % { { [ 0 - 9 ] + } } to float * <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * } undef , float * % { { [ 0 - 9 ] + } } , 0 <nl> - % 0 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - % 1 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - % 2 = llvm . mul % 0 , % 1 : ! llvm < " i64 " > <nl> + % 0 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + % 1 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + % 2 = llvm . mul % 0 , % 1 : ! llvm . i64 <nl> % 3 = llvm . undef : ! llvm < " { float * } " > <nl> - % 4 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 5 = llvm . mul % 2 , % 4 : ! llvm < " i64 " > <nl> - % 6 = llvm . call @ malloc ( % 5 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + % 4 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 5 = llvm . mul % 2 , % 4 : ! llvm . i64 <nl> + % 6 = llvm . call @ malloc ( % 5 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> % 7 = llvm . bitcast % 6 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 8 = llvm . insertvalue % 7 , % 3 [ 0 ] : ! llvm < " { float * } " > <nl> / / CHECK - NEXT : ret void <nl> func @ memref_alloc ( ) { <nl> } <nl> <nl> / / CHECK - LABEL : declare i64 @ get_index ( ) <nl> - func @ get_index ( ) - > ! llvm < " i64 " > <nl> + func @ get_index ( ) - > ! llvm . i64 <nl> <nl> / / CHECK - LABEL : define void @ store_load_static ( ) <nl> func @ store_load_static ( ) { <nl> func @ store_load_static ( ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i8 * @ malloc ( i64 40 ) <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = bitcast i8 * % { { [ 0 - 9 ] + } } to float * <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * } undef , float * % { { [ 0 - 9 ] + } } , 0 <nl> - % 0 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 0 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 1 = llvm . undef : ! llvm < " { float * } " > <nl> - % 2 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 3 = llvm . mul % 0 , % 2 : ! llvm < " i64 " > <nl> - % 4 = llvm . call @ malloc ( % 3 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + % 2 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 3 = llvm . mul % 0 , % 2 : ! llvm . i64 <nl> + % 4 = llvm . call @ malloc ( % 3 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> % 5 = llvm . bitcast % 4 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 6 = llvm . insertvalue % 5 , % 1 [ 0 ] : ! llvm < " { float * } " > <nl> - % 7 = llvm . constant ( 1 . 000000e + 00 : f32 ) : ! llvm < " float " > <nl> + % 7 = llvm . constant ( 1 . 000000e + 00 : f32 ) : ! llvm . float <nl> llvm . br ^ bb1 <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 8 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 9 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 8 : ! llvm < " i64 " > ) <nl> + % 8 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 9 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 8 : ! llvm . i64 ) <nl> / / CHECK : % { { [ 0 - 9 ] + } } = phi i64 [ % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } ] , [ 0 , % { { [ 0 - 9 ] + } } ] <nl> - ^ bb2 ( % 10 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + ^ bb2 ( % 10 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = icmp slt i64 % { { [ 0 - 9 ] + } } , 10 <nl> - % 11 = llvm . icmp " slt " % 10 , % 9 : ! llvm < " i64 " > <nl> + % 11 = llvm . icmp " slt " % 10 , % 9 : ! llvm . i64 <nl> / / CHECK - NEXT : br i1 % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } <nl> llvm . cond_br % 11 , ^ bb3 , ^ bb4 <nl> ^ bb3 : / / pred : ^ bb2 <nl> / / CHECK : % { { [ 0 - 9 ] + } } = extractvalue { float * } % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : store float 1 . 000000e + 00 , float * % { { [ 0 - 9 ] + } } <nl> - % 12 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 12 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 13 = llvm . extractvalue % 6 [ 0 ] : ! llvm < " { float * } " > <nl> - % 14 = llvm . getelementptr % 13 [ % 10 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 14 = llvm . getelementptr % 13 [ % 10 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 7 , % 14 : ! llvm < " float * " > <nl> - % 15 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> + % 15 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = add i64 % { { [ 0 - 9 ] + } } , 1 <nl> - % 16 = llvm . add % 10 , % 15 : ! llvm < " i64 " > <nl> + % 16 = llvm . add % 10 , % 15 : ! llvm . i64 <nl> / / CHECK - NEXT : br label % { { [ 0 - 9 ] + } } <nl> - llvm . br ^ bb2 ( % 16 : ! llvm < " i64 " > ) <nl> + llvm . br ^ bb2 ( % 16 : ! llvm . i64 ) <nl> ^ bb4 : / / pred : ^ bb2 <nl> llvm . br ^ bb5 <nl> ^ bb5 : / / pred : ^ bb4 <nl> - % 17 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 18 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb6 ( % 17 : ! llvm < " i64 " > ) <nl> + % 17 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 18 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb6 ( % 17 : ! llvm . i64 ) <nl> / / CHECK : % { { [ 0 - 9 ] + } } = phi i64 [ % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } ] , [ 0 , % { { [ 0 - 9 ] + } } ] <nl> - ^ bb6 ( % 19 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb5 , ^ bb7 <nl> + ^ bb6 ( % 19 : ! llvm . i64 ) : / / 2 preds : ^ bb5 , ^ bb7 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = icmp slt i64 % { { [ 0 - 9 ] + } } , 10 <nl> - % 20 = llvm . icmp " slt " % 19 , % 18 : ! llvm < " i64 " > <nl> + % 20 = llvm . icmp " slt " % 19 , % 18 : ! llvm . i64 <nl> / / CHECK - NEXT : br i1 % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } <nl> llvm . cond_br % 20 , ^ bb7 , ^ bb8 <nl> ^ bb7 : / / pred : ^ bb6 <nl> / / CHECK : % { { [ 0 - 9 ] + } } = extractvalue { float * } % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = load float , float * % { { [ 0 - 9 ] + } } <nl> - % 21 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 21 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 22 = llvm . extractvalue % 6 [ 0 ] : ! llvm < " { float * } " > <nl> - % 23 = llvm . getelementptr % 22 [ % 19 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 23 = llvm . getelementptr % 22 [ % 19 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> % 24 = llvm . load % 23 : ! llvm < " float * " > <nl> - % 25 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> + % 25 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = add i64 % { { [ 0 - 9 ] + } } , 1 <nl> - % 26 = llvm . add % 19 , % 25 : ! llvm < " i64 " > <nl> + % 26 = llvm . add % 19 , % 25 : ! llvm . i64 <nl> / / CHECK - NEXT : br label % { { [ 0 - 9 ] + } } <nl> - llvm . br ^ bb6 ( % 26 : ! llvm < " i64 " > ) <nl> + llvm . br ^ bb6 ( % 26 : ! llvm . i64 ) <nl> ^ bb8 : / / pred : ^ bb6 <nl> / / CHECK : ret void <nl> llvm . return <nl> } <nl> <nl> / / CHECK - LABEL : define void @ store_load_dynamic ( i64 ) <nl> - func @ store_load_dynamic ( % arg0 : ! llvm < " i64 " > ) { <nl> + func @ store_load_dynamic ( % arg0 : ! llvm . i64 ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 % { { [ 0 - 9 ] + } } , 4 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i8 * @ malloc ( i64 % { { [ 0 - 9 ] + } } ) <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = bitcast i8 * % { { [ 0 - 9 ] + } } to float * <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 } undef , float * % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 } % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } , 1 <nl> % 0 = llvm . undef : ! llvm < " { float * , i64 } " > <nl> - % 1 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 2 = llvm . mul % arg0 , % 1 : ! llvm < " i64 " > <nl> - % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + % 1 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 2 = llvm . mul % arg0 , % 1 : ! llvm . i64 <nl> + % 3 = llvm . call @ malloc ( % 2 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> % 4 = llvm . bitcast % 3 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 5 = llvm . insertvalue % 4 , % 0 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> % 6 = llvm . insertvalue % arg0 , % 5 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> - % 7 = llvm . constant ( 1 . 000000e + 00 : f32 ) : ! llvm < " float " > <nl> + % 7 = llvm . constant ( 1 . 000000e + 00 : f32 ) : ! llvm . float <nl> / / CHECK - NEXT : br label % { { [ 0 - 9 ] + } } <nl> llvm . br ^ bb1 <nl> ^ bb1 : / / pred : ^ bb0 <nl> - % 8 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb2 ( % 8 : ! llvm < " i64 " > ) <nl> + % 8 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb2 ( % 8 : ! llvm . i64 ) <nl> / / CHECK : % { { [ 0 - 9 ] + } } = phi i64 [ % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } ] , [ 0 , % { { [ 0 - 9 ] + } } ] <nl> - ^ bb2 ( % 9 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> + ^ bb2 ( % 9 : ! llvm . i64 ) : / / 2 preds : ^ bb1 , ^ bb3 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = icmp slt i64 % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } <nl> - % 10 = llvm . icmp " slt " % 9 , % arg0 : ! llvm < " i64 " > <nl> + % 10 = llvm . icmp " slt " % 9 , % arg0 : ! llvm . i64 <nl> / / CHECK - NEXT : br i1 % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } <nl> llvm . cond_br % 10 , ^ bb3 , ^ bb4 <nl> ^ bb3 : / / pred : ^ bb2 <nl> func @ store_load_dynamic ( % arg0 : ! llvm < " i64 " > ) { <nl> / / CHECK - NEXT : store float 1 . 000000e + 00 , float * % { { [ 0 - 9 ] + } } <nl> % 11 = llvm . extractvalue % 6 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> % 12 = llvm . extractvalue % 6 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - % 13 = llvm . getelementptr % 12 [ % 9 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 13 = llvm . getelementptr % 12 [ % 9 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 7 , % 13 : ! llvm < " float * " > <nl> - % 14 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> + % 14 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = add i64 % { { [ 0 - 9 ] + } } , 1 <nl> - % 15 = llvm . add % 9 , % 14 : ! llvm < " i64 " > <nl> + % 15 = llvm . add % 9 , % 14 : ! llvm . i64 <nl> / / CHECK - NEXT : br label % { { [ 0 - 9 ] + } } <nl> - llvm . br ^ bb2 ( % 15 : ! llvm < " i64 " > ) <nl> + llvm . br ^ bb2 ( % 15 : ! llvm . i64 ) <nl> ^ bb4 : / / pred : ^ bb3 <nl> llvm . br ^ bb5 <nl> ^ bb5 : / / pred : ^ bb4 <nl> - % 16 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - llvm . br ^ bb6 ( % 16 : ! llvm < " i64 " > ) <nl> + % 16 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + llvm . br ^ bb6 ( % 16 : ! llvm . i64 ) <nl> / / CHECK : % { { [ 0 - 9 ] + } } = phi i64 [ % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } ] , [ 0 , % { { [ 0 - 9 ] + } } ] <nl> - ^ bb6 ( % 17 : ! llvm < " i64 " > ) : / / 2 preds : ^ bb5 , ^ bb7 <nl> + ^ bb6 ( % 17 : ! llvm . i64 ) : / / 2 preds : ^ bb5 , ^ bb7 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = icmp slt i64 % { { [ 0 - 9 ] + } } , % { { [ 0 - 9 ] + } } <nl> - % 18 = llvm . icmp " slt " % 17 , % arg0 : ! llvm < " i64 " > <nl> + % 18 = llvm . icmp " slt " % 17 , % arg0 : ! llvm . i64 <nl> / / CHECK - NEXT : br i1 % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } , label % { { [ 0 - 9 ] + } } <nl> llvm . cond_br % 18 , ^ bb7 , ^ bb8 <nl> ^ bb7 : / / pred : ^ bb6 <nl> func @ store_load_dynamic ( % arg0 : ! llvm < " i64 " > ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = load float , float * % { { [ 0 - 9 ] + } } <nl> % 19 = llvm . extractvalue % 6 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> % 20 = llvm . extractvalue % 6 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - % 21 = llvm . getelementptr % 20 [ % 17 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 21 = llvm . getelementptr % 20 [ % 17 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> % 22 = llvm . load % 21 : ! llvm < " float * " > <nl> - % 23 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> + % 23 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = add i64 % { { [ 0 - 9 ] + } } , 1 <nl> - % 24 = llvm . add % 17 , % 23 : ! llvm < " i64 " > <nl> + % 24 = llvm . add % 17 , % 23 : ! llvm . i64 <nl> / / CHECK - NEXT : br label % { { [ 0 - 9 ] + } } <nl> - llvm . br ^ bb6 ( % 24 : ! llvm < " i64 " > ) <nl> + llvm . br ^ bb6 ( % 24 : ! llvm . i64 ) <nl> ^ bb8 : / / pred : ^ bb6 <nl> / / CHECK : ret void <nl> llvm . return <nl> } <nl> <nl> / / CHECK - LABEL : define void @ store_load_mixed ( i64 ) <nl> - func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> - % 0 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + func @ store_load_mixed ( % arg0 : ! llvm . i64 ) { <nl> + % 0 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 2 , % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 % { { [ 0 - 9 ] + } } , 4 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 % { { [ 0 - 9 ] + } } , 10 <nl> func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 , i64 } undef , float * % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , i64 10 , 2 <nl> - % 1 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - % 2 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 3 = llvm . mul % 1 , % arg0 : ! llvm < " i64 " > <nl> - % 4 = llvm . mul % 3 , % 2 : ! llvm < " i64 " > <nl> - % 5 = llvm . mul % 4 , % 0 : ! llvm < " i64 " > <nl> + % 1 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + % 2 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 3 = llvm . mul % 1 , % arg0 : ! llvm . i64 <nl> + % 4 = llvm . mul % 3 , % 2 : ! llvm . i64 <nl> + % 5 = llvm . mul % 4 , % 0 : ! llvm . i64 <nl> % 6 = llvm . undef : ! llvm < " { float * , i64 , i64 } " > <nl> - % 7 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 8 = llvm . mul % 5 , % 7 : ! llvm < " i64 " > <nl> - % 9 = llvm . call @ malloc ( % 8 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + % 7 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 8 = llvm . mul % 5 , % 7 : ! llvm . i64 <nl> + % 9 = llvm . call @ malloc ( % 8 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> % 10 = llvm . bitcast % 9 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 11 = llvm . insertvalue % 10 , % 6 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> % 12 = llvm . insertvalue % arg0 , % 11 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i64 @ get_index ( ) <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i64 @ get_index ( ) <nl> - % 14 = llvm . constant ( 1 : index ) : ! llvm < " i64 " > <nl> - % 15 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> - % 16 = llvm . call @ get_index ( ) : ( ) - > ! llvm < " i64 " > <nl> - % 17 = llvm . call @ get_index ( ) : ( ) - > ! llvm < " i64 " > <nl> - % 18 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm < " float " > <nl> - % 19 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> + % 14 = llvm . constant ( 1 : index ) : ! llvm . i64 <nl> + % 15 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> + % 16 = llvm . call @ get_index ( ) : ( ) - > ! llvm . i64 <nl> + % 17 = llvm . call @ get_index ( ) : ( ) - > ! llvm . i64 <nl> + % 18 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm . float <nl> + % 19 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , 2 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 1 , % { { [ 0 - 9 ] + } } <nl> func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : store float 4 . 200000e + 01 , float * % { { [ 0 - 9 ] + } } <nl> % 20 = llvm . extractvalue % 13 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 21 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> + % 21 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> % 22 = llvm . extractvalue % 13 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 23 = llvm . mul % 14 , % 20 : ! llvm < " i64 " > <nl> - % 24 = llvm . add % 23 , % 15 : ! llvm < " i64 " > <nl> - % 25 = llvm . mul % 24 , % 21 : ! llvm < " i64 " > <nl> - % 26 = llvm . add % 25 , % 16 : ! llvm < " i64 " > <nl> - % 27 = llvm . mul % 26 , % 22 : ! llvm < " i64 " > <nl> - % 28 = llvm . add % 27 , % 17 : ! llvm < " i64 " > <nl> + % 23 = llvm . mul % 14 , % 20 : ! llvm . i64 <nl> + % 24 = llvm . add % 23 , % 15 : ! llvm . i64 <nl> + % 25 = llvm . mul % 24 , % 21 : ! llvm . i64 <nl> + % 26 = llvm . add % 25 , % 16 : ! llvm . i64 <nl> + % 27 = llvm . mul % 26 , % 22 : ! llvm . i64 <nl> + % 28 = llvm . add % 27 , % 17 : ! llvm . i64 <nl> % 29 = llvm . extractvalue % 13 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 30 = llvm . getelementptr % 29 [ % 28 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 30 = llvm . getelementptr % 29 [ % 28 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 18 , % 30 : ! llvm < " float * " > <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , 2 <nl> func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 , i64 } % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = load float , float * % { { [ 0 - 9 ] + } } <nl> - % 31 = llvm . constant ( 2 : index ) : ! llvm < " i64 " > <nl> + % 31 = llvm . constant ( 2 : index ) : ! llvm . i64 <nl> % 32 = llvm . extractvalue % 13 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 33 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> + % 33 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> % 34 = llvm . extractvalue % 13 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 35 = llvm . mul % 17 , % 32 : ! llvm < " i64 " > <nl> - % 36 = llvm . add % 35 , % 16 : ! llvm < " i64 " > <nl> - % 37 = llvm . mul % 36 , % 33 : ! llvm < " i64 " > <nl> - % 38 = llvm . add % 37 , % 15 : ! llvm < " i64 " > <nl> - % 39 = llvm . mul % 38 , % 34 : ! llvm < " i64 " > <nl> - % 40 = llvm . add % 39 , % 14 : ! llvm < " i64 " > <nl> + % 35 = llvm . mul % 17 , % 32 : ! llvm . i64 <nl> + % 36 = llvm . add % 35 , % 16 : ! llvm . i64 <nl> + % 37 = llvm . mul % 36 , % 33 : ! llvm . i64 <nl> + % 38 = llvm . add % 37 , % 15 : ! llvm . i64 <nl> + % 39 = llvm . mul % 38 , % 34 : ! llvm . i64 <nl> + % 40 = llvm . add % 39 , % 14 : ! llvm . i64 <nl> % 41 = llvm . extractvalue % 13 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 42 = llvm . getelementptr % 41 [ % 40 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 42 = llvm . getelementptr % 41 [ % 40 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> % 43 = llvm . load % 42 : ! llvm < " float * " > <nl> / / CHECK - NEXT : ret void <nl> llvm . return <nl> func @ store_load_mixed ( % arg0 : ! llvm < " i64 " > ) { <nl> <nl> / / CHECK - LABEL : define { float * , i64 } @ memref_args_rets ( { float * } , { float * , i64 } , { float * , i64 } ) { <nl> func @ memref_args_rets ( % arg0 : ! llvm < " { float * } " > , % arg1 : ! llvm < " { float * , i64 } " > , % arg2 : ! llvm < " { float * , i64 } " > ) - > ! llvm < " { float * , i64 } " > { <nl> - % 0 = llvm . constant ( 7 : index ) : ! llvm < " i64 " > <nl> + % 0 = llvm . constant ( 7 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = call i64 @ get_index ( ) <nl> - % 1 = llvm . call @ get_index ( ) : ( ) - > ! llvm < " i64 " > <nl> - % 2 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm < " float " > <nl> + % 1 = llvm . call @ get_index ( ) : ( ) - > ! llvm . i64 <nl> + % 2 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm . float <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * } % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 7 <nl> / / CHECK - NEXT : store float 4 . 200000e + 01 , float * % { { [ 0 - 9 ] + } } <nl> - % 3 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 3 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 4 = llvm . extractvalue % arg0 [ 0 ] : ! llvm < " { float * } " > <nl> - % 5 = llvm . getelementptr % 4 [ % 0 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 5 = llvm . getelementptr % 4 [ % 0 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 2 , % 5 : ! llvm < " float * " > <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 } % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 } % { { [ 0 - 9 ] + } } , 0 <nl> func @ memref_args_rets ( % arg0 : ! llvm < " { float * } " > , % arg1 : ! llvm < " { float * , i64 } <nl> / / CHECK - NEXT : store float 4 . 200000e + 01 , float * % { { [ 0 - 9 ] + } } <nl> % 6 = llvm . extractvalue % arg1 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> % 7 = llvm . extractvalue % arg1 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - % 8 = llvm . getelementptr % 7 [ % 0 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 8 = llvm . getelementptr % 7 [ % 0 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 2 , % 8 : ! llvm < " float * " > <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 } % { { [ 0 - 9 ] + } } , 1 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 7 , % { { [ 0 - 9 ] + } } <nl> func @ memref_args_rets ( % arg0 : ! llvm < " { float * } " > , % arg1 : ! llvm < " { float * , i64 } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = extractvalue { float * , i64 } % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = getelementptr float , float * % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : store float 4 . 200000e + 01 , float * % { { [ 0 - 9 ] + } } <nl> - % 9 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 9 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 10 = llvm . extractvalue % arg2 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> - % 11 = llvm . mul % 0 , % 10 : ! llvm < " i64 " > <nl> - % 12 = llvm . add % 11 , % 1 : ! llvm < " i64 " > <nl> + % 11 = llvm . mul % 0 , % 10 : ! llvm . i64 <nl> + % 12 = llvm . add % 11 , % 1 : ! llvm . i64 <nl> % 13 = llvm . extractvalue % arg2 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> - % 14 = llvm . getelementptr % 13 [ % 12 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 14 = llvm . getelementptr % 13 [ % 12 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> llvm . store % 2 , % 14 : ! llvm < " float * " > <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 10 , % { { [ 0 - 9 ] + } } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = mul i64 % { { [ 0 - 9 ] + } } , 4 <nl> func @ memref_args_rets ( % arg0 : ! llvm < " { float * } " > , % arg1 : ! llvm < " { float * , i64 } <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = bitcast i8 * % { { [ 0 - 9 ] + } } to float * <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 } undef , float * % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { float * , i64 } % { { [ 0 - 9 ] + } } , i64 % { { [ 0 - 9 ] + } } , 1 <nl> - % 15 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> - % 16 = llvm . mul % 15 , % 1 : ! llvm < " i64 " > <nl> + % 15 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> + % 16 = llvm . mul % 15 , % 1 : ! llvm . i64 <nl> % 17 = llvm . undef : ! llvm < " { float * , i64 } " > <nl> - % 18 = llvm . constant ( 4 : index ) : ! llvm < " i64 " > <nl> - % 19 = llvm . mul % 16 , % 18 : ! llvm < " i64 " > <nl> - % 20 = llvm . call @ malloc ( % 19 ) : ( ! llvm < " i64 " > ) - > ! llvm < " i8 * " > <nl> + % 18 = llvm . constant ( 4 : index ) : ! llvm . i64 <nl> + % 19 = llvm . mul % 16 , % 18 : ! llvm . i64 <nl> + % 20 = llvm . call @ malloc ( % 19 ) : ( ! llvm . i64 ) - > ! llvm < " i8 * " > <nl> % 21 = llvm . bitcast % 20 : ! llvm < " i8 * " > to ! llvm < " float * " > <nl> % 22 = llvm . insertvalue % 21 , % 17 [ 0 ] : ! llvm < " { float * , i64 } " > <nl> % 23 = llvm . insertvalue % 1 , % 22 [ 1 ] : ! llvm < " { float * , i64 } " > <nl> func @ memref_args_rets ( % arg0 : ! llvm < " { float * } " > , % arg1 : ! llvm < " { float * , i64 } <nl> <nl> <nl> / / CHECK - LABEL : define i64 @ memref_dim ( { float * , i64 , i64 } ) <nl> - func @ memref_dim ( % arg0 : ! llvm < " { float * , i64 , i64 } " > ) - > ! llvm < " i64 " > { <nl> + func @ memref_dim ( % arg0 : ! llvm < " { float * , i64 , i64 } " > ) - > ! llvm . i64 { <nl> / / Expecting this to create an LLVM constant . <nl> - % 0 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + % 0 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 2 = extractvalue { float * , i64 , i64 } % 0 , 1 <nl> % 1 = llvm . extractvalue % arg0 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / Expecting this to create an LLVM constant . <nl> - % 2 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 2 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> / / CHECK - NEXT : % 3 = extractvalue { float * , i64 , i64 } % 0 , 2 <nl> % 3 = llvm . extractvalue % arg0 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> / / Checking that the constant for d0 has been created . <nl> / / CHECK - NEXT : % 4 = add i64 42 , % 2 <nl> - % 4 = llvm . add % 0 , % 1 : ! llvm < " i64 " > <nl> + % 4 = llvm . add % 0 , % 1 : ! llvm . i64 <nl> / / Checking that the constant for d2 has been created . <nl> / / CHECK - NEXT : % 5 = add i64 10 , % 3 <nl> - % 5 = llvm . add % 2 , % 3 : ! llvm < " i64 " > <nl> + % 5 = llvm . add % 2 , % 3 : ! llvm . i64 <nl> / / CHECK - NEXT : % 6 = add i64 % 4 , % 5 <nl> - % 6 = llvm . add % 4 , % 5 : ! llvm < " i64 " > <nl> + % 6 = llvm . add % 4 , % 5 : ! llvm . i64 <nl> / / CHECK - NEXT : ret i64 % 6 <nl> - llvm . return % 6 : ! llvm < " i64 " > <nl> + llvm . return % 6 : ! llvm . i64 <nl> } <nl> <nl> - func @ get_i64 ( ) - > ! llvm < " i64 " > <nl> - func @ get_f32 ( ) - > ! llvm < " float " > <nl> + func @ get_i64 ( ) - > ! llvm . i64 <nl> + func @ get_f32 ( ) - > ! llvm . float <nl> func @ get_memref ( ) - > ! llvm < " { float * , i64 , i64 } " > <nl> <nl> / / CHECK - LABEL : define { i64 , float , { float * , i64 , i64 } } @ multireturn ( ) { <nl> func @ multireturn ( ) - > ! llvm < " { i64 , float , { float * , i64 , i64 } } " > { <nl> - % 0 = llvm . call @ get_i64 ( ) : ( ) - > ! llvm < " i64 " > <nl> - % 1 = llvm . call @ get_f32 ( ) : ( ) - > ! llvm < " float " > <nl> + % 0 = llvm . call @ get_i64 ( ) : ( ) - > ! llvm . i64 <nl> + % 1 = llvm . call @ get_f32 ( ) : ( ) - > ! llvm . float <nl> % 2 = llvm . call @ get_memref ( ) : ( ) - > ! llvm < " { float * , i64 , i64 } " > <nl> / / CHECK : % { { [ 0 - 9 ] + } } = insertvalue { i64 , float , { float * , i64 , i64 } } undef , i64 % { { [ 0 - 9 ] + } } , 0 <nl> / / CHECK - NEXT : % { { [ 0 - 9 ] + } } = insertvalue { i64 , float , { float * , i64 , i64 } } % { { [ 0 - 9 ] + } } , float % { { [ 0 - 9 ] + } } , 1 <nl> func @ multireturn_caller ( ) { <nl> % 1 = llvm . extractvalue % 0 [ 0 ] : ! llvm < " { i64 , float , { float * , i64 , i64 } } " > <nl> % 2 = llvm . extractvalue % 0 [ 1 ] : ! llvm < " { i64 , float , { float * , i64 , i64 } } " > <nl> % 3 = llvm . extractvalue % 0 [ 2 ] : ! llvm < " { i64 , float , { float * , i64 , i64 } } " > <nl> - % 4 = llvm . constant ( 42 ) : ! llvm < " i64 " > <nl> + % 4 = llvm . constant ( 42 ) : ! llvm . i64 <nl> / / CHECK : add i64 [ [ ret0 ] ] , 42 <nl> - % 5 = llvm . add % 1 , % 4 : ! llvm < " i64 " > <nl> - % 6 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm < " float " > <nl> + % 5 = llvm . add % 1 , % 4 : ! llvm . i64 <nl> + % 6 = llvm . constant ( 4 . 200000e + 01 : f32 ) : ! llvm . float <nl> / / CHECK : fadd float [ [ ret1 ] ] , 4 . 200000e + 01 <nl> - % 7 = llvm . fadd % 2 , % 6 : ! llvm < " float " > <nl> - % 8 = llvm . constant ( 0 : index ) : ! llvm < " i64 " > <nl> - % 9 = llvm . constant ( 42 : index ) : ! llvm < " i64 " > <nl> + % 7 = llvm . fadd % 2 , % 6 : ! llvm . float <nl> + % 8 = llvm . constant ( 0 : index ) : ! llvm . i64 <nl> + % 9 = llvm . constant ( 42 : index ) : ! llvm . i64 <nl> / / CHECK : extractvalue { float * , i64 , i64 } [ [ ret2 ] ] , 0 <nl> % 10 = llvm . extractvalue % 3 [ 1 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 11 = llvm . constant ( 10 : index ) : ! llvm < " i64 " > <nl> + % 11 = llvm . constant ( 10 : index ) : ! llvm . i64 <nl> % 12 = llvm . extractvalue % 3 [ 2 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 13 = llvm . mul % 8 , % 10 : ! llvm < " i64 " > <nl> - % 14 = llvm . add % 13 , % 8 : ! llvm < " i64 " > <nl> - % 15 = llvm . mul % 14 , % 11 : ! llvm < " i64 " > <nl> - % 16 = llvm . add % 15 , % 8 : ! llvm < " i64 " > <nl> - % 17 = llvm . mul % 16 , % 12 : ! llvm < " i64 " > <nl> - % 18 = llvm . add % 17 , % 8 : ! llvm < " i64 " > <nl> + % 13 = llvm . mul % 8 , % 10 : ! llvm . i64 <nl> + % 14 = llvm . add % 13 , % 8 : ! llvm . i64 <nl> + % 15 = llvm . mul % 14 , % 11 : ! llvm . i64 <nl> + % 16 = llvm . add % 15 , % 8 : ! llvm . i64 <nl> + % 17 = llvm . mul % 16 , % 12 : ! llvm . i64 <nl> + % 18 = llvm . add % 17 , % 8 : ! llvm . i64 <nl> % 19 = llvm . extractvalue % 3 [ 0 ] : ! llvm < " { float * , i64 , i64 } " > <nl> - % 20 = llvm . getelementptr % 19 [ % 18 ] : ( ! llvm < " float * " > , ! llvm < " i64 " > ) - > ! llvm < " float * " > <nl> + % 20 = llvm . getelementptr % 19 [ % 18 ] : ( ! llvm < " float * " > , ! llvm . i64 ) - > ! llvm < " float * " > <nl> % 21 = llvm . load % 20 : ! llvm < " float * " > <nl> llvm . return <nl> } <nl> func @ vector_ops ( % arg0 : ! llvm < " < 4 x float > " > , % arg1 : ! llvm < " < 4 x i1 > " > , % arg2 : ! <nl> } <nl> <nl> / / CHECK - LABEL : @ ops <nl> - func @ ops ( % arg0 : ! llvm < " float " > , % arg1 : ! llvm < " float " > , % arg2 : ! llvm < " i32 " > , % arg3 : ! llvm < " i32 " > ) - > ! llvm < " { float , i32 } " > { <nl> + func @ ops ( % arg0 : ! llvm . float , % arg1 : ! llvm . float , % arg2 : ! llvm . i32 , % arg3 : ! llvm . i32 ) - > ! llvm < " { float , i32 } " > { <nl> / / CHECK - NEXT : fsub float % 0 , % 1 <nl> - % 0 = llvm . fsub % arg0 , % arg1 : ! llvm < " float " > <nl> + % 0 = llvm . fsub % arg0 , % arg1 : ! llvm . float <nl> / / CHECK - NEXT : % 6 = sub i32 % 2 , % 3 <nl> - % 1 = llvm . sub % arg2 , % arg3 : ! llvm < " i32 " > <nl> + % 1 = llvm . sub % arg2 , % arg3 : ! llvm . i32 <nl> / / CHECK - NEXT : % 7 = icmp slt i32 % 2 , % 6 <nl> - % 2 = llvm . icmp " slt " % arg2 , % 1 : ! llvm < " i32 " > <nl> + % 2 = llvm . icmp " slt " % arg2 , % 1 : ! llvm . i32 <nl> / / CHECK - NEXT : % 8 = select i1 % 7 , i32 % 2 , i32 % 6 <nl> - % 3 = llvm . select % 2 , % arg2 , % 1 : ! llvm < " i1 " > , ! llvm < " i32 " > <nl> + % 3 = llvm . select % 2 , % arg2 , % 1 : ! llvm . i1 , ! llvm . i32 <nl> / / CHECK - NEXT : % 9 = sdiv i32 % 2 , % 3 <nl> - % 4 = llvm . sdiv % arg2 , % arg3 : ! llvm < " i32 " > <nl> + % 4 = llvm . sdiv % arg2 , % arg3 : ! llvm . i32 <nl> / / CHECK - NEXT : % 10 = udiv i32 % 2 , % 3 <nl> - % 5 = llvm . udiv % arg2 , % arg3 : ! llvm < " i32 " > <nl> + % 5 = llvm . udiv % arg2 , % arg3 : ! llvm . i32 <nl> / / CHECK - NEXT : % 11 = srem i32 % 2 , % 3 <nl> - % 6 = llvm . srem % arg2 , % arg3 : ! llvm < " i32 " > <nl> + % 6 = llvm . srem % arg2 , % arg3 : ! llvm . i32 <nl> / / CHECK - NEXT : % 12 = urem i32 % 2 , % 3 <nl> - % 7 = llvm . urem % arg2 , % arg3 : ! llvm < " i32 " > <nl> + % 7 = llvm . urem % arg2 , % arg3 : ! llvm . i32 <nl> <nl> % 8 = llvm . undef : ! llvm < " { float , i32 } " > <nl> % 9 = llvm . insertvalue % 0 , % 8 [ 0 ] : ! llvm < " { float , i32 } " > <nl> % 10 = llvm . insertvalue % 3 , % 9 [ 1 ] : ! llvm < " { float , i32 } " > <nl> <nl> / / CHECK : % 15 = fdiv float % 0 , % 1 <nl> - % 11 = llvm . fdiv % arg0 , % arg1 : ! llvm < " float " > <nl> + % 11 = llvm . fdiv % arg0 , % arg1 : ! llvm . float <nl> / / CHECK - NEXT : % 16 = frem float % 0 , % 1 <nl> - % 12 = llvm . frem % arg0 , % arg1 : ! llvm < " float " > <nl> + % 12 = llvm . frem % arg0 , % arg1 : ! llvm . float <nl> <nl> llvm . return % 10 : ! llvm < " { float , i32 } " > <nl> } <nl> func @ ops ( % arg0 : ! llvm < " float " > , % arg1 : ! llvm < " float " > , % arg2 : ! llvm < " i32 " > , % ar <nl> / / <nl> <nl> / / CHECK - LABEL : define void @ indirect_const_call ( i64 ) { <nl> - func @ indirect_const_call ( % arg0 : ! llvm < " i64 " > ) { <nl> + func @ indirect_const_call ( % arg0 : ! llvm . i64 ) { <nl> / / CHECK - NEXT : call void @ body ( i64 % 0 ) <nl> - % 0 = llvm . constant ( @ body : ( ! llvm < " i64 " > ) - > ( ) ) : ! llvm < " void ( i64 ) * " > <nl> - llvm . call % 0 ( % arg0 ) : ( ! llvm < " i64 " > ) - > ( ) <nl> + % 0 = llvm . constant ( @ body : ( ! llvm . i64 ) - > ( ) ) : ! llvm < " void ( i64 ) * " > <nl> + llvm . call % 0 ( % arg0 ) : ( ! llvm . i64 ) - > ( ) <nl> / / CHECK - NEXT : ret void <nl> llvm . return <nl> } <nl> <nl> / / CHECK - LABEL : define i32 @ indirect_call ( i32 ( float ) * , float ) { <nl> - func @ indirect_call ( % arg0 : ! llvm < " i32 ( float ) * " > , % arg1 : ! llvm < " float " > ) - > ! llvm < " i32 " > { <nl> + func @ indirect_call ( % arg0 : ! llvm < " i32 ( float ) * " > , % arg1 : ! llvm . float ) - > ! llvm . i32 { <nl> / / CHECK - NEXT : % 3 = call i32 % 0 ( float % 1 ) <nl> - % 0 = llvm . call % arg0 ( % arg1 ) : ( ! llvm < " float " > ) - > ! llvm < " i32 " > <nl> + % 0 = llvm . call % arg0 ( % arg1 ) : ( ! llvm . float ) - > ! llvm . i32 <nl> / / CHECK - NEXT : ret i32 % 3 <nl> - llvm . return % 0 : ! llvm < " i32 " > <nl> + llvm . return % 0 : ! llvm . i32 <nl> } <nl> <nl> / / <nl> func @ indirect_call ( % arg0 : ! llvm < " i32 ( float ) * " > , % arg1 : ! llvm < " float " > ) - > ! llv <nl> / / <nl> <nl> / / CHECK - LABEL : define void @ cond_br_arguments ( i1 , i1 ) { <nl> - func @ cond_br_arguments ( % arg0 : ! llvm < " i1 " > , % arg1 : ! llvm < " i1 " > ) { <nl> + func @ cond_br_arguments ( % arg0 : ! llvm . i1 , % arg1 : ! llvm . i1 ) { <nl> / / CHECK - NEXT : br i1 % 0 , label % 3 , label % 5 <nl> - llvm . cond_br % arg0 , ^ bb1 ( % arg0 : ! llvm < " i1 " > ) , ^ bb2 <nl> + llvm . cond_br % arg0 , ^ bb1 ( % arg0 : ! llvm . i1 ) , ^ bb2 <nl> <nl> / / CHECK : 3 : <nl> / / CHECK - NEXT : % 4 = phi i1 [ % 1 , % 5 ] , [ % 0 , % 2 ] <nl> - ^ bb1 ( % 0 : ! llvm < " i1 " > ) : <nl> + ^ bb1 ( % 0 : ! llvm . i1 ) : <nl> / / CHECK - NEXT : ret void <nl> llvm . return <nl> <nl> / / CHECK : 5 : <nl> ^ bb2 : <nl> / / CHECK - NEXT : br label % 3 <nl> - llvm . br ^ bb1 ( % arg1 : ! llvm < " i1 " > ) <nl> + llvm . br ^ bb1 ( % arg1 : ! llvm . i1 ) <nl> } <nl> <nl> / / CHECK - LABEL : define void @ llvm_noalias ( float * noalias ) { <nl> | Change the asmprinter to use pretty syntax for dialect types when it can , | tensorflow/tensorflow | 5d1371d43d58ae449a8ff1d19a3d9f10e88e30b0 | 2019-04-08T01:21:13Z |
mmm a / src / arch / linux / disk / accounting . hpp <nl> ppp b / src / arch / linux / disk / accounting . hpp <nl> struct accounting_diskmgr_t { <nl> passive_producer_t < payload_t * > * const producer ; <nl> void done ( payload_t * p ) { <nl> / / p really is an action_t . . . <nl> - action_t * a = reinterpret_cast < action_t * > ( p ) ; <nl> + action_t * a = static_cast < action_t * > ( p ) ; <nl> a - > account - > outstanding_requests_limiter . unlock ( 1 ) ; <nl> done_fun ( static_cast < action_t * > ( p ) ) ; <nl> } <nl> | Turned a reinterpret_cast into a static_cast . | rethinkdb/rethinkdb | aafb76f35550d319eddf4382cc83a2af5b85dc7c | 2011-07-12T00:18:45Z |
mmm a / port / win / env_win . cc <nl> ppp b / port / win / env_win . cc <nl> class WinMmapReadableFile : public RandomAccessFile { <nl> char * scratch ) const override { <nl> Status s ; <nl> <nl> - if ( offset + n > length_ ) { <nl> + if ( offset > length_ ) { <nl> * result = Slice ( ) ; <nl> - s = IOError ( fileName_ , EINVAL ) ; <nl> - } else { <nl> - * result = <nl> - Slice ( reinterpret_cast < const char * > ( mapped_region_ ) + offset , n ) ; <nl> + return IOError ( fileName_ , EINVAL ) ; <nl> + } else if ( offset + n > length_ ) { <nl> + n = length_ - offset ; <nl> } <nl> + * result = <nl> + Slice ( reinterpret_cast < const char * > ( mapped_region_ ) + offset , n ) ; <nl> return s ; <nl> } <nl> <nl> | Mmap reads should not return error if reading past file | facebook/rocksdb | e95b703b7fe7a7d7c116195e4e0c44b6d0c8ae93 | 2015-10-06T23:19:58Z |
mmm a / src / core / lib / channel / channelz_registry . h <nl> ppp b / src / core / lib / channel / channelz_registry . h <nl> <nl> * <nl> * / <nl> <nl> - # ifndef GRPC_CORE_LIB_CHANNEL_CHANNELz_REGISTRY_H <nl> - # define GRPC_CORE_LIB_CHANNEL_CHANNELz_REGISTRY_H <nl> + # ifndef GRPC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H <nl> + # define GRPC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H <nl> <nl> # include < grpc / impl / codegen / port_platform . h > <nl> <nl> class ChannelzRegistry { <nl> <nl> } / / namespace grpc_core <nl> <nl> - # endif / * GRPC_CORE_LIB_CHANNEL_CHANNELz_REGISTRY_H * / <nl> + # endif / * GRPC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H * / <nl> mmm a / test / core / channel / channelz_registry_test . cc <nl> ppp b / test / core / channel / channelz_registry_test . cc <nl> <nl> # include " src / core / lib / json / json . h " <nl> <nl> # include " test / core / util / test_config . h " <nl> - # include " test / cpp / util / channel_trace_proto_helper . h " <nl> <nl> # include < stdlib . h > <nl> # include < string . h > <nl> | fix sanity and bazel | grpc/grpc | 7243c5f1f6bc4e384800900e4fda295a5c24c0ff | 2018-05-17T22:07:53Z |
mmm a / src / btree / btree_store . cc <nl> ppp b / src / btree / btree_store . cc <nl> <nl> <nl> sindex_not_post_constructed_exc_t : : sindex_not_post_constructed_exc_t ( <nl> std : : string sindex_name ) <nl> - : info ( strprintf ( " Sindex : % s was accessed before it was finished post constructing . " , <nl> + : info ( strprintf ( " Index ` % s ` was accessed before its construction was finished . " , <nl> sindex_name . c_str ( ) ) ) <nl> { } <nl> <nl> mmm a / src / rdb_protocol / protocol . cc <nl> ppp b / src / rdb_protocol / protocol . cc <nl> struct rdb_read_visitor_t : public boost : : static_visitor < void > { <nl> NULL ) ; <nl> return ; <nl> } <nl> - } catch ( const sindex_not_post_constructed_exc_t & ) { <nl> + } catch ( const sindex_not_post_constructed_exc_t & e ) { <nl> res - > result = ql : : exc_t ( <nl> - ql : : base_exc_t : : GENERIC , <nl> - strprintf ( " Index ` % s ` was accessed before its construction " <nl> - " was finished . " , rget . sindex - > id . c_str ( ) ) , <nl> - NULL ) ; <nl> + ql : : base_exc_t : : GENERIC , e . what ( ) , NULL ) ; <nl> return ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / terms / sindex . cc <nl> ppp b / src / rdb_protocol / terms / sindex . cc <nl> class sindex_status_term_t : public op_term_t { <nl> virtual const char * name ( ) const { return " sindex_status " ; } <nl> } ; <nl> <nl> - / * We wait 10 seconds between polls to the indexes . * / <nl> - int64_t poll_ms = 10000 ; <nl> + / * We wait for no more than 10 seconds between polls to the indexes . * / <nl> + int64_t initial_poll_ms = 50 ; <nl> + int64_t max_poll_ms = 10000 ; <nl> <nl> bool all_ready ( counted_t < const datum_t > statuses ) { <nl> for ( size_t i = 0 ; i < statuses - > size ( ) ; + + i ) { <nl> class sindex_wait_term_t : public op_term_t { <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> sindexes . insert ( arg ( env , i ) - > as_str ( ) . to_std ( ) ) ; <nl> } <nl> + / / Start with initial_poll_ms , then double the waiting period after each <nl> + / / attempt up to a maximum of max_poll_ms . <nl> + int64_t current_poll_ms = initial_poll_ms ; <nl> for ( ; ; ) { <nl> counted_t < const datum_t > statuses = <nl> table - > sindex_status ( env - > env , sindexes ) ; <nl> if ( all_ready ( statuses ) ) { <nl> return new_val ( statuses ) ; <nl> } else { <nl> - nap ( poll_ms , env - > env - > interruptor ) ; <nl> + nap ( current_poll_ms , env - > env - > interruptor ) ; <nl> + current_poll_ms = std : : min ( max_poll_ms , current_poll_ms * 2 ) ; <nl> } <nl> } <nl> } <nl> | Improved the sindex_wait ( ) polling nap logic . Minor cleanup of the sindex not ready error handling . | rethinkdb/rethinkdb | 13e7f38121e626dc9cf2171c8068eda1281c36d8 | 2014-03-27T04:43:48Z |
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> matrix : <nl> - bash . / install . sh <nl> script : <nl> # todo : use python unittest <nl> - - mkdir run ; cd run ; python - c " import vnpy . api . ctp . vnctp ; import vnpy . api . oes . vnoes ; exit ( 0 ) ; " <nl> + - mkdir run ; cd run ; python - c " import vnpy . api . ctp . vnctpmd ; import vnpy . api . oes . vnoes ; exit ( 0 ) ; " <nl> <nl> - name : " pip install under Ubuntu : gcc - 7 " <nl> before_install : <nl> | [ Fix ] travis . yml : fixed miss typed vnctp | vnpy/vnpy | 27d49b3604f60de96d3ae5260477e7ed92512161 | 2019-03-19T14:42:53Z |
mmm a / tensorflow / python / util / tf_export . py <nl> ppp b / tensorflow / python / util / tf_export . py <nl> def get_canonical_name ( api_names , deprecated_api_names ) : <nl> return None <nl> <nl> <nl> + def get_v1_names ( symbol ) : <nl> + " " " Get a list of TF 1 . * names for this symbol . <nl> + <nl> + Args : <nl> + symbol : symbol to get API names for . <nl> + <nl> + Returns : <nl> + List of all API names for this symbol including TensorFlow and <nl> + Estimator names . <nl> + " " " <nl> + names_v1 = [ ] <nl> + tensorflow_api_attr_v1 = API_ATTRS_V1 [ TENSORFLOW_API_NAME ] . names <nl> + estimator_api_attr_v1 = API_ATTRS_V1 [ ESTIMATOR_API_NAME ] . names <nl> + <nl> + if not hasattr ( symbol , tensorflow_api_attr_v1 ) : <nl> + return names_v1 <nl> + if tensorflow_api_attr_v1 in symbol . __dict__ : <nl> + names_v1 . extend ( getattr ( symbol , tensorflow_api_attr_v1 ) ) <nl> + if estimator_api_attr_v1 in symbol . __dict__ : <nl> + names_v1 . extend ( getattr ( symbol , estimator_api_attr_v1 ) ) <nl> + return names_v1 <nl> + <nl> + <nl> + def get_v2_names ( symbol ) : <nl> + " " " Get a list of TF 2 . 0 names for this symbol . <nl> + <nl> + Args : <nl> + symbol : symbol to get API names for . <nl> + <nl> + Returns : <nl> + List of all API names for this symbol including TensorFlow and <nl> + Estimator names . <nl> + " " " <nl> + names_v2 = [ ] <nl> + tensorflow_api_attr = API_ATTRS [ TENSORFLOW_API_NAME ] . names <nl> + estimator_api_attr = API_ATTRS [ ESTIMATOR_API_NAME ] . names <nl> + <nl> + if not hasattr ( symbol , tensorflow_api_attr ) : <nl> + return names_v2 <nl> + if tensorflow_api_attr in symbol . __dict__ : <nl> + names_v2 . extend ( getattr ( symbol , tensorflow_api_attr ) ) <nl> + if estimator_api_attr in symbol . __dict__ : <nl> + names_v2 . extend ( getattr ( symbol , estimator_api_attr ) ) <nl> + return names_v2 <nl> + <nl> + <nl> + def get_v1_constants ( module ) : <nl> + " " " Get a list of TF 1 . * constants in this module . <nl> + <nl> + Args : <nl> + module : TensorFlow module . <nl> + <nl> + Returns : <nl> + List of all API constants under the given module including TensorFlow and <nl> + Estimator constants . <nl> + " " " <nl> + constants_v1 = [ ] <nl> + tensorflow_constants_attr_v1 = API_ATTRS_V1 [ TENSORFLOW_API_NAME ] . constants <nl> + estimator_constants_attr_v1 = API_ATTRS_V1 [ ESTIMATOR_API_NAME ] . constants <nl> + <nl> + if hasattr ( module , tensorflow_constants_attr_v1 ) : <nl> + constants_v1 . extend ( getattr ( module , tensorflow_constants_attr_v1 ) ) <nl> + if hasattr ( module , estimator_constants_attr_v1 ) : <nl> + constants_v1 . extend ( getattr ( module , estimator_constants_attr_v1 ) ) <nl> + return constants_v1 <nl> + <nl> + <nl> + def get_v2_constants ( module ) : <nl> + " " " Get a list of TF 2 . 0 constants in this module . <nl> + <nl> + Args : <nl> + module : TensorFlow module . <nl> + <nl> + Returns : <nl> + List of all API constants under the given module including TensorFlow and <nl> + Estimator constants . <nl> + " " " <nl> + constants_v2 = [ ] <nl> + tensorflow_constants_attr = API_ATTRS [ TENSORFLOW_API_NAME ] . constants <nl> + estimator_constants_attr = API_ATTRS [ ESTIMATOR_API_NAME ] . constants <nl> + <nl> + if hasattr ( module , tensorflow_constants_attr ) : <nl> + constants_v2 . extend ( getattr ( module , tensorflow_constants_attr ) ) <nl> + if hasattr ( module , estimator_constants_attr ) : <nl> + constants_v2 . extend ( getattr ( module , estimator_constants_attr ) ) <nl> + return constants_v2 <nl> + <nl> + <nl> class api_export ( object ) : # pylint : disable = invalid - name <nl> " " " Provides ways to export symbols to the TensorFlow API . " " " <nl> <nl> mmm a / tensorflow / python / util / tf_export_test . py <nl> ppp b / tensorflow / python / util / tf_export_test . py <nl> def tearDown ( self ) : <nl> del symbol . _tf_api_names <nl> if hasattr ( symbol , ' _tf_api_names_v1 ' ) : <nl> del symbol . _tf_api_names_v1 <nl> + if hasattr ( symbol , ' _estimator_api_names ' ) : <nl> + del symbol . _estimator_api_names <nl> + if hasattr ( symbol , ' _estimator_api_names_v1 ' ) : <nl> + del symbol . _estimator_api_names_v1 <nl> <nl> def _CreateMockModule ( self , name ) : <nl> mock_module = self . MockModule ( name ) <nl> def testExportSingleFunction ( self ) : <nl> decorated_function = export_decorator ( _test_function ) <nl> self . assertEquals ( decorated_function , _test_function ) <nl> self . assertEquals ( ( ' nameA ' , ' nameB ' ) , decorated_function . _tf_api_names ) <nl> + self . assertEquals ( [ ' nameA ' , ' nameB ' ] , <nl> + tf_export . get_v1_names ( decorated_function ) ) <nl> + self . assertEquals ( [ ' nameA ' , ' nameB ' ] , <nl> + tf_export . get_v2_names ( decorated_function ) ) <nl> <nl> def testExportMultipleFunctions ( self ) : <nl> export_decorator1 = tf_export . tf_export ( ' nameA ' , ' nameB ' ) <nl> def testExportClasses ( self ) : <nl> export_decorator_b ( TestClassB ) <nl> self . assertEquals ( ( ' TestClassA1 ' , ) , TestClassA . _tf_api_names ) <nl> self . assertEquals ( ( ' TestClassB1 ' , ) , TestClassB . _tf_api_names ) <nl> + self . assertEquals ( [ ' TestClassA1 ' ] , tf_export . get_v1_names ( TestClassA ) ) <nl> + self . assertEquals ( [ ' TestClassB1 ' ] , tf_export . get_v1_names ( TestClassB ) ) <nl> + <nl> + def testExportClassInEstimator ( self ) : <nl> + export_decorator_a = tf_export . tf_export ( ' TestClassA1 ' ) <nl> + export_decorator_a ( TestClassA ) <nl> + self . assertEquals ( ( ' TestClassA1 ' , ) , TestClassA . _tf_api_names ) <nl> + <nl> + export_decorator_b = tf_export . estimator_export ( <nl> + ' estimator . TestClassB1 ' ) <nl> + export_decorator_b ( TestClassB ) <nl> + self . assertTrue ( ' _tf_api_names ' not in TestClassB . __dict__ ) <nl> + self . assertEquals ( ( ' TestClassA1 ' , ) , TestClassA . _tf_api_names ) <nl> + self . assertEquals ( [ ' TestClassA1 ' ] , tf_export . get_v1_names ( TestClassA ) ) <nl> + self . assertEquals ( [ ' estimator . TestClassB1 ' ] , <nl> + tf_export . get_v1_names ( TestClassB ) ) <nl> <nl> def testExportSingleConstant ( self ) : <nl> module1 = self . _CreateMockModule ( ' module1 ' ) <nl> def testExportSingleConstant ( self ) : <nl> export_decorator . export_constant ( ' module1 ' , ' test_constant ' ) <nl> self . assertEquals ( [ ( ( ' NAME_A ' , ' NAME_B ' ) , ' test_constant ' ) ] , <nl> module1 . _tf_api_constants ) <nl> + self . assertEquals ( [ ( ( ' NAME_A ' , ' NAME_B ' ) , ' test_constant ' ) ] , <nl> + tf_export . get_v1_constants ( module1 ) ) <nl> + self . assertEquals ( [ ( ( ' NAME_A ' , ' NAME_B ' ) , ' test_constant ' ) ] , <nl> + tf_export . get_v2_constants ( module1 ) ) <nl> <nl> def testExportMultipleConstants ( self ) : <nl> module1 = self . _CreateMockModule ( ' module1 ' ) <nl> mmm a / tensorflow / tools / compatibility / tf_upgrade_v2_test . py <nl> ppp b / tensorflow / tools / compatibility / tf_upgrade_v2_test . py <nl> <nl> from tensorflow . tools . compatibility import tf_upgrade_v2 <nl> <nl> <nl> - _TENSORFLOW_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . TENSORFLOW_API_NAME ] . names ) <nl> - _TENSORFLOW_API_ATTR = tf_export . API_ATTRS [ tf_export . TENSORFLOW_API_NAME ] . names <nl> - _ESTIMATOR_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . ESTIMATOR_API_NAME ] . names ) <nl> - _ESTIMATOR_API_ATTR = tf_export . API_ATTRS [ tf_export . ESTIMATOR_API_NAME ] . names <nl> - <nl> - <nl> - def get_v1_names ( symbol ) : <nl> - names_v1 = [ ] <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) ) <nl> - return names_v1 <nl> - <nl> - <nl> - def get_v2_names ( symbol ) : <nl> - names_v2 = set ( ) <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR ) : <nl> - names_v2 . update ( getattr ( symbol , _TENSORFLOW_API_ATTR ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR ) : <nl> - names_v2 . update ( getattr ( symbol , _ESTIMATOR_API_ATTR ) ) <nl> - return list ( names_v2 ) <nl> - <nl> - <nl> def get_symbol_for_name ( root , name ) : <nl> name_parts = name . split ( " . " ) <nl> symbol = root <nl> def setUpClass ( cls ) : <nl> def symbol_collector ( unused_path , unused_parent , children ) : <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names_v2 = get_v2_names ( attr ) <nl> + api_names_v2 = tf_export . get_v2_names ( attr ) <nl> for name in api_names_v2 : <nl> cls . v2_symbols [ " tf . " + name ] = attr <nl> <nl> def testAllAPI ( self ) : <nl> def conversion_visitor ( unused_path , unused_parent , children ) : <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names = get_v1_names ( attr ) <nl> + api_names = tf_export . get_v1_names ( attr ) <nl> for name in api_names : <nl> _ , _ , _ , text = self . _upgrade ( " tf . " + name ) <nl> if ( text and <nl> def testAllAPIV1 ( self ) : <nl> def conversion_visitor ( unused_path , unused_parent , children ) : <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names = get_v1_names ( attr ) <nl> + api_names = tf_export . get_v1_names ( attr ) <nl> for name in api_names : <nl> if collect : <nl> v1_symbols . add ( " tf . " + name ) <nl> def testV1KeywordArgNames ( self ) : <nl> def arg_test_visitor ( unused_path , unused_parent , children ) : <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - names_v1 = get_v1_names ( attr ) <nl> + names_v1 = tf_export . get_v1_names ( attr ) <nl> <nl> for name in names_v1 : <nl> name = " tf . % s " % name <nl> def conversion_visitor ( unused_path , unused_parent , children ) : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> if not tf_inspect . isfunction ( attr ) : <nl> continue <nl> - names_v1 = get_v1_names ( attr ) <nl> + names_v1 = tf_export . get_v1_names ( attr ) <nl> arg_names_v1 = get_args ( attr ) <nl> <nl> for name in names_v1 : <nl> def testReorderFileNeedsUpdate ( self ) : <nl> # get other names for this function <nl> attr = get_symbol_for_name ( tf . compat . v1 , name ) <nl> _ , attr = tf_decorator . unwrap ( attr ) <nl> - v1_names = get_v1_names ( attr ) <nl> + v1_names = tf_export . get_v1_names ( attr ) <nl> self . assertTrue ( v1_names ) <nl> v1_names = [ " tf . % s " % n for n in v1_names ] <nl> # check if any other name is in <nl> mmm a / tensorflow / tools / compatibility / update / generate_v2_renames_map . py <nl> ppp b / tensorflow / tools / compatibility / update / generate_v2_renames_map . py <nl> <nl> <nl> " " " <nl> <nl> - _TENSORFLOW_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . TENSORFLOW_API_NAME ] . names ) <nl> - _TENSORFLOW_API_ATTR = tf_export . API_ATTRS [ tf_export . TENSORFLOW_API_NAME ] . names <nl> - _TENSORFLOW_CONSTANTS_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . TENSORFLOW_API_NAME ] . constants ) <nl> - _TENSORFLOW_CONSTANTS_ATTR = ( <nl> - tf_export . API_ATTRS [ tf_export . TENSORFLOW_API_NAME ] . constants ) <nl> - <nl> - _ESTIMATOR_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . ESTIMATOR_API_NAME ] . names ) <nl> - _ESTIMATOR_API_ATTR = tf_export . API_ATTRS [ tf_export . ESTIMATOR_API_NAME ] . names <nl> - _ESTIMATOR_CONSTANTS_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . ESTIMATOR_API_NAME ] . constants ) <nl> - _ESTIMATOR_CONSTANTS_ATTR = ( <nl> - tf_export . API_ATTRS [ tf_export . ESTIMATOR_API_NAME ] . constants ) <nl> - <nl> - <nl> - def get_v1_names ( symbol ) : <nl> - names_v1 = [ ] <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) ) <nl> - return names_v1 <nl> - <nl> - <nl> - def get_v2_names ( symbol ) : <nl> - names_v2 = [ ] <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR ) : <nl> - names_v2 . extend ( getattr ( symbol , _TENSORFLOW_API_ATTR ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR ) : <nl> - names_v2 . extend ( getattr ( symbol , _ESTIMATOR_API_ATTR ) ) <nl> - return list ( names_v2 ) <nl> - <nl> - <nl> - def get_v1_constants ( module ) : <nl> - constants_v1 = [ ] <nl> - if hasattr ( module , _TENSORFLOW_CONSTANTS_ATTR_V1 ) : <nl> - constants_v1 . extend ( getattr ( module , _TENSORFLOW_CONSTANTS_ATTR_V1 ) ) <nl> - if hasattr ( module , _ESTIMATOR_CONSTANTS_ATTR_V1 ) : <nl> - constants_v1 . extend ( getattr ( module , _ESTIMATOR_CONSTANTS_ATTR_V1 ) ) <nl> - return constants_v1 <nl> - <nl> - <nl> - def get_v2_constants ( module ) : <nl> - constants_v2 = [ ] <nl> - if hasattr ( module , _TENSORFLOW_CONSTANTS_ATTR ) : <nl> - constants_v2 . extend ( getattr ( module , _TENSORFLOW_CONSTANTS_ATTR ) ) <nl> - if hasattr ( module , _ESTIMATOR_CONSTANTS_ATTR ) : <nl> - constants_v2 . extend ( getattr ( module , _ESTIMATOR_CONSTANTS_ATTR ) ) <nl> - return constants_v2 <nl> - <nl> <nl> def get_canonical_name ( v2_names , v1_name ) : <nl> if v2_names : <nl> def visit ( unused_path , unused_parent , children ) : <nl> " " " Visitor that collects TF 2 . 0 names . " " " <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names_v2 = get_v2_names ( attr ) <nl> + api_names_v2 = tf_export . get_v2_names ( attr ) <nl> for name in api_names_v2 : <nl> v2_names . add ( name ) <nl> <nl> def collect_constant_renames ( ) : <nl> " " " <nl> renames = set ( ) <nl> for module in sys . modules . values ( ) : <nl> - constants_v1_list = get_v1_constants ( module ) <nl> - constants_v2_list = get_v2_constants ( module ) <nl> + constants_v1_list = tf_export . get_v1_constants ( module ) <nl> + constants_v2_list = tf_export . get_v2_constants ( module ) <nl> <nl> # _tf_api_constants attribute contains a list of tuples : <nl> # ( api_names_list , constant_name ) <nl> def visit ( unused_path , unused_parent , children ) : <nl> " " " Visitor that collects rename strings to add to rename_line_set . " " " <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names_v1 = get_v1_names ( attr ) <nl> - api_names_v2 = get_v2_names ( attr ) <nl> + api_names_v1 = tf_export . get_v1_names ( attr ) <nl> + api_names_v2 = tf_export . get_v2_names ( attr ) <nl> deprecated_api_names = set ( api_names_v1 ) - set ( api_names_v2 ) <nl> for name in deprecated_api_names : <nl> renames . add ( ( name , get_canonical_name ( api_names_v2 , name ) ) ) <nl> mmm a / tensorflow / tools / compatibility / update / generate_v2_reorders_map . py <nl> ppp b / tensorflow / tools / compatibility / update / generate_v2_reorders_map . py <nl> <nl> <nl> " " " <nl> <nl> - _TENSORFLOW_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . TENSORFLOW_API_NAME ] . names ) <nl> - _TENSORFLOW_API_ATTR = tf_export . API_ATTRS [ tf_export . TENSORFLOW_API_NAME ] . names <nl> - _TENSORFLOW_CONSTANTS_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . TENSORFLOW_API_NAME ] . constants ) <nl> - _TENSORFLOW_CONSTANTS_ATTR = ( <nl> - tf_export . API_ATTRS [ tf_export . TENSORFLOW_API_NAME ] . constants ) <nl> - <nl> - _ESTIMATOR_API_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . ESTIMATOR_API_NAME ] . names ) <nl> - _ESTIMATOR_API_ATTR = tf_export . API_ATTRS [ tf_export . ESTIMATOR_API_NAME ] . names <nl> - _ESTIMATOR_CONSTANTS_ATTR_V1 = ( <nl> - tf_export . API_ATTRS_V1 [ tf_export . ESTIMATOR_API_NAME ] . constants ) <nl> - _ESTIMATOR_CONSTANTS_ATTR = ( <nl> - tf_export . API_ATTRS [ tf_export . ESTIMATOR_API_NAME ] . constants ) <nl> - <nl> - <nl> - def get_v1_names ( symbol ) : <nl> - names_v1 = [ ] <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _TENSORFLOW_API_ATTR_V1 ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) : <nl> - names_v1 . extend ( getattr ( symbol , _ESTIMATOR_API_ATTR_V1 ) ) <nl> - return names_v1 <nl> - <nl> - <nl> - def get_v2_names ( symbol ) : <nl> - names_v2 = [ ] <nl> - if hasattr ( symbol , _TENSORFLOW_API_ATTR ) : <nl> - names_v2 . extend ( getattr ( symbol , _TENSORFLOW_API_ATTR ) ) <nl> - if hasattr ( symbol , _ESTIMATOR_API_ATTR ) : <nl> - names_v2 . extend ( getattr ( symbol , _ESTIMATOR_API_ATTR ) ) <nl> - return list ( names_v2 ) <nl> - <nl> <nl> def collect_function_arg_names ( function_names ) : <nl> " " " Determines argument names for reordered function signatures . <nl> def visit ( unused_path , unused_parent , children ) : <nl> " " " Visitor that collects arguments for reordered functions . " " " <nl> for child in children : <nl> _ , attr = tf_decorator . unwrap ( child [ 1 ] ) <nl> - api_names_v1 = get_v1_names ( attr ) <nl> + api_names_v1 = tf_export . get_v1_names ( attr ) <nl> api_names_v1 = [ ' tf . % s ' % name for name in api_names_v1 ] <nl> matches_function_names = any ( <nl> name in function_names for name in api_names_v1 ) <nl> | Use " in symbol . __dict__ " instead of " hasattr " to check if a symbol has api | tensorflow/tensorflow | 93439a553937e77e8877a149d13039960da59abf | 2018-12-11T21:47:46Z |
mmm a / src / core / lib / channel / channel_stack . c <nl> ppp b / src / core / lib / channel / channel_stack . c <nl> <nl> * / <nl> <nl> # include " src / core / lib / channel / channel_stack . h " <nl> + # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> <nl> # include < stdlib . h > <nl> grpc_call_stack * grpc_call_stack_from_top_element ( grpc_call_element * elem ) { <nl> sizeof ( grpc_call_stack ) ) ) ; <nl> } <nl> <nl> + static void destroy_op ( grpc_exec_ctx * exec_ctx , void * op , grpc_error * error ) { <nl> + gpr_free ( op ) ; <nl> + } <nl> + <nl> void grpc_call_element_send_cancel ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * cur_elem ) { <nl> - grpc_transport_stream_op op ; <nl> - memset ( & op , 0 , sizeof ( op ) ) ; <nl> - op . cancel_error = GRPC_ERROR_CANCELLED ; <nl> - grpc_call_next_op ( exec_ctx , cur_elem , & op ) ; <nl> + grpc_transport_stream_op * op = gpr_malloc ( sizeof ( * op ) ) ; <nl> + memset ( op , 0 , sizeof ( * op ) ) ; <nl> + op - > cancel_error = GRPC_ERROR_CANCELLED ; <nl> + op - > on_complete = grpc_closure_create ( destroy_op , op ) ; <nl> + grpc_call_next_op ( exec_ctx , cur_elem , op ) ; <nl> } <nl> <nl> void grpc_call_element_send_cancel_with_message ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * cur_elem , <nl> grpc_status_code status , <nl> gpr_slice * optional_message ) { <nl> - grpc_transport_stream_op op ; <nl> - memset ( & op , 0 , sizeof ( op ) ) ; <nl> - grpc_transport_stream_op_add_cancellation_with_message ( & op , status , <nl> + grpc_transport_stream_op * op = gpr_malloc ( sizeof ( * op ) ) ; <nl> + memset ( op , 0 , sizeof ( * op ) ) ; <nl> + op - > on_complete = grpc_closure_create ( destroy_op , op ) ; <nl> + grpc_transport_stream_op_add_cancellation_with_message ( op , status , <nl> optional_message ) ; <nl> - grpc_call_next_op ( exec_ctx , cur_elem , & op ) ; <nl> + grpc_call_next_op ( exec_ctx , cur_elem , op ) ; <nl> } <nl> mmm a / src / core / lib / channel / compress_filter . c <nl> ppp b / src / core / lib / channel / compress_filter . c <nl> typedef struct call_data { <nl> / * * If true , contents of \ a compression_algorithm are authoritative * / <nl> int has_compression_algorithm ; <nl> <nl> - grpc_transport_stream_op send_op ; <nl> + grpc_transport_stream_op * send_op ; <nl> uint32_t send_length ; <nl> uint32_t send_flags ; <nl> gpr_slice incoming_slice ; <nl> static void finish_send_message ( grpc_exec_ctx * exec_ctx , <nl> <nl> grpc_slice_buffer_stream_init ( & calld - > replacement_stream , & calld - > slices , <nl> calld - > send_flags ) ; <nl> - calld - > send_op . send_message = & calld - > replacement_stream . base ; <nl> - calld - > post_send = calld - > send_op . on_complete ; <nl> - calld - > send_op . on_complete = & calld - > send_done ; <nl> + calld - > send_op - > send_message = & calld - > replacement_stream . base ; <nl> + calld - > post_send = calld - > send_op - > on_complete ; <nl> + calld - > send_op - > on_complete = & calld - > send_done ; <nl> <nl> - grpc_call_next_op ( exec_ctx , elem , & calld - > send_op ) ; <nl> + grpc_call_next_op ( exec_ctx , elem , calld - > send_op ) ; <nl> } <nl> <nl> static void got_slice ( grpc_exec_ctx * exec_ctx , void * elemp , grpc_error * error ) { <nl> static void got_slice ( grpc_exec_ctx * exec_ctx , void * elemp , grpc_error * error ) { <nl> static void continue_send_message ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * elem ) { <nl> call_data * calld = elem - > call_data ; <nl> - while ( grpc_byte_stream_next ( exec_ctx , calld - > send_op . send_message , <nl> + while ( grpc_byte_stream_next ( exec_ctx , calld - > send_op - > send_message , <nl> & calld - > incoming_slice , ~ ( size_t ) 0 , <nl> & calld - > got_slice ) ) { <nl> gpr_slice_buffer_add ( & calld - > slices , calld - > incoming_slice ) ; <nl> static void compress_start_transport_stream_op ( grpc_exec_ctx * exec_ctx , <nl> } <nl> if ( op - > send_message ! = NULL & & ! skip_compression ( elem ) & & <nl> 0 = = ( op - > send_message - > flags & GRPC_WRITE_NO_COMPRESS ) ) { <nl> - calld - > send_op = * op ; <nl> + calld - > send_op = op ; <nl> calld - > send_length = op - > send_message - > length ; <nl> calld - > send_flags = op - > send_message - > flags ; <nl> continue_send_message ( exec_ctx , elem ) ; <nl> mmm a / src / core / lib / security / transport / server_auth_filter . c <nl> ppp b / src / core / lib / security / transport / server_auth_filter . c <nl> typedef struct call_data { <nl> up - call on transport_op , and remember to call our on_done_recv member after <nl> handling it . * / <nl> grpc_closure auth_on_recv ; <nl> - grpc_transport_stream_op transport_op ; <nl> + grpc_transport_stream_op * transport_op ; <nl> grpc_metadata_array md ; <nl> const grpc_metadata * consumed_md ; <nl> size_t num_consumed_md ; <nl> static grpc_mdelem * remove_consumed_md ( void * user_data , grpc_mdelem * md ) { <nl> return md ; <nl> } <nl> <nl> + static void destroy_op ( grpc_exec_ctx * exec_ctx , void * arg , grpc_error * error ) { <nl> + gpr_free ( arg ) ; <nl> + } <nl> + <nl> / * called from application code * / <nl> static void on_md_processing_done ( <nl> void * user_data , const grpc_metadata * consumed_md , size_t num_consumed_md , <nl> static void on_md_processing_done ( <nl> grpc_exec_ctx_sched ( & exec_ctx , calld - > on_done_recv , GRPC_ERROR_NONE , NULL ) ; <nl> } else { <nl> gpr_slice message ; <nl> - grpc_transport_stream_op close_op ; <nl> - memset ( & close_op , 0 , sizeof ( close_op ) ) ; <nl> + grpc_transport_stream_op * close_op = gpr_malloc ( sizeof ( * close_op ) ) ; <nl> + memset ( close_op , 0 , sizeof ( * close_op ) ) ; <nl> grpc_metadata_array_destroy ( & calld - > md ) ; <nl> error_details = error_details ! = NULL <nl> ? error_details <nl> : " Authentication metadata processing failed . " ; <nl> message = gpr_slice_from_copied_string ( error_details ) ; <nl> - calld - > transport_op . send_initial_metadata = NULL ; <nl> - if ( calld - > transport_op . send_message ! = NULL ) { <nl> - grpc_byte_stream_destroy ( & exec_ctx , calld - > transport_op . send_message ) ; <nl> - calld - > transport_op . send_message = NULL ; <nl> + calld - > transport_op - > send_initial_metadata = NULL ; <nl> + if ( calld - > transport_op - > send_message ! = NULL ) { <nl> + grpc_byte_stream_destroy ( & exec_ctx , calld - > transport_op - > send_message ) ; <nl> + calld - > transport_op - > send_message = NULL ; <nl> } <nl> - calld - > transport_op . send_trailing_metadata = NULL ; <nl> - grpc_transport_stream_op_add_close ( & close_op , status , & message ) ; <nl> - grpc_call_next_op ( & exec_ctx , elem , & close_op ) ; <nl> + calld - > transport_op - > send_trailing_metadata = NULL ; <nl> + close_op - > on_complete = grpc_closure_create ( destroy_op , close_op ) ; <nl> + grpc_transport_stream_op_add_close ( close_op , status , & message ) ; <nl> + grpc_call_next_op ( & exec_ctx , elem , close_op ) ; <nl> grpc_exec_ctx_sched ( & exec_ctx , calld - > on_done_recv , <nl> grpc_error_set_int ( GRPC_ERROR_CREATE ( error_details ) , <nl> GRPC_ERROR_INT_GRPC_STATUS , status ) , <nl> static void set_recv_ops_md_callbacks ( grpc_call_element * elem , <nl> calld - > recv_initial_metadata = op - > recv_initial_metadata ; <nl> calld - > on_done_recv = op - > recv_initial_metadata_ready ; <nl> op - > recv_initial_metadata_ready = & calld - > auth_on_recv ; <nl> - calld - > transport_op = * op ; <nl> + calld - > transport_op = op ; <nl> } <nl> } <nl> <nl> mmm a / src / core / lib / surface / call . c <nl> ppp b / src / core / lib / surface / call . c <nl> typedef struct batch_control { <nl> uint8_t recv_message ; <nl> uint8_t recv_final_op ; <nl> uint8_t is_notify_tag_closure ; <nl> + <nl> + / * TODO ( ctiller ) : now that this is inlined , figure out how much of the above <nl> + state can be eliminated * / <nl> + grpc_transport_stream_op op ; <nl> } batch_control ; <nl> <nl> struct grpc_call { <nl> typedef struct termination_closure { <nl> grpc_error * error ; <nl> grpc_closure * op_closure ; <nl> enum { TC_CANCEL , TC_CLOSE } type ; <nl> + grpc_transport_stream_op op ; <nl> } termination_closure ; <nl> <nl> static void done_termination ( grpc_exec_ctx * exec_ctx , void * tcp , <nl> static void done_termination ( grpc_exec_ctx * exec_ctx , void * tcp , <nl> } <nl> <nl> static void send_cancel ( grpc_exec_ctx * exec_ctx , void * tcp , grpc_error * error ) { <nl> - grpc_transport_stream_op op ; <nl> termination_closure * tc = tcp ; <nl> - memset ( & op , 0 , sizeof ( op ) ) ; <nl> - op . cancel_error = tc - > error ; <nl> + memset ( & tc - > op , 0 , sizeof ( tc - > op ) ) ; <nl> + tc - > op . cancel_error = tc - > error ; <nl> / * reuse closure to catch completion * / <nl> grpc_closure_init ( & tc - > closure , done_termination , tc ) ; <nl> - op . on_complete = & tc - > closure ; <nl> - execute_op ( exec_ctx , tc - > call , & op ) ; <nl> + tc - > op . on_complete = & tc - > closure ; <nl> + execute_op ( exec_ctx , tc - > call , & tc - > op ) ; <nl> } <nl> <nl> static void send_close ( grpc_exec_ctx * exec_ctx , void * tcp , grpc_error * error ) { <nl> - grpc_transport_stream_op op ; <nl> termination_closure * tc = tcp ; <nl> - memset ( & op , 0 , sizeof ( op ) ) ; <nl> - op . close_error = tc - > error ; <nl> + memset ( & tc - > op , 0 , sizeof ( tc - > op ) ) ; <nl> + tc - > op . close_error = tc - > error ; <nl> / * reuse closure to catch completion * / <nl> grpc_closure_init ( & tc - > closure , done_termination , tc ) ; <nl> - tc - > op_closure = op . on_complete ; <nl> - op . on_complete = & tc - > closure ; <nl> - execute_op ( exec_ctx , tc - > call , & op ) ; <nl> + tc - > op_closure = tc - > op . on_complete ; <nl> + tc - > op . on_complete = & tc - > closure ; <nl> + execute_op ( exec_ctx , tc - > call , & tc - > op ) ; <nl> } <nl> <nl> static grpc_call_error terminate_with_status ( grpc_exec_ctx * exec_ctx , <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> grpc_call * call , const grpc_op * ops , <nl> size_t nops , void * notify_tag , <nl> int is_notify_tag_closure ) { <nl> - grpc_transport_stream_op stream_op ; <nl> size_t i ; <nl> const grpc_op * op ; <nl> batch_control * bctl ; <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> <nl> GRPC_CALL_LOG_BATCH ( GPR_INFO , call , ops , nops , notify_tag ) ; <nl> <nl> - memset ( & stream_op , 0 , sizeof ( stream_op ) ) ; <nl> - <nl> / * TODO ( ctiller ) : this feels like it could be made lock - free * / <nl> gpr_mu_lock ( & call - > mu ) ; <nl> bctl = allocate_batch_control ( call ) ; <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> bctl - > notify_tag = notify_tag ; <nl> bctl - > is_notify_tag_closure = ( uint8_t ) ( is_notify_tag_closure ! = 0 ) ; <nl> <nl> + grpc_transport_stream_op * stream_op = & bctl - > op ; <nl> + memset ( stream_op , 0 , sizeof ( * stream_op ) ) ; <nl> + <nl> if ( nops = = 0 ) { <nl> GRPC_CALL_INTERNAL_REF ( call , " completion " ) ; <nl> bctl - > error = GRPC_ERROR_NONE ; <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> } <nl> / * TODO ( ctiller ) : just make these the same variable ? * / <nl> call - > metadata_batch [ 0 ] [ 0 ] . deadline = call - > send_deadline ; <nl> - stream_op . send_initial_metadata = <nl> + stream_op - > send_initial_metadata = <nl> & call - > metadata_batch [ 0 / * is_receiving * / ] [ 0 / * is_trailing * / ] ; <nl> - stream_op . send_initial_metadata_flags = op - > flags ; <nl> + stream_op - > send_initial_metadata_flags = op - > flags ; <nl> break ; <nl> case GRPC_OP_SEND_MESSAGE : <nl> if ( ! are_write_flags_valid ( op - > flags ) ) { <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> grpc_slice_buffer_stream_init ( <nl> & call - > sending_stream , <nl> & op - > data . send_message - > data . raw . slice_buffer , op - > flags ) ; <nl> - stream_op . send_message = & call - > sending_stream . base ; <nl> + stream_op - > send_message = & call - > sending_stream . base ; <nl> break ; <nl> case GRPC_OP_SEND_CLOSE_FROM_CLIENT : <nl> / * Flag validation : currently allow no flags * / <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> } <nl> bctl - > send_final_op = 1 ; <nl> call - > sent_final_op = 1 ; <nl> - stream_op . send_trailing_metadata = <nl> + stream_op - > send_trailing_metadata = <nl> & call - > metadata_batch [ 0 / * is_receiving * / ] [ 1 / * is_trailing * / ] ; <nl> break ; <nl> case GRPC_OP_SEND_STATUS_FROM_SERVER : <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> error = GRPC_CALL_ERROR_INVALID_METADATA ; <nl> goto done_with_error ; <nl> } <nl> - stream_op . send_trailing_metadata = <nl> + stream_op - > send_trailing_metadata = <nl> & call - > metadata_batch [ 0 / * is_receiving * / ] [ 1 / * is_trailing * / ] ; <nl> break ; <nl> case GRPC_OP_RECV_INITIAL_METADATA : <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> grpc_closure_init ( & call - > receiving_initial_metadata_ready , <nl> receiving_initial_metadata_ready , bctl ) ; <nl> bctl - > recv_initial_metadata = 1 ; <nl> - stream_op . recv_initial_metadata = <nl> + stream_op - > recv_initial_metadata = <nl> & call - > metadata_batch [ 1 / * is_receiving * / ] [ 0 / * is_trailing * / ] ; <nl> - stream_op . recv_initial_metadata_ready = <nl> + stream_op - > recv_initial_metadata_ready = <nl> & call - > receiving_initial_metadata_ready ; <nl> num_completion_callbacks_needed + + ; <nl> break ; <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> call - > receiving_message = 1 ; <nl> bctl - > recv_message = 1 ; <nl> call - > receiving_buffer = op - > data . recv_message ; <nl> - stream_op . recv_message = & call - > receiving_stream ; <nl> + stream_op - > recv_message = & call - > receiving_stream ; <nl> grpc_closure_init ( & call - > receiving_stream_ready , receiving_stream_ready , <nl> bctl ) ; <nl> - stream_op . recv_message_ready = & call - > receiving_stream_ready ; <nl> + stream_op - > recv_message_ready = & call - > receiving_stream_ready ; <nl> num_completion_callbacks_needed + + ; <nl> break ; <nl> case GRPC_OP_RECV_STATUS_ON_CLIENT : <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> call - > final_op . client . status_details_capacity = <nl> op - > data . recv_status_on_client . status_details_capacity ; <nl> bctl - > recv_final_op = 1 ; <nl> - stream_op . recv_trailing_metadata = <nl> + stream_op - > recv_trailing_metadata = <nl> & call - > metadata_batch [ 1 / * is_receiving * / ] [ 1 / * is_trailing * / ] ; <nl> - stream_op . collect_stats = & call - > stats . transport_stream_stats ; <nl> + stream_op - > collect_stats = & call - > stats . transport_stream_stats ; <nl> break ; <nl> case GRPC_OP_RECV_CLOSE_ON_SERVER : <nl> / * Flag validation : currently allow no flags * / <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> call - > final_op . server . cancelled = <nl> op - > data . recv_close_on_server . cancelled ; <nl> bctl - > recv_final_op = 1 ; <nl> - stream_op . recv_trailing_metadata = <nl> + stream_op - > recv_trailing_metadata = <nl> & call - > metadata_batch [ 1 / * is_receiving * / ] [ 1 / * is_trailing * / ] ; <nl> - stream_op . collect_stats = & call - > stats . transport_stream_stats ; <nl> + stream_op - > collect_stats = & call - > stats . transport_stream_stats ; <nl> break ; <nl> } <nl> } <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> } <nl> gpr_ref_init ( & bctl - > steps_to_complete , num_completion_callbacks_needed ) ; <nl> <nl> - stream_op . context = call - > context ; <nl> + stream_op - > context = call - > context ; <nl> grpc_closure_init ( & bctl - > finish_batch , finish_batch , bctl ) ; <nl> - stream_op . on_complete = & bctl - > finish_batch ; <nl> + stream_op - > on_complete = & bctl - > finish_batch ; <nl> gpr_mu_unlock ( & call - > mu ) ; <nl> <nl> - execute_op ( exec_ctx , call , & stream_op ) ; <nl> + execute_op ( exec_ctx , call , stream_op ) ; <nl> <nl> done : <nl> GPR_TIMER_END ( " grpc_call_start_batch " , 0 ) ; <nl> | Make transport_stream_ops all be heap allocated | grpc/grpc | 6e7b45ed215fe113abed17002fddf5635c97549c | 2016-07-09T00:25:49Z |
mmm a / validation - test / compiler_crashers / 1293 - swift - modulefile - getimportedmodules . swift <nl> ppp b / validation - test / compiler_crashers / 1293 - swift - modulefile - getimportedmodules . swift <nl> <nl> - / / RUN : not - - crash % target - swift - frontend % s - parse <nl> - / / XFAIL : asan <nl> + / / RUN : not % target - swift - frontend % s - parse <nl> <nl> / / Distributed under the terms of the MIT license <nl> / / Test case submitted to project by https : / / github . com / practicalswift ( practicalswift ) <nl> | Compiler crasher 1293 no longer crashes after r26508 . | apple/swift | 972d0d6cba13befa83fe12232e58c400b5eb2423 | 2015-03-25T18:46:50Z |
new file mode 100644 <nl> index 0000000000000 . . ce17ac4fa0d37 <nl> mmm / dev / null <nl> ppp b / tensorflow / lite / java / jni / BUILD <nl> <nl> + package ( default_visibility = [ " / / tensorflow / lite : __subpackages__ " ] ) <nl> + <nl> + licenses ( [ " notice " ] ) # Apache 2 . 0 <nl> + <nl> + # Helper target for exposing JNI headers across multiple platforms . <nl> + cc_library ( <nl> + name = " jni " , <nl> + hdrs = select ( { <nl> + # The Android toolchain makes " jni . h " available in the include path . <nl> + # For non - Android toolchains , generate jni . h and jni_md . h . <nl> + " / / tensorflow : android " : [ ] , <nl> + " / / conditions : default " : [ <nl> + " : jni . h " , <nl> + " : jni_md . h " , <nl> + ] , <nl> + } ) , <nl> + includes = select ( { <nl> + " / / tensorflow : android " : [ ] , <nl> + " / / conditions : default " : [ " . " ] , <nl> + } ) , <nl> + ) <nl> + <nl> + # Silly rules to make <nl> + # # include < jni . h > <nl> + # in the source headers work <nl> + # ( in combination with the " includes " attribute of the tf_cuda_library rule <nl> + # above . Not needed when using the Android toolchain ) . <nl> + # <nl> + # Inspired from : <nl> + # https : / / github . com / bazelbuild / bazel / blob / f99a0543f8d97339d32075c7176b79f35be84606 / src / main / native / BUILD <nl> + # but hopefully there is a simpler alternative to this . <nl> + genrule ( <nl> + name = " copy_jni_h " , <nl> + srcs = [ " @ bazel_tools / / tools / jdk : jni_header " ] , <nl> + outs = [ " jni . h " ] , <nl> + cmd = " cp - f $ < $ @ " , <nl> + ) <nl> + <nl> + genrule ( <nl> + name = " copy_jni_md_h " , <nl> + srcs = select ( { <nl> + " / / tensorflow : darwin " : [ " @ bazel_tools / / tools / jdk : jni_md_header - darwin " ] , <nl> + " / / conditions : default " : [ " @ bazel_tools / / tools / jdk : jni_md_header - linux " ] , <nl> + } ) , <nl> + outs = [ " jni_md . h " ] , <nl> + cmd = " cp - f $ < $ @ " , <nl> + ) <nl> mmm a / tensorflow / lite / java / src / main / native / BUILD <nl> ppp b / tensorflow / lite / java / src / main / native / BUILD <nl> cc_library ( <nl> " nativeinterpreterwrapper_jni . cc " , <nl> " tensor_jni . cc " , <nl> " tensorflow_lite_jni . cc " , <nl> - ] + select ( { <nl> - # The Android toolchain makes " jni . h " available in the include path . <nl> - # For non - Android toolchains , generate jni . h and jni_md . h . <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ <nl> - " : jni . h " , <nl> - " : jni_md . h " , <nl> - ] , <nl> - } ) , <nl> + ] , <nl> hdrs = [ <nl> " exception_jni . h " , <nl> " nativeinterpreterwrapper_jni . h " , <nl> cc_library ( <nl> " tensorflow_lite_jni . h " , <nl> ] , <nl> copts = tflite_copts ( ) , <nl> - includes = select ( { <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ " . " ] , <nl> - } ) , <nl> linkopts = [ <nl> " - lm " , <nl> " - ldl " , <nl> ] , <nl> deps = [ <nl> - " / / tensorflow / lite : context " , <nl> " / / tensorflow / lite : framework " , <nl> " / / tensorflow / lite : schema_fbs_version " , <nl> " / / tensorflow / lite : string_util " , <nl> + " / / tensorflow / lite / c : c_api_internal " , <nl> + " / / tensorflow / lite / java / jni " , <nl> ] , <nl> alwayslink = 1 , <nl> ) <nl> <nl> - # Silly rules to make <nl> - # # include < jni . h > <nl> - # in the source headers work <nl> - # ( in combination with the " includes " attribute of the tf_cuda_library rule <nl> - # above . Not needed when using the Android toolchain ) . <nl> - # <nl> - # Inspired from : <nl> - # https : / / github . com / bazelbuild / bazel / blob / f99a0543f8d97339d32075c7176b79f35be84606 / src / main / native / BUILD <nl> - # but hopefully there is a simpler alternative to this . <nl> - genrule ( <nl> - name = " copy_jni_h " , <nl> - srcs = [ " @ bazel_tools / / tools / jdk : jni_header " ] , <nl> - outs = [ " jni . h " ] , <nl> - cmd = " cp - f $ < $ @ " , <nl> - ) <nl> - <nl> - genrule ( <nl> - name = " copy_jni_md_h " , <nl> - srcs = select ( { <nl> - " / / tensorflow : darwin " : [ " @ bazel_tools / / tools / jdk : jni_md_header - darwin " ] , <nl> - " / / conditions : default " : [ " @ bazel_tools / / tools / jdk : jni_md_header - linux " ] , <nl> - } ) , <nl> - outs = [ " jni_md . h " ] , <nl> - cmd = " cp - f $ < $ @ " , <nl> - ) <nl> - <nl> cc_library ( <nl> name = " init_tensorflow " , <nl> srcs = [ <nl> " init_tensorflow_jni . cc " , <nl> - ] + select ( { <nl> - # The Android toolchain makes " jni . h " available in the include path . <nl> - # For non - Android toolchains , generate jni . h and jni_md . h . <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ <nl> - " : jni . h " , <nl> - " : jni_md . h " , <nl> - ] , <nl> - } ) , <nl> + ] , <nl> hdrs = [ <nl> " init_tensorflow_jni . h " , <nl> ] , <nl> copts = tflite_copts ( ) , <nl> - includes = select ( { <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ " . " ] , <nl> - } ) , <nl> - linkopts = [ <nl> - " - lm " , <nl> - " - ldl " , <nl> - ] , <nl> deps = [ <nl> + " / / tensorflow / lite / java / jni " , <nl> " / / tensorflow / lite / testing : init_tensorflow " , <nl> ] , <nl> alwayslink = 1 , <nl> mmm a / tensorflow / lite / java / src / test / native / BUILD <nl> ppp b / tensorflow / lite / java / src / test / native / BUILD <nl> cc_library ( <nl> testonly = 1 , <nl> srcs = [ <nl> " interpreter_test_jni . cc " , <nl> - ] + select ( { <nl> - # The Android toolchain makes " jni . h " available in the include path . <nl> - # For non - Android toolchains , generate jni . h and jni_md . h . <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ <nl> - " / / tensorflow / lite / java / src / main / native : jni . h " , <nl> - " / / tensorflow / lite / java / src / main / native : jni_md . h " , <nl> - ] , <nl> - } ) , <nl> - includes = select ( { <nl> - " / / tensorflow : android " : [ ] , <nl> - " / / conditions : default " : [ " . . / . . / main / native / . " ] , <nl> - } ) , <nl> - deps = [ " / / tensorflow / lite / c : c_api_internal " ] , <nl> + ] , <nl> + deps = [ <nl> + " / / tensorflow / lite / c : c_api_internal " , <nl> + " / / tensorflow / lite / java / jni " , <nl> + ] , <nl> ) <nl> <nl> tflite_jni_binary ( <nl> mmm a / tensorflow / lite / models / smartreply / demo / app / src / main / BUILD <nl> ppp b / tensorflow / lite / models / smartreply / demo / app / src / main / BUILD <nl> cc_library ( <nl> ] , <nl> deps = [ <nl> " / / tensorflow / lite : framework " , <nl> + " / / tensorflow / lite / java / jni " , <nl> " / / tensorflow / lite / models / smartreply : predictor_lib " , <nl> ] , <nl> alwayslink = 1 , <nl> | Consolidate JNI inclusion code | tensorflow/tensorflow | 5dfbcfbba04197117cff01a07397f499682d3f56 | 2018-12-08T00:31:45Z |
mmm a / test / test_utils . py <nl> ppp b / test / test_utils . py <nl> <nl> import unittest <nl> import traceback <nl> import torch <nl> + import torch . utils . data <nl> import torch . cuda <nl> import warnings <nl> from torch . autograd import Variable <nl> def __len__ ( self ) : <nl> return 10 <nl> <nl> <nl> + class TestDataLoader ( TestCase ) : <nl> + def setUp ( self ) : <nl> + self . dataset = torch . randn ( 5 , 3 , 3 , 2 ) <nl> + self . batch_size = 3 <nl> + <nl> + def test_single_keep ( self ) : <nl> + dataloader = torch . utils . data . DataLoader ( self . dataset , <nl> + batch_size = self . batch_size , <nl> + num_workers = 0 , <nl> + drop_last = False ) <nl> + dataiter = iter ( dataloader ) <nl> + self . assertEqual ( len ( list ( dataiter ) ) , 2 ) <nl> + <nl> + def test_single_drop ( self ) : <nl> + dataloader = torch . utils . data . DataLoader ( self . dataset , <nl> + batch_size = self . batch_size , <nl> + num_workers = 0 , <nl> + drop_last = True ) <nl> + dataiter = iter ( dataloader ) <nl> + self . assertEqual ( len ( list ( dataiter ) ) , 1 ) <nl> + <nl> + def test_multi_keep ( self ) : <nl> + dataloader = torch . utils . data . DataLoader ( self . dataset , <nl> + batch_size = self . batch_size , <nl> + num_workers = 2 , <nl> + drop_last = False ) <nl> + dataiter = iter ( dataloader ) <nl> + self . assertEqual ( len ( list ( dataiter ) ) , 2 ) <nl> + <nl> + def test_multi_drop ( self ) : <nl> + dataloader = torch . utils . data . DataLoader ( self . dataset , <nl> + batch_size = self . batch_size , <nl> + num_workers = 2 , <nl> + drop_last = True ) <nl> + dataiter = iter ( dataloader ) <nl> + self . assertEqual ( len ( list ( dataiter ) ) , 1 ) <nl> + <nl> + <nl> class TestTrainer ( TestCase ) : <nl> <nl> intervals = [ <nl> mmm a / torch / utils / data / dataloader . py <nl> ppp b / torch / utils / data / dataloader . py <nl> def __init__ ( self , loader ) : <nl> self . sampler = loader . sampler <nl> self . num_workers = loader . num_workers <nl> self . pin_memory = loader . pin_memory <nl> + self . drop_last = loader . drop_last <nl> self . done_event = threading . Event ( ) <nl> <nl> self . samples_remaining = len ( self . sampler ) <nl> def __init__ ( self , loader ) : <nl> self . _put_indices ( ) <nl> <nl> def __len__ ( self ) : <nl> - return int ( math . ceil ( len ( self . sampler ) / float ( self . batch_size ) ) ) <nl> + if self . drop_last : <nl> + return len ( self . sampler ) / / self . batch_size <nl> + else : <nl> + return ( len ( self . sampler ) + self . batch_size - 1 ) / / self . batch_size <nl> <nl> def __next__ ( self ) : <nl> - if self . num_workers = = 0 : <nl> - # same - process loading <nl> + if self . num_workers = = 0 : # same - process loading <nl> + if self . drop_last and self . samples_remaining < self . batch_size : <nl> + raise StopIteration <nl> if self . samples_remaining = = 0 : <nl> raise StopIteration <nl> indices = self . _next_indices ( ) <nl> def _next_indices ( self ) : <nl> def _put_indices ( self ) : <nl> assert self . batches_outstanding < 2 * self . num_workers <nl> if self . samples_remaining > 0 : <nl> - self . index_queue . put ( ( self . send_idx , self . _next_indices ( ) ) ) <nl> - self . batches_outstanding + = 1 <nl> - self . send_idx + = 1 <nl> + if self . samples_remaining < self . batch_size and self . drop_last : <nl> + self . _next_indices ( ) <nl> + else : <nl> + self . index_queue . put ( ( self . send_idx , self . _next_indices ( ) ) ) <nl> + self . batches_outstanding + = 1 <nl> + self . send_idx + = 1 <nl> <nl> def _process_next_batch ( self , batch ) : <nl> self . rcvd_idx + = 1 <nl> class DataLoader ( object ) : <nl> ( default : 0 ) <nl> collate_fn ( callable , optional ) <nl> pin_memory ( bool , optional ) <nl> + drop_last ( bool , optional ) : set to ` ` True ` ` to drop the last incomplete batch , <nl> + if the dataset size is not divisible by the batch size . If False and <nl> + the size of dataset is not divisible by the batch size , then the last batch <nl> + will be smaller . ( default : False ) <nl> " " " <nl> <nl> - def __init__ ( self , dataset , batch_size = 1 , shuffle = False , sampler = None , <nl> - num_workers = 0 , collate_fn = default_collate , pin_memory = False ) : <nl> + def __init__ ( self , dataset , batch_size = 1 , shuffle = False , sampler = None , num_workers = 0 , <nl> + collate_fn = default_collate , pin_memory = False , drop_last = False ) : <nl> self . dataset = dataset <nl> self . batch_size = batch_size <nl> self . num_workers = num_workers <nl> self . collate_fn = collate_fn <nl> self . pin_memory = pin_memory <nl> + self . drop_last = drop_last <nl> <nl> if sampler is not None : <nl> self . sampler = sampler <nl> def __iter__ ( self ) : <nl> return DataLoaderIter ( self ) <nl> <nl> def __len__ ( self ) : <nl> - return int ( math . ceil ( len ( self . sampler ) / float ( self . batch_size ) ) ) <nl> + if self . drop_last : <nl> + return len ( self . sampler ) / / self . batch_size <nl> + else : <nl> + return ( len ( self . sampler ) + self . batch_size - 1 ) / / self . batch_size <nl> | Add a flag to fix when dataset size is not divisible by batch size . ( ) | pytorch/pytorch | 9f2a5d804d812607afc7a0e549e0849c5ae11a73 | 2017-04-06T04:18:43Z |
mmm a / src / replication / slave . cc <nl> ppp b / src / replication / slave . cc <nl> slave_t : : slave_t ( btree_key_value_store_t * internal_store , replication_config_t r <nl> failover_config_t failover_config , failover_t * failover ) : <nl> failover_ ( failover ) , <nl> timeout_ ( INITIAL_TIMEOUT ) , <nl> - failover_reset_control_ ( std : : string ( " failover reset " ) , this ) , <nl> - new_master_control_ ( std : : string ( " new master " ) , this ) , <nl> + failover_reset_control_ ( this ) , <nl> + new_master_control_ ( this ) , <nl> internal_store_ ( internal_store ) , <nl> replication_config_ ( replication_config ) , <nl> failover_config_ ( failover_config ) <nl> slave_t : : ~ slave_t ( ) { <nl> pulsed_when_run_loop_done_ . wait ( ) ; <nl> } <nl> <nl> - std : : string slave_t : : failover_reset ( ) { <nl> - / / TODO don ' t say get_num_threads ( ) - 2 , what does this mean ? <nl> - on_thread_t thread_switch ( get_num_threads ( ) - 2 ) ; <nl> + void slave_t : : failover_reset ( ) { <nl> + on_thread_t thread_switch ( home_thread ) ; <nl> give_up_ . reset ( ) ; <nl> timeout_ = INITIAL_TIMEOUT ; <nl> <nl> std : : string slave_t : : failover_reset ( ) { <nl> on connecting to the master , this will cause us to resume trying to connect . If we <nl> are in a timeout before retrying the connection , this will cut the timout short . * / <nl> pulse_to_interrupt_run_loop_ . pulse_if_non_null ( ) ; <nl> + } <nl> + <nl> + void slave_t : : new_master ( std : : string host , int port ) { <nl> + on_thread_t thread_switcher ( home_thread ) ; <nl> + <nl> + / * redo the replication_config info * / <nl> + strcpy ( replication_config_ . hostname , host . c_str ( ) ) ; <nl> + replication_config_ . port = port ; <nl> <nl> - return std : : string ( " Resetting failover \ n " ) ; <nl> + failover_reset ( ) ; <nl> } <nl> <nl> / * give_up_t interface : the give_up_t struct keeps track of the last N times <nl> void run ( slave_t * slave ) { <nl> } else { <nl> logINF ( " Master at % s : % d has failed % d times in the last % d seconds , " <nl> " going rogue . To resume slave behavior send the command " <nl> - " \ " rethinkdb failover reset \ " ( over telnet ) . \ n " , <nl> + " \ " rethinkdb failover - reset \ " ( over telnet ) . \ n " , <nl> slave - > replication_config_ . hostname , slave - > replication_config_ . port , <nl> MAX_RECONNECTS_PER_N_SECONDS , N_SECONDS ) ; <nl> <nl> void run ( slave_t * slave ) { <nl> slave - > pulsed_when_run_loop_done_ . pulse ( ) ; <nl> } <nl> <nl> - std : : string slave_t : : new_master ( int argc , char * * argv ) { <nl> - guarantee ( argc = = 3 ) ; / / TODO : Handle argc = 0 . <nl> - std : : string host = argv [ 1 ] ; <nl> - if ( host . length ( ) > MAX_HOSTNAME_LEN - 1 ) <nl> - return " That hostname is too long ; use a shorter one . \ n " ; <nl> - <nl> - / * redo the replication_config info * / <nl> - strcpy ( replication_config_ . hostname , host . c_str ( ) ) ; <nl> - replication_config_ . port = atoi ( argv [ 2 ] ) ; / / TODO this is ugly <nl> - <nl> - failover_reset ( ) ; <nl> - <nl> - return " New master set \ n " ; <nl> - } <nl> - <nl> - / / TODO : instead of UNUSED , ensure that these parameters are empty . <nl> - std : : string slave_t : : failover_reset_control_t : : call ( UNUSED int argc , UNUSED char * * argv ) { <nl> - return slave - > failover_reset ( ) ; <nl> - } <nl> - <nl> - std : : string slave_t : : new_master_control_t : : call ( UNUSED int argc , UNUSED char * * argv ) { <nl> - return slave - > new_master ( argc , argv ) ; <nl> - } <nl> - <nl> } / / namespace replication <nl> <nl> mmm a / src / replication / slave . hpp <nl> ppp b / src / replication / slave . hpp <nl> class slave_t : <nl> / * Failover controllers * / <nl> <nl> / * Control to allow the failover state to be reset during run time * / <nl> - std : : string failover_reset ( ) ; <nl> + void failover_reset ( ) ; <nl> <nl> class failover_reset_control_t : public control_t { <nl> public : <nl> - failover_reset_control_t ( std : : string key , slave_t * slave ) <nl> - : control_t ( key , " Reset the failover module to the state at startup ( will force a reconnection to the master ) . " ) , slave ( slave ) <nl> - { } <nl> - std : : string call ( int argc , char * * argv ) ; <nl> + failover_reset_control_t ( slave_t * slave ) <nl> + : control_t ( " failover - reset " , " Reset the failover module to the state at startup . This will force a reconnection to the master . " ) , slave ( slave ) <nl> + { } <nl> + std : : string call ( int argc , UNUSED char * * argv ) { <nl> + if ( argc = = 1 ) { <nl> + slave - > failover_reset ( ) ; <nl> + return " Failover module was reset . \ r \ n " ; <nl> + } else { <nl> + return " \ " failover - reset \ " expects no arguments . \ r \ n " ; <nl> + } <nl> + } <nl> private : <nl> slave_t * slave ; <nl> } ; <nl> <nl> / * Control to allow the master to be changed during run time * / <nl> - std : : string new_master ( int argc , char * * argv ) ; <nl> + void new_master ( std : : string host , int port ) ; <nl> <nl> class new_master_control_t : public control_t { <nl> public : <nl> - new_master_control_t ( std : : string key , slave_t * slave ) <nl> - : control_t ( key , " Set a new master for replication ( the slave will disconnect and immediately reconnect to the new server ) . Syntax : \ " rdb new_master host port \ " " ) , slave ( slave ) <nl> - { } <nl> - std : : string call ( int argc , char * * argv ) ; <nl> + new_master_control_t ( slave_t * slave ) <nl> + : control_t ( " new - master " , " Set a new master for replication . The slave will disconnect and immediately reconnect to the new server . Syntax : \ " rethinkdb new - master host port \ " " ) , slave ( slave ) <nl> + { } <nl> + std : : string call ( int argc , char * * argv ) { <nl> + if ( argc ! = 3 ) return " Syntax : \ " rethinkdb new - master host port \ " \ r \ n " ; <nl> + std : : string host = argv [ 1 ] ; <nl> + if ( host . length ( ) > MAX_HOSTNAME_LEN - 1 ) <nl> + return " That hostname is too long ; use a shorter one . \ r \ n " ; <nl> + int port = atoi ( argv [ 2 ] ) ; <nl> + if ( port < = 0 ) <nl> + return " Can ' t interpret \ " " + std : : string ( argv [ 2 ] ) + " \ " as a valid port . \ r \ n " ; <nl> + slave - > new_master ( host , port ) ; <nl> + return " New master was set . \ r \ n " ; <nl> + } <nl> private : <nl> slave_t * slave ; <nl> } ; <nl> mmm a / src / server / control . cc <nl> ppp b / src / server / control . cc <nl> <nl> <nl> control_map_t & get_control_map ( ) { <nl> / * Getter function so that we can be sure that control_list is initialized before it is needed , <nl> - as advised by the C + + FAQ . Otherwise , a control_t might be initialized before the control list <nl> + as advised by the C + + FAQ . Otherwise , a control_t might be initialized before the control list <nl> was initialized . * / <nl> <nl> static control_map_t control_map ; <nl> spinlock_t & get_control_lock ( ) { <nl> } <nl> <nl> std : : string control_t : : exec ( int argc , char * * argv ) { <nl> - if ( argc = = 0 ) return help ( ) ; <nl> + if ( argc = = 0 ) { <nl> + return " You must provide a command name . Type \ " rethinkdb help \ " for a list of available " <nl> + " commands . \ r \ n " ; <nl> + } <nl> std : : string command = argv [ 0 ] ; <nl> <nl> control_map_t : : iterator it = get_control_map ( ) . find ( command ) ; <nl> if ( it = = get_control_map ( ) . end ( ) ) { <nl> - return help ( ) ; <nl> + return " There is no command called \ " " + command + " \ " . Type \ " rethinkdb help \ " for a " <nl> + " list of available commands . \ r \ n " ; <nl> } else { <nl> return ( * it ) . second - > call ( argc , argv ) ; <nl> } <nl> } <nl> <nl> - std : : string control_t : : help ( ) { <nl> - std : : string res ; <nl> - for ( control_map_t : : iterator it = get_control_map ( ) . begin ( ) ; it ! = get_control_map ( ) . end ( ) ; it + + ) { <nl> - if ( ( * it ) . second - > help_string . size ( ) = = 0 ) continue ; <nl> - res + = ( ( * it ) . first + " : " + ( * it ) . second - > help_string + " \ r \ n " ) ; <nl> - } <nl> - return res ; <nl> - } <nl> - <nl> - control_t : : control_t ( const std : : string & _key , const std : : string & _help_string ) <nl> - : key ( _key ) , help_string ( _help_string ) <nl> + control_t : : control_t ( const std : : string & _key , const std : : string & _help_string , bool _secret ) <nl> + : key ( _key ) , help_string ( _help_string ) , secret ( _secret ) <nl> { <nl> rassert ( key . size ( ) > 0 ) ; <nl> spinlock_acq_t control_acq ( & get_control_lock ( ) ) ; <nl> control_t : : ~ control_t ( ) { <nl> map . erase ( it ) ; <nl> } <nl> <nl> + / * Control that displays a list of controls * / <nl> + struct help_control_t : public control_t <nl> + { <nl> + help_control_t ( ) : control_t ( " help " , " Display this help message . " ) { } <nl> + std : : string call ( int argc , char * * argv ) { <nl> + <nl> + bool show_secret = false ; <nl> + if ( argc = = 2 & & argv [ 1 ] = = std : : string ( " secret " ) ) { <nl> + show_secret = true ; <nl> + } else if ( argc ! = 1 ) { <nl> + return " \ " rethinkdb help \ " does not expect a parameter . \ r \ n " ; <nl> + } <nl> + <nl> + # ifndef NDEBUG <nl> + show_secret = true ; <nl> + # endif <nl> + <nl> + spinlock_acq_t control_acq ( & get_control_lock ( ) ) ; <nl> + std : : string res = " \ r \ nThe following commands are available : \ r \ n \ r \ n " ; <nl> + for ( control_map_t : : iterator it = get_control_map ( ) . begin ( ) ; it ! = get_control_map ( ) . end ( ) ; it + + ) { <nl> + if ( ( * it ) . second - > secret & & ! show_secret ) continue ; <nl> + res + = ( * it ) . first + " : " + ( * it ) . second - > help_string ; <nl> + if ( ( * it ) . second - > secret ) res + = " ( secret ) " ; <nl> + res + = " \ r \ n " ; <nl> + } <nl> + res + = " \ r \ n " ; <nl> + return res ; <nl> + } <nl> + } help_control ; <nl> + <nl> / * Example of how to add a control * / <nl> - struct hi_t : public control_t <nl> + struct hi_control_t : public control_t <nl> { <nl> private : <nl> int counter ; <nl> public : <nl> - hi_t ( std : : string key ) <nl> - : control_t ( key , " " ) , counter ( 0 ) <nl> - { } <nl> + hi_control_t ( ) : <nl> + control_t ( " hi " , " Say ' hi ' to the server , and it will say ' hi ' back . " , true ) , <nl> + counter ( 0 ) <nl> + { } <nl> std : : string call ( UNUSED int argc , UNUSED char * * argv ) { <nl> counter + + ; <nl> if ( counter < 3 ) <nl> struct hi_t : public control_t <nl> else <nl> return " Base QPS decreased by 100 , 000 . \ r \ n " ; <nl> } <nl> - } ; <nl> - <nl> - hi_t hi ( " hi " ) ; <nl> + } hi_control ; <nl> mmm a / src / server / control . hpp <nl> ppp b / src / server / control . hpp <nl> <nl> <nl> class control_t { <nl> public : <nl> - control_t ( const std : : string & key , const std : : string & help_string ) ; <nl> + control_t ( const std : : string & key , const std : : string & help_string , bool secret = false ) ; <nl> virtual ~ control_t ( ) ; <nl> <nl> virtual std : : string call ( int argc , char * * argv ) = 0 ; <nl> <nl> static std : : string exec ( int argc , char * * argv ) ; <nl> - static std : : string help ( ) ; <nl> - <nl> <nl> private : <nl> + friend class help_control_t ; <nl> std : : string key ; <nl> std : : string help_string ; <nl> + bool secret ; <nl> } ; <nl> <nl> typedef std : : map < std : : string , control_t * > control_map_t ; <nl> mmm a / src / server / key_value_store . hpp <nl> ppp b / src / server / key_value_store . hpp <nl> class btree_key_value_store_t : <nl> { <nl> public : <nl> hash_control_t ( btree_key_value_store_t * btkvs ) <nl> - # ifndef NDEBUG / / No documentation if we ' re in release mode . <nl> - : control_t ( " hash " , std : : string ( " Get hash , slice , and thread of a key . Syntax : rdb hash key " ) ) , btkvs ( btkvs ) <nl> - # else <nl> - : control_t ( " hash " , std : : string ( " " ) ) , btkvs ( btkvs ) <nl> - # endif <nl> + : control_t ( " hash " , std : : string ( " Get hash , slice , and thread of a key . Syntax : rdb hash key " ) , true ) , btkvs ( btkvs ) <nl> { } <nl> virtual ~ hash_control_t ( ) { } ; <nl> <nl> mmm a / src / server / server . cc <nl> ppp b / src / server / server . cc <nl> shutdown_control_t shutdown_control ( std : : string ( " shutdown " ) ) ; <nl> <nl> struct malloc_control_t : public control_t { <nl> malloc_control_t ( std : : string key ) <nl> - : control_t ( key , " tcmalloc - testing control . " ) { } <nl> + : control_t ( key , " tcmalloc - testing control . " , true ) { } <nl> <nl> std : : string call ( UNUSED int argc , UNUSED char * * argv ) { <nl> std : : vector < void * > ptrs ; <nl> struct malloc_control_t : public control_t { <nl> <nl> return ret ; <nl> } <nl> - } ; <nl> - <nl> - malloc_control_t malloc_control ( " malloc_control " ) ; <nl> + } malloc_control ( " malloc_control " ) ; <nl> | Fixed some problems with the replication - related control_ts . Added a mechanism for marking control_ts as secret , so they will not be displayed in release mode unless ' rethinkdb help secret ' is run . | rethinkdb/rethinkdb | cc0299287cb961c715a2519f2d61c7f69f04db22 | 2011-04-26T01:27:33Z |
mmm a / src / wasm / module - compiler . cc <nl> ppp b / src / wasm / module - compiler . cc <nl> wasm : : WasmCode * LazyCompileFunction ( Isolate * isolate , <nl> { <nl> ModuleWireBytes wire_bytes ( native_module - > wire_bytes ( ) ) ; <nl> WireBytesRef name_ref = <nl> - module_env - > module - > LookupName ( wire_bytes , func_index ) ; <nl> + module_env - > module - > LookupFunctionName ( wire_bytes , func_index ) ; <nl> func_name = wire_bytes . GetName ( name_ref ) ; <nl> } <nl> <nl> void InstanceBuilder : : ProcessExports ( Handle < WasmInstanceObject > instance ) { <nl> MaybeHandle < String > func_name ; <nl> if ( is_asm_js ) { <nl> / / For modules arising from asm . js , honor the names section . <nl> - WireBytesRef func_name_ref = module_ - > LookupName ( <nl> + WireBytesRef func_name_ref = module_ - > LookupFunctionName ( <nl> module_object_ - > native_module ( ) - > wire_bytes ( ) , <nl> function . func_index ) ; <nl> func_name = WasmModuleObject : : ExtractUtf8StringFromModuleBytes ( <nl> void InstanceBuilder : : LoadTableSegments ( Handle < WasmInstanceObject > instance ) { <nl> MaybeHandle < String > func_name ; <nl> if ( module_ - > origin = = kAsmJsOrigin ) { <nl> / / For modules arising from asm . js , honor the names section . <nl> - WireBytesRef func_name_ref = <nl> - module_ - > LookupName ( native_module - > wire_bytes ( ) , func_index ) ; <nl> + WireBytesRef func_name_ref = module_ - > LookupFunctionName ( <nl> + native_module - > wire_bytes ( ) , func_index ) ; <nl> func_name = WasmModuleObject : : ExtractUtf8StringFromModuleBytes ( <nl> isolate_ , module_object_ , func_name_ref ) <nl> . ToHandleChecked ( ) ; <nl> mmm a / src / wasm / wasm - code - manager . cc <nl> ppp b / src / wasm / wasm - code - manager . cc <nl> void WasmCode : : LogCode ( Isolate * isolate ) const { <nl> ModuleWireBytes wire_bytes ( native_module ( ) - > wire_bytes ( ) ) ; <nl> / / TODO ( herhut ) : Allow to log code without on - heap round - trip of the name . <nl> ModuleEnv * module_env = GetModuleEnv ( native_module ( ) - > compilation_state ( ) ) ; <nl> - WireBytesRef name_ref = module_env - > module - > LookupName ( wire_bytes , index ( ) ) ; <nl> + WireBytesRef name_ref = <nl> + module_env - > module - > LookupFunctionName ( wire_bytes , index ( ) ) ; <nl> WasmName name_vec = wire_bytes . GetName ( name_ref ) ; <nl> MaybeHandle < String > maybe_name = <nl> isolate - > factory ( ) - > NewStringFromUtf8 ( Vector < const char > : : cast ( name_vec ) ) ; <nl> mmm a / src / wasm / wasm - module . cc <nl> ppp b / src / wasm / wasm - module . cc <nl> constexpr const char * WasmException : : kRuntimeIdStr ; <nl> / / static <nl> constexpr const char * WasmException : : kRuntimeValuesStr ; <nl> <nl> - WireBytesRef WasmModule : : LookupName ( const ModuleWireBytes & wire_bytes , <nl> - uint32_t function_index ) const { <nl> - if ( ! names_ ) { <nl> - names_ . reset ( new std : : unordered_map < uint32_t , WireBytesRef > ( ) ) ; <nl> + WireBytesRef WasmModule : : LookupFunctionName ( const ModuleWireBytes & wire_bytes , <nl> + uint32_t function_index ) const { <nl> + if ( ! function_names ) { <nl> + function_names . reset ( new std : : unordered_map < uint32_t , WireBytesRef > ( ) ) ; <nl> wasm : : DecodeFunctionNames ( wire_bytes . start ( ) , wire_bytes . end ( ) , <nl> - names_ . get ( ) ) ; <nl> + function_names . get ( ) ) ; <nl> } <nl> - auto it = names_ - > find ( function_index ) ; <nl> - if ( it = = names_ - > end ( ) ) return WireBytesRef ( ) ; <nl> + auto it = function_names - > find ( function_index ) ; <nl> + if ( it = = function_names - > end ( ) ) return WireBytesRef ( ) ; <nl> return it - > second ; <nl> } <nl> <nl> - void WasmModule : : AddNameForTesting ( int function_index , WireBytesRef name ) { <nl> - if ( ! names_ ) { <nl> - names_ . reset ( new std : : unordered_map < uint32_t , WireBytesRef > ( ) ) ; <nl> + void WasmModule : : AddFunctionNameForTesting ( int function_index , <nl> + WireBytesRef name ) { <nl> + if ( ! function_names ) { <nl> + function_names . reset ( new std : : unordered_map < uint32_t , WireBytesRef > ( ) ) ; <nl> } <nl> - names_ - > insert ( std : : make_pair ( function_index , name ) ) ; <nl> + function_names - > insert ( std : : make_pair ( function_index , name ) ) ; <nl> } <nl> <nl> / / Get a string stored in the module bytes representing a name . <nl> WasmName ModuleWireBytes : : GetName ( WireBytesRef ref ) const { <nl> if ( ref . is_empty ( ) ) return { " < ? > " , 3 } ; / / no name . <nl> CHECK ( BoundsCheck ( ref . offset ( ) , ref . length ( ) ) ) ; <nl> - return Vector < const char > : : cast ( <nl> + return WasmName : : cast ( <nl> module_bytes_ . SubVector ( ref . offset ( ) , ref . end_offset ( ) ) ) ; <nl> } <nl> <nl> / / Get a string stored in the module bytes representing a function name . <nl> WasmName ModuleWireBytes : : GetName ( const WasmFunction * function , <nl> const WasmModule * module ) const { <nl> - return GetName ( module - > LookupName ( * this , function - > func_index ) ) ; <nl> + return GetName ( module - > LookupFunctionName ( * this , function - > func_index ) ) ; <nl> } <nl> <nl> / / Get a string stored in the module bytes representing a name . <nl> WasmName ModuleWireBytes : : GetNameOrNull ( WireBytesRef ref ) const { <nl> if ( ! ref . is_set ( ) ) return { nullptr , 0 } ; / / no name . <nl> CHECK ( BoundsCheck ( ref . offset ( ) , ref . length ( ) ) ) ; <nl> - return Vector < const char > : : cast ( <nl> + return WasmName : : cast ( <nl> module_bytes_ . SubVector ( ref . offset ( ) , ref . end_offset ( ) ) ) ; <nl> } <nl> <nl> / / Get a string stored in the module bytes representing a function name . <nl> WasmName ModuleWireBytes : : GetNameOrNull ( const WasmFunction * function , <nl> const WasmModule * module ) const { <nl> - return GetNameOrNull ( module - > LookupName ( * this , function - > func_index ) ) ; <nl> + return GetNameOrNull ( module - > LookupFunctionName ( * this , function - > func_index ) ) ; <nl> } <nl> <nl> std : : ostream & operator < < ( std : : ostream & os , const WasmFunctionName & name ) { <nl> mmm a / src / wasm / wasm - module . h <nl> ppp b / src / wasm / wasm - module . h <nl> struct V8_EXPORT_PRIVATE WasmModule { <nl> SignatureMap signature_map ; / / canonicalizing map for signature indexes . <nl> <nl> ModuleOrigin origin = kWasmOrigin ; / / origin of the module <nl> - mutable std : : unique_ptr < std : : unordered_map < uint32_t , WireBytesRef > > names_ ; <nl> + mutable std : : unique_ptr < std : : unordered_map < uint32_t , WireBytesRef > > <nl> + function_names ; <nl> <nl> WasmModule ( ) : WasmModule ( nullptr ) { } <nl> WasmModule ( std : : unique_ptr < Zone > owned ) ; <nl> <nl> - WireBytesRef LookupName ( const ModuleWireBytes & wire_bytes , <nl> - uint32_t function_index ) const ; <nl> - void AddNameForTesting ( int function_index , WireBytesRef name ) ; <nl> + WireBytesRef LookupFunctionName ( const ModuleWireBytes & wire_bytes , <nl> + uint32_t function_index ) const ; <nl> + void AddFunctionNameForTesting ( int function_index , WireBytesRef name ) ; <nl> } ; <nl> <nl> size_t EstimateWasmModuleSize ( const WasmModule * module ) ; <nl> mmm a / src / wasm / wasm - objects . cc <nl> ppp b / src / wasm / wasm - objects . cc <nl> MaybeHandle < String > WasmModuleObject : : GetFunctionNameOrNull ( <nl> Isolate * isolate , Handle < WasmModuleObject > module_object , <nl> uint32_t func_index ) { <nl> DCHECK_LT ( func_index , module_object - > module ( ) - > functions . size ( ) ) ; <nl> - wasm : : WireBytesRef name = module_object - > module ( ) - > LookupName ( <nl> + wasm : : WireBytesRef name = module_object - > module ( ) - > LookupFunctionName ( <nl> wasm : : ModuleWireBytes ( module_object - > native_module ( ) - > wire_bytes ( ) ) , <nl> func_index ) ; <nl> if ( ! name . is_set ( ) ) return { } ; <nl> Vector < const uint8_t > WasmModuleObject : : GetRawFunctionName ( <nl> uint32_t func_index ) { <nl> DCHECK_GT ( module ( ) - > functions . size ( ) , func_index ) ; <nl> wasm : : ModuleWireBytes wire_bytes ( native_module ( ) - > wire_bytes ( ) ) ; <nl> - wasm : : WireBytesRef name_ref = module ( ) - > LookupName ( wire_bytes , func_index ) ; <nl> + wasm : : WireBytesRef name_ref = <nl> + module ( ) - > LookupFunctionName ( wire_bytes , func_index ) ; <nl> wasm : : WasmName name = wire_bytes . GetName ( name_ref ) ; <nl> return Vector < const uint8_t > : : cast ( name ) ; <nl> } <nl> mmm a / test / cctest / wasm / wasm - run - utils . cc <nl> ppp b / test / cctest / wasm / wasm - run - utils . cc <nl> uint32_t TestingModuleBuilder : : AddFunction ( FunctionSig * sig , const char * name , <nl> test_module_ - > num_declared_functions ) ; <nl> if ( name ) { <nl> Vector < const byte > name_vec = Vector < const byte > : : cast ( CStrVector ( name ) ) ; <nl> - test_module_ - > AddNameForTesting ( <nl> + test_module_ - > AddFunctionNameForTesting ( <nl> index , { AddBytes ( name_vec ) , static_cast < uint32_t > ( name_vec . length ( ) ) } ) ; <nl> } <nl> if ( interpreter_ ) { <nl> void WasmFunctionCompiler : : Build ( const byte * start , const byte * end ) { <nl> memcpy ( func_wire_bytes . start ( ) , wire_bytes . start ( ) + function_ - > code . offset ( ) , <nl> func_wire_bytes . length ( ) ) ; <nl> WireBytesRef func_name_ref = <nl> - module_env . module - > LookupName ( wire_bytes , function_ - > func_index ) ; <nl> + module_env . module - > LookupFunctionName ( wire_bytes , function_ - > func_index ) ; <nl> ScopedVector < char > func_name ( func_name_ref . length ( ) ) ; <nl> memcpy ( func_name . start ( ) , wire_bytes . start ( ) + func_name_ref . offset ( ) , <nl> func_name_ref . length ( ) ) ; <nl> | [ wasm ] [ cleanup ] Rename fields and methods for function names | v8/v8 | a71f40ded6040e1dd0c10f476a0ae564ff29fd97 | 2018-06-29T09:41:15Z |
mmm a / settings . py <nl> ppp b / settings . py <nl> <nl> <nl> EMSCRIPTEN_ROOT = os . path . expanduser ( " ~ / Dev / emscripten " ) # TODO : Use this <nl> <nl> - TEMP_DIR = ' / dev / shm ' <nl> + TEMP_DIR = ' / tmp ' <nl> <nl> LLVM_ROOT = os . path . expanduser ( ' ~ / Dev / llvm - 2 . 9 / cbuild / bin ' ) <nl> <nl> | default temp dir to / tmp | emscripten-core/emscripten | 94a47a44bcb863be743a289b9c349480f2a30c4b | 2011-11-06T03:42:08Z |
mmm a / tensorflow / compiler / xla / tools / dumped_computation_to_text . cc <nl> ppp b / tensorflow / compiler / xla / tools / dumped_computation_to_text . cc <nl> void RealMain ( tensorflow : : gtl : : ArraySlice < char * > args , bool compile ) { <nl> layouts . push_back ( & program_shape - > parameters ( i ) ) ; <nl> } <nl> StatusOr < std : : unique_ptr < Executable > > executable = <nl> - local_service - > CompileExecutable ( <nl> - computation . handle ( ) , layouts , & program_shape - > result ( ) , <nl> - / * device_ordinal = * / 0 , / * has_hybrid_result = * / true ) ; <nl> + local_service - > CompileExecutable ( computation . handle ( ) , layouts , <nl> + & program_shape - > result ( ) , <nl> + / * device_ordinal = * / 0 ) ; <nl> <nl> const HloModule & module = executable . ValueOrDie ( ) - > module ( ) ; <nl> <nl> | [ XLA ] Fix build of dumped_computation_to_text after change that removed an arg from CompileExecutable . | tensorflow/tensorflow | c38773f18bfdce1de16ab5110e0cbbd50f0d6a79 | 2017-10-05T02:18:12Z |
mmm a / xbmc / interfaces / json - rpc / ServiceDescription . h <nl> ppp b / xbmc / interfaces / json - rpc / ServiceDescription . h <nl> namespace JSONRPC <nl> " \ " List . Limits \ " : { " <nl> " \ " type \ " : \ " object \ " , " <nl> " \ " properties \ " : { " <nl> - " \ " start \ " : { \ " type \ " : \ " integer \ " , \ " minimum \ " : 0 , \ " default \ " : 0 } , " <nl> - " \ " end \ " : { \ " type \ " : \ " integer \ " , \ " minimum \ " : 0 , \ " default \ " : - 1 , \ " description \ " : \ " The number of items in the list being returned \ " } " <nl> + " \ " start \ " : { \ " type \ " : \ " integer \ " , \ " minimum \ " : 0 , \ " default \ " : 0 , \ " description \ " : \ " Index of the first item to return \ " } , " <nl> + " \ " end \ " : { \ " type \ " : \ " integer \ " , \ " minimum \ " : 0 , \ " default \ " : - 1 , \ " description \ " : \ " Index of the last item to return \ " } " <nl> " } , " <nl> " \ " additionalProperties \ " : false " <nl> " } " , <nl> mmm a / xbmc / interfaces / json - rpc / types . json <nl> ppp b / xbmc / interfaces / json - rpc / types . json <nl> <nl> " List . Limits " : { <nl> " type " : " object " , <nl> " properties " : { <nl> - " start " : { " type " : " integer " , " minimum " : 0 , " default " : 0 } , <nl> - " end " : { " type " : " integer " , " minimum " : 0 , " default " : - 1 , " description " : " The number of items in the list being returned " } <nl> + " start " : { " type " : " integer " , " minimum " : 0 , " default " : 0 , " description " : " Index of the first item to return " } , <nl> + " end " : { " type " : " integer " , " minimum " : 0 , " default " : - 1 , " description " : " Index of the last item to return " } <nl> } , <nl> " additionalProperties " : false <nl> } , <nl> | jsonrpc : fix JSON schema description for List . Limits properties | xbmc/xbmc | 0e62ff83d2bfd8d6d017685c4545e26ecc273b7c | 2012-09-03T18:00:40Z |
mmm a / tests / hello_world_gles . c <nl> ppp b / tests / hello_world_gles . c <nl> gears_idle ( void ) <nl> tRate0 = t ; <nl> frames = 0 ; <nl> } <nl> + <nl> + glutIdleFunc ( gears_idle ) ; <nl> } <nl> <nl> static const char vertex_shader [ ] = <nl> main ( int argc , char * argv [ ] ) <nl> glutCreateWindow ( " es2gears " ) ; <nl> <nl> / * Set up glut callback functions * / <nl> - gears_idle ( ) ; <nl> + glutIdleFunc ( gears_idle ) ; <nl> glutReshapeFunc ( gears_reshape ) ; <nl> glutDisplayFunc ( gears_draw ) ; <nl> glutSpecialFunc ( gears_special ) ; <nl> | Make gears demo request animation frames | emscripten-core/emscripten | bcafbea2fccaaeb05cbeabbc84bf89fc234266c0 | 2012-04-05T05:53:20Z |
mmm a / package . json <nl> ppp b / package . json <nl> <nl> " mocha " : " * " , <nl> " walkdir " : " * " , <nl> " unzip " : " * " , <nl> + " d3 " : " * " , <nl> " int64 - native " : " * " <nl> } , <nl> <nl> new file mode 100644 <nl> index 000000000000 . . be462b150352 <nl> mmm / dev / null <nl> ppp b / spec / modules / d3 . coffee <nl> <nl> + describe ' modules ' , - > <nl> + describe ' d3 module ' , - > <nl> + it ' can be required ' , ( done ) - > <nl> + require ' d3 ' <nl> + done ( ) <nl> | Add test for d3 module . | electron/electron | f9750f9ea9d2c4ab4cc920c349933b983d36bbb7 | 2013-08-12T05:59:34Z |
mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> MaybeObject * Heap : : CreateCode ( const CodeDesc & desc , <nl> code - > set_is_crankshafted ( crankshafted ) ; <nl> code - > set_deoptimization_data ( empty_fixed_array ( ) , SKIP_WRITE_BARRIER ) ; <nl> code - > set_raw_type_feedback_info ( undefined_value ( ) ) ; <nl> + code - > set_next_code_link ( undefined_value ( ) ) ; <nl> code - > set_handler_table ( empty_fixed_array ( ) , SKIP_WRITE_BARRIER ) ; <nl> code - > set_gc_metadata ( Smi : : FromInt ( 0 ) ) ; <nl> code - > set_ic_age ( global_ic_age_ ) ; <nl> mmm a / src / mark - compact . cc <nl> ppp b / src / mark - compact . cc <nl> class RootMarkingVisitor : public ObjectVisitor { <nl> for ( Object * * p = start ; p < end ; p + + ) MarkObjectByPointer ( p ) ; <nl> } <nl> <nl> + / / Skip the weak next code link in a code object , which is visited in <nl> + / / ProcessTopOptimizedFrame . <nl> + void VisitNextCodeLink ( Object * * p ) { } <nl> + <nl> private : <nl> void MarkObjectByPointer ( Object * * p ) { <nl> if ( ! ( * p ) - > IsHeapObject ( ) ) return ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> void HeapObject : : IteratePointer ( ObjectVisitor * v , int offset ) { <nl> } <nl> <nl> <nl> + void HeapObject : : IterateNextCodeLink ( ObjectVisitor * v , int offset ) { <nl> + v - > VisitNextCodeLink ( reinterpret_cast < Object * * > ( FIELD_ADDR ( this , offset ) ) ) ; <nl> + } <nl> + <nl> + <nl> double HeapNumber : : value ( ) { <nl> return READ_DOUBLE_FIELD ( this , kValueOffset ) ; <nl> } <nl> ACCESSORS ( Code , relocation_info , ByteArray , kRelocationInfoOffset ) <nl> ACCESSORS ( Code , handler_table , FixedArray , kHandlerTableOffset ) <nl> ACCESSORS ( Code , deoptimization_data , FixedArray , kDeoptimizationDataOffset ) <nl> ACCESSORS ( Code , raw_type_feedback_info , Object , kTypeFeedbackInfoOffset ) <nl> + ACCESSORS ( Code , next_code_link , Object , kNextCodeLinkOffset ) <nl> <nl> <nl> void Code : : WipeOutHeader ( ) { <nl> void Code : : set_type_feedback_info ( Object * value , WriteBarrierMode mode ) { <nl> } <nl> <nl> <nl> - Object * Code : : next_code_link ( ) { <nl> - CHECK ( kind ( ) = = OPTIMIZED_FUNCTION ) ; <nl> - return raw_type_feedback_info ( ) ; <nl> - } <nl> - <nl> - <nl> - void Code : : set_next_code_link ( Object * value , WriteBarrierMode mode ) { <nl> - CHECK ( kind ( ) = = OPTIMIZED_FUNCTION ) ; <nl> - set_raw_type_feedback_info ( value ) ; <nl> - CONDITIONAL_WRITE_BARRIER ( GetHeap ( ) , this , kTypeFeedbackInfoOffset , <nl> - value , mode ) ; <nl> - } <nl> - <nl> - <nl> int Code : : stub_info ( ) { <nl> ASSERT ( kind ( ) = = COMPARE_IC | | kind ( ) = = COMPARE_NIL_IC | | <nl> kind ( ) = = BINARY_OP_IC | | kind ( ) = = LOAD_IC ) ; <nl> mmm a / src / objects - visiting - inl . h <nl> ppp b / src / objects - visiting - inl . h <nl> void Code : : CodeIterateBody ( ObjectVisitor * v ) { <nl> IteratePointer ( v , kHandlerTableOffset ) ; <nl> IteratePointer ( v , kDeoptimizationDataOffset ) ; <nl> IteratePointer ( v , kTypeFeedbackInfoOffset ) ; <nl> + IterateNextCodeLink ( v , kNextCodeLinkOffset ) ; <nl> IteratePointer ( v , kConstantPoolOffset ) ; <nl> <nl> RelocIterator it ( this , mode_mask ) ; <nl> void Code : : CodeIterateBody ( Heap * heap ) { <nl> StaticVisitor : : VisitPointer ( <nl> heap , <nl> reinterpret_cast < Object * * > ( this - > address ( ) + kTypeFeedbackInfoOffset ) ) ; <nl> + StaticVisitor : : VisitNextCodeLink ( <nl> + heap , <nl> + reinterpret_cast < Object * * > ( this - > address ( ) + kNextCodeLinkOffset ) ) ; <nl> StaticVisitor : : VisitPointer ( <nl> heap , <nl> reinterpret_cast < Object * * > ( this - > address ( ) + kConstantPoolOffset ) ) ; <nl> mmm a / src / objects - visiting . h <nl> ppp b / src / objects - visiting . h <nl> class StaticMarkingVisitor : public StaticVisitorBase { <nl> INLINE ( static void VisitCodeAgeSequence ( Heap * heap , RelocInfo * rinfo ) ) ; <nl> INLINE ( static void VisitExternalReference ( RelocInfo * rinfo ) ) { } <nl> INLINE ( static void VisitRuntimeEntry ( RelocInfo * rinfo ) ) { } <nl> + / / Skip the weak next code link in a code object . <nl> + INLINE ( static void VisitNextCodeLink ( Heap * heap , Object * * slot ) ) { } <nl> <nl> / / TODO ( mstarzinger ) : This should be made protected once refactoring is done . <nl> / / Mark non - optimize code for functions inlined into the given optimized <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class HeapObject : public Object { <nl> inline void IteratePointers ( ObjectVisitor * v , int start , int end ) ; <nl> / / as above , for the single element at " offset " <nl> inline void IteratePointer ( ObjectVisitor * v , int offset ) ; <nl> + / / as above , for the next code link of a code object . <nl> + inline void IterateNextCodeLink ( ObjectVisitor * v , int offset ) ; <nl> <nl> private : <nl> DISALLOW_IMPLICIT_CONSTRUCTORS ( HeapObject ) ; <nl> class Code : public HeapObject { <nl> / / the kind of the code object . <nl> / / FUNCTION = > type feedback information . <nl> / / STUB = > various things , e . g . a SMI <nl> - / / OPTIMIZED_FUNCTION = > the next_code_link for optimized code list . <nl> DECL_ACCESSORS ( raw_type_feedback_info , Object ) <nl> inline Object * type_feedback_info ( ) ; <nl> inline void set_type_feedback_info ( <nl> class Code : public HeapObject { <nl> kHandlerTableOffset + kPointerSize ; <nl> static const int kTypeFeedbackInfoOffset = <nl> kDeoptimizationDataOffset + kPointerSize ; <nl> - static const int kNextCodeLinkOffset = kTypeFeedbackInfoOffset ; / / Shared . <nl> - static const int kGCMetadataOffset = kTypeFeedbackInfoOffset + kPointerSize ; <nl> + static const int kNextCodeLinkOffset = kTypeFeedbackInfoOffset + kPointerSize ; <nl> + static const int kGCMetadataOffset = kNextCodeLinkOffset + kPointerSize ; <nl> static const int kICAgeOffset = <nl> kGCMetadataOffset + kPointerSize ; <nl> static const int kFlagsOffset = kICAgeOffset + kIntSize ; <nl> class ObjectVisitor BASE_EMBEDDED { <nl> / / Handy shorthand for visiting a single pointer . <nl> virtual void VisitPointer ( Object * * p ) { VisitPointers ( p , p + 1 ) ; } <nl> <nl> + / / Visit weak next_code_link in Code object . <nl> + virtual void VisitNextCodeLink ( Object * * p ) { VisitPointers ( p , p + 1 ) ; } <nl> + <nl> / / To allow lazy clearing of inline caches the visitor has <nl> / / a rich interface for iterating over Code objects . . <nl> <nl> mmm a / test / cctest / test - heap . cc <nl> ppp b / test / cctest / test - heap . cc <nl> TEST ( ObjectsInOptimizedCodeAreWeak ) { <nl> } <nl> <nl> <nl> + <nl> + static Handle < JSFunction > OptimizeDummyFunction ( const char * name ) { <nl> + char source [ 256 ] ; <nl> + snprintf ( source , sizeof ( source ) , <nl> + " function % s ( ) { return 0 ; } " <nl> + " % s ( ) ; % s ( ) ; " <nl> + " % % OptimizeFunctionOnNextCall ( % s ) ; " <nl> + " % s ( ) ; " , name , name , name , name , name ) ; <nl> + CompileRun ( source ) ; <nl> + Handle < JSFunction > fun = <nl> + v8 : : Utils : : OpenHandle ( <nl> + * v8 : : Handle < v8 : : Function > : : Cast ( <nl> + CcTest : : global ( ) - > Get ( v8_str ( name ) ) ) ) ; <nl> + return fun ; <nl> + } <nl> + <nl> + <nl> + static int GetCodeChainLength ( Code * code ) { <nl> + int result = 0 ; <nl> + while ( code - > next_code_link ( ) - > IsCode ( ) ) { <nl> + result + + ; <nl> + code = Code : : cast ( code - > next_code_link ( ) ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + <nl> + TEST ( NextCodeLinkIsWeak ) { <nl> + i : : FLAG_allow_natives_syntax = true ; <nl> + CcTest : : InitializeVM ( ) ; <nl> + Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> + v8 : : internal : : Heap * heap = CcTest : : heap ( ) ; <nl> + <nl> + if ( ! isolate - > use_crankshaft ( ) ) return ; <nl> + HandleScope outer_scope ( heap - > isolate ( ) ) ; <nl> + Handle < Code > code ; <nl> + heap - > CollectAllAvailableGarbage ( ) ; <nl> + int code_chain_length_before , code_chain_length_after ; <nl> + { <nl> + HandleScope scope ( heap - > isolate ( ) ) ; <nl> + Handle < JSFunction > mortal = OptimizeDummyFunction ( " mortal " ) ; <nl> + Handle < JSFunction > immortal = OptimizeDummyFunction ( " immortal " ) ; <nl> + CHECK_EQ ( immortal - > code ( ) - > next_code_link ( ) , mortal - > code ( ) ) ; <nl> + code_chain_length_before = GetCodeChainLength ( immortal - > code ( ) ) ; <nl> + / / Keep the immortal code and let the mortal code die . <nl> + code = scope . CloseAndEscape ( Handle < Code > ( immortal - > code ( ) ) ) ; <nl> + CompileRun ( " mortal = null ; immortal = null ; " ) ; <nl> + } <nl> + heap - > CollectAllAvailableGarbage ( ) ; <nl> + / / Now mortal code should be dead . <nl> + code_chain_length_after = GetCodeChainLength ( * code ) ; <nl> + CHECK_EQ ( code_chain_length_before - 1 , code_chain_length_after ) ; <nl> + } <nl> + <nl> + <nl> + static Handle < Code > DummyOptimizedCode ( Isolate * isolate ) { <nl> + i : : byte buffer [ i : : Assembler : : kMinimalBufferSize ] ; <nl> + MacroAssembler masm ( isolate , buffer , sizeof ( buffer ) ) ; <nl> + CodeDesc desc ; <nl> + masm . Prologue ( BUILD_FUNCTION_FRAME ) ; <nl> + masm . GetCode ( & desc ) ; <nl> + Handle < Object > undefined ( isolate - > heap ( ) - > undefined_value ( ) , isolate ) ; <nl> + Handle < Code > code = isolate - > factory ( ) - > NewCode ( <nl> + desc , Code : : ComputeFlags ( Code : : OPTIMIZED_FUNCTION ) , undefined ) ; <nl> + CHECK ( code - > IsCode ( ) ) ; <nl> + return code ; <nl> + } <nl> + <nl> + <nl> + TEST ( NextCodeLinkIsWeak2 ) { <nl> + i : : FLAG_allow_natives_syntax = true ; <nl> + CcTest : : InitializeVM ( ) ; <nl> + Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> + v8 : : internal : : Heap * heap = CcTest : : heap ( ) ; <nl> + <nl> + if ( ! isolate - > use_crankshaft ( ) ) return ; <nl> + HandleScope outer_scope ( heap - > isolate ( ) ) ; <nl> + heap - > CollectAllAvailableGarbage ( ) ; <nl> + Handle < Context > context ( Context : : cast ( heap - > native_contexts_list ( ) ) , isolate ) ; <nl> + Handle < Code > new_head ; <nl> + Handle < Object > old_head ( context - > get ( Context : : OPTIMIZED_CODE_LIST ) , isolate ) ; <nl> + { <nl> + HandleScope scope ( heap - > isolate ( ) ) ; <nl> + Handle < Code > immortal = DummyOptimizedCode ( isolate ) ; <nl> + Handle < Code > mortal = DummyOptimizedCode ( isolate ) ; <nl> + mortal - > set_next_code_link ( * old_head ) ; <nl> + immortal - > set_next_code_link ( * mortal ) ; <nl> + context - > set ( Context : : OPTIMIZED_CODE_LIST , * immortal ) ; <nl> + new_head = scope . CloseAndEscape ( immortal ) ; <nl> + } <nl> + heap - > CollectAllAvailableGarbage ( ) ; <nl> + / / Now mortal code should be dead . <nl> + CHECK_EQ ( * old_head , new_head - > next_code_link ( ) ) ; <nl> + } <nl> + <nl> + <nl> # ifdef DEBUG <nl> TEST ( AddInstructionChangesNewSpacePromotion ) { <nl> i : : FLAG_allow_natives_syntax = true ; <nl> | Fix memory leak caused by treating Code : : next_code_link as strong in marker . | v8/v8 | 2f2670088531a1d87542743947ed0dd06ba820c0 | 2014-03-13T14:09:18Z |
mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> <nl> # include " playlists / PlayList . h " <nl> # include " profiles / ProfilesManager . h " <nl> # include " windowing / WinSystem . h " <nl> - # include " powermanagement / PowerManager . h " <nl> # include " powermanagement / DPMSSupport . h " <nl> + # include " powermanagement / PowerManager . h " <nl> + # include " powermanagement / PowerTypes . h " <nl> # include " settings / Settings . h " <nl> # include " settings / AdvancedSettings . h " <nl> # include " settings / DisplaySettings . h " <nl> mmm a / xbmc / ServiceManager . cpp <nl> ppp b / xbmc / ServiceManager . cpp <nl> bool CServiceManager : : InitStageTwo ( const CAppParamParser & params ) <nl> m_fileExtensionProvider . reset ( new CFileExtensionProvider ( * m_addonMgr , <nl> * m_binaryAddonManager ) ) ; <nl> <nl> - m_powerManager . reset ( new CPowerManager ( ) ) ; <nl> + m_powerManager . reset ( new CPowerManager ( * m_settings ) ) ; <nl> m_powerManager - > Initialize ( ) ; <nl> m_powerManager - > SetDefaults ( ) ; <nl> <nl> mmm a / xbmc / interfaces / builtins / Builtins . cpp <nl> ppp b / xbmc / interfaces / builtins / Builtins . cpp <nl> <nl> <nl> # include " ServiceBroker . h " <nl> # include " input / InputManager . h " <nl> - # include " powermanagement / PowerManager . h " <nl> + # include " powermanagement / PowerTypes . h " <nl> # include " settings / Settings . h " <nl> # include " Util . h " <nl> # include " utils / log . h " <nl> mmm a / xbmc / platform / win32 / powermanagement / Win32PowerSyscall . cpp <nl> ppp b / xbmc / platform / win32 / powermanagement / Win32PowerSyscall . cpp <nl> <nl> <nl> # include " Win32PowerSyscall . h " <nl> # include " platform / win32 / WIN32Util . h " <nl> - # include " powermanagement / PowerManager . h " <nl> # include " utils / log . h " <nl> # include " utils / SystemInfo . h " <nl> <nl> mmm a / xbmc / platform / win32 / powermanagement / Win32PowerSyscall . h <nl> ppp b / xbmc / platform / win32 / powermanagement / Win32PowerSyscall . h <nl> <nl> # pragma once <nl> <nl> # include " powermanagement / IPowerSyscall . h " <nl> - # include " powermanagement / PowerManager . h " <nl> + # include " powermanagement / PowerTypes . h " <nl> # include " threads / Event . h " <nl> # include " threads / Thread . h " <nl> # include < atomic > <nl> mmm a / xbmc / powermanagement / CMakeLists . txt <nl> ppp b / xbmc / powermanagement / CMakeLists . txt <nl> set ( SOURCES DPMSSupport . cpp <nl> <nl> set ( HEADERS DPMSSupport . h <nl> IPowerSyscall . h <nl> - PowerManager . h ) <nl> + PowerManager . h <nl> + PowerTypes . h ) <nl> <nl> if ( CORE_SYSTEM_NAME MATCHES windows ) <nl> list ( APPEND HEADERS WinIdleTimer . h ) <nl> mmm a / xbmc / powermanagement / PowerManager . cpp <nl> ppp b / xbmc / powermanagement / PowerManager . cpp <nl> <nl> # include < list > <nl> # include < memory > <nl> <nl> + # include " PowerTypes . h " <nl> # include " Application . h " <nl> # include " ServiceBroker . h " <nl> # include " cores / AudioEngine / Interfaces / AE . h " <nl> <nl> # include " pvr / PVRManager . h " <nl> # include " ServiceBroker . h " <nl> # include " settings / lib / Setting . h " <nl> + # include " settings / lib / SettingsManager . h " <nl> # include " settings / Settings . h " <nl> # include " utils / log . h " <nl> # include " weather / WeatherManager . h " <nl> <nl> extern HWND g_hWnd ; <nl> # endif <nl> <nl> - CPowerManager : : CPowerManager ( ) = default ; <nl> + CPowerManager : : CPowerManager ( CSettings & settings ) : <nl> + m_settings ( settings ) <nl> + { <nl> + m_settings . GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " shutdownstates " , SettingOptionsShutdownStatesFiller ) ; <nl> + } <nl> <nl> CPowerManager : : ~ CPowerManager ( ) = default ; <nl> <nl> void CPowerManager : : Initialize ( ) <nl> <nl> void CPowerManager : : SetDefaults ( ) <nl> { <nl> - int defaultShutdown = CServiceBroker : : GetSettings ( ) . GetInt ( CSettings : : SETTING_POWERMANAGEMENT_SHUTDOWNSTATE ) ; <nl> + int defaultShutdown = m_settings . GetInt ( CSettings : : SETTING_POWERMANAGEMENT_SHUTDOWNSTATE ) ; <nl> <nl> switch ( defaultShutdown ) <nl> { <nl> void CPowerManager : : SetDefaults ( ) <nl> break ; <nl> } <nl> <nl> - std : : static_pointer_cast < CSettingInt > ( CServiceBroker : : GetSettings ( ) . GetSetting ( CSettings : : SETTING_POWERMANAGEMENT_SHUTDOWNSTATE ) ) - > SetDefault ( defaultShutdown ) ; <nl> + std : : static_pointer_cast < CSettingInt > ( m_settings . GetSetting ( CSettings : : SETTING_POWERMANAGEMENT_SHUTDOWNSTATE ) ) - > SetDefault ( defaultShutdown ) ; <nl> } <nl> <nl> bool CPowerManager : : Powerdown ( ) <nl> mmm a / xbmc / powermanagement / PowerManager . h <nl> ppp b / xbmc / powermanagement / PowerManager . h <nl> <nl> <nl> class CFileItem ; <nl> class CSetting ; <nl> - <nl> - enum PowerState <nl> - { <nl> - POWERSTATE_QUIT = 0 , <nl> - POWERSTATE_SHUTDOWN , <nl> - POWERSTATE_HIBERNATE , <nl> - POWERSTATE_SUSPEND , <nl> - POWERSTATE_REBOOT , <nl> - POWERSTATE_MINIMIZE , <nl> - POWERSTATE_NONE , <nl> - POWERSTATE_ASK <nl> - } ; <nl> + class CSettings ; <nl> <nl> / / This class will wrap and handle PowerSyscalls . <nl> / / It will handle and decide if syscalls are needed . <nl> class CPowerManager : public IPowerEventsCallback <nl> { <nl> public : <nl> - CPowerManager ( ) ; <nl> + CPowerManager ( CSettings & settings ) ; <nl> ~ CPowerManager ( ) override ; <nl> <nl> void Initialize ( ) ; <nl> class CPowerManager : public IPowerEventsCallback <nl> void RestorePlayerState ( ) ; <nl> void StorePlayerState ( ) ; <nl> <nl> + / / Construction parameters <nl> + CSettings & m_settings ; <nl> + <nl> std : : unique_ptr < IPowerSyscall > m_instance ; <nl> std : : unique_ptr < CFileItem > m_lastPlayedFileItem ; <nl> std : : string m_lastUsedPlayer ; <nl> new file mode 100644 <nl> index 000000000000 . . 625d00e1a115 <nl> mmm / dev / null <nl> ppp b / xbmc / powermanagement / PowerTypes . h <nl> <nl> + / * <nl> + * Copyright ( C ) 2018 Team Kodi <nl> + * This file is part of Kodi - https : / / kodi . tv <nl> + * <nl> + * SPDX - License - Identifier : GPL - 2 . 0 - or - later <nl> + * See LICENSES / README . md for more information . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + enum PowerState <nl> + { <nl> + POWERSTATE_QUIT = 0 , <nl> + POWERSTATE_SHUTDOWN , <nl> + POWERSTATE_HIBERNATE , <nl> + POWERSTATE_SUSPEND , <nl> + POWERSTATE_REBOOT , <nl> + POWERSTATE_MINIMIZE , <nl> + POWERSTATE_NONE , <nl> + POWERSTATE_ASK <nl> + } ; <nl> mmm a / xbmc / settings / Settings . cpp <nl> ppp b / xbmc / settings / Settings . cpp <nl> <nl> # if defined ( HAS_LIBAMCODEC ) <nl> # include " utils / AMLUtils . h " <nl> # endif / / defined ( HAS_LIBAMCODEC ) <nl> - # include " powermanagement / PowerManager . h " <nl> + # include " powermanagement / PowerTypes . h " <nl> # include " profiles / ProfilesManager . h " <nl> # include " pvr / PVRSettings . h " <nl> # include " pvr / windows / GUIWindowPVRGuide . h " <nl> void CSettings : : InitializeOptionFillers ( ) <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " cmsprimaries " , CDisplaySettings : : SettingOptionsCmsPrimariesFiller ) ; <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " cmsgammamodes " , CDisplaySettings : : SettingOptionsCmsGammaModesFiller ) ; <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " videoseeksteps " , CSeekHandler : : SettingOptionsSeekStepsFiller ) ; <nl> - GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " shutdownstates " , CPowerManager : : SettingOptionsShutdownStatesFiller ) ; <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " startupwindows " , ADDON : : CSkinInfo : : SettingOptionsStartupWindowsFiller ) ; <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " audiostreamlanguages " , CLangInfo : : SettingOptionsAudioStreamLanguagesFiller ) ; <nl> GetSettingsManager ( ) - > RegisterSettingOptionsFiller ( " subtitlestreamlanguages " , CLangInfo : : SettingOptionsSubtitleStreamLanguagesFiller ) ; <nl> | Merge pull request from garbear / circular - deps3 | xbmc/xbmc | f01f932dffce9d124702b3f7a56e2008d9246eb7 | 2018-08-21T17:27:00Z |
mmm a / cmake / modules / AddSwift . cmake <nl> ppp b / cmake / modules / AddSwift . cmake <nl> endfunction ( ) <nl> # [ INTERFACE_LINK_LIBRARIES dep1 . . . ] <nl> # [ SWIFT_MODULE_DEPENDS dep1 . . . ] <nl> # [ LLVM_COMPONENT_DEPENDS comp1 . . . ] <nl> - # [ FILE_DEPENDS target1 . . . ] <nl> # [ C_COMPILE_FLAGS flag1 . . . ] <nl> # [ LINK_FLAGS flag1 . . . ] <nl> # [ INSTALL ] <nl> endfunction ( ) <nl> # LLVM_COMPONENT_DEPENDS <nl> # LLVM components this library depends on . <nl> # <nl> - # FILE_DEPENDS <nl> - # Additional files this library depends on . <nl> - # <nl> # C_COMPILE_FLAGS <nl> # Extra compiler flags ( C , C + + , ObjC ) . <nl> # <nl> function ( add_swift_host_library name ) <nl> set ( multiple_parameter_options <nl> C_COMPILE_FLAGS <nl> DEPENDS <nl> - FILE_DEPENDS <nl> INTERFACE_LINK_LIBRARIES <nl> LINK_FLAGS <nl> LINK_LIBRARIES <nl> function ( add_swift_host_library name ) <nl> DEPENDS $ { ASHL_DEPENDS } <nl> LINK_LIBRARIES $ { ASHL_LINK_LIBRARIES } <nl> LLVM_COMPONENT_DEPENDS $ { ASHL_LLVM_COMPONENT_DEPENDS } <nl> - FILE_DEPENDS $ { ASHL_FILE_DEPENDS } <nl> C_COMPILE_FLAGS $ { ASHL_C_COMPILE_FLAGS } <nl> LINK_FLAGS $ { ASHL_LINK_FLAGS } <nl> INTERFACE_LINK_LIBRARIES $ { ASHL_INTERFACE_LINK_LIBRARIES } <nl> mmm a / lib / Option / CMakeLists . txt <nl> ppp b / lib / Option / CMakeLists . txt <nl> add_swift_host_library ( swiftOption STATIC <nl> Options . cpp <nl> SanitizerOptions . cpp <nl> DEPENDS SwiftOptions <nl> - LINK_LIBRARIES swiftBasic <nl> - FILE_DEPENDS SwiftOptions ) <nl> + LINK_LIBRARIES swiftBasic ) <nl> <nl> | add_swift_host_library : remove FILE_DEPENDS | apple/swift | 738a00a0c01b60b0ad0c546c972a680bde2e1988 | 2018-10-31T19:46:31Z |
mmm a / src / ppc / builtins - ppc . cc <nl> ppp b / src / ppc / builtins - ppc . cc <nl> void Builtins : : Generate_InterpreterExitTrampoline ( MacroAssembler * masm ) { <nl> <nl> / / Leave the frame ( also dropping the register file ) . <nl> __ LeaveFrame ( StackFrame : : JAVA_SCRIPT ) ; <nl> - / / Drop receiver + arguments . <nl> - __ Drop ( 1 ) ; / / TODO ( rmcilroy ) : Get number of arguments from BytecodeArray . <nl> + <nl> + / / Drop receiver + arguments and return . <nl> + __ lwz ( r0 , FieldMemOperand ( kInterpreterBytecodeArrayRegister , <nl> + BytecodeArray : : kParameterSizeOffset ) ) ; <nl> + __ add ( sp , sp , r0 ) ; <nl> __ blr ( ) ; <nl> } <nl> <nl> | PPC : [ Interpreter ] Add support for parameter variables . | v8/v8 | ae781735b4567290d7069e14b4edb990ce81d94d | 2015-08-27T17:12:58Z |
new file mode 100644 <nl> index 00000000000 . . e5b74d628f0 <nl> mmm / dev / null <nl> ppp b / patches / mcrouter - no - thrift - transport - include . patch <nl> <nl> + Index : hhvm - nightly - 2019 . 09 . 20 / third - party / mcrouter / mcrouter / lib / network / gen / MemcacheRouterInfo . h <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + mmm hhvm - nightly - 2019 . 09 . 20 . orig / third - party / mcrouter / mcrouter / lib / network / gen / MemcacheRouterInfo . h <nl> ppp + hhvm - nightly - 2019 . 09 . 20 / third - party / mcrouter / mcrouter / lib / network / gen / MemcacheRouterInfo . h <nl> + struct MemcacheRouterInfo { <nl> + } ; <nl> + } / / namespace memcache <nl> + } / / namespace facebook <nl> + - <nl> + - # include " mcrouter / lib / network / gen / MemcacheThriftTransport . h " <nl> + \ No newline at end of file <nl> | fix hhvm / mcrouter build with openssl 1 . 0 . 1 ( Debian 8 ) | facebook/hhvm | 7f31d4994735f40d2090f331ba5f8c5969c8194e | 2019-09-20T18:19:35Z |
mmm a / torch / optim / lr_scheduler . py <nl> ppp b / torch / optim / lr_scheduler . py <nl> def get_lr ( self ) : <nl> for base_lr in self . base_lrs ] <nl> <nl> def step ( self , epoch = None ) : <nl> - " " " Step could be called after every batch update <nl> - <nl> - Example : <nl> - > > > scheduler = CosineAnnealingWarmRestarts ( optimizer , T_0 , T_mult ) <nl> - > > > iters = len ( dataloader ) <nl> - > > > for epoch in range ( 20 ) : <nl> - > > > for i , sample in enumerate ( dataloader ) : <nl> - > > > inputs , labels = sample [ ' inputs ' ] , sample [ ' labels ' ] <nl> - > > > scheduler . step ( epoch + i / iters ) <nl> - > > > optimizer . zero_grad ( ) <nl> - > > > outputs = net ( inputs ) <nl> - > > > loss = criterion ( outputs , labels ) <nl> - > > > loss . backward ( ) <nl> - > > > optimizer . step ( ) <nl> + " " " Step could be called after every update , i . e . if one epoch has 10 iterations <nl> + ( number_of_train_examples / batch_size ) , we should call SGDR . step ( 0 . 1 ) , SGDR . step ( 0 . 2 ) , etc . <nl> <nl> This function can be called in an interleaved way . <nl> <nl> Example : <nl> - > > > scheduler = ConsineAnnealingWarmRestarts ( optimizer , T_0 , T_mult ) <nl> + > > > scheduler = SGDR ( optimizer , T_0 , T_mult ) <nl> > > > for epoch in range ( 20 ) : <nl> > > > scheduler . step ( ) <nl> > > > scheduler . step ( 26 ) <nl> > > > scheduler . step ( ) # scheduler . step ( 27 ) , instead of scheduler ( 20 ) <nl> " " " <nl> - if epoch < 0 : <nl> - raise ValueError ( " Expected non - negative epoch , but got { } " . format ( epoch ) ) <nl> if epoch is None : <nl> epoch = self . last_epoch + 1 <nl> self . T_cur = self . T_cur + 1 <nl> | Revert D15393514 : [ pytorch ] [ PR ] Refine CosineAnnealingWarmRestarts doc for issue | pytorch/pytorch | 839a69f587ede071755332bd4ebe102ace5d06b4 | 2019-05-17T16:55:56Z |
mmm a / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . h <nl> <nl> <nl> # import < Foundation / Foundation . h > <nl> # import < JavaScriptCore / JavaScriptCore . h > <nl> + # import " WXBridgeProtocol . h " <nl> <nl> @ class WXCallJSMethod ; <nl> @ class WXSDKInstance ; <nl> <nl> * @ param method : object of bridge method <nl> * * / <nl> - ( void ) executeJsMethod : ( WXCallJSMethod * ) method ; <nl> + <nl> + - ( JSValue * ) excuteJSMethodWithResult : ( WXCallJSMethod * ) method ; <nl> + <nl> / * * <nl> * Register Modules Method <nl> * @ param modules : module list <nl> mmm a / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . m <nl> <nl> * / <nl> <nl> # import " WXBridgeContext . h " <nl> - # import " WXBridgeProtocol . h " <nl> # import " WXJSCoreBridge . h " <nl> # import " WXLog . h " <nl> # import " WXUtility . h " <nl> - ( void ) callJSMethod : ( NSString * ) method args : ( NSArray * ) args onContext : ( JSContex <nl> } <nl> } <nl> <nl> + - ( JSValue * ) excuteJSMethodWithResult : ( WXCallJSMethod * ) method <nl> + { <nl> + WXAssertBridgeThread ( ) ; <nl> + return [ self . jsBridge callJSMethod : @ " callJS " args : @ [ method . instance . instanceId , @ [ [ method callJSTask ] ] ] ] ; <nl> + } <nl> + <nl> - ( void ) executeAllJsService <nl> { <nl> for ( NSDictionary * service in _jsServiceQueue ) { <nl> - ( void ) _sendQueueLoop <nl> for ( WXCallJSMethod * method in sendQueue ) { <nl> [ tasks addObject : [ method callJSTask ] ] ; <nl> } <nl> - <nl> [ sendQueue removeAllObjects ] ; <nl> execIns = instance ; <nl> break ; <nl> mmm a / ios / sdk / WeexSDK / Sources / Component / RecycleList / WXRecycleListComponent . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / RecycleList / WXRecycleListComponent . m <nl> <nl> # import " WXSDKManager . h " <nl> # import " WXComponent + DataBinding . h " <nl> <nl> + @ interface WXRecycleListComponentView : UICollectionView <nl> + @ end <nl> + <nl> + @ implementation WXRecycleListComponentView <nl> + - ( BOOL ) gestureRecognizer : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> + { <nl> + return [ self . wx_component requestGestureShouldStopPropagation : gestureRecognizer shouldReceiveTouch : touch ] ; <nl> + } <nl> + <nl> + @ end <nl> + <nl> @ interface WXRecycleListComponent ( ) < WXRecycleListLayoutDelegate , WXRecycleListUpdateDelegate , UICollectionViewDelegateFlowLayout , UICollectionViewDataSource > <nl> <nl> @ end <nl> - ( instancetype ) initWithRef : ( NSString * ) ref <nl> - ( UIView * ) loadView <nl> { <nl> WXRecycleListLayout * layout = [ self recycleListLayout ] ; <nl> - return [ [ UICollectionView alloc ] initWithFrame : CGRectZero collectionViewLayout : layout ] ; <nl> + return [ [ WXRecycleListComponentView alloc ] initWithFrame : CGRectZero collectionViewLayout : layout ] ; <nl> } <nl> <nl> - ( void ) viewDidLoad <nl> mmm a / ios / sdk / WeexSDK / Sources / Component / WXComponent_internal . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / WXComponent_internal . h <nl> typedef id ( ^ WXDataBindingBlock ) ( NSDictionary * data , BOOL * needUpdate ) ; <nl> BOOL _listenHorizontalPan ; <nl> BOOL _listenVerticalPan ; <nl> <nl> + BOOL _listenStopPropagation ; <nl> + <nl> WXTouchGestureRecognizer * _touchGesture ; <nl> <nl> / * * <nl> mmm a / ios / sdk / WeexSDK / Sources / Component / WXListComponent . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / WXListComponent . m <nl> + ( BOOL ) requiresConstraintBasedLayout <nl> return NO ; <nl> } <nl> <nl> + - ( BOOL ) gestureRecognizer : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> + { <nl> + return [ self . wx_component requestGestureShouldStopPropagation : gestureRecognizer shouldReceiveTouch : touch ] ; <nl> + } <nl> + <nl> - ( void ) layoutSubviews <nl> { <nl> [ super layoutSubviews ] ; <nl> mmm a / ios / sdk / WeexSDK / Sources / Component / WXScrollerComponent . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / WXScrollerComponent . h <nl> <nl> <nl> # import " WXScrollerProtocol . h " <nl> # import " WXComponent . h " <nl> - <nl> + # import " WXComponent + Events . h " <nl> @ interface WXScrollerComponent : WXComponent < WXScrollerProtocol , UIScrollViewDelegate > <nl> <nl> @ property ( nonatomic , copy ) void ( ^ onScroll ) ( UIScrollView * ) ; <nl> mmm a / ios / sdk / WeexSDK / Sources / Component / WXScrollerComponent . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / WXScrollerComponent . m <nl> <nl> # import " WXConfigCenterProtocol . h " <nl> # import " WXSDKEngine . h " <nl> <nl> - @ interface WXScrollerComponnetView : UIScrollView <nl> + @ interface WXScrollerComponentView : UIScrollView <nl> @ end <nl> <nl> - @ implementation WXScrollerComponnetView <nl> + @ implementation WXScrollerComponentView <nl> + - ( BOOL ) gestureRecognizer : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> + { <nl> + return [ self . wx_component requestGestureShouldStopPropagation : gestureRecognizer shouldReceiveTouch : touch ] ; <nl> + } <nl> @ end <nl> <nl> @ interface WXScrollToTarget : NSObject <nl> - ( instancetype ) initWithRef : ( NSString * ) ref type : ( NSString * ) type styles : ( NSDicti <nl> <nl> - ( UIView * ) loadView <nl> { <nl> - return [ [ WXScrollerComponnetView alloc ] init ] ; <nl> + return [ [ WXScrollerComponentView alloc ] init ] ; <nl> } <nl> <nl> - ( void ) viewDidLoad <nl> { <nl> [ super viewDidLoad ] ; <nl> [ self setContentSize : _contentSize ] ; <nl> - WXScrollerComponnetView * scrollView = ( WXScrollerComponnetView * ) self . view ; <nl> + WXScrollerComponentView * scrollView = ( WXScrollerComponentView * ) self . view ; <nl> scrollView . delegate = self ; <nl> scrollView . exclusiveTouch = YES ; <nl> scrollView . autoresizesSubviews = NO ; <nl> - ( NSString * ) refreshType <nl> { <nl> return _refreshType ; <nl> } <nl> + - ( BOOL ) requestGestureShouldStopPropagation : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> + { <nl> + return [ self gestureShouldStopPropagation : gestureRecognizer shouldReceiveTouch : touch ] ; <nl> + } <nl> <nl> # pragma mark UIScrollViewDelegate <nl> - ( void ) scrollViewWillBeginDragging : ( UIScrollView * ) scrollView <nl> mmm a / ios / sdk / WeexSDK / Sources / Events / WXComponent + Events . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Events / WXComponent + Events . h <nl> <nl> * / <nl> <nl> # import " WXComponent . h " <nl> + # import < objc / runtime . h > <nl> <nl> - @ interface WXComponent ( Events ) < UIGestureRecognizerDelegate > <nl> + @ interface UITouch ( WXTouchGestureRecognizer ) <nl> + <nl> + @ property ( nonatomic , strong ) NSNumber * wx_identifier ; <nl> + @ property ( nonatomic , strong ) NSNumber * wx_stopPropagation ; <nl> + <nl> + @ end <nl> + <nl> + @ implementation UITouch ( WXTouchGestureRecognizer ) <nl> + <nl> + - ( NSNumber * ) wx_identifier <nl> + { <nl> + return objc_getAssociatedObject ( self , _cmd ) ; <nl> + } <nl> + <nl> + - ( void ) setWx_identifier : ( NSNumber * ) wx_identifier <nl> + { <nl> + objc_setAssociatedObject ( self , @ selector ( wx_identifier ) , wx_identifier , OBJC_ASSOCIATION_RETAIN_NONATOMIC ) ; <nl> + } <nl> <nl> + - ( NSNumber * ) wx_stopPropagation <nl> + { <nl> + return objc_getAssociatedObject ( self , _cmd ) ; <nl> + } <nl> + <nl> + - ( void ) setWx_stopPropagation : ( NSNumber * ) wx_stopPropagation <nl> + { <nl> + objc_setAssociatedObject ( self , @ selector ( wx_stopPropagation ) , wx_stopPropagation , OBJC_ASSOCIATION_RETAIN_NONATOMIC ) ; <nl> + } <nl> + <nl> + @ end <nl> + <nl> + <nl> + @ interface WXComponent ( Events ) < UIGestureRecognizerDelegate > <nl> + - ( BOOL ) gestureShouldStopPropagation : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch ; <nl> + - ( BOOL ) requestGestureShouldStopPropagation : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch ; <nl> @ end <nl> mmm a / ios / sdk / WeexSDK / Sources / Events / WXComponent + Events . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Events / WXComponent + Events . m <nl> <nl> # import " WXDefine . h " <nl> # import " WXRecycleListComponent . h " <nl> # import " WXRecycleListDataManager . h " <nl> - <nl> # import < objc / runtime . h > <nl> # import < UIKit / UIGestureRecognizerSubclass . h > <nl> # import " WXComponent + PseudoClassManagement . h " <nl> <nl> # pragma clang diagnostic ignored " - Wobjc - protocol - method - implementation " <nl> <nl> - @ interface UITouch ( WXTouchGestureRecognizer ) <nl> - <nl> - @ property ( nonatomic , strong ) NSNumber * wx_identifier ; <nl> - <nl> - @ end <nl> - <nl> - @ implementation UITouch ( WXTouchGestureRecognizer ) <nl> - <nl> - - ( NSNumber * ) wx_identifier <nl> - { <nl> - return objc_getAssociatedObject ( self , _cmd ) ; <nl> - } <nl> - <nl> - - ( void ) setWx_identifier : ( NSNumber * ) wx_identifier <nl> - { <nl> - objc_setAssociatedObject ( self , @ selector ( wx_identifier ) , wx_identifier , OBJC_ASSOCIATION_RETAIN_NONATOMIC ) ; <nl> - } <nl> - <nl> - @ end <nl> - <nl> @ interface UIGestureRecognizer ( WXGesture ) <nl> <nl> @ property ( nonatomic , strong ) NSNumber * wx_identifier ; <nl> - ( instancetype ) initWithComponent : ( WXComponent * ) component NS_DESIGNATED_INITIAL <nl> <nl> @ end <nl> <nl> + @ interface WXEventManager : NSObject <nl> + + ( instancetype ) sharedManager ; <nl> + - ( BOOL ) stopPropagation : ( NSString * ) instanceId ref : ( NSString * ) ref type : ( NSString * ) type params : ( NSDictionary * ) params ; <nl> + @ end <nl> + <nl> + @ implementation WXEventManager <nl> + <nl> + - ( instancetype ) init <nl> + { <nl> + self = [ super init ] ; <nl> + if ( self ) { <nl> + <nl> + } <nl> + return self ; <nl> + } <nl> + <nl> + + ( instancetype ) sharedManager <nl> + { <nl> + static id _sharedInstance = nil ; <nl> + static dispatch_once_t oncePredicate ; <nl> + dispatch_once ( & oncePredicate , ^ { <nl> + _sharedInstance = [ [ self alloc ] init ] ; <nl> + } ) ; <nl> + return _sharedInstance ; <nl> + } <nl> + <nl> + - ( BOOL ) stopPropagation : ( NSString * ) instanceId ref : ( NSString * ) ref type : ( NSString * ) type params : ( NSDictionary * ) params <nl> + { <nl> + JSValue * value = [ [ WXSDKManager bridgeMgr ] fireEventWithResult : instanceId ref : ref type : type params : params domChanges : nil ] ; <nl> + <nl> + if ( [ value . toString isEqualToString : @ " true " ] ) { <nl> + return YES ; <nl> + } <nl> + return NO ; <nl> + } <nl> + <nl> + @ end <nl> + <nl> @ implementation WXComponent ( Events ) <nl> <nl> # pragma mark Public <nl> - ( void ) _addEventOnMainThread : ( NSString * ) addEventName <nl> WX_ADD_EVENT ( touchcancel , addTouchCancelEvent ) <nl> WX_ADD_EVENT ( accessibilityMagicTap , addAccessibilityMagicTapEvent ) <nl> <nl> + WX_ADD_EVENT ( stopPropagation , addStopPropagationEvent ) <nl> + <nl> if ( _isListenPseudoTouch ) { <nl> self . touchGesture . listenPseudoTouch = YES ; <nl> } <nl> - ( void ) _removeEventOnMainThread : ( NSString * ) removeEventName <nl> WX_REMOVE_EVENT ( touchend , removeTouchEndEvent ) <nl> WX_REMOVE_EVENT ( touchcancel , removeTouchCancelEvent ) <nl> WX_REMOVE_EVENT ( accessibilityMagicTap , removeAccessibilityMagicTapEvent ) <nl> + <nl> + WX_REMOVE_EVENT ( stopPropagation , removeStopPropagationEvent ) <nl> + <nl> if ( _isListenPseudoTouch ) { <nl> self . touchGesture . listenPseudoTouch = NO ; <nl> } <nl> - ( void ) removeAccessibilityMagicTapEvent <nl> _accessibilityMagicTapEvent = NO ; <nl> } <nl> <nl> + # pragma mark - StopPropagation <nl> + <nl> + - ( void ) addStopPropagationEvent <nl> + { <nl> + _listenStopPropagation = YES ; <nl> + self . touchGesture . listenTouchMove = YES ; <nl> + } <nl> + <nl> + - ( void ) removeStopPropagationEvent <nl> + { <nl> + _listenStopPropagation = NO ; <nl> + self . touchGesture . listenTouchMove = NO ; <nl> + } <nl> + <nl> # pragma mark - Click Event <nl> <nl> - ( void ) addClickEvent <nl> - ( void ) onClick : ( __unused UITapGestureRecognizer * ) recognizer <nl> position [ @ " width " ] = @ ( frame . size . width / scaleFactor ) ; <nl> position [ @ " height " ] = @ ( frame . size . height / scaleFactor ) ; <nl> } <nl> - <nl> [ self fireEvent : @ " click " params : @ { @ " position " : position } ] ; <nl> } <nl> <nl> - ( WXTouchGestureRecognizer * ) touchGesture <nl> _touchGesture . delegate = self ; <nl> [ self . view addGestureRecognizer : _touchGesture ] ; <nl> } <nl> - <nl> return _touchGesture ; <nl> } <nl> <nl> - ( void ) checkRemoveTouchGesture <nl> } <nl> } <nl> <nl> - # pragma mark - UIGestureRecognizerDelegate <nl> + - ( BOOL ) gestureShouldStopPropagation : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> + { <nl> + if ( touch . wx_stopPropagation & & [ touch . wx_stopPropagation isEqualToNumber : @ 1 ] ) { <nl> + return NO ; <nl> + } <nl> + else <nl> + { <nl> + if ( _listenStopPropagation ) <nl> + { <nl> + NSString * ref = _templateComponent ? _templateComponent . ref : self . ref ; <nl> + CGPoint screenLocation = [ touch locationInView : touch . window ] ; <nl> + CGPoint pageLocation = [ touch locationInView : self . weexInstance . rootView ] ; <nl> + NSDictionary * resultTouch = [ self touchResultWithScreenLocation : screenLocation pageLocation : pageLocation identifier : touch . wx_identifier ] ; <nl> + NSString * touchState ; <nl> + if ( touch . phase = = UITouchPhaseBegan ) { <nl> + touchState = @ " start " ; <nl> + } <nl> + else if ( touch . phase = = UITouchPhaseMoved ) { <nl> + touchState = @ " move " ; <nl> + } <nl> + else { <nl> + touchState = @ " end " ; <nl> + } <nl> + BOOL stopPropagation = [ [ WXEventManager sharedManager ] stopPropagation : self . weexInstance . instanceId ref : ref type : @ " stopPropagation " params : @ { @ " changedTouches " : resultTouch ? @ [ resultTouch ] : @ [ ] , @ " action " : touchState } ] ; <nl> + touch . wx_stopPropagation = stopPropagation ? @ 1 : @ 0 ; <nl> + } <nl> + } <nl> + return YES ; <nl> + } <nl> <nl> + # pragma mark - UIGestureRecognizerDelegate <nl> - ( BOOL ) gestureRecognizer : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch <nl> { <nl> - return YES ; <nl> + return [ self gestureShouldStopPropagation : gestureRecognizer shouldReceiveTouch : touch ] ; <nl> } <nl> <nl> - ( BOOL ) gestureRecognizerShouldBegin : ( UIGestureRecognizer * ) gestureRecognizer <nl> mmm a / ios / sdk / WeexSDK / Sources / Manager / WXBridgeManager . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Manager / WXBridgeManager . h <nl> <nl> <nl> # import < Foundation / Foundation . h > <nl> # import < JavaScriptCore / JavaScriptCore . h > <nl> + # import " WXBridgeContext . h " <nl> <nl> @ class WXBridgeMethod ; <nl> @ class WXSDKInstance ; <nl> extern void WXPerformBlockOnBridgeThread ( void ( ^ block ) ( void ) ) ; <nl> * * / <nl> - ( void ) fireEvent : ( NSString * ) instanceId ref : ( NSString * ) ref type : ( NSString * ) type params : ( NSDictionary * ) params domChanges : ( NSDictionary * ) domChanges handlerArguments : ( NSArray * ) handlerArguments ; <nl> <nl> + - ( JSValue * ) fireEventWithResult : ( NSString * ) instanceId ref : ( NSString * ) ref type : ( NSString * ) type params : ( NSDictionary * ) params domChanges : ( NSDictionary * ) domChanges ; <nl> + <nl> / * * <nl> * componentHook <nl> * @ param instanceId : instance id <nl> mmm a / ios / sdk / WeexSDK / Sources / Manager / WXBridgeManager . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Manager / WXBridgeManager . m <nl> <nl> * / <nl> <nl> # import " WXBridgeManager . h " <nl> - # import " WXBridgeContext . h " <nl> # import " WXLog . h " <nl> # import " WXAssert . h " <nl> # import " WXBridgeMethod . h " <nl> + ( void ) _performBlockOnBridgeThread : ( void ( ^ ) ( void ) ) block <nl> } <nl> } <nl> <nl> + void WXPerformBlockSyncOnBridgeThread ( void ( ^ block ) ( void ) ) <nl> + { <nl> + [ WXBridgeManager _performBlockSyncOnBridgeThread : block ] ; <nl> + } <nl> + <nl> + + ( void ) _performBlockSyncOnBridgeThread : ( void ( ^ ) ( void ) ) block <nl> + { <nl> + if ( [ NSThread currentThread ] = = [ self jsThread ] ) { <nl> + block ( ) ; <nl> + } else { <nl> + [ self performSelector : @ selector ( _performBlockSyncOnBridgeThread : ) <nl> + onThread : [ self jsThread ] <nl> + withObject : [ block copy ] <nl> + waitUntilDone : YES ] ; <nl> + } <nl> + } <nl> + <nl> # pragma mark JSBridge Management <nl> <nl> - ( void ) createInstance : ( NSString * ) instance <nl> - ( void ) callJsMethod : ( WXCallJSMethod * ) method <nl> } ) ; <nl> } <nl> <nl> + - ( JSValue * ) callJSMethodWithResult : ( WXCallJSMethod * ) method <nl> + { <nl> + if ( ! method ) return nil ; <nl> + __weak typeof ( self ) weakSelf = self ; <nl> + __block JSValue * value ; <nl> + WXPerformBlockSyncOnBridgeThread ( ^ ( ) { <nl> + value = [ weakSelf . bridgeCtx excuteJSMethodWithResult : method ] ; <nl> + } ) ; <nl> + return value ; <nl> + } <nl> + <nl> - ( void ) registerService : ( NSString * ) name withServiceUrl : ( NSURL * ) serviceScriptUrl withOptions : ( NSDictionary * ) options <nl> { <nl> if ( ! name | | ! serviceScriptUrl | | ! options ) return ; <nl> - ( void ) callComponentHook : ( NSString * ) instanceId componentId : ( NSString * ) component <nl> } ) ; <nl> } <nl> <nl> + - ( JSValue * ) fireEventWithResult : ( NSString * ) instanceId ref : ( NSString * ) ref type : ( NSString * ) type params : ( NSDictionary * ) params domChanges : ( NSDictionary * ) domChanges <nl> + { <nl> + if ( ! type | | ! ref ) { <nl> + WXLogError ( @ " Event type and component ref should not be nil " ) ; <nl> + return nil ; <nl> + } <nl> + NSArray * args = @ [ ref , type , params ? : @ { } , domChanges ? : @ { } ] ; <nl> + WXSDKInstance * instance = [ WXSDKManager instanceForID : instanceId ] ; <nl> + WXCallJSMethod * method = [ [ WXCallJSMethod alloc ] initWithModuleName : nil methodName : @ " fireEvent " arguments : args instance : instance ] ; <nl> + return [ self callJSMethodWithResult : method ] ; <nl> + } <nl> + <nl> - ( void ) callBack : ( NSString * ) instanceId funcId : ( NSString * ) funcId params : ( id ) params keepAlive : ( BOOL ) keepAlive <nl> { <nl> NSArray * args = nil ; <nl> mmm a / ios / sdk / WeexSDK / Sources / Protocol / WXScrollerProtocol . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Protocol / WXScrollerProtocol . h <nl> <nl> <nl> - ( WXScrollDirection ) scrollDirection ; <nl> <nl> + @ optional <nl> - ( NSString * ) refreshType ; <nl> + <nl> + - ( BOOL ) requestGestureShouldStopPropagation : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch ; <nl> @ end <nl> <nl> | [ WEEX - 113 ] [ iOS ] New Touch Dispatch Mechanism And Bubble Sync Method | apache/incubator-weex | eccc224ab2195b14cd42f38d52ef64a774b9d6aa | 2018-04-03T07:55:01Z |
mmm a / xbmc / guilib / GUIVisualisationControl . cpp <nl> ppp b / xbmc / guilib / GUIVisualisationControl . cpp <nl> void CGUIVisualisationControl : : OnInitialize ( int channels , int samplesPerSec , int <nl> <nl> void CGUIVisualisationControl : : OnAudioData ( const float * audioData , unsigned int audioDataLength ) <nl> { <nl> - if ( ! m_instance | | ! m_alreadyStarted ) <nl> + if ( ! m_instance | | ! m_alreadyStarted | | ! audioData | | audioDataLength = = 0 ) <nl> return ; <nl> <nl> / / Save our audio data in the buffers <nl> | Merge pull request from djp952 / visualization - nullpackets | xbmc/xbmc | 19f60fecab8f4f2bffe4467431cf6e2e7072e076 | 2019-11-28T08:16:52Z |
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> option ( SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING <nl> " Enable experimental Swift differentiable programming features " <nl> FALSE ) <nl> <nl> + option ( SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY <nl> + " Enable experimental Swift concurrency model " <nl> + FALSE ) <nl> + <nl> # <nl> # End of user - configurable options . <nl> # <nl> if ( SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY ) <nl> message ( STATUS " " ) <nl> <nl> message ( STATUS " Differentiable Programming Support : $ { SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING } " ) <nl> + message ( STATUS " Concurrency Support : $ { SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY } " ) <nl> message ( STATUS " " ) <nl> else ( ) <nl> message ( STATUS " Not building Swift standard library , SDK overlays , and runtime " ) <nl> mmm a / stdlib / public / CMakeLists . txt <nl> ppp b / stdlib / public / CMakeLists . txt <nl> if ( SWIFT_BUILD_STDLIB ) <nl> if ( SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING ) <nl> add_subdirectory ( Differentiation ) <nl> endif ( ) <nl> + <nl> + if ( SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ) <nl> + add_subdirectory ( Concurrency ) <nl> + endif ( ) <nl> endif ( ) <nl> <nl> if ( SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR ) <nl> new file mode 100644 <nl> index 000000000000 . . fa491ec43129 <nl> mmm / dev / null <nl> ppp b / stdlib / public / Concurrency / CMakeLists . txt <nl> <nl> + # = = = mmm CMakeLists . txt - Concurrency support library mmmmmmmmmmmmmmmmmmmmm = = = # <nl> + # <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2019 - 2020 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See https : / / swift . org / LICENSE . txt for license information <nl> + # See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + # <nl> + # = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = # <nl> + <nl> + add_swift_target_library ( swift_Concurrency $ { SWIFT_STDLIB_LIBRARY_BUILD_TYPES } IS_STDLIB <nl> + PartialAsyncTask . swift <nl> + <nl> + SWIFT_MODULE_DEPENDS_OSX Darwin <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin <nl> + SWIFT_MODULE_DEPENDS_LINUX Glibc <nl> + SWIFT_MODULE_DEPENDS_FREEBSD Glibc <nl> + SWIFT_MODULE_DEPENDS_OPENBSD Glibc <nl> + SWIFT_MODULE_DEPENDS_CYGWIN Glibc <nl> + SWIFT_MODULE_DEPENDS_HAIKU Glibc <nl> + SWIFT_MODULE_DEPENDS_WINDOWS MSVCRT <nl> + <nl> + SWIFT_COMPILE_FLAGS <nl> + $ { SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS } <nl> + - parse - stdlib <nl> + LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> + DARWIN_INSTALL_NAME_DIR " @ rpath " <nl> + INSTALL_IN_COMPONENT stdlib ) <nl> new file mode 100644 <nl> index 000000000000 . . fe55edc48a18 <nl> mmm / dev / null <nl> ppp b / stdlib / public / Concurrency / PartialAsyncTask . swift <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2020 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + import Swift <nl> + @ _implementationOnly import _SwiftConcurrencyShims <nl> + <nl> + public struct PartialAsyncTask { <nl> + private var context : UnsafeMutablePointer < _SwiftContext > <nl> + <nl> + public func run ( ) { } <nl> + } <nl> mmm a / stdlib / public / SwiftShims / CMakeLists . txt <nl> ppp b / stdlib / public / SwiftShims / CMakeLists . txt <nl> set ( sources <nl> ThreadLocalStorage . h <nl> UnicodeShims . h <nl> Visibility . h <nl> + _SwiftConcurrency . h <nl> <nl> CoreMediaOverlayShims . h <nl> DispatchOverlayShims . h <nl> new file mode 100644 <nl> index 000000000000 . . c714fdf2e31f <nl> mmm / dev / null <nl> ppp b / stdlib / public / SwiftShims / _SwiftConcurrency . h <nl> <nl> + / / = = = mmm _SwiftConcurrency . h - Swift Concurrency Support mmmmmm - - * - C + + - * - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2020 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / Defines types and support functions for the Swift concurrency model . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + # ifndef SWIFT_CONCURRENCY_H <nl> + # define SWIFT_CONCURRENCY_H <nl> + <nl> + # ifdef __cplusplus <nl> + namespace swift { <nl> + extern " C " { <nl> + # endif <nl> + <nl> + typedef struct _SwiftContext { <nl> + struct _SwiftContext * parentContext ; <nl> + } _SwiftContext ; <nl> + <nl> + # ifdef __cplusplus <nl> + } / / extern " C " <nl> + } / / namespace swift <nl> + # endif <nl> + <nl> + # endif / / SWIFT_CONCURRENCY_H <nl> mmm a / stdlib / public / SwiftShims / module . modulemap <nl> ppp b / stdlib / public / SwiftShims / module . modulemap <nl> module _SwiftClockKitOverlayShims { <nl> module _SwiftCoreMediaOverlayShims { <nl> header " CoreMediaOverlayShims . h " <nl> } <nl> + <nl> + module _SwiftConcurrencyShims { <nl> + header " _SwiftConcurrency . h " <nl> + } <nl> mmm a / test / CMakeLists . txt <nl> ppp b / test / CMakeLists . txt <nl> normalize_boolean_spelling ( SWIFT_ASAN_BUILD ) <nl> normalize_boolean_spelling ( SWIFT_BUILD_SYNTAXPARSERLIB ) <nl> normalize_boolean_spelling ( SWIFT_ENABLE_SOURCEKIT_TESTS ) <nl> normalize_boolean_spelling ( SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING ) <nl> + normalize_boolean_spelling ( SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ) <nl> is_build_type_optimized ( " $ { SWIFT_STDLIB_BUILD_TYPE } " SWIFT_OPTIMIZED ) <nl> <nl> set ( profdata_merge_worker <nl> _Block_release ( void ) { } \ n " ) <nl> list ( APPEND LIT_ARGS " - - param " " differentiable_programming " ) <nl> endif ( ) <nl> <nl> + if ( SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ) <nl> + list ( APPEND LIT_ARGS " - - param " " concurrency " ) <nl> + endif ( ) <nl> + <nl> foreach ( test_subset $ { TEST_SUBSETS } ) <nl> set ( directories ) <nl> set ( dependencies $ { test_dependencies } ) <nl> mmm a / test / lit . site . cfg . in <nl> ppp b / test / lit . site . cfg . in <nl> if ' @ SWIFT_INCLUDE_TOOLS @ ' = = ' TRUE ' : <nl> <nl> if " @ SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING @ " = = " TRUE " : <nl> config . available_features . add ( ' differentiable_programming ' ) <nl> + if " @ SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY @ " = = " TRUE " : <nl> + config . available_features . add ( ' concurrency ' ) <nl> <nl> # Let the main config do the real work . <nl> if config . test_exec_root is None : <nl> new file mode 100644 <nl> index 000000000000 . . fe70fa1b77ce <nl> mmm / dev / null <nl> ppp b / test / stdlib / Concurrency . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift <nl> + / / REQUIRES : concurrency <nl> + <nl> + / / Make sure the import succeeds <nl> + import _Concurrency <nl> + <nl> + / / Make sure the type shows up <nl> + extension PartialAsyncTask { <nl> + } <nl> mmm a / utils / build_swift / build_swift / driver_arguments . py <nl> ppp b / utils / build_swift / build_swift / driver_arguments . py <nl> def create_argument_parser ( ) : <nl> help = ' Enable experimental Swift differentiable programming language ' <nl> ' features . ' ) <nl> <nl> + option ( ' - - enable - experimental - concurrency ' , toggle_true , <nl> + default = True , <nl> + help = ' Enable experimental Swift concurrency model . ' ) <nl> + <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> in_group ( ' Unsupported options ' ) <nl> <nl> mmm a / utils / build_swift / tests / expected_options . py <nl> ppp b / utils / build_swift / tests / expected_options . py <nl> <nl> ' dry_run ' : False , <nl> ' enable_asan ' : False , <nl> ' enable_experimental_differentiable_programming ' : True , <nl> + ' enable_experimental_concurrency ' : True , <nl> ' enable_lsan ' : False , <nl> ' enable_sanitize_coverage ' : False , <nl> ' disable_guaranteed_normal_arguments ' : False , <nl> class BuildScriptImplOption ( _BaseOption ) : <nl> EnableOption ( ' - - distcc ' ) , <nl> EnableOption ( ' - - enable - asan ' ) , <nl> EnableOption ( ' - - enable - experimental - differentiable - programming ' ) , <nl> + EnableOption ( ' - - enable - experimental - concurrency ' ) , <nl> EnableOption ( ' - - enable - lsan ' ) , <nl> EnableOption ( ' - - enable - sanitize - coverage ' ) , <nl> EnableOption ( ' - - enable - tsan ' ) , <nl> mmm a / utils / swift_build_support / swift_build_support / products / swift . py <nl> ppp b / utils / swift_build_support / swift_build_support / products / swift . py <nl> def __init__ ( self , args , toolchain , source_dir , build_dir ) : <nl> self . cmake_options . extend ( <nl> self . _enable_experimental_differentiable_programming ) <nl> <nl> + # Add experimental concurrency flag . <nl> + self . cmake_options . extend ( self . _enable_experimental_concurrency ) <nl> + <nl> @ classmethod <nl> def is_build_script_impl_product ( cls ) : <nl> " " " is_build_script_impl_product - > bool <nl> def _enable_experimental_differentiable_programming ( self ) : <nl> return [ ( ' SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING : BOOL ' , <nl> self . args . enable_experimental_differentiable_programming ) ] <nl> <nl> + @ property <nl> + def _enable_experimental_concurrency ( self ) : <nl> + return [ ( ' SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY : BOOL ' , <nl> + self . args . enable_experimental_concurrency ) ] <nl> + <nl> @ classmethod <nl> def get_dependencies ( cls ) : <nl> return [ cmark . CMark , <nl> mmm a / utils / swift_build_support / tests / products / test_swift . py <nl> ppp b / utils / swift_build_support / tests / products / test_swift . py <nl> def setUp ( self ) : <nl> disable_guaranteed_normal_arguments = True , <nl> force_optimized_typechecker = False , <nl> enable_stdlibcore_exclusivity_checking = False , <nl> - enable_experimental_differentiable_programming = False ) <nl> + enable_experimental_differentiable_programming = False , <nl> + enable_experimental_concurrency = False ) <nl> <nl> # Setup shell <nl> shell . dry_run = True <nl> def test_by_default_no_cmake_options ( self ) : <nl> ' - DCMAKE_EXPORT_COMPILE_COMMANDS = TRUE ' , <nl> ' - DSWIFT_FORCE_OPTIMIZED_TYPECHECKER : BOOL = FALSE ' , <nl> ' - DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING : BOOL = FALSE ' , <nl> - ' - DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING : BOOL = FALSE ' <nl> + ' - DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING : BOOL = FALSE ' , <nl> + ' - DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY : BOOL = FALSE ' , <nl> ] <nl> self . assertEqual ( set ( swift . cmake_options ) , set ( expected ) ) <nl> <nl> def test_swift_runtime_tsan ( self ) : <nl> ' - DCMAKE_EXPORT_COMPILE_COMMANDS = TRUE ' , <nl> ' - DSWIFT_FORCE_OPTIMIZED_TYPECHECKER : BOOL = FALSE ' , <nl> ' - DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING : BOOL = FALSE ' , <nl> - ' - DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING : BOOL = FALSE ' <nl> + ' - DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING : BOOL = FALSE ' , <nl> + ' - DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY : BOOL = FALSE ' <nl> ] <nl> self . assertEqual ( set ( swift . cmake_options ) , set ( flags_set ) ) <nl> <nl> def test_experimental_differentiable_programming_flags ( self ) : <nl> ' TRUE ' ] , <nl> [ x for x in swift . cmake_options <nl> if ' DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING ' in x ] ) <nl> + <nl> + def test_experimental_concurrency_flags ( self ) : <nl> + self . args . enable_experimental_concurrency = True <nl> + swift = Swift ( <nl> + args = self . args , <nl> + toolchain = self . toolchain , <nl> + source_dir = ' / path / to / src ' , <nl> + build_dir = ' / path / to / build ' ) <nl> + self . assertEqual ( <nl> + [ ' - DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY : BOOL = ' <nl> + ' TRUE ' ] , <nl> + [ x for x in swift . cmake_options <nl> + if ' DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ' in x ] ) <nl> | Merge remote - tracking branch ' origin / master ' into master - rebranch | apple/swift | 501c9440d67461d51e339fa898e50d075382f7c4 | 2020-07-30T19:03:55Z |
mmm a / googlemock / include / gmock / gmock - matchers . h <nl> ppp b / googlemock / include / gmock / gmock - matchers . h <nl> class OptionalMatcher { <nl> : value_matcher_ ( value_matcher ) { } <nl> <nl> template < typename Optional > <nl> - operator Matcher < Optional > ( ) const { / / NOLINT <nl> + operator Matcher < Optional > ( ) const { <nl> return Matcher < Optional > ( new Impl < const Optional & > ( value_matcher_ ) ) ; <nl> } <nl> <nl> - template < typename Optional1 , typename ValueType2 > <nl> - operator Matcher < std : : tuple < Optional1 , ValueType2 > > ( ) const { / / NOLINT <nl> - return MakeMatcher ( <nl> - new PairImpl < Optional1 , ValueType2 > ( value_matcher_ ) ) ; <nl> - } <nl> - <nl> template < typename Optional > <nl> class Impl : public MatcherInterface < Optional > { <nl> public : <nl> class OptionalMatcher { <nl> GTEST_DISALLOW_ASSIGN_ ( Impl ) ; <nl> } ; <nl> <nl> - template < typename Optional1 , typename ValueType2 > <nl> - class PairImpl : public MatcherInterface < std : : tuple < Optional1 , ValueType2 > > { <nl> - public : <nl> - typedef GTEST_REMOVE_REFERENCE_AND_CONST_ ( Optional1 ) Optional1View ; <nl> - typedef typename Optional1View : : value_type ValueType1 ; <nl> - typedef std : : tuple < Optional1 , ValueType2 > OptionalTuple ; <nl> - typedef std : : tuple < ValueType1 , ValueType2 > ValuePair ; <nl> - <nl> - explicit PairImpl ( const ValueMatcher & value_matcher ) <nl> - : value_matcher_ ( MatcherCast < ValuePair > ( value_matcher ) ) { } <nl> - <nl> - void DescribeTo ( : : std : : ostream * os ) const override { <nl> - * os < < " are optionals where the values " ; <nl> - value_matcher_ . DescribeTo ( os ) ; <nl> - } <nl> - <nl> - void DescribeNegationTo ( : : std : : ostream * os ) const override { <nl> - * os < < " are optionals where the values " ; <nl> - value_matcher_ . DescribeNegationTo ( os ) ; <nl> - } <nl> - <nl> - bool MatchAndExplain ( OptionalTuple optional_tuple , <nl> - MatchResultListener * listener ) const override { <nl> - const auto & optional1 = std : : get < 0 > ( optional_tuple ) ; <nl> - const auto & value2 = std : : get < 1 > ( optional_tuple ) ; <nl> - if ( ! optional1 ) { <nl> - * listener < < " left is nullopt " ; <nl> - return false ; <nl> - } <nl> - const ValueType1 & value1 = * optional1 ; <nl> - StringMatchResultListener value_listener ; <nl> - const bool match = value_matcher_ . MatchAndExplain ( <nl> - std : : make_tuple ( value1 , value2 ) , & value_listener ) ; <nl> - * listener < < ( match ? " which match " : " whose values don ' t match " ) ; <nl> - PrintIfNotEmpty ( value_listener . str ( ) , listener - > stream ( ) ) ; <nl> - return match ; <nl> - } <nl> - <nl> - private : <nl> - const Matcher < ValuePair > value_matcher_ ; <nl> - GTEST_DISALLOW_ASSIGN_ ( PairImpl ) ; <nl> - } ; <nl> - <nl> private : <nl> const ValueMatcher value_matcher_ ; <nl> GTEST_DISALLOW_ASSIGN_ ( OptionalMatcher ) ; <nl> mmm a / googlemock / test / gmock - matchers_test . cc <nl> ppp b / googlemock / test / gmock - matchers_test . cc <nl> class SampleOptional { <nl> explicit SampleOptional ( T value ) <nl> : value_ ( std : : move ( value ) ) , has_value_ ( true ) { } <nl> SampleOptional ( ) : value_ ( ) , has_value_ ( false ) { } <nl> - explicit operator bool ( ) const { return has_value_ ; } <nl> + operator bool ( ) const { return has_value_ ; } <nl> const T & operator * ( ) const { return value_ ; } <nl> <nl> private : <nl> TEST ( OptionalTest , WorksWithMoveOnly ) { <nl> EXPECT_TRUE ( m . Matches ( SampleOptional < std : : unique_ptr < int > > ( nullptr ) ) ) ; <nl> } <nl> <nl> - TEST ( OptionalTest , TupleDescribesSelf ) { <nl> - const Matcher < std : : tuple < SampleOptional < int > , int > > m = Optional ( Eq ( ) ) ; <nl> - EXPECT_EQ ( " are optionals where the values are an equal pair " , Describe ( m ) ) ; <nl> - } <nl> - <nl> - TEST ( OptionalTest , TupleExplainsSelf ) { <nl> - const Matcher < std : : tuple < SampleOptional < int > , int > > m = Optional ( Eq ( ) ) ; <nl> - EXPECT_EQ ( " which match " , <nl> - Explain ( m , std : : make_tuple ( SampleOptional < int > ( 1 ) , 1 ) ) ) ; <nl> - EXPECT_EQ ( " whose values don ' t match " , <nl> - Explain ( m , std : : make_tuple ( SampleOptional < int > ( 1 ) , 2 ) ) ) ; <nl> - } <nl> - <nl> - TEST ( OptionalTest , TupleMatchesNonEmpty ) { <nl> - const Matcher < std : : tuple < SampleOptional < int > , int > > m1 = Optional ( Eq ( ) ) ; <nl> - const Matcher < std : : tuple < SampleOptional < int > , int > > m2 = Optional ( Lt ( ) ) ; <nl> - EXPECT_TRUE ( m1 . Matches ( std : : make_tuple ( SampleOptional < int > ( 1 ) , 1 ) ) ) ; <nl> - EXPECT_FALSE ( m1 . Matches ( std : : make_tuple ( SampleOptional < int > ( 1 ) , 2 ) ) ) ; <nl> - EXPECT_FALSE ( m2 . Matches ( std : : make_tuple ( SampleOptional < int > ( 1 ) , 1 ) ) ) ; <nl> - EXPECT_TRUE ( m2 . Matches ( std : : make_tuple ( SampleOptional < int > ( 1 ) , 2 ) ) ) ; <nl> - } <nl> - <nl> - TEST ( OptionalTest , TupleDoesNotMatchNullopt ) { <nl> - const Matcher < std : : tuple < SampleOptional < int > , int > > m1 = Optional ( Eq ( ) ) ; <nl> - EXPECT_FALSE ( m1 . Matches ( std : : make_tuple ( SampleOptional < int > ( ) , 1 ) ) ) ; <nl> - } <nl> - <nl> - TEST ( OptionalTest , TupleWorksInPointwise ) { <nl> - std : : vector < SampleOptional < int > > v = { <nl> - SampleOptional < int > ( 1 ) , SampleOptional < int > ( 2 ) , SampleOptional < int > ( 3 ) } ; <nl> - EXPECT_THAT ( v , Pointwise ( Optional ( Eq ( ) ) , { 1 , 2 , 3 } ) ) ; <nl> - } <nl> - <nl> class SampleVariantIntString { <nl> public : <nl> SampleVariantIntString ( int i ) : i_ ( i ) , has_int_ ( true ) { } <nl> | Googletest export | google/googletest | 6a3d632f40a1882cb09aeefa767f0fdf1f61c80e | 2019-08-26T18:43:56Z |
mmm a / site / source / docs / api_reference / emscripten . h . rst <nl> ppp b / site / source / docs / api_reference / emscripten . h . rst <nl> Functions <nl> <nl> : param int status : The same as for the * libc * function ` exit ( ) < http : / / linux . die . net / man / 3 / exit > ` _ . <nl> <nl> + . . c : function : : double emscripten_get_device_pixel_ratio ( void ) <nl> + <nl> + Returns the value of ` ` window . devicePixelRatio ` ` . <nl> + <nl> + : rtype : double <nl> + : return : The pixel ratio or 1 . 0 if not supported . <nl> <nl> . . c : function : : void emscripten_hide_mouse ( void ) <nl> <nl> Functions <nl> : param int * height : New pixel height of canvas element . <nl> : param int * isFullscreen : If True ( ` ` * int > 0 ` ` ) , ` ` < canvas > ` ` is full screen . <nl> <nl> + . . c : function : : void emscripten_set_element_css_size ( const char * target , double width , double height ) <nl> + <nl> + Resizes the css width and height of the element specified by ` ` target ` ` on the Emscripten web page . <nl> + <nl> + : param target : Element to resize , works the same as in the html5 api . <nl> + : type target : const char * <nl> + : param double width : New width of the element . <nl> + : param double height : New height of the element . <nl> + <nl> + <nl> + . . c : function : : void emscripten_get_element_css_size ( const char * target , double * width , double * height ) <nl> + <nl> + Gets the current css width and height of the element specified by ` ` target ` ` . <nl> + <nl> + : param target : Element to get size of , works the same as in the html5 api . <nl> + : type target : const char * <nl> + : param double * width : Width of the element . <nl> + : param double * height : Height of the element . <nl> <nl> . . c : function : : double emscripten_get_now ( void ) <nl> <nl> | add docs | emscripten-core/emscripten | d444015c83ddd0eac02079285f94066a583fecc3 | 2014-09-06T11:32:07Z |
mmm a / stdlib / private / StdlibCollectionUnittest / CheckCollectionInstance . swift . gyb <nl> ppp b / stdlib / private / StdlibCollectionUnittest / CheckCollectionInstance . swift . gyb <nl> public func checkCollection < $ { genericParam } , C : Collection > ( <nl> $ { TRACE } , <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all , <nl> sameValue : ( $ { Element } , $ { Element } ) - > Bool <nl> - ) where C . Iterator . Element = = $ { Element } { <nl> + ) where C . Iterator . Element = = $ { Element } , <nl> + C . SubSequence : Collection { <nl> <nl> checkForwardCollection ( expected , collection , message ( ) , <nl> stackTrace : stackTrace , showFrame : showFrame , file : file , line : line , <nl> public func check $ { Traversal } Collection < <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all <nl> ) where <nl> C . Iterator . Element = = $ { Element } , <nl> + C . SubSequence : $ { TraversalCollection } , <nl> $ { Element } : Equatable { <nl> <nl> check $ { Traversal } Collection ( <nl> public func check $ { Traversal } Collection < <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all , <nl> sameValue : ( $ { Element } , $ { Element } ) - > Bool <nl> ) where <nl> - C . Iterator . Element = = $ { Element } { <nl> + C . Iterator . Element = = $ { Element } , <nl> + C . SubSequence : $ { TraversalCollection } { <nl> <nl> checkOneLevelOf $ { Traversal } Collection ( expected , collection , $ { trace } , <nl> resiliencyChecks : resiliencyChecks , sameValue : sameValue ) <nl> $ { genericParam } , S : $ { TraversalCollection } <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all , <nl> sameValue : ( $ { Element } , $ { Element } ) - > Bool <nl> ) where <nl> - S . Iterator . Element = = $ { Element } { <nl> + S . Iterator . Element = = $ { Element } , <nl> + S . SubSequence : $ { TraversalCollection } { <nl> <nl> let expectedArray = Array ( expected ) <nl> <nl> mmm a / stdlib / private / StdlibCollectionUnittest / CheckCollectionType . swift . gyb <nl> ppp b / stdlib / private / StdlibCollectionUnittest / CheckCollectionType . swift . gyb <nl> internal enum _SubSequenceSubscriptOnRangeMode { <nl> % { <nl> from gyb_stdlib_support import collectionForTraversal <nl> def testConstraints ( protocol ) : <nl> + if protocol = = ' Collection ' : <nl> + subseq_as_collection = ' CollectionWithEquatableElement . SubSequence : Collection , ' <nl> + else : <nl> + subseq_as_collection = ' ' <nl> return ' ' ' <nl> C : % ( protocol ) s , <nl> CollectionWithEquatableElement : % ( protocol ) s , <nl> + % ( subseq_as_collection ) s <nl> + C . SubSequence : % ( protocol ) s , <nl> + C . Indices : % ( protocol ) s , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable <nl> ' ' ' % locals ( ) <nl> <nl> internal enum _SubSequenceSubscriptOnRangeMode { <nl> [ CollectionWithEquatableElement . Iterator . Element ] <nl> ) - > CollectionWithEquatableElement , <nl> <nl> - <nl> wrapValueIntoEquatable : @ escaping ( <nl> MinimalEquatableValue ) - > CollectionWithEquatableElement . Iterator . Element , <nl> <nl> mmm a / stdlib / private / StdlibCollectionUnittest / CheckMutableCollectionType . swift . gyb <nl> ppp b / stdlib / private / StdlibCollectionUnittest / CheckMutableCollectionType . swift . gyb <nl> extension TestSuite { <nl> isFixedLengthCollection : Bool , <nl> collectionIsBidirectional : Bool = false <nl> ) where <nl> + C . SubSequence : MutableCollection , <nl> + C . Indices : Collection , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable , <nl> CollectionWithComparableElement . Iterator . Element : Comparable { <nl> <nl> self . test ( " \ ( testNamePrefix ) . partition / InvalidOrderings " ) { <nl> withUnsafeMutableBufferPointerIsSupported : Bool , <nl> isFixedLengthCollection : Bool <nl> ) where <nl> + C . SubSequence : BidirectionalCollection & MutableCollection , <nl> + C . Indices : BidirectionalCollection , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable , <nl> CollectionWithComparableElement . Iterator . Element : Comparable { <nl> <nl> self . test ( " \ ( testNamePrefix ) . partition / DispatchesThrough_withUnsafeMutableBuffer <nl> withUnsafeMutableBufferPointerIsSupported : Bool , <nl> isFixedLengthCollection : Bool <nl> ) where <nl> + C . SubSequence : RandomAccessCollection & MutableCollection , <nl> + C . Indices : RandomAccessCollection , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable , <nl> CollectionWithComparableElement . Iterator . Element : Comparable { <nl> <nl> mmm a / stdlib / private / StdlibCollectionUnittest / CheckRangeReplaceableCollectionType . swift <nl> ppp b / stdlib / private / StdlibCollectionUnittest / CheckRangeReplaceableCollectionType . swift <nl> extension TestSuite { <nl> outOfBoundsIndexOffset : Int = 1 , <nl> collectionIsBidirectional : Bool = false <nl> ) where <nl> - CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> + C . SubSequence : Collection , <nl> + C . Indices : Collection , <nl> + CollectionWithEquatableElement . Iterator . Element : Equatable , <nl> + CollectionWithEquatableElement . SubSequence : Collection { <nl> <nl> var testNamePrefix = testNamePrefix <nl> <nl> self . test ( " \ ( testNamePrefix ) . OperatorPlus " ) { <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all , <nl> outOfBoundsIndexOffset : Int = 1 <nl> ) where <nl> + C . SubSequence : BidirectionalCollection & RangeReplaceableCollection , <nl> + C . Indices : BidirectionalCollection , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> <nl> var testNamePrefix = testNamePrefix <nl> self . test ( " \ ( testNamePrefix ) . removeLast ( n : Int ) / whereIndexIsBidirectional / remove <nl> resiliencyChecks : CollectionMisuseResiliencyChecks = . all , <nl> outOfBoundsIndexOffset : Int = 1 <nl> ) where <nl> + C . SubSequence : RandomAccessCollection & RangeReplaceableCollection , <nl> + C . Indices : RandomAccessCollection , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> <nl> var testNamePrefix = testNamePrefix <nl> mmm a / stdlib / private / StdlibCollectionUnittest / CheckRangeReplaceableSliceType . swift <nl> ppp b / stdlib / private / StdlibCollectionUnittest / CheckRangeReplaceableSliceType . swift <nl> extension TestSuite { <nl> collectionIsBidirectional : Bool = false <nl> ) where <nl> C . SubSequence = = C , <nl> + C . Indices : Collection , <nl> CollectionWithEquatableElement . SubSequence = = CollectionWithEquatableElement , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> <nl> extension TestSuite { <nl> outOfBoundsIndexOffset : Int = 1 <nl> ) where <nl> C . SubSequence = = C , <nl> + C . Indices : BidirectionalCollection , <nl> CollectionWithEquatableElement . SubSequence = = CollectionWithEquatableElement , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> <nl> extension TestSuite { <nl> outOfBoundsIndexOffset : Int = 1 <nl> ) where <nl> C . SubSequence = = C , <nl> + C . Indices : RandomAccessCollection , <nl> CollectionWithEquatableElement . SubSequence = = CollectionWithEquatableElement , <nl> CollectionWithEquatableElement . Iterator . Element : Equatable { <nl> <nl> mmm a / stdlib / private / StdlibUnittest / StdlibUnittest . swift . gyb <nl> ppp b / stdlib / private / StdlibUnittest / StdlibUnittest . swift . gyb <nl> public func expectSequenceType < X : Sequence > ( _ x : X ) - > X <nl> % for Mutable in [ ' ' , ' Mutable ' ] : <nl> public func expect $ { Mutable } CollectionType < X : $ { Mutable } Collection > ( <nl> _ x : X . Type <nl> - ) { } <nl> + ) where <nl> + / / FIXME ( ABI ) # 2 ( Associated Types with where clauses ) : there should be no constraints in <nl> + / / the ' where ' clause , all of these should be required by the protocol . <nl> + % if Mutable = = ' ' : <nl> + X . SubSequence : Collection , <nl> + % end <nl> + / / X . SubSequence . Indices = = X . Indices , / / FIXME ( ABI ) # 3 ( Recursive Protocol Constraints ) : can ' t have this constraint now . <nl> + X . Indices : Collection { } <nl> % end <nl> <nl> / / / A slice is a ` Collection ` that when sliced returns an instance of <nl> public func expectCollectionAssociatedTypes < X : Collection > ( <nl> indexType : X . Index . Type , <nl> indexDistanceType : X . IndexDistance . Type , <nl> indicesType : X . Indices . Type <nl> - ) { } <nl> + ) where <nl> + / / FIXME ( ABI ) # 6 ( Associated Types with where clauses ) : there should be no constraints in <nl> + / / the ' where ' clause , all of these should be required by the protocol . <nl> + X . SubSequence : Collection , <nl> + / / X . SubSequence . Indices = = X . Indices , / / FIXME ( ABI ) # 7 ( Recursive Protocol Constraints ) : can ' t have this constraint now . <nl> + X . Indices : Collection { } <nl> <nl> / / / Check that all associated types of a ` BidirectionalCollection ` are what we <nl> / / / expect them to be . <nl> public func expectBidirectionalCollectionAssociatedTypes < X : BidirectionalCollec <nl> indexType : X . Index . Type , <nl> indexDistanceType : X . IndexDistance . Type , <nl> indicesType : X . Indices . Type <nl> - ) { } <nl> + ) where <nl> + / / FIXME ( ABI ) # 8 ( Associated Types with where clauses ) : there should be no constraints in <nl> + / / the ' where ' clause , all of these should be required by the protocol . <nl> + X . SubSequence : BidirectionalCollection , <nl> + / / X . SubSequence . Indices = = X . Indices , / / FIXME ( ABI ) # 9 ( Recursive Protocol Constraints ) : can ' t have this constraint now . <nl> + X . Indices : BidirectionalCollection { } <nl> <nl> / / / Check that all associated types of a ` RandomAccessCollection ` are what we <nl> / / / expect them to be . <nl> public func expectRandomAccessCollectionAssociatedTypes < X : RandomAccessCollecti <nl> indexType : X . Index . Type , <nl> indexDistanceType : X . IndexDistance . Type , <nl> indicesType : X . Indices . Type <nl> - ) { } <nl> + ) where <nl> + / / FIXME ( ABI ) # 10 ( Associated Types with where clauses ) : there should be no constraints in <nl> + / / the ' where ' clause , all of these should be required by the protocol . <nl> + X . SubSequence : RandomAccessCollection , <nl> + / / X . SubSequence . Indices = = X . Indices , / / FIXME ( ABI ) # 11 ( Recursive Protocol Constraints ) : can ' t have this constraint now . <nl> + X . Indices : RandomAccessCollection { } <nl> <nl> public struct AssertionResult : CustomStringConvertible { <nl> init ( isPass : Bool ) { <nl> mmm a / stdlib / public / core / ArrayBufferProtocol . swift <nl> ppp b / stdlib / public / core / ArrayBufferProtocol . swift <nl> <nl> internal protocol _ArrayBufferProtocol <nl> : MutableCollection , RandomAccessCollection { <nl> <nl> - associatedtype Indices = CountableRange < Int > <nl> + associatedtype Indices <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove this conformance <nl> + : RandomAccessCollection <nl> + = CountableRange < Int > <nl> <nl> / / / The type of elements stored in the buffer . <nl> associatedtype Element <nl> mmm a / stdlib / public / core / BidirectionalCollection . swift <nl> ppp b / stdlib / public / core / BidirectionalCollection . swift <nl> public protocol _BidirectionalIndexable : _Indexable { <nl> / / / - If ` i > c . startIndex & & i < = c . endIndex ` <nl> / / / ` c . index ( after : c . index ( before : i ) ) = = i ` . <nl> public protocol BidirectionalCollection : _BidirectionalIndexable , Collection <nl> - where SubSequence : BidirectionalCollection , Indices : BidirectionalCollection { <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Restore these <nl> + / / where SubSequence : BidirectionalCollection , Indices : BidirectionalCollection <nl> + { <nl> <nl> / / TODO : swift - 3 - indexing - model - replaces functionality in BidirectionalIndex <nl> / / / Returns the position immediately before the given index . <nl> where SubSequence : BidirectionalCollection , Indices : BidirectionalCollection { <nl> <nl> / / / A sequence that can represent a contiguous subrange of the collection ' s <nl> / / / elements . <nl> - associatedtype SubSequence = BidirectionalSlice < Self > <nl> + associatedtype SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these conformances <nl> + : _BidirectionalIndexable , Collection <nl> + = BidirectionalSlice < Self > <nl> <nl> / / / A type that represents the indices that are valid for subscripting the <nl> / / / collection , in ascending order . <nl> - associatedtype Indices = DefaultBidirectionalIndices < Self > <nl> + associatedtype Indices <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these conformances <nl> + : _BidirectionalIndexable , Collection <nl> + = DefaultBidirectionalIndices < Self > <nl> <nl> / / / The indices that are valid for subscripting the collection , in ascending <nl> / / / order . <nl> mmm a / stdlib / public / core / Collection . swift <nl> ppp b / stdlib / public / core / Collection . swift <nl> public struct IndexingIterator < <nl> / / / count the number of contained elements , accessing its ` count ` property is <nl> / / / an O ( * n * ) operation . <nl> public protocol Collection : _Indexable , Sequence <nl> - where SubSequence : Collection , Indices : Collection , <nl> - SubSequence . Index = = Index <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Restore these <nl> + / / where SubSequence : Collection , Indices : Collection , <nl> { <nl> / / / A type that represents the number of steps between a pair of <nl> / / / indices . <nl> where SubSequence : Collection , Indices : Collection , <nl> / / / This associated type appears as a requirement in the ` Sequence ` <nl> / / / protocol , but it is restated here with stricter constraints . In a <nl> / / / collection , the subsequence should also conform to ` Collection ` . <nl> - associatedtype SubSequence = Slice < Self > <nl> - where Iterator . Element = = SubSequence . Iterator . Element , <nl> - SubSequence . SubSequence = = SubSequence <nl> + associatedtype SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : remove these conformances : <nl> + : _IndexableBase , Sequence <nl> + = Slice < Self > <nl> + where SubSequence . SubSequence = = SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : and this where clause : <nl> + , Iterator . Element = = SubSequence . Iterator . Element <nl> + , SubSequence . Index = = Index <nl> + <nl> <nl> / / FIXME ( ABI ) # 98 ( Recursive Protocol Constraints ) : <nl> / / FIXME ( ABI ) # 99 ( Associated Types with where clauses ) : <nl> where SubSequence : Collection , Indices : Collection , <nl> <nl> / / / A type that represents the indices that are valid for subscripting the <nl> / / / collection , in ascending order . <nl> - associatedtype Indices = DefaultIndices < Self > <nl> - where Indices . Iterator . Element = = Index , <nl> + associatedtype Indices <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these two conformances <nl> + : _Indexable , Sequence <nl> + = DefaultIndices < Self > <nl> + where Indices . Iterator . Element = = Index , <nl> Indices . Index = = Index <nl> - <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove this where clause <nl> + , Indices . SubSequence = = Indices <nl> + <nl> / / FIXME ( ABI ) # 100 ( Recursive Protocol Constraints ) : <nl> / / associatedtype Indices : Collection <nl> / / where <nl> mmm a / stdlib / public / core / ExistentialCollection . swift . gyb <nl> ppp b / stdlib / public / core / ExistentialCollection . swift . gyb <nl> internal class _AnyRandomAccessCollectionBox < Element > <nl> % assert False , ' Unknown kind ' <nl> % end <nl> <nl> + <nl> + <nl> @ _fixed_layout <nl> @ _versioned <nl> internal final class _ $ { Kind } Box < S : $ { Kind } > : _Any $ { Kind } Box < S . Iterator . Element > <nl> - % if Kind = = ' Sequence ' : <nl> where <nl> S . SubSequence : $ { Kind } , <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : apply all this only to Sequence : <nl> + % if Kind = = ' Sequence ' : <nl> S . SubSequence . Iterator . Element = = S . Iterator . Element , <nl> S . SubSequence . SubSequence = = S . SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : remove this else clause : <nl> + % else : <nl> + S . SubSequence . Indices : $ { Kind } , <nl> + S . Indices : $ { Kind } <nl> % end <nl> { <nl> internal typealias Element = S . Iterator . Element <nl> public struct $ { Self } < Element > <nl> @ _inlineable <nl> public init < C : $ { SubProtocol } > ( _ base : C ) <nl> where <nl> - / / FIXME ( ABI ) # 101 ( Associated Types with where clauses ) : these constraints should be applied to <nl> - / / associated types of Collection . <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : remove next 3 lines <nl> + C . SubSequence : $ { SubProtocol } , <nl> + C . SubSequence . Indices : $ { SubProtocol } , <nl> + C . Indices : $ { SubProtocol } , <nl> + / / FIXME ( ABI ) # 101 ( Associated Types with where clauses ) : these constraints <nl> + / / should be applied to associated types of Collection . <nl> C . SubSequence . Iterator . Element = = Element <nl> { <nl> / / Traversal : $ { Traversal } <nl> mmm a / stdlib / public / core / Mirror . swift <nl> ppp b / stdlib / public / core / Mirror . swift <nl> public struct Mirror { <nl> children : C , <nl> displayStyle : DisplayStyle ? = nil , <nl> ancestorRepresentation : AncestorRepresentation = . generated <nl> - ) where C . Iterator . Element = = Child { <nl> + ) where C . Iterator . Element = = Child <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these <nl> + , C . SubSequence : Collection , C . SubSequence . Indices : Collection , C . Indices : Collection <nl> + { <nl> <nl> self . subjectType = Subject . self <nl> self . _makeSuperclassMirror = Mirror . _superclassIterator ( <nl> public struct Mirror { <nl> unlabeledChildren : C , <nl> displayStyle : DisplayStyle ? = nil , <nl> ancestorRepresentation : AncestorRepresentation = . generated <nl> - ) { <nl> + ) <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these two clauses <nl> + where C . SubSequence : Collection , C . Indices : Collection <nl> + { <nl> <nl> self . subjectType = Subject . self <nl> self . _makeSuperclassMirror = Mirror . _superclassIterator ( <nl> mmm a / stdlib / public / core / MutableCollection . swift <nl> ppp b / stdlib / public / core / MutableCollection . swift <nl> public protocol _MutableIndexable : _Indexable { <nl> / / / a [ i ] = x <nl> / / / let y = x <nl> public protocol MutableCollection : _MutableIndexable , Collection <nl> - where SubSequence : MutableCollection { <nl> - associatedtype SubSequence = MutableSlice < Self > <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : restore this : <nl> + / / where SubSequence : MutableCollection <nl> + { <nl> + associatedtype SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : remove this conformance : <nl> + : Collection <nl> + = MutableSlice < Self > <nl> <nl> / / / Accesses the element at the specified position . <nl> / / / <nl> mmm a / stdlib / public / core / RandomAccessCollection . swift <nl> ppp b / stdlib / public / core / RandomAccessCollection . swift <nl> public protocol _RandomAccessIndexable : _BidirectionalIndexable { <nl> / / / ` distance ( from : to : ) ` methods with O ( 1 ) efficiency . <nl> public protocol RandomAccessCollection : <nl> _RandomAccessIndexable , BidirectionalCollection <nl> - where SubSequence : RandomAccessCollection , Indices : RandomAccessCollection <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Restore this : <nl> + / / where SubSequence : RandomAccessCollection , Indices : RandomAccessCollection <nl> { <nl> / / / A collection that represents a contiguous subrange of the collection ' s <nl> / / / elements . <nl> - associatedtype SubSequence = RandomAccessSlice < Self > <nl> + associatedtype SubSequence <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these two constraints : <nl> + : _RandomAccessIndexable , BidirectionalCollection <nl> + = RandomAccessSlice < Self > <nl> <nl> / / / A type that represents the indices that are valid for subscripting the <nl> / / / collection , in ascending order . <nl> - associatedtype Indices = DefaultRandomAccessIndices < Self > <nl> + associatedtype Indices <nl> + / / FIXME ( ABI ) ( Revert Where Clauses ) : Remove these two constraints : <nl> + : _RandomAccessIndexable , BidirectionalCollection <nl> + = DefaultRandomAccessIndices < Self > <nl> <nl> / / / The indices that are valid for subscripting the collection , in ascending <nl> / / / order . <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | b530ea801d545677438291caa91788afc347fcbb | 2017-05-12T00:28:41Z |
mmm a / src / third_party / wiredtiger / dist / api_data . py <nl> ppp b / src / third_party / wiredtiger / dist / api_data . py <nl> def __ge__ ( self , other ) : <nl> object exists , check that its settings match the specified <nl> configuration ' ' ' , <nl> type = ' boolean ' ) , <nl> + Config ( ' import ' , ' ' , r ' ' ' <nl> + configure import of an existing object into the currently running database ' ' ' , <nl> + type = ' category ' , subconfig = [ <nl> + Config ( ' enabled ' , ' false ' , r ' ' ' <nl> + whether to import the input URI from disk ' ' ' , <nl> + type = ' boolean ' ) , <nl> + Config ( ' repair ' , ' false ' , r ' ' ' <nl> + whether to reconstruct the metadata from the raw file content ' ' ' , <nl> + type = ' boolean ' ) , <nl> + Config ( ' file_metadata ' , ' ' , r ' ' ' <nl> + the file configuration extracted from the metadata of the export database ' ' ' ) , <nl> + ] ) , <nl> ] ) , <nl> <nl> ' WT_SESSION . drop ' : Method ( [ <nl> mmm a / src / third_party / wiredtiger / import . data <nl> ppp b / src / third_party / wiredtiger / import . data <nl> <nl> " vendor " : " wiredtiger " , <nl> " github " : " wiredtiger / wiredtiger . git " , <nl> " branch " : " mongodb - 4 . 6 " , <nl> - " commit " : " 3e693213fe4c31f84ead39bb3bef575f2f222af6 " <nl> + " commit " : " 472039bd1c9fd31f22730ba25afc23f4b09f59a8 " <nl> } <nl> mmm a / src / third_party / wiredtiger / src / config / config_def . c <nl> ppp b / src / third_party / wiredtiger / src / config / config_def . c <nl> static const WT_CONFIG_CHECK confchk_WT_SESSION_create_encryption_subconfigs [ ] = <nl> { " keyid " , " string " , NULL , NULL , NULL , 0 } , { " name " , " string " , NULL , NULL , NULL , 0 } , <nl> { NULL , NULL , NULL , NULL , NULL , 0 } } ; <nl> <nl> + static const WT_CONFIG_CHECK confchk_WT_SESSION_create_import_subconfigs [ ] = { <nl> + { " enabled " , " boolean " , NULL , NULL , NULL , 0 } , { " file_metadata " , " string " , NULL , NULL , NULL , 0 } , <nl> + { " repair " , " boolean " , NULL , NULL , NULL , 0 } , { NULL , NULL , NULL , NULL , NULL , 0 } } ; <nl> + <nl> static const WT_CONFIG_CHECK confchk_WT_SESSION_create_merge_custom_subconfigs [ ] = { <nl> { " prefix " , " string " , NULL , NULL , NULL , 0 } , <nl> { " start_generation " , " int " , NULL , " min = 0 , max = 10 " , NULL , 0 } , <nl> static const WT_CONFIG_CHECK confchk_WT_SESSION_create [ ] = { <nl> { " huffman_key " , " string " , NULL , NULL , NULL , 0 } , { " huffman_value " , " string " , NULL , NULL , NULL , 0 } , <nl> { " ignore_in_memory_cache_size " , " boolean " , NULL , NULL , NULL , 0 } , <nl> { " immutable " , " boolean " , NULL , NULL , NULL , 0 } , <nl> + { " import " , " category " , NULL , NULL , confchk_WT_SESSION_create_import_subconfigs , 3 } , <nl> { " internal_item_max " , " int " , NULL , " min = 0 " , NULL , 0 } , <nl> { " internal_key_max " , " int " , NULL , " min = 0 " , NULL , 0 } , <nl> { " internal_key_truncate " , " boolean " , NULL , NULL , NULL , 0 } , <nl> static const WT_CONFIG_ENTRY config_entries [ ] = { { " WT_CONNECTION . add_collator " , <nl> " columns = , dictionary = 0 , encryption = ( keyid = , name = ) , exclusive = false , " <nl> " extractor = , format = btree , huffman_key = , huffman_value = , " <nl> " ignore_in_memory_cache_size = false , immutable = false , " <nl> + " import = ( enabled = false , file_metadata = , repair = false ) , " <nl> " internal_item_max = 0 , internal_key_max = 0 , " <nl> " internal_key_truncate = true , internal_page_max = 4KB , key_format = u , " <nl> " key_gap = 10 , leaf_item_max = 0 , leaf_key_max = 0 , leaf_page_max = 32KB , " <nl> static const WT_CONFIG_ENTRY config_entries [ ] = { { " WT_CONNECTION . add_collator " , <nl> " prefix_compression = false , prefix_compression_min = 4 , source = , " <nl> " split_deepen_min_child = 0 , split_deepen_per_child = 0 , split_pct = 90 , " <nl> " type = file , value_format = u " , <nl> - confchk_WT_SESSION_create , 44 } , <nl> + confchk_WT_SESSION_create , 45 } , <nl> { " WT_SESSION . drop " , <nl> " checkpoint_wait = true , force = false , lock_wait = true , " <nl> " remove_files = true " , <nl> mmm a / src / third_party / wiredtiger / src / include / wiredtiger . in <nl> ppp b / src / third_party / wiredtiger / src / include / wiredtiger . in <nl> struct __wt_session { <nl> * the configured cache limit . , a boolean flag ; default \ c false . } <nl> * @ config { immutable , configure the index to be immutable - that is an index is not changed <nl> * by any update to a record in the table . , a boolean flag ; default \ c false . } <nl> + * @ config { import = ( , configure import of an existing object into the currently running <nl> + * database . , a set of related configuration options defined below . } <nl> + * @ config { & nbsp ; & nbsp ; & nbsp ; & nbsp ; enabled , whether to import the input URI from disk . , a <nl> + * boolean flag ; default \ c false . } <nl> + * @ config { & nbsp ; & nbsp ; & nbsp ; & nbsp ; file_metadata , the file <nl> + * configuration extracted from the metadata of the export database . , a string ; default <nl> + * empty . } <nl> + * @ config { & nbsp ; & nbsp ; & nbsp ; & nbsp ; repair , whether to reconstruct the metadata from <nl> + * the raw file content . , a boolean flag ; default \ c false . } <nl> + * @ config { ) , , } <nl> * @ config { internal_key_max , the largest key stored in an internal node \ , in bytes . If <nl> * set \ , keys larger than the specified size are stored as overflow items ( which may require <nl> * additional I / O to access ) . The default and the maximum allowed value are both one - tenth <nl> | Import wiredtiger : 472039bd1c9fd31f22730ba25afc23f4b09f59a8 from branch mongodb - 4 . 6 | mongodb/mongo | f4dd1b0c7ee46c6882ffe36f08c97099fda27fbc | 2020-09-21T06:41:04Z |
mmm a / build / deps / github_hashes / facebook / fbthrift - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / fbthrift - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 28f4b885f5d524d7f71e2179774979ee1d950c45 <nl> + Subproject commit 471978898790aa132e0f5c2a4b66a7506688d380 <nl> mmm a / build / deps / github_hashes / facebook / folly - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / folly - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit a04d119cb2d58b6329c7fe0d739b9e4b03dfeadd <nl> + Subproject commit 6e296e642385fe28e2c620f7ab90391f9cb135af <nl> | Updating submodules | facebook/watchman | 79da271b535c3148ce95327a2dcc94eb0a7a163d | 2019-02-19T19:26:34Z |
mmm a / test / stdlib / NSValueBridging . swift . gyb <nl> ppp b / test / stdlib / NSValueBridging . swift . gyb <nl> <nl> / / RUN : % target - codesign % t . out <nl> / / RUN : % target - run % t . out <nl> / / REQUIRES : executable_test <nl> + / / rdar : / / problem / 64995079 <nl> + / / XFAIL : OS = ios & & CPU = armv7s <nl> / / <nl> / / REQUIRES : objc_interop <nl> <nl> | [ Test ] Xfail stdlib / NSValueBridging . swift | apple/swift | c5270a596874f3bcafdfa65d2bd02f060de99649 | 2020-07-10T13:29:52Z |
mmm a / cmake / addons / depends / common / kodi - platform / kodi - platform . txt <nl> ppp b / cmake / addons / depends / common / kodi - platform / kodi - platform . txt <nl> @ @ - 1 + 1 @ @ <nl> - kodi - platform https : / / github . com / xbmc / kodi - platform c8188d82678fec6b784597db69a68e74ff4986b5 <nl> + kodi - platform https : / / github . com / xbmc / kodi - platform 36fb49371dbce49bf470a5bb1fc51b74b4a3612d <nl> mmm a / cmake / addons / depends / common / p8 - platform / p8 - platform . txt <nl> ppp b / cmake / addons / depends / common / p8 - platform / p8 - platform . txt <nl> @ @ - 1 + 1 @ @ <nl> - p8 - platform https : / / github . com / Pulse - Eight / platform . git 38343e0acd6a636ac46139aa666aee4a8d1f13db <nl> + p8 - platform https : / / github . com / xbmc / platform . git 81c38cd885f822983dbf27b198239729bae13786 <nl> | Fix addon build after the unicode changes | xbmc/xbmc | 2d722752953d8213a1b10ff607a6b814ba89ecba | 2017-03-06T19:59:22Z |
mmm a / hphp / runtime / base / backtrace . cpp <nl> ppp b / hphp / runtime / base / backtrace . cpp <nl> struct BTContext { <nl> fakeAR [ 0 ] . m_numArgsAndFlags = fakeAR [ 1 ] . m_numArgsAndFlags = flags ; <nl> } <nl> <nl> + BTContext ( const BTContext & ) = delete ; <nl> + BTContext ( BTContext & & ) = delete ; <nl> + BTContext & operator = ( const BTContext & ) = delete ; <nl> + BTContext & operator = ( BTContext & & ) = delete ; <nl> + <nl> + const ActRec * clone ( const BTContext & src , const ActRec * fp ) { <nl> + fakeAR [ 0 ] . m_func = src . fakeAR [ 0 ] . m_func ; <nl> + fakeAR [ 0 ] . m_callOff = src . fakeAR [ 0 ] . m_callOff ; <nl> + <nl> + fakeAR [ 1 ] . m_func = src . fakeAR [ 1 ] . m_func ; <nl> + fakeAR [ 1 ] . m_callOff = src . fakeAR [ 1 ] . m_callOff ; <nl> + <nl> + stashedAR = src . stashedAR ; <nl> + stashedPC = src . stashedPC ; <nl> + inlineStack = src . inlineStack ; <nl> + hasInlFrames = src . hasInlFrames ; <nl> + assertx ( ! ! stashedAR = = ( fp = = & src . fakeAR [ 0 ] | | fp = = & src . fakeAR [ 1 ] ) ) ; <nl> + <nl> + return <nl> + fp = = & src . fakeAR [ 0 ] ? & fakeAR [ 0 ] : <nl> + fp = = & src . fakeAR [ 1 ] ? & fakeAR [ 1 ] : <nl> + fp ; <nl> + } <nl> + <nl> bool hasInlFrames { false } ; <nl> <nl> / / fakeAR is used to generate pseudo - frames representing inlined functions <nl> ActRec * getActRecFromWaitHandle ( <nl> ActRec * initBTContextAt ( <nl> BTContext & ctx , jit : : CTCA ip , ActRec * fp , Offset * prevPc <nl> ) { <nl> + / / The bytecode supports a limited form of inlining via FCallBuiltin . If the <nl> + / / call itself was interpreted there won ' t be any fixup information , but <nl> + / / we should still be able to extract the target from the bytecode on the <nl> + / / stack and use that directly . <nl> + auto const getBuiltin = [ & ] ( ) - > const Func * { <nl> + if ( ! fp | | ! prevPc ) { <nl> + return nullptr ; <nl> + } <nl> + auto const func = fp - > func ( ) ; <nl> + auto const pc = func - > unit ( ) - > entry ( ) + * prevPc ; <nl> + if ( peek_op ( pc ) ! = OpFCallBuiltin ) return nullptr ; <nl> + auto const ne = func - > unit ( ) - > lookupNamedEntityId ( getImm ( pc , 2 ) . u_SA ) ; <nl> + return Unit : : lookupFunc ( ne ) ; <nl> + } ; <nl> if ( auto stk = jit : : inlineStackAt ( ip ) ) { <nl> assertx ( stk - > nframes ! = 0 ) ; <nl> auto prevFp = & ctx . fakeAR [ 0 ] ; <nl> ActRec * initBTContextAt ( <nl> * prevPc = stk - > callOff + ifr . func - > base ( ) ; <nl> } <nl> return prevFp ; <nl> + } else if ( auto const f = getBuiltin ( ) ) { <nl> + auto prevFp = & ctx . fakeAR [ 0 ] ; <nl> + prevFp - > m_func = f ; <nl> + prevFp - > m_callOff = * prevPc - fp - > func ( ) - > base ( ) ; <nl> + ctx . stashedAR = fp ; <nl> + if ( prevPc ) { <nl> + ctx . stashedPC = * prevPc ; <nl> + * prevPc = f - > base ( ) ; <nl> + } <nl> + return prevFp ; <nl> } <nl> return nullptr ; <nl> } <nl> Array createBacktrace ( const BacktraceArgs & btArgs ) { <nl> / / Handle the top frame . <nl> if ( btArgs . m_withSelf ) { <nl> / / Builtins don ' t have a file and line number , so find the first user frame <nl> - auto curFp = fp ; <nl> + BTContext ctxCopy ; <nl> + auto curFp = ctxCopy . clone ( ctx , fp ) ; <nl> auto curPc = pc ; <nl> while ( curFp & & curFp - > func ( ) - > isBuiltin ( ) ) { <nl> - curFp = g_context - > getPrevVMState ( curFp , & curPc ) ; <nl> + curFp = getPrevActRec ( ctxCopy , curFp , & curPc , visitedWHs ) ; <nl> } <nl> if ( curFp ) { <nl> auto const unit = curFp - > func ( ) - > unit ( ) ; <nl> mmm a / hphp / runtime / vm / jit / cg - meta . cpp <nl> ppp b / hphp / runtime / vm / jit / cg - meta . cpp <nl> using InlineFrameVec = AtomicVector < IFrame > ; <nl> InlineFrameVec s_inlineFrames { 4096 , IFrame { } } ; <nl> <nl> constexpr uint32_t kInvalidCatchTrace = 0x0 ; <nl> + constexpr uint32_t kInvalidFrameID = - 1 ; <nl> <nl> IFrameID insertFrames ( const std : : vector < IFrame > & frames ) { <nl> auto const start = s_nextFrameKey . fetch_add ( frames . size ( ) ) ; <nl> void processInlineFrames ( const CGMeta & cm ) { <nl> } <nl> <nl> folly : : Optional < IStack > inlineStackAt ( CTCA addr ) { <nl> + if ( ! addr ) return folly : : none ; <nl> auto off = stackAddrToOffset ( addr ) ; <nl> if ( auto pos = s_inlineStacks . find ( off ) ) { <nl> - return * pos ; <nl> + if ( pos - > frame ! = kInvalidFrameID ) return * pos ; <nl> } <nl> return folly : : none ; <nl> } <nl> IFrame getInlineFrame ( IFrameID id ) { <nl> return s_inlineFrames [ id ] ; <nl> } <nl> <nl> + void eraseInlineStack ( CTCA addr ) { <nl> + if ( auto stk = s_inlineStacks . find ( tc : : addrToOffset ( addr ) ) ) { <nl> + stk - > frame = kInvalidFrameID ; <nl> + } <nl> + } <nl> + <nl> const uint64_t * addrForLiteral ( uint64_t val ) { <nl> if ( auto it = s_literals . find ( val ) ) { <nl> assertx ( * * it = = val ) ; <nl> mmm a / hphp / runtime / vm / jit / cg - meta . h <nl> ppp b / hphp / runtime / vm / jit / cg - meta . h <nl> struct IStack { <nl> IFrameID frame ; / / leaf frame in this stack <nl> uint32_t nframes ; <nl> uint32_t callOff ; <nl> + <nl> + template < class SerDe > void serde ( SerDe & sd ) { <nl> + sd <nl> + ( frame ) <nl> + ( nframes ) <nl> + ( callOff ) <nl> + ; <nl> + } <nl> } ; <nl> <nl> / * <nl> void addVeneer ( CGMeta & meta , TCA source , TCA target ) ; <nl> <nl> folly : : Optional < IStack > inlineStackAt ( CTCA addr ) ; <nl> IFrame getInlineFrame ( IFrameID id ) ; <nl> + void eraseInlineStack ( CTCA addr ) ; <nl> <nl> } } <nl> <nl> mmm a / hphp / runtime / vm / jit / irlower - call . cpp <nl> ppp b / hphp / runtime / vm / jit / irlower - call . cpp <nl> void cgCallBuiltin ( IRLS & env , const IRInstruction * inst ) { <nl> return callDest ( env , inst ) ; <nl> } ( ) ; <nl> <nl> + auto const isInlined = env . unit . context ( ) . func ! = callee ; <nl> + if ( isInlined ) v < < inlinestart { callee , 0 } ; <nl> + auto const end = [ & ] ( Vout & v ) { if ( isInlined ) v < < inlineend { } ; } ; <nl> + <nl> cgCallHelper ( v , env , CallSpec : : direct ( callee - > nativeFuncPtr ( ) , nullptr ) , <nl> dest , SyncOptions : : Sync , args ) ; <nl> <nl> / / For primitive return types ( int , bool , double ) and returnByValue , the <nl> / / return value is already in dstData / dstType . <nl> - if ( returnType . isSimpleType ( ) | | returnByValue ) return ; <nl> + if ( returnType . isSimpleType ( ) | | returnByValue ) return end ( v ) ; <nl> <nl> / / For return by reference ( String , Object , Array , Variant ) , the builtin <nl> / / writes the return value into MInstrState : : tvBuiltinReturn , from where it <nl> void cgCallBuiltin ( IRLS & env , const IRInstruction * inst ) { <nl> v < < testq { dstData , dstData , sf } ; <nl> v < < cmovb { CC_Z , sf , rtype , nulltype , dstType } ; <nl> } <nl> - return ; <nl> + return end ( v ) ; <nl> } <nl> <nl> if ( returnType < = TCell | | returnType < = TBoxedCell ) { <nl> void cgCallBuiltin ( IRLS & env , const IRInstruction * inst ) { <nl> v < < testb { rtype , rtype , sf } ; <nl> v < < cmovb { CC_Z , sf , rtype , nulltype , dstType } ; <nl> } <nl> - return ; <nl> + return end ( v ) ; <nl> } <nl> <nl> not_reached ( ) ; <nl> mmm a / hphp / runtime / vm / jit / tc - recycle . cpp <nl> ppp b / hphp / runtime / vm / jit / tc - recycle . cpp <nl> void clearTCMaps ( TCA start , TCA end ) { <nl> } <nl> } <nl> eraseCatchTrace ( start ) ; <nl> + eraseInlineStack ( start ) ; <nl> if ( isCall ) { <nl> if ( auto call = eraseSmashedCall ( start ) ) { <nl> clearProfCaller ( start , call - > isGuard , call - > rec ) ; <nl> mmm a / hphp / runtime / vm / jit / tc - relocate . cpp <nl> ppp b / hphp / runtime / vm / jit / tc - relocate . cpp <nl> struct TransRelocInfoHelper { <nl> std : : vector < uint32_t > addressImmediates ; <nl> std : : vector < uint64_t > codePointers ; <nl> std : : vector < std : : pair < uint32_t , std : : pair < Alignment , AlignContext > > > alignments ; <nl> + std : : vector < std : : tuple < FuncId , int32_t , IFrameID > > inlineFrames ; <nl> + std : : vector < std : : pair < uint32_t , IStack > > inlineStacks ; <nl> <nl> template < class SerDe > void serde ( SerDe & sd ) { <nl> sd <nl> struct TransRelocInfoHelper { <nl> ( addressImmediates ) <nl> ( codePointers ) <nl> ( alignments ) <nl> + ( inlineFrames ) <nl> + ( inlineStacks ) <nl> ; <nl> } <nl> <nl> struct TransRelocInfoHelper { <nl> for ( auto v : alignments ) { <nl> tri . fixups . alignments . emplace ( v . first + code . base ( ) , v . second ) ; <nl> } <nl> + for ( auto s : inlineFrames ) { <nl> + auto const func = Func : : fromFuncId ( std : : get < 0 > ( s ) ) ; <nl> + tri . fixups . inlineFrames . emplace_back ( IFrame { <nl> + func , std : : get < 1 > ( s ) , std : : get < 2 > ( s ) <nl> + } ) ; <nl> + } <nl> + for ( auto s : inlineStacks ) { <nl> + tri . fixups . inlineStacks . emplace_back ( std : : make_pair ( <nl> + s . first + code . base ( ) , <nl> + s . second <nl> + ) ) ; <nl> + } <nl> return tri ; <nl> } <nl> } ; <nl> perfRelocMapInfo ( TCA start , TCA / * end * / , TCA coldStart , TCA coldEnd , SrcKey sk , <nl> trih . alignments . emplace_back ( v . first - code ( ) . base ( ) , v . second ) ; <nl> } <nl> <nl> + for ( auto f : fixups . inlineFrames ) { <nl> + trih . inlineFrames . emplace_back ( f . func - > getFuncId ( ) , f . callOff , f . parent ) ; <nl> + } <nl> + <nl> + for ( auto s : fixups . inlineStacks ) { <nl> + trih . inlineStacks . emplace_back ( s . first - code ( ) . base ( ) , s . second ) ; <nl> + } <nl> + <nl> trih . coldRange = std : : make_pair ( uint32_t ( coldStart - code ( ) . base ( ) ) , <nl> uint32_t ( coldEnd - code ( ) . base ( ) ) ) ; <nl> <nl> mmm a / hphp / runtime / vm / jit / vasm - internal - inl . h <nl> ppp b / hphp / runtime / vm / jit / vasm - internal - inl . h <nl> void computeFrames ( Vunit & unit ) ; <nl> <nl> inline void Venv : : record_inline_stack ( TCA addr ) { <nl> uint32_t callOff = 0 ; <nl> - if ( origin ) { <nl> + auto const func = unit . frames [ frame ] . func ; <nl> + auto const in_builtin = func & & func - > isCPPBuiltin ( ) ; <nl> + if ( origin & & ! in_builtin ) { <nl> auto const marker = origin - > marker ( ) ; <nl> callOff = marker . bcOff ( ) - marker . func ( ) - > base ( ) ; <nl> } <nl> mmm a / hphp / test / slow / collection_classes / to_array_logging . php <nl> ppp b / hphp / test / slow / collection_classes / to_array_logging . php <nl> <nl> < ? hh <nl> <nl> - / / TODO ( T41519835 ) the reported location is wrong in non - PGO mode <nl> - < < __NEVER_INLINE > > <nl> function test ( $ input ) { <nl> $ _ = $ input - > toArray ( ) ; <nl> $ _ = ( array ) $ input ; <nl> mmm a / hphp / test / slow / collection_classes / to_array_logging . php . expectf <nl> ppp b / hphp / test / slow / collection_classes / to_array_logging . php . expectf <nl> <nl> - Notice : Hack Array Compat : Calling array producing function Vector : : toArray in % s / to_array_logging . php on line 6 <nl> + Notice : Hack Array Compat : Calling array producing function Vector : : toArray in % s / to_array_logging . php on line 4 <nl> <nl> - Notice : Hack Array Compat : Calling array producing function Set : : toArray in % s / to_array_logging . php on line 6 <nl> + Notice : Hack Array Compat : Calling array producing function Set : : toArray in % s / to_array_logging . php on line 4 <nl> <nl> - Notice : Hack Array Compat : Calling array producing function Map : : toArray in % s / to_array_logging . php on line 6 <nl> + Notice : Hack Array Compat : Calling array producing function Map : : toArray in % s / to_array_logging . php on line 4 <nl> <nl> - Notice : Hack Array Compat : Calling array producing function Pair : : toArray in % s / to_array_logging . php on line 6 <nl> + Notice : Hack Array Compat : Calling array producing function Pair : : toArray in % s / to_array_logging . php on line 4 <nl> deleted file mode 100644 <nl> index 4cbcde08b1f . . 00000000000 <nl> mmm a / hphp / test / slow / debug_backtrace / metadata_call_user_func . php . expectf - repo <nl> ppp / dev / null <nl> <nl> - Fatal error : Uncaught exception ' InvalidArgumentException ' with message ' Unsupported dynamic call of set_frame_metadata ( ) ' in % smetadata_call_user_func . php : 8 <nl> - Stack trace : <nl> - # 0 % smetadata_call_user_func . php ( 8 ) : HH \ set_frame_metadata ( ) <nl> - # 1 % smetadata_call_user_func . php ( 12 ) : foo ( ) <nl> - # 2 { main } <nl> | Handle CallBuiltin with inline stack fixups | facebook/hhvm | 47261961b3b0cdfb3b2d8a7e00afbfa0b7e0b535 | 2019-03-15T15:40:35Z |
mmm a / include / osquery / expected . h <nl> ppp b / include / osquery / expected . h <nl> class Expected final { <nl> <nl> Expected & operator = ( Expected & & other ) { <nl> if ( this ! = & other ) { <nl> - errorChecked_ . verify ( " Error was not checked " ) ; <nl> + errorChecked_ . verify ( " Expected was not checked before assigning " ) ; <nl> <nl> object_ = std : : move ( other . object_ ) ; <nl> errorChecked_ = other . errorChecked_ ; <nl> class Expected final { <nl> Expected & operator = ( const Expected & other ) = delete ; <nl> <nl> ~ Expected ( ) { <nl> - errorChecked_ . verify ( " Error was not checked " ) ; <nl> + errorChecked_ . verify ( " Expected was not checked before destruction " ) ; <nl> } <nl> <nl> static SelfType success ( ValueType value ) { <nl> mmm a / osquery / core / tests / exptected_tests . cpp <nl> ppp b / osquery / core / tests / exptected_tests . cpp <nl> GTEST_TEST ( ExpectedTest , error_handling_example ) { <nl> } <nl> } <nl> <nl> - GTEST_TEST ( ExpectedTest , error_was_not_checked ) { <nl> + GTEST_TEST ( ExpectedTest , expected_was_not_checked_before_destruction_failure ) { <nl> auto action = [ ] ( ) { auto expected = ExpectedSuccess < TestError > { Success ( ) } ; } ; <nl> # ifndef NDEBUG <nl> - ASSERT_DEATH ( action ( ) , " Error was not checked " ) ; <nl> + ASSERT_DEATH ( action ( ) , " Expected was not checked before destruction " ) ; <nl> # else <nl> boost : : ignore_unused ( action ) ; <nl> # endif <nl> } <nl> <nl> + GTEST_TEST ( ExpectedTest , expected_was_not_checked_before_assigning_failure ) { <nl> + auto action = [ ] ( ) { <nl> + auto expected = ExpectedSuccess < TestError > { Success ( ) } ; <nl> + expected = ExpectedSuccess < TestError > { Success ( ) } ; <nl> + expected . isValue ( ) ; <nl> + } ; <nl> + # ifndef NDEBUG <nl> + ASSERT_DEATH ( action ( ) , " Expected was not checked before assigning " ) ; <nl> + # else <nl> + boost : : ignore_unused ( action ) ; <nl> + # endif <nl> + } <nl> + <nl> + GTEST_TEST ( ExpectedTest , expected_move_is_safe ) { <nl> + auto expected = ExpectedSuccess < TestError > { Success ( ) } ; <nl> + expected . isValue ( ) ; <nl> + expected = ExpectedSuccess < TestError > { Success ( ) } ; <nl> + expected . isValue ( ) ; <nl> + } <nl> + <nl> GTEST_TEST ( ExpectedTest , get_value_from_expected_with_error ) { <nl> auto action = [ ] ( ) { <nl> auto expected = Expected < int , TestError > ( TestError : : Logical , <nl> | Make error messages in Expected check different to distinguish problems ( ) | osquery/osquery | b6edf00892361b782077d76da0235344f6a21a15 | 2018-08-22T12:26:55Z |
mmm a / hphp / runtime / version . h <nl> ppp b / hphp / runtime / version . h <nl> <nl> * / <nl> # ifndef HHVM_VERSION_OVERRIDE <nl> # define HHVM_VERSION_MAJOR 4 <nl> - # define HHVM_VERSION_MINOR 31 <nl> + # define HHVM_VERSION_MINOR 32 <nl> # define HHVM_VERSION_PATCH 0 <nl> # define HHVM_VERSION_SUFFIX " - dev " <nl> # endif <nl> | update version header | facebook/hhvm | 8c4723cb896cf6929069ef23d8894fc78cc4379d | 2019-11-11T21:17:00Z |
mmm a / tensorflow / lite / delegates / gpu / common / model . cc <nl> ppp b / tensorflow / lite / delegates / gpu / common / model . cc <nl> absl : : Status ConnectTwoNodes ( GraphFloat32 * graph , const Node * from_node , <nl> } <nl> <nl> bool IsBatchMatchesForAllValues ( const GraphFloat32 & model ) { <nl> + if ( model . values ( ) . empty ( ) ) return true ; <nl> const int32_t b = model . values ( ) [ 0 ] - > tensor . shape . b ; <nl> for ( auto value : model . values ( ) ) { <nl> if ( value - > tensor . shape . b ! = b ) { <nl> mmm a / tensorflow / lite / delegates / gpu / common / model . h <nl> ppp b / tensorflow / lite / delegates / gpu / common / model . h <nl> absl : : Status AddOutput ( GraphFloat32 * graph , const Node * from_node , <nl> absl : : Status ConnectTwoNodes ( GraphFloat32 * graph , const Node * from_node , <nl> const Node * to_node , Value * * output ) ; <nl> <nl> - / / @ return true if all tensors have same batch value . <nl> + / / @ return true if all tensors have same batch value or if model has no values . <nl> bool IsBatchMatchesForAllValues ( const GraphFloat32 & model ) ; <nl> <nl> } / / namespace gpu <nl> mmm a / tensorflow / lite / delegates / gpu / common / model_test . cc <nl> ppp b / tensorflow / lite / delegates / gpu / common / model_test . cc <nl> TEST ( Model , InsertNodeAfter ) { <nl> EXPECT_THAT ( graph . nodes ( ) , ElementsAre ( node1 , new_node1 , node2 , new_node2 ) ) ; <nl> } <nl> <nl> + TEST ( BatchMatchingTest , EmptyGraph ) { <nl> + GraphFloat32 graph ; <nl> + ASSERT_TRUE ( IsBatchMatchesForAllValues ( graph ) ) ; <nl> + } <nl> + <nl> + TEST ( BatchMatchingTest , AllMatch ) { <nl> + GraphFloat32 graph ; <nl> + Value * a = graph . NewValue ( ) ; <nl> + Value * b = graph . NewValue ( ) ; <nl> + a - > tensor . shape = BHWC ( 1 , 1 , 1 , 1 ) ; <nl> + b - > tensor . shape = BHWC ( 1 , 1 , 1 , 1 ) ; <nl> + ASSERT_TRUE ( IsBatchMatchesForAllValues ( graph ) ) ; <nl> + } <nl> + <nl> + TEST ( BatchMatchingTest , NotAllMatch ) { <nl> + GraphFloat32 graph ; <nl> + Value * a = graph . NewValue ( ) ; <nl> + Value * b = graph . NewValue ( ) ; <nl> + a - > tensor . shape = BHWC ( 1 , 1 , 1 , 1 ) ; <nl> + b - > tensor . shape = BHWC ( 2 , 1 , 1 , 1 ) ; <nl> + ASSERT_FALSE ( IsBatchMatchesForAllValues ( graph ) ) ; <nl> + } <nl> + <nl> } / / namespace <nl> } / / namespace gpu <nl> } / / namespace tflite <nl> mmm a / tensorflow / lite / delegates / gpu / gl / kernels / elementwise . cc <nl> ppp b / tensorflow / lite / delegates / gpu / gl / kernels / elementwise . cc <nl> std : : unique_ptr < NodeShader > NewElementwiseNodeShader ( <nl> OperationType operation_type ) { <nl> switch ( operation_type ) { <nl> case OperationType : : ABS : <nl> - case OperationType : : COPY : <nl> case OperationType : : COS : <nl> + case OperationType : : COPY : <nl> case OperationType : : ELU : <nl> case OperationType : : EXP : <nl> - case OperationType : : LOG : <nl> case OperationType : : HARD_SWISH : <nl> + case OperationType : : LOG : <nl> + case OperationType : : NEG : <nl> case OperationType : : RSQRT : <nl> case OperationType : : SIGMOID : <nl> case OperationType : : SIN : <nl> | Fix batch value matching for the empty vector + clean up few typos . | tensorflow/tensorflow | 6bdae6145a521693aba42eff7f3c8b070429c05b | 2020-09-18T23:08:12Z |
mmm a / src / qtlibtorrent / torrentmodel . cpp <nl> ppp b / src / qtlibtorrent / torrentmodel . cpp <nl> void TorrentModel : : removeTorrent ( const QString & hash ) <nl> qDebug ( ) < < Q_FUNC_INFO < < hash < < row ; <nl> if ( row > = 0 ) { <nl> beginRemoveTorrent ( row ) ; <nl> + delete m_torrents [ row ] ; <nl> m_torrents . removeAt ( row ) ; <nl> endRemoveTorrent ( ) ; <nl> } <nl> | Merge pull request from sorokin / fix - memleak - in - torrentmodel | qbittorrent/qBittorrent | d62498b48c9631c39e25c4b7f6bb748c172bd487 | 2014-11-02T14:43:04Z |
mmm a / Code / CryEngine / CryEntitySystem / EntityArchetype . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / EntityArchetype . cpp <nl> void CEntityArchetype : : SaveEntityAttributesToXML ( XmlNodeRef & entityAttributes ) <nl> IEntityArchetype * CEntityArchetypeManager : : CreateArchetype ( IEntityClass * pClass , const char * sArchetype ) <nl> { <nl> CEntityArchetype * pArchetype = stl : : find_in_map ( m_nameToArchetypeMap , sArchetype , NULL ) ; <nl> - if ( pArchetype & & stricmp ( pClass - > GetName ( ) , pArchetype - > GetName ( ) ) = = 0 ) <nl> + if ( pArchetype ) <nl> return pArchetype ; <nl> pArchetype = new CEntityArchetype ( ( CEntityClass * ) pClass ) ; <nl> pArchetype - > SetName ( sArchetype ) ; <nl> | ! XI / / ce / game_hunt - > / / ce / main : 1335445 ( Approved by achim ) | CRYTEK/CRYENGINE | ef5394bb6190006194c3b12fcc26d3f53b0cde91 | 2016-10-06T16:52:02Z |
mmm a / tensorflow / contrib / BUILD <nl> ppp b / tensorflow / contrib / BUILD <nl> py_library ( <nl> " / / tensorflow / contrib / solvers : solvers_py " , <nl> " / / tensorflow / contrib / specs " , <nl> " / / tensorflow / contrib / stat_summarizer : stat_summarizer_py " , <nl> + " / / tensorflow / contrib / tensor_forest : tensor_forest_ops_py " , <nl> " / / tensorflow / contrib / tensor_forest : tensor_forest_py " , <nl> " / / tensorflow / contrib / tensor_forest / hybrid : ops_lib " , <nl> " / / tensorflow / contrib / tensorboard " , <nl> mmm a / tensorflow / contrib / crf / BUILD <nl> ppp b / tensorflow / contrib / crf / BUILD <nl> py_library ( <nl> srcs = [ " __init__ . py " ] + glob ( [ " python / ops / * . py " ] ) , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / rnn : rnn_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : math_ops " , <nl> mmm a / tensorflow / contrib / framework / BUILD <nl> ppp b / tensorflow / contrib / framework / BUILD <nl> licenses ( [ " notice " ] ) # Apache 2 . 0 <nl> <nl> exports_files ( [ " LICENSE " ] ) <nl> <nl> - package ( default_visibility = [ " / / tensorflow : __subpackages__ " ] ) <nl> + package ( default_visibility = [ <nl> + " / / learning / brain : __subpackages__ " , <nl> + " / / tensorflow : __subpackages__ " , <nl> + ] ) <nl> <nl> load ( " / / tensorflow : tensorflow . bzl " , " cuda_py_test " ) <nl> load ( " / / tensorflow : tensorflow . bzl " , " tf_custom_op_library " ) <nl> mmm a / tensorflow / contrib / grid_rnn / BUILD <nl> ppp b / tensorflow / contrib / grid_rnn / BUILD <nl> py_library ( <nl> srcs = [ " __init__ . py " ] + glob ( [ " python / ops / * . py " ] ) , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> + " / / tensorflow / contrib / rnn : rnn_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : nn " , <nl> mmm a / tensorflow / contrib / layers / BUILD <nl> ppp b / tensorflow / contrib / layers / BUILD <nl> licenses ( [ " notice " ] ) # Apache 2 . 0 <nl> <nl> exports_files ( [ " LICENSE " ] ) <nl> <nl> - package ( default_visibility = [ " / / tensorflow : __subpackages__ " ] ) <nl> + package ( default_visibility = [ <nl> + " / / learning / brain : __subpackages__ " , <nl> + " / / tensorflow : __subpackages__ " , <nl> + ] ) <nl> <nl> load ( " / / tensorflow : tensorflow . bzl " , " cuda_py_test " ) <nl> load ( " / / tensorflow : tensorflow . bzl " , " tf_custom_op_library " ) <nl> py_library ( <nl> " / / tensorflow / python : sparse_ops " , <nl> " / / tensorflow / python : standard_ops " , <nl> " / / tensorflow / python : string_ops " , <nl> + " / / tensorflow / python : summary " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> " / / tensorflow / python : variable_scope " , <nl> mmm a / tensorflow / contrib / learn / BUILD <nl> ppp b / tensorflow / contrib / learn / BUILD <nl> licenses ( [ " notice " ] ) # Apache 2 . 0 <nl> <nl> exports_files ( [ " LICENSE " ] ) <nl> <nl> - package ( default_visibility = [ " / / tensorflow : __subpackages__ " ] ) <nl> + package ( default_visibility = [ <nl> + " / / engedu / ml / tf_from_scratch : __pkg__ " , <nl> + " / / tensorflow : __subpackages__ " , <nl> + ] ) <nl> <nl> py_library ( <nl> name = " learn " , <nl> py_library ( <nl> " / / tensorflow / contrib / learn / python / learn / datasets " , <nl> " / / tensorflow / contrib / linear_optimizer : sdca_ops_py " , <nl> " / / tensorflow / contrib / losses : losses_py " , <nl> + " / / tensorflow / contrib / metrics : metrics_py " , <nl> + " / / tensorflow / contrib / rnn : rnn_py " , <nl> " / / tensorflow / contrib / session_bundle : exporter " , <nl> " / / tensorflow / contrib / session_bundle : gc " , <nl> " / / tensorflow / contrib / tensor_forest : client_lib " , <nl> py_library ( <nl> " / / tensorflow / python : sparse_ops " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : string_ops " , <nl> + " / / tensorflow / python : summary " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> " / / tensorflow / python : variable_scope " , <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn / python / learn / datasets " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> ) <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / testing : testing_py " , <nl> " / / tensorflow / python : extra_py_tests_deps " , <nl> " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / testing : testing_py " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : training " , <nl> py_test ( <nl> ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn / python / learn / datasets " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> ) <nl> py_test ( <nl> deps = [ <nl> " : learn " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / contrib / learn / python / learn / datasets / BUILD <nl> ppp b / tensorflow / contrib / learn / python / learn / datasets / BUILD <nl> py_library ( <nl> data = [ " : data_csv " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / framework : framework_py " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : platform " , <nl> " / / third_party / py / numpy " , <nl> py_test ( <nl> srcs = [ " load_csv_test . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : datasets " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / contrib / learn " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> py_test ( <nl> srcs = [ " synthetic_test . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : datasets " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / contrib / learn " , <nl> + " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / contrib / linalg / BUILD <nl> ppp b / tensorflow / contrib / linalg / BUILD <nl> py_library ( <nl> srcs = [ " __init__ . py " ] + glob ( [ " python / ops / * . py " ] ) , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / framework : framework_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : check_ops " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> mmm a / tensorflow / contrib / linear_optimizer / BUILD <nl> ppp b / tensorflow / contrib / linear_optimizer / BUILD <nl> py_library ( <nl> deps = [ <nl> " : sharded_mutable_dense_hashtable_py " , <nl> " : sparse_feature_column_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> py_library ( <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : sdca_ops_gen " , <nl> " / / tensorflow / python : state_ops " , <nl> + " / / tensorflow / python : summary " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / contrib / metrics / BUILD <nl> ppp b / tensorflow / contrib / metrics / BUILD <nl> licenses ( [ " notice " ] ) # Apache 2 . 0 <nl> <nl> exports_files ( [ " LICENSE " ] ) <nl> <nl> - package ( default_visibility = [ " / / tensorflow : __subpackages__ " ] ) <nl> + package ( default_visibility = [ <nl> + " / / engedu / ml / tf_from_scratch : __pkg__ " , <nl> + " / / tensorflow : __subpackages__ " , <nl> + ] ) <nl> <nl> py_library ( <nl> name = " metrics_py " , <nl> mmm a / tensorflow / contrib / rnn / BUILD <nl> ppp b / tensorflow / contrib / rnn / BUILD <nl> cuda_py_tests ( <nl> size = " small " , <nl> srcs = [ " python / kernel_tests / core_rnn_cell_test . py " ] , <nl> additional_deps = [ <nl> + " : rnn_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / python : rnn_cell " , <nl> ] , <nl> cuda_py_tests ( <nl> size = " medium " , <nl> srcs = [ " python / kernel_tests / core_rnn_test . py " ] , <nl> additional_deps = [ <nl> + " : rnn_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / python : array_ops " , <nl> + " / / tensorflow / python : client_testlib " , <nl> + " / / tensorflow / python : control_flow_ops " , <nl> + " / / tensorflow / python : framework_for_generated_wrappers " , <nl> + " / / tensorflow / python : gradients " , <nl> + " / / tensorflow / python : init_ops " , <nl> + " / / tensorflow / python : math_ops " , <nl> + " / / tensorflow / python : platform " , <nl> + " / / tensorflow / python : rnn " , <nl> + " / / tensorflow / python : tensor_array_ops " , <nl> " / / tensorflow / python : util " , <nl> + " / / tensorflow / python : variable_scope " , <nl> + " / / tensorflow / python : variables " , <nl> ] , <nl> shard_count = 10 , <nl> ) <nl> mmm a / tensorflow / contrib / seq2seq / BUILD <nl> ppp b / tensorflow / contrib / seq2seq / BUILD <nl> py_library ( <nl> srcs = [ " __init__ . py " ] + glob ( [ " python / ops / * . py " ] ) , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> cuda_py_test ( <nl> additional_deps = [ <nl> " : seq2seq_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : platform_test " , <nl> ] , <nl> mmm a / tensorflow / contrib / tensor_forest / BUILD <nl> ppp b / tensorflow / contrib / tensor_forest / BUILD <nl> py_library ( <nl> srcs = [ " client / eval_metrics . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " / / tensorflow / contrib / losses : losses_py " , <nl> " / / tensorflow / contrib / metrics : metrics_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : math_ops " , <nl> mmm a / tensorflow / contrib / tensor_forest / hybrid / BUILD <nl> ppp b / tensorflow / contrib / tensor_forest / hybrid / BUILD <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / contrib / tensor_forest : tensor_forest_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : math_ops " , <nl> py_library ( <nl> deps = [ <nl> " : hybrid_layer " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> ] , <nl> py_library ( <nl> " : hybrid_model " , <nl> " : ops_lib " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> " / / tensorflow / contrib / tensor_forest : tensor_forest_py " , <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : training " , <nl> mmm a / tensorflow / contrib / training / BUILD <nl> ppp b / tensorflow / contrib / training / BUILD <nl> py_library ( <nl> " / / tensorflow / python : random_ops " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : string_ops " , <nl> + " / / tensorflow / python : summary " , <nl> " / / tensorflow / python : tensor_array_ops " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> mmm a / tensorflow / examples / learn / BUILD <nl> ppp b / tensorflow / examples / learn / BUILD <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> name = " hdf5_classification " , <nl> srcs = [ " hdf5_classification . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ " / / tensorflow : tensorflow_py " ] , <nl> + deps = [ <nl> + " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> + ] , <nl> ) <nl> <nl> py_binary ( <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> " / / tensorflow / examples / tutorials / mnist : input_data " , <nl> ] , <nl> ) <nl> py_binary ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / contrib / layers : layers_py " , <nl> + " / / tensorflow / contrib / learn " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> <nl> # Python support for TensorFlow . <nl> <nl> package ( default_visibility = [ <nl> + " / / engedu / ml / tf_from_scratch : __pkg__ " , <nl> " / / tensorflow : internal " , <nl> " / / tensorflow_models : __subpackages__ " , <nl> ] ) <nl> py_library ( <nl> " : errors " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : functional_ops " , <nl> " : gradient_checker " , <nl> " : histogram_ops " , <nl> py_library ( <nl> " : math_ops " , <nl> " : nn " , <nl> " : platform " , <nl> - " : platform_test " , <nl> " : script_ops " , <nl> " : sdca_ops " , <nl> " : session_ops " , <nl> py_library ( <nl> " : tensor_array_ops " , <nl> " : training " , <nl> " : ops " , <nl> - " : test_ops " , <nl> " : util " , <nl> " / / tensorflow / python / ops / losses " , <nl> - " / / tensorflow / python / debug : debug_py " , <nl> ] + if_not_windows ( [ <nl> " / / tensorflow / contrib : contrib_py " , <nl> ] ) , <nl> py_library ( <nl> name = " platform_test " , <nl> srcs = [ " platform / googletest . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " : platform " , <nl> - " : platform_benchmark " , <nl> - " : timeline " , <nl> - ] , <nl> + deps = [ " : platform_benchmark " ] , <nl> ) <nl> <nl> tf_py_test ( <nl> tf_py_test ( <nl> name = " flags_test " , <nl> size = " small " , <nl> srcs = [ " platform / flags_test . py " ] , <nl> - additional_deps = [ <nl> - " : platform " , <nl> - " : platform_test " , <nl> - ] , <nl> + additional_deps = [ " : platform " ] , <nl> ) <nl> <nl> tf_py_test ( <nl> name = " app_test " , <nl> size = " small " , <nl> srcs = [ " platform / app_test . py " ] , <nl> - additional_deps = [ <nl> - " : platform " , <nl> - " : platform_test " , <nl> - ] , <nl> + additional_deps = [ " : platform " ] , <nl> tags = [ <nl> " manual " , <nl> " notap " , <nl> py_test ( <nl> " : data_flow_ops " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : io_ops " , <nl> " : platform " , <nl> " : util " , <nl> py_library ( <nl> " : platform " , <nl> " : platform_test " , <nl> " : pywrap_tensorflow " , <nl> - " : session " , <nl> " : util " , <nl> " / / third_party / py / numpy " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : client " , <nl> - " : device_lib " , <nl> " : framework_test_lib " , <nl> " : gradient_checker " , <nl> " : platform_test " , <nl> py_test ( <nl> deps = [ <nl> " : client_testlib " , <nl> " : errors " , <nl> - " : framework_test_lib " , <nl> - " : platform_test " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> ) <nl> py_test ( <nl> deps = [ <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> ] , <nl> ) <nl> <nl> - tf_gen_op_wrapper_private_py ( name = " functional_ops_gen " ) <nl> + tf_gen_op_wrapper_private_py ( <nl> + name = " functional_ops_gen " , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> + ) <nl> <nl> py_library ( <nl> name = " functional_ops " , <nl> cuda_py_tests ( <nl> " : nn_ops " , <nl> " : platform " , <nl> " : random_ops " , <nl> - " : session " , <nl> " : variable_scope " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> py_test ( <nl> deps = [ <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : platform_test " , <nl> ] , <nl> ) <nl> <nl> py_test ( <nl> " : client_testlib " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : gradients " , <nl> " : math_ops " , <nl> " : nn_grad " , <nl> " : nn_ops " , <nl> - " : platform_test " , <nl> " : random_ops " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> py_test ( <nl> " : data_flow_ops " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : math_ops " , <nl> " : nn_ops " , <nl> " : platform " , <nl> - " : platform_test " , <nl> " : random_ops " , <nl> " : training " , <nl> " : variables " , <nl> py_test ( <nl> " : math_ops " , <nl> " : platform_test " , <nl> " : resources " , <nl> - " : session " , <nl> - " : sparse_ops " , <nl> " : test_ops " , <nl> " : test_ops_2 " , <nl> " : util " , <nl> py_test ( <nl> deps = [ <nl> " : client_testlib " , <nl> " : framework " , <nl> - " : framework_test_lib " , <nl> - " : platform_test " , <nl> ] , <nl> ) <nl> <nl> py_test ( <nl> " : client_testlib " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : math_ops " , <nl> - " : platform_test " , <nl> - " : state_ops " , <nl> " : state_ops_gen " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> " : framework_test_lib " , <nl> - " : logging_ops " , <nl> " : platform_test " , <nl> " : random_ops " , <nl> ] , <nl> tf_gen_op_wrapper_private_py ( <nl> name = " array_ops_gen " , <nl> require_shape_functions = True , <nl> visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> " / / tensorflow / compiler / tests : __pkg__ " , <nl> " / / tensorflow / contrib / quantization : __pkg__ " , <nl> " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> tf_gen_op_wrapper_private_py ( <nl> tf_gen_op_wrapper_private_py ( <nl> name = " candidate_sampling_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " control_flow_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> deps = [ <nl> " / / tensorflow / core : control_flow_ops_op_lib " , <nl> " / / tensorflow / core : no_op_op_lib " , <nl> tf_gen_op_wrapper_private_py ( <nl> name = " data_flow_ops_gen " , <nl> require_shape_functions = True , <nl> visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> " / / tensorflow / contrib / lookup : __pkg__ " , <nl> " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> ] , <nl> tf_gen_op_wrapper_private_py ( <nl> tf_gen_op_wrapper_private_py ( <nl> name = " image_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " io_ops_gen " , <nl> require_shape_functions = True , <nl> - visibility = [ " / / tensorflow / python / kernel_tests : __pkg__ " ] , <nl> + visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> + " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> + ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " linalg_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " logging_ops_gen " , <nl> require_shape_functions = True , <nl> - visibility = [ " / / tensorflow / python / kernel_tests : __pkg__ " ] , <nl> + visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> + " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> + ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " math_ops_gen " , <nl> require_shape_functions = True , <nl> visibility = [ <nl> + " / / learning / brain / google / python / ops : __pkg__ " , <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> " / / tensorflow / compiler / tests : __pkg__ " , <nl> " / / tensorflow / contrib / quantization : __pkg__ " , <nl> " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> tf_gen_op_wrapper_private_py ( <nl> name = " nn_ops_gen " , <nl> require_shape_functions = True , <nl> visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> " / / tensorflow / compiler / tests : __pkg__ " , <nl> " / / tensorflow / contrib / quantization : __pkg__ " , <nl> " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> tf_gen_op_wrapper_private_py ( <nl> tf_gen_op_wrapper_private_py ( <nl> name = " parsing_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> + ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> name = " random_ops_gen " , <nl> require_shape_functions = True , <nl> + visibility = [ " / / learning / brain / python / ops : __pkg__ " ] , <nl> ) <nl> <nl> tf_gen_op_wrapper_private_py ( <nl> tf_gen_op_wrapper_private_py ( <nl> name = " state_ops_gen " , <nl> require_shape_functions = True , <nl> visibility = [ <nl> + " / / learning / brain / python / ops : __pkg__ " , <nl> " / / tensorflow / contrib / framework : __pkg__ " , <nl> " / / tensorflow / python / kernel_tests : __pkg__ " , <nl> ] , <nl> py_library ( <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : set_ops_gen " , <nl> + " : util " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> " : nn_ops_gen " , <nl> py_library ( <nl> " : data_flow_ops_gen " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : logging_ops " , <nl> " : logging_ops_gen " , <nl> " : math_ops " , <nl> " : platform " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : data_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> ] , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : clip_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : image_ops_gen " , <nl> ] , <nl> py_library ( <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : image_ops_gen " , <nl> - " : logging_ops " , <nl> " : math_ops " , <nl> " : nn_ops_gen " , <nl> " : random_ops " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : linalg_ops " , <nl> " : math_ops " , <nl> py_library ( <nl> srcs = [ " ops / io_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : io_ops_gen " , <nl> " : lib " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : linalg_ops " , <nl> " : math_ops " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : linalg_ops_gen " , <nl> " : math_ops " , <nl> py_library ( <nl> srcs = [ " ops / logging_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : logging_ops_gen " , <nl> " : util " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : math_ops " , <nl> " : resource_variable_ops_gen " , <nl> - " : resources " , <nl> " : util " , <nl> ] , <nl> ) <nl> py_library ( <nl> " : nn_ops " , <nl> " : nn_ops_gen " , <nl> " : rnn " , <nl> - " : rnn_cell " , <nl> " : sparse_ops " , <nl> " : util " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> " : nn_ops " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> ] , <nl> ) <nl> py_library ( <nl> srcs = [ " ops / partitioned_variables . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : platform " , <nl> " : variable_scope " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : logging_ops " , <nl> " : math_ops " , <nl> " : rnn_cell " , <nl> " : tensor_array_ops " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : clip_ops " , <nl> - " : embedding_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : init_ops " , <nl> - " : math_ops " , <nl> - " : nn_ops " , <nl> - " : partitioned_variables " , <nl> - " : platform " , <nl> " : util " , <nl> - " : variable_scope " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> srcs = [ " ops / script_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : script_ops_gen " , <nl> ] , <nl> py_library ( <nl> srcs = [ " ops / sdca_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : sdca_ops_gen " , <nl> ] , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : data_flow_ops_gen " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : util " , <nl> ] , <nl> py_library ( <nl> " : sets " , <nl> " : sparse_ops " , <nl> " : state_ops " , <nl> + " : util " , <nl> " : variable_scope " , <nl> " : variables " , <nl> ] , <nl> py_library ( <nl> " : array_ops " , <nl> " : check_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> " : platform " , <nl> py_library ( <nl> " : control_flow_ops " , <nl> " : data_flow_grad " , <nl> " : data_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : functional_ops " , <nl> " : gradients " , <nl> py_library ( <nl> " : partitioned_variables " , <nl> " : random_ops " , <nl> " : script_ops " , <nl> - " : sdca_ops " , <nl> " : session_ops " , <nl> " : sparse_grad " , <nl> " : sparse_ops " , <nl> py_library ( <nl> name = " state_grad " , <nl> srcs = [ " ops / state_grad . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> - " : state_ops " , <nl> - ] , <nl> + deps = [ " : framework_for_generated_wrappers " ] , <nl> ) <nl> <nl> py_library ( <nl> py_library ( <nl> srcs = [ " ops / state_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : resource_variable_ops_gen " , <nl> " : state_ops_gen " , <nl> py_library ( <nl> srcs = [ " ops / summary_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : logging_ops_gen " , <nl> ] , <nl> py_library ( <nl> srcs = [ " ops / template . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : platform " , <nl> + " : util " , <nl> " : variable_scope " , <nl> ] , <nl> ) <nl> py_library ( <nl> srcs = [ " ops / tensor_array_grad . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : tensor_array_ops " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : init_ops " , <nl> " : platform " , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> " : state_ops " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " : gradients " , <nl> " : platform " , <nl> ] , <nl> ) <nl> <nl> - # # This target is deprecated , it contributes to massive dependency bloat . <nl> - # # If you are adding a test to this directory , consider depending on the <nl> - # # individual library targets your test depends on . If you are a client , <nl> - # # you should be importing the rules in third_party / py / tensorflow to get <nl> - # # access to TensorFlow . <nl> + # This target is deprecated . <nl> py_library ( <nl> name = " ops " , <nl> srcs = [ " user_ops / user_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : array_grad " , <nl> - " : array_ops " , <nl> - " : array_ops_gen " , <nl> - " : candidate_sampling_ops " , <nl> - " : check_ops " , <nl> - " : clip_ops " , <nl> - " : control_flow_grad " , <nl> - " : control_flow_ops " , <nl> - " : control_flow_ops_gen " , <nl> - " : ctc_ops " , <nl> - " : ctc_ops_gen " , <nl> - " : data_flow_grad " , <nl> - " : data_flow_ops " , <nl> - " : data_flow_ops_gen " , <nl> - " : embedding_ops " , <nl> - " : gradients " , <nl> - " : histogram_ops " , <nl> - " : image_grad " , <nl> - " : image_ops " , <nl> - " : image_ops_gen " , <nl> - " : init_ops " , <nl> - " : io_ops " , <nl> - " : io_ops_gen " , <nl> - " : linalg_grad " , <nl> - " : linalg_ops " , <nl> - " : linalg_ops_gen " , <nl> - " : logging_ops " , <nl> - " : logging_ops_gen " , <nl> - " : math_grad " , <nl> - " : math_ops " , <nl> - " : math_ops_gen " , <nl> - " : nn " , <nl> - " : nn_grad " , <nl> - " : nn_ops " , <nl> - " : nn_ops_gen " , <nl> - " : numerics " , <nl> - " : parsing_ops " , <nl> - " : partitioned_variables " , <nl> - " : random_ops " , <nl> - " : random_ops_gen " , <nl> - " : resource_variable_ops " , <nl> - " : resources " , <nl> - " : rnn " , <nl> - " : rnn_cell " , <nl> - " : script_ops " , <nl> - " : session_ops " , <nl> - " : sets " , <nl> - " : sparse_grad " , <nl> - " : sparse_ops " , <nl> - " : special_math_ops " , <nl> - " : standard_ops " , <nl> - " : state_grad " , <nl> - " : state_ops " , <nl> - " : state_ops_gen " , <nl> - " : string_ops " , <nl> - " : string_ops_gen " , <nl> - " : summary_ops " , <nl> - " : template " , <nl> - " : tensor_array_grad " , <nl> - " : tensor_array_ops " , <nl> " : user_ops_gen " , <nl> - " : variable_scope " , <nl> - " : variables " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " : framework_test_lib " , <nl> " : gradients " , <nl> " : init_ops " , <nl> - " : lib " , <nl> " : math_ops " , <nl> " : platform_test " , <nl> - " : standard_ops " , <nl> + " : state_ops " , <nl> " : tensor_array_grad " , <nl> " : tensor_array_ops " , <nl> " : training " , <nl> cuda_py_test ( <nl> additional_deps = [ <nl> " : array_ops " , <nl> " : client_testlib " , <nl> - " : device_lib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : gradients " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : math_ops " , <nl> " : nn_grad " , <nl> " : nn_ops " , <nl> cuda_py_test ( <nl> " : framework_test_lib " , <nl> " : functional_ops " , <nl> " : gradients " , <nl> - " : lib " , <nl> " : math_grad " , <nl> " : math_ops " , <nl> " : nn_grad " , <nl> cuda_py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : histogram_ops " , <nl> " : init_ops " , <nl> - " : lib " , <nl> " : variables " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> additional_deps = [ <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : gradients " , <nl> " : image_ops " , <nl> - " : lib " , <nl> ] , <nl> ) <nl> <nl> cuda_py_test ( <nl> " : client " , <nl> " : client_testlib " , <nl> " : control_flow_ops " , <nl> - " : device_lib " , <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> " : framework_test_lib " , <nl> " : image_ops " , <nl> " : io_ops " , <nl> - " : lib " , <nl> " : math_ops " , <nl> " : platform_test " , <nl> " : random_ops " , <nl> - " : session " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> cuda_py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : math_ops " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : gradients " , <nl> - " : lib " , <nl> " : math_ops " , <nl> " : nn " , <nl> " : nn_grad " , <nl> cuda_py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : nn " , <nl> " : nn_grad " , <nl> ] , <nl> cuda_py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : nn " , <nl> " : nn_grad " , <nl> " : nn_ops " , <nl> cuda_py_test ( <nl> additional_deps = [ <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : gradients " , <nl> - " : lib " , <nl> " : nn " , <nl> " : nn_grad " , <nl> ] , <nl> cuda_py_test ( <nl> " : client " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : math_ops " , <nl> - " : session " , <nl> " : special_math_ops " , <nl> ] , <nl> ) <nl> py_library ( <nl> " : io_ops " , <nl> " : io_ops_gen " , <nl> " : lib " , <nl> - " : logging_ops " , <nl> " : math_ops " , <nl> " : platform " , <nl> " : protos_all_py " , <nl> py_library ( <nl> " : random_ops " , <nl> " : resource_variable_ops " , <nl> " : resources " , <nl> - " : session " , <nl> " : sparse_ops " , <nl> " : state_ops " , <nl> " : string_ops " , <nl> py_library ( <nl> deps = [ <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : platform " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : client " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : parsing_ops " , <nl> - " : platform " , <nl> - " : platform_test " , <nl> - " : session " , <nl> " : util_example_parser_configuration " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : client " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : lib " , <nl> " : math_ops " , <nl> - " : platform_test " , <nl> " : pywrap_tensorflow " , <nl> - " : session " , <nl> ] , <nl> ) <nl> <nl> cuda_py_tests ( <nl> additional_deps = [ <nl> " : client " , <nl> " : client_testlib " , <nl> - " : device_lib " , <nl> " : framework_test_lib " , <nl> " : platform_test " , <nl> ] , <nl> py_test ( <nl> " : data_flow_ops " , <nl> " : errors " , <nl> " : extra_py_tests_deps " , <nl> - " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : math_ops " , <nl> - " : session " , <nl> " : training " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> cuda_py_test ( <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> " : partitioned_variables " , <nl> - " : session " , <nl> " : training " , <nl> " : variable_scope " , <nl> " : variables " , <nl> py_test ( <nl> " : framework_test_lib " , <nl> " : math_ops " , <nl> " : platform_test " , <nl> - " : session " , <nl> " : state_ops " , <nl> " : training " , <nl> " : util " , <nl> cuda_py_test ( <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> - " : session " , <nl> - " : timeline " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : client_testlib " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : math_ops " , <nl> - " : session " , <nl> " : state_ops_gen " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> cuda_py_tests ( <nl> " : random_ops " , <nl> " : resource_variable_ops " , <nl> " : resources " , <nl> - " : session " , <nl> " : sparse_ops " , <nl> " : state_ops " , <nl> " : state_ops_gen " , <nl> py_test ( <nl> " : client_testlib " , <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> - " : session " , <nl> " : training " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> py_test ( <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> " : partitioned_variables " , <nl> - " : session " , <nl> " : training " , <nl> " : variables " , <nl> ] , <nl> cuda_py_test ( <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> " : platform " , <nl> - " : session " , <nl> " : training " , <nl> " : variables " , <nl> ] , <nl> py_test ( <nl> " : framework_for_generated_wrappers " , <nl> " : nn_grad " , <nl> " : platform " , <nl> - " : session " , <nl> " : state_ops " , <nl> " : summary " , <nl> " : training " , <nl> py_test ( <nl> " : client_testlib " , <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> - " : session " , <nl> " : state_ops " , <nl> " : summary " , <nl> " : training " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> visibility = [ " / / visibility : public " ] , <nl> deps = [ <nl> - " : client " , <nl> " : errors " , <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> py_library ( <nl> name = " docs " , <nl> srcs = [ " framework / docs . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " : platform " , <nl> - ] , <nl> ) <nl> <nl> py_library ( <nl> py_library ( <nl> " : docs " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / contrib / ffmpeg : ffmpeg_ops_py " , <nl> + " / / tensorflow / python / debug : debug_py " , <nl> ] , <nl> ) <nl> <nl> py_binary ( <nl> " : framework " , <nl> " : framework_for_generated_wrappers " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / python / debug : debug_py " , <nl> ] , <nl> ) <nl> <nl> py_test ( <nl> " : array_ops " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> - " : ops " , <nl> ] , <nl> ) <nl> <nl> py_test ( <nl> deps = [ <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : framework_test_lib " , <nl> " : nn_ops " , <nl> - " : ops " , <nl> ] , <nl> ) <nl> <nl> cuda_py_test ( <nl> " : framework_for_generated_wrappers " , <nl> " : math_ops " , <nl> " : random_ops " , <nl> - " : session " , <nl> " : state_ops " , <nl> " : state_ops_gen " , <nl> ] , <nl> cuda_py_test ( <nl> " : gradients " , <nl> " : math_ops " , <nl> " : nn " , <nl> - " : nn_ops " , <nl> " : nn_ops_gen " , <nl> " : platform " , <nl> " : random_ops " , <nl> - " : session " , <nl> " : variables " , <nl> ] , <nl> main = " ops / batch_norm_benchmark . py " , <nl> cuda_py_test ( <nl> " : control_flow_ops " , <nl> " : framework_for_generated_wrappers " , <nl> " : gradients " , <nl> - " : nn_ops " , <nl> " : platform " , <nl> - " : session " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> cuda_py_test ( <nl> " : framework_for_generated_wrappers " , <nl> " : platform " , <nl> " : platform_benchmark " , <nl> - " : nn_ops " , <nl> - " : session " , <nl> " : variables " , <nl> " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> cuda_py_test ( <nl> " : client " , <nl> " : client_testlib " , <nl> " : framework_for_generated_wrappers " , <nl> - " : platform_benchmark " , <nl> " : random_ops " , <nl> " : training " , <nl> " : variables " , <nl> mmm a / tensorflow / python / debug / BUILD <nl> ppp b / tensorflow / python / debug / BUILD <nl> py_library ( <nl> name = " debug_utils " , <nl> srcs = [ " debug_utils . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " / / tensorflow / python : session " , <nl> - ] , <nl> ) <nl> <nl> py_library ( <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : debug_data " , <nl> - " / / tensorflow / python : data_flow_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : session_ops " , <nl> " @ six_archive / / : six " , <nl> py_library ( <nl> " : stepper " , <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : errors " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> " : command_parser " , <nl> " : debugger_cli_common " , <nl> " : tensor_format " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : variables " , <nl> " @ six_archive / / : six " , <nl> py_library ( <nl> " : curses_ui " , <nl> " : debug_data " , <nl> " : debugger_cli_common " , <nl> - " : tensor_format " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> py_library ( <nl> " : debugger_cli_common " , <nl> " : framework " , <nl> " : stepper_cli " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> " : framework " , <nl> " : local_cli_wrapper " , <nl> " : stepper " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : training " , <nl> ] , <nl> ) <nl> py_binary ( <nl> srcs = [ " examples / debug_fibonacci . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : debug_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / third_party / py / numpy " , <nl> " @ six_archive / / : six " , <nl> py_binary ( <nl> srcs = [ " examples / debug_errors . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : debug_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / third_party / py / numpy " , <nl> ] , <nl> py_binary ( <nl> srcs = [ " examples / debug_mnist . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : debug_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / examples / tutorials / mnist : input_data " , <nl> ] , <nl> py_binary ( <nl> srcs = [ " examples / debug_tflearn_iris . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : debug_py " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / third_party / py / numpy " , <nl> " @ six_archive / / : six " , <nl> py_test ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : debug_data " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : platform_test " , <nl> ] , <nl> py_test ( <nl> deps = [ <nl> " : debug_utils " , <nl> " / / tensorflow / python : client " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> cuda_py_test ( <nl> " : stepper " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : client " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> py_test ( <nl> deps = [ <nl> " : debug_data " , <nl> " : framework " , <nl> - " : stepper " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : errors " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : curses_ui " , <nl> " : debugger_cli_common " , <nl> " : tensor_format " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : platform_test " , <nl> py_library ( <nl> " : debug_data " , <nl> " : debug_utils " , <nl> " / / tensorflow : tensorflow_py " , <nl> + " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> " / / tensorflow / python : errors " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : variables " , <nl> " @ six_archive / / : six " , <nl> cuda_py_test ( <nl> " : session_debug_testlib " , <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> - " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> py_test ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : cli_shared " , <nl> + " : debugger_cli_common " , <nl> " / / tensorflow / python : errors " , <nl> " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> cuda_py_test ( <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " @ six_archive / / : six " , <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : client " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : platform_test " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> py_test ( <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> mmm a / tensorflow / python / kernel_tests / BUILD <nl> ppp b / tensorflow / python / kernel_tests / BUILD <nl> tf_py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : platform_benchmark " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> tf_py_test ( <nl> " / / tensorflow / python : data_flow_ops " , <nl> " / / tensorflow / python : errors " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : util " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : random_ops " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> tf_py_test ( <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : io_ops_gen " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> tf_py_test ( <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : gradients " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> tf_py_test ( <nl> " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : sparse_grad " , <nl> " / / tensorflow / python : sparse_ops " , <nl> ] , <nl> tf_py_test ( <nl> " / / tensorflow / python : init_ops " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : nn_grad " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : template " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : variable_scope " , <nl> cuda_py_test ( <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : gradients " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : test_ops " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> cuda_py_test ( <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : resource_variable_ops " , <nl> " / / tensorflow / python : script_ops " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : state_ops " , <nl> " / / tensorflow / python : state_ops_gen " , <nl> " / / tensorflow / python : tensor_array_grad " , <nl> cuda_py_test ( <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : gradients " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : random_ops " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> cuda_py_test ( <nl> " / / tensorflow / python : errors " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : script_ops " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> tf_py_test ( <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : sparse_ops " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> cuda_py_test ( <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : nn_ops_gen " , <nl> " / / tensorflow / python : platform " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : sparse_ops " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : random_ops " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> cuda_py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : gradients " , <nl> " / / tensorflow / python : init_ops " , <nl> - " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : nn_grad " , <nl> - " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : rnn " , <nl> " / / tensorflow / python : rnn_cell " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : sparse_grad " , <nl> " / / tensorflow / python : tensor_array_grad " , <nl> - " / / tensorflow / python : tensor_array_ops " , <nl> - " / / tensorflow / python : util " , <nl> - " / / tensorflow / python : variable_scope " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> shard_count = 10 , <nl> cuda_py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : platform " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : sparse_ops " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / python / ops / losses / BUILD <nl> ppp b / tensorflow / python / ops / losses / BUILD <nl> <nl> package ( <nl> - default_visibility = [ " / / tensorflow : internal " ] , <nl> + default_visibility = [ <nl> + " / / engedu / ml / tf_from_scratch : __pkg__ " , <nl> + " / / tensorflow : internal " , <nl> + ] , <nl> features = [ <nl> " - layering_check " , <nl> " - parse_headers " , <nl> py_library ( <nl> " util . py " , <nl> ] , <nl> srcs_version = " PY2AND3 " , <nl> - visibility = [ " / / tensorflow : internal " ] , <nl> deps = [ <nl> " / / tensorflow / python : array_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> py_library ( <nl> " / / tensorflow / python : nn " , <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : platform " , <nl> + " / / tensorflow / python : util " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / python / saved_model / BUILD <nl> ppp b / tensorflow / python / saved_model / BUILD <nl> py_library ( <nl> " / / tensorflow / core : protos_all_py " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : lib " , <nl> - " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> ] , <nl> py_library ( <nl> srcs = [ " main_op . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : constants " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> " / / tensorflow / python : data_flow_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> - " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : main_op " , <nl> " : signature_def_utils " , <nl> " : tag_constants " , <nl> - " : utils " , <nl> " / / tensorflow / core : protos_all_py " , <nl> " / / tensorflow / python : client " , <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : control_flow_ops " , <nl> " / / tensorflow / python : errors " , <nl> - " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : lib " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : platform " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : state_ops " , <nl> - " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> mmm a / tensorflow / python / tools / BUILD <nl> ppp b / tensorflow / python / tools / BUILD <nl> py_library ( <nl> name = " freeze_graph_lib " , <nl> srcs = [ " freeze_graph . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " / / tensorflow : tensorflow_py " , <nl> - " / / tensorflow / python : platform " , <nl> - ] , <nl> + deps = [ " / / tensorflow : tensorflow_py " ] , <nl> ) <nl> <nl> py_binary ( <nl> py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python : variables " , <nl> ] , <nl> py_library ( <nl> deps = [ <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / python : framework " , <nl> - " / / tensorflow / python : platform " , <nl> ] , <nl> ) <nl> <nl> py_test ( <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : platform_test " , <nl> - " / / tensorflow / python : session " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> " : strip_unused_lib " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / python : framework " , <nl> - " / / tensorflow / python : platform " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> py_test ( <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : framework " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> - " / / tensorflow / python : framework_test_lib " , <nl> " / / tensorflow / python : image_ops " , <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : nn_ops " , <nl> " / / tensorflow / python : nn_ops_gen " , <nl> - " / / tensorflow / python : platform_test " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / tensorboard / BUILD <nl> ppp b / tensorflow / tensorboard / BUILD <nl> py_library ( <nl> " : base_plugin " , <nl> " / / tensorflow / contrib / tensorboard : projector " , <nl> " / / tensorflow / contrib / tensorboard : protos_all_py " , <nl> + " / / tensorflow / python : errors " , <nl> " / / tensorflow / python : lib " , <nl> + " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : training " , <nl> ] , <nl> ) <nl> - <nl> - py_library ( <nl> - name = " plugins " , <nl> - srcs = [ " plugins / __init__ . py " ] , <nl> - srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - # All registered plugins go in here . <nl> - " : projector " , <nl> - ] , <nl> - ) <nl> mmm a / tensorflow / tensorboard / backend / BUILD <nl> ppp b / tensorflow / tensorboard / backend / BUILD <nl> py_library ( <nl> " : process_graph " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : summary " , <nl> - " / / tensorflow / python : util " , <nl> - " / / tensorflow / tensorboard : plugins " , <nl> + " / / tensorflow / tensorboard : projector " , <nl> " / / tensorflow / tensorboard / lib / python : http " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> py_test ( <nl> data = [ " / / tensorflow / tensorboard : frontend " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : handler " , <nl> " : server " , <nl> " / / tensorflow : tensorflow_py " , <nl> " / / tensorflow / python : platform " , <nl> mmm a / tensorflow / tensorboard / backend / handler . py <nl> ppp b / tensorflow / tensorboard / backend / handler . py <nl> <nl> from tensorflow . python . summary import event_accumulator <nl> from tensorflow . tensorboard . backend import process_graph <nl> from tensorflow . tensorboard . lib . python import http <nl> - from tensorflow . tensorboard . plugins import REGISTERED_PLUGINS <nl> - <nl> + from tensorflow . tensorboard . plugins . projector import plugin as projector_plugin <nl> <nl> DATA_PREFIX = ' / data ' <nl> LOGDIR_ROUTE = ' / logdir ' <nl> <nl> RUN_METADATA_ROUTE = ' / ' + event_accumulator . RUN_METADATA <nl> TAB_ROUTES = [ ' ' , ' / events ' , ' / images ' , ' / audio ' , ' / graphs ' , ' / histograms ' ] <nl> <nl> + REGISTERED_PLUGINS = { <nl> + ' projector ' : projector_plugin . ProjectorPlugin ( ) , <nl> + } <nl> + <nl> _IMGHDR_TO_MIMETYPE = { <nl> ' bmp ' : ' image / bmp ' , <nl> ' gif ' : ' image / gif ' , <nl> mmm a / tensorflow / tensorboard / backend / server_test . py <nl> ppp b / tensorflow / tensorboard / backend / server_test . py <nl> <nl> from tensorflow . core . protobuf import meta_graph_pb2 <nl> from tensorflow . python . platform import resource_loader <nl> from tensorflow . python . summary import event_multiplexer <nl> + from tensorflow . tensorboard . backend import handler <nl> from tensorflow . tensorboard . backend import server <nl> - from tensorflow . tensorboard . plugins import REGISTERED_PLUGINS <nl> <nl> <nl> class TensorboardServerTest ( tf . test . TestCase ) : <nl> def testGraph ( self ) : <nl> <nl> def testProjectorRunsWithEmbeddings ( self ) : <nl> " " " Test the format of / runs endpoint in projector . " " " <nl> - if ' projector ' not in REGISTERED_PLUGINS : <nl> + if ' projector ' not in handler . REGISTERED_PLUGINS : <nl> return <nl> <nl> run_json = self . _getJson ( ' / data / plugin / projector / runs ' ) <nl> def testProjectorRunsWithEmbeddings ( self ) : <nl> <nl> def testProjectorInfo ( self ) : <nl> " " " Test the format of / info endpoint in projector . " " " <nl> - if ' projector ' not in REGISTERED_PLUGINS : <nl> + if ' projector ' not in handler . REGISTERED_PLUGINS : <nl> return <nl> <nl> info_json = self . _getJson ( ' / data / plugin / projector / info ? run = run1 ' ) <nl> def testProjectorInfo ( self ) : <nl> <nl> def testProjectorTensor ( self ) : <nl> " " " Test the format of / tensor endpoint in projector . " " " <nl> - if ' projector ' not in REGISTERED_PLUGINS : <nl> + if ' projector ' not in handler . REGISTERED_PLUGINS : <nl> return <nl> <nl> url = ' / data / plugin / projector / tensor ? run = run1 & name = var1 ' <nl> def _GenerateTestData ( self ) : <nl> writer . flush ( ) <nl> writer . close ( ) <nl> <nl> - if ' projector ' in REGISTERED_PLUGINS : <nl> + if ' projector ' in handler . REGISTERED_PLUGINS : <nl> self . _GenerateProjectorTestData ( run1_path ) <nl> <nl> return temp_dir <nl> deleted file mode 100644 <nl> index defcd304fa4f2 . . 0000000000000 <nl> mmm a / tensorflow / tensorboard / plugins / __init__ . py <nl> ppp / dev / null <nl> <nl> - # Copyright 2016 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> - " " " Holds the list of registered plugins to TensorBoard . " " " <nl> - from __future__ import absolute_import <nl> - from __future__ import division <nl> - from __future__ import print_function <nl> - <nl> - from tensorflow . tensorboard . plugins . projector . plugin import ProjectorPlugin <nl> - # Map of registered plugins in TensorBoard . <nl> - REGISTERED_PLUGINS = { ' projector ' : ProjectorPlugin ( ) } <nl> mmm a / tensorflow / tools / quantization / BUILD <nl> ppp b / tensorflow / tools / quantization / BUILD <nl> py_library ( <nl> name = " quantize_graph_lib " , <nl> srcs = [ " quantize_graph . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> - deps = [ <nl> - " / / tensorflow : tensorflow_py " , <nl> - " / / tensorflow / python : platform " , <nl> - ] , <nl> + deps = [ " / / tensorflow : tensorflow_py " ] , <nl> ) <nl> <nl> py_binary ( <nl> py_test ( <nl> deps = [ <nl> " : quantize_graph " , <nl> " / / tensorflow / python : framework " , <nl> - " / / tensorflow / python : framework_test_lib " , <nl> - " / / tensorflow / python : platform_test " , <nl> ] , <nl> ) <nl> <nl> | Remove superfluous Python deps | tensorflow/tensorflow | cc0de74ff0fbaee205826f7cef23e91892fb5db2 | 2016-12-29T01:06:03Z |
mmm a / dbms / include / DB / Storages / MergeTree / MergeTreeDataMerger . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / MergeTreeDataMerger . h <nl> class MergeTreeDataMerger <nl> <nl> Logger * log ; <nl> <nl> + / / / Когда в последний раз писали в лог , что место на диске кончилось ( чтобы не писать об этом слишком часто ) . <nl> + time_t disk_space_warning_time = 0 ; <nl> + <nl> volatile bool canceled ; <nl> } ; <nl> <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeDataMerger . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeDataMerger . cpp <nl> bool MergeTreeDataMerger : : selectPartsToMerge ( MergeTreeData : : DataPartsVector & pa <nl> cur_longest_len = cur_len ; <nl> } <nl> else <nl> - LOG_WARNING ( log , " Won ' t merge parts from " < < first_part - > name < < " to " < < last_part - > name <nl> - < < " because not enough free space : " < < available_disk_space < < " free and unreserved , " <nl> - < < cur_total_size < < " required now ( + " < < static_cast < int > ( ( DISK_USAGE_COEFFICIENT_TO_SELECT - 1 . 0 ) * 100 ) <nl> - < < " % on overhead ) " ) ; <nl> + { <nl> + time_t now = time ( 0 ) ; <nl> + if ( now - disk_space_warning_time > 3600 ) <nl> + { <nl> + disk_space_warning_time = now ; <nl> + LOG_WARNING ( log , " Won ' t merge parts from " < < first_part - > name < < " to " < < last_part - > name <nl> + < < " because not enough free space : " < < available_disk_space < < " free and unreserved , " <nl> + < < cur_total_size < < " required now ( + " < < static_cast < int > ( ( DISK_USAGE_COEFFICIENT_TO_SELECT - 1 . 0 ) * 100 ) <nl> + < < " % on overhead ) ; suppressing similar warnings for the next hour " ) ; <nl> + } <nl> + } <nl> } <nl> } <nl> <nl> | Merge | ClickHouse/ClickHouse | df4c963bc109f895a8aebd3f49cb11e69305a0d6 | 2014-05-21T10:20:41Z |
mmm a / tools / run_tests / build_ruby . sh <nl> ppp b / tools / run_tests / build_ruby . sh <nl> <nl> <nl> set - ex <nl> <nl> - export CONFIG = $ { CONFIG : - opt } <nl> + export GRPC_CONFIG = $ { CONFIG : - opt } <nl> <nl> # change to grpc ' s ruby directory <nl> cd $ ( dirname $ 0 ) / . . / . . / src / ruby <nl> | Fixing variable names discrepancy in ruby ' s extension builder . | grpc/grpc | 21a38b44226f4664f1c6108c610d5ab16682473d | 2015-07-08T21:29:13Z |
mmm a / lib / Sema / LookupVisibleDecls . cpp <nl> ppp b / lib / Sema / LookupVisibleDecls . cpp <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> <nl> struct KeyPathDynamicMemberConsumer : public VisibleDeclConsumer { <nl> VisibleDeclConsumer & consumer ; <nl> - std : : function < bool ( DeclBaseName ) > seenBaseName ; <nl> + std : : function < bool ( DeclBaseName ) > seenStaticBaseName ; <nl> + llvm : : DenseSet < DeclBaseName > seen ; <nl> <nl> SubscriptDecl * currentSubscript = nullptr ; <nl> Type currentBaseType = Type ( ) ; <nl> <nl> KeyPathDynamicMemberConsumer ( VisibleDeclConsumer & consumer , <nl> std : : function < bool ( DeclBaseName ) > seenBaseName ) <nl> - : consumer ( consumer ) , seenBaseName ( std : : move ( seenBaseName ) ) { } <nl> + : consumer ( consumer ) , seenStaticBaseName ( std : : move ( seenBaseName ) ) { } <nl> + <nl> + bool checkShadowed ( ValueDecl * VD ) { <nl> + / / Dynamic lookup members are only visible if they are not shadowed by <nl> + / / other members . <nl> + return ! isa < SubscriptDecl > ( VD ) & & seen . insert ( VD - > getBaseName ( ) ) . second & & <nl> + ! seenStaticBaseName ( VD - > getBaseName ( ) ) ; <nl> + } <nl> <nl> void foundDecl ( ValueDecl * VD , DeclVisibilityKind reason , <nl> DynamicLookupInfo dynamicLookupInfo ) override { <nl> + assert ( dynamicLookupInfo . getKind ( ) ! = <nl> + DynamicLookupInfo : : KeyPathDynamicMember ) ; <nl> + <nl> / / Only variables and subscripts are allowed in a keypath . <nl> if ( ! isa < AbstractStorageDecl > ( VD ) ) <nl> return ; <nl> <nl> - assert ( dynamicLookupInfo . getKind ( ) ! = <nl> - DynamicLookupInfo : : KeyPathDynamicMember ) ; <nl> - <nl> / / Dynamic lookup members are only visible if they are not shadowed by <nl> / / non - dynamic members . <nl> - if ( isa < SubscriptDecl > ( VD ) | | ! seenBaseName ( VD - > getBaseName ( ) ) ) <nl> + if ( checkShadowed ( VD ) ) <nl> consumer . foundDecl ( VD , DeclVisibilityKind : : DynamicLookup , <nl> { currentSubscript , currentBaseType , reason } ) ; <nl> } <nl> static void lookupVisibleDynamicMemberLookupDecls ( <nl> Type baseType , KeyPathDynamicMemberConsumer & consumer , <nl> const DeclContext * dc , LookupState LS , DeclVisibilityKind reason , <nl> LazyResolver * typeResolver , GenericSignatureBuilder * GSB , <nl> - VisitedSet & visited ) { <nl> + VisitedSet & visited , llvm : : DenseSet < TypeBase * > & seenDynamicLookup ) ; <nl> + <nl> + / / / Enumerates all members of \ c baseType , including both directly visible and <nl> + / / / members visible by keypath dynamic member lookup . <nl> + / / / <nl> + / / / \ note This is an implementation detail of \ c lookupVisibleMemberDecls and <nl> + / / / exists to create the correct recursion for dynamic member lookup . <nl> + static void lookupVisibleMemberAndDynamicMemberDecls ( <nl> + Type baseType , VisibleDeclConsumer & consumer , <nl> + KeyPathDynamicMemberConsumer & dynamicMemberConsumer , const DeclContext * DC , <nl> + LookupState LS , DeclVisibilityKind reason , LazyResolver * typeResolver , <nl> + GenericSignatureBuilder * GSB , VisitedSet & visited , <nl> + llvm : : DenseSet < TypeBase * > & seenDynamicLookup ) { <nl> + lookupVisibleMemberDeclsImpl ( baseType , consumer , DC , LS , reason , typeResolver , <nl> + GSB , visited ) ; <nl> + lookupVisibleDynamicMemberLookupDecls ( baseType , dynamicMemberConsumer , DC , LS , <nl> + reason , typeResolver , GSB , visited , <nl> + seenDynamicLookup ) ; <nl> + } <nl> + <nl> + / / / Enumerates all keypath dynamic members of \ c baseType , as seen from the <nl> + / / / context \ c dc . <nl> + / / / <nl> + / / / If \ c baseType is \ c @ dynamicMemberLookup , this looks up any keypath <nl> + / / / dynamic member subscripts and looks up the members of the keypath ' s root <nl> + / / / type . <nl> + static void lookupVisibleDynamicMemberLookupDecls ( <nl> + Type baseType , KeyPathDynamicMemberConsumer & consumer , <nl> + const DeclContext * dc , LookupState LS , DeclVisibilityKind reason , <nl> + LazyResolver * typeResolver , GenericSignatureBuilder * GSB , <nl> + VisitedSet & visited , llvm : : DenseSet < TypeBase * > & seenDynamicLookup ) { <nl> + if ( ! seenDynamicLookup . insert ( baseType . getPointer ( ) ) . second ) <nl> + return ; <nl> <nl> if ( ! hasDynamicMemberLookupAttribute ( baseType ) ) <nl> return ; <nl> static void lookupVisibleDynamicMemberLookupDecls ( <nl> KeyPathDynamicMemberConsumer : : SubscriptChange ( consumer , subscript , <nl> baseType ) ; <nl> <nl> - lookupVisibleMemberDeclsImpl ( memberType , consumer , dc , LS , reason , <nl> - typeResolver , GSB , visited ) ; <nl> + lookupVisibleMemberAndDynamicMemberDecls ( memberType , consumer , consumer , dc , <nl> + LS , reason , typeResolver , GSB , <nl> + visited , seenDynamicLookup ) ; <nl> } <nl> } <nl> <nl> static void lookupVisibleMemberDecls ( <nl> GenericSignatureBuilder * GSB ) { <nl> OverrideFilteringConsumer overrideConsumer ( BaseTy , CurrDC , TypeResolver ) ; <nl> KeyPathDynamicMemberConsumer dynamicConsumer ( <nl> - overrideConsumer , <nl> + Consumer , <nl> [ & ] ( DeclBaseName name ) { return overrideConsumer . seenBaseName ( name ) ; } ) ; <nl> <nl> VisitedSet Visited ; <nl> - lookupVisibleMemberDeclsImpl ( BaseTy , overrideConsumer , CurrDC , LS , Reason , <nl> - TypeResolver , GSB , Visited ) ; <nl> - <nl> - lookupVisibleDynamicMemberLookupDecls ( BaseTy , dynamicConsumer , CurrDC , LS , <nl> - Reason , TypeResolver , GSB , Visited ) ; <nl> + llvm : : DenseSet < TypeBase * > seenDynamicLookup ; <nl> + lookupVisibleMemberAndDynamicMemberDecls ( <nl> + BaseTy , overrideConsumer , dynamicConsumer , CurrDC , LS , Reason , <nl> + TypeResolver , GSB , Visited , seenDynamicLookup ) ; <nl> <nl> / / Report the declarations we found to the real consumer . <nl> for ( const auto & DeclAndReason : overrideConsumer . DeclsToReport ) <nl> mmm a / test / IDE / complete_keypath_member_lookup . swift <nl> ppp b / test / IDE / complete_keypath_member_lookup . swift <nl> func testShadow1 ( r : Shadow1 < Point > ) { <nl> r . # ^ testShadow1 ^ # <nl> } <nl> / / testShadow1 - NOT : x [ # Int # ] ; <nl> - / / testShadow1 : Decl [ InstanceVar ] / CurrNominal : x [ # String # ] ; <nl> - / / testShadow1 - NOT : x [ # Int # ] ; <nl> / / testShadow1 : Decl [ InstanceVar ] / CurrNominal : y [ # Int # ] ; <nl> + / / testShadow1 - NOT : x [ # Int # ] ; <nl> + / / testShadow1 : Decl [ InstanceVar ] / CurrNominal : x [ # String # ] ; <nl> <nl> @ dynamicMemberLookup <nl> protocol P { <nl> func testAnyObjectRoot1 ( r : AnyObjectRoot ) { <nl> func testNested1 ( r : Lens < Lens < Point > > ) { <nl> r . # ^ testNested1 ^ # <nl> / / testNested1 : Begin completions <nl> - / / FIXME - DAG : Decl [ InstanceVar ] / CurrNominal : x [ # Int # ] ; <nl> - / / FIXME - DAG : Decl [ InstanceVar ] / CurrNominal : y [ # Int # ] ; <nl> + / / testNested1 - DAG : Decl [ InstanceVar ] / CurrNominal : x [ # Int # ] ; <nl> + / / testNested1 - DAG : Decl [ InstanceVar ] / CurrNominal : y [ # Int # ] ; <nl> / / testNested1 : End completions <nl> } <nl> <nl> func testNested2 ( r : Lens < Lens < Lens < Point > > > ) { <nl> r . # ^ testNested2 ^ # <nl> / / testNested2 : Begin completions <nl> - / / FIXME - DAG : Decl [ InstanceVar ] / CurrNominal : x [ # Int # ] ; <nl> - / / FIXME - DAG : Decl [ InstanceVar ] / CurrNominal : y [ # Int # ] ; <nl> + / / testNested2 - DAG : Decl [ InstanceVar ] / CurrNominal : x [ # Int # ] ; <nl> + / / testNested2 - DAG : Decl [ InstanceVar ] / CurrNominal : y [ # Int # ] ; <nl> / / testNested2 : End completions <nl> } <nl> <nl> | Merge pull request from benlangmuir / cc - nested - keypath | apple/swift | e9384bb3519f2ad83d1f2770c512fdf349e0f92b | 2019-05-14T20:30:48Z |
mmm a / RELEASE_NOTES . md <nl> ppp b / RELEASE_NOTES . md <nl> A new header is inserted each time a * tag * is created . <nl> <nl> # # Next release <nl> <nl> + - Added missing API documentation . <nl> + - Improved existing API documentation . <nl> + - Added ` Camera : : setExposure ( float ) ` to directly control the camera ' s exposure . <nl> - Backface culling can now be toggled on material instances . <nl> - Face direction is now reversed when transforms have negative scale . <nl> - Dielectrics now behave properly under a white furnace ( energy preserving and conserving ) . <nl> mmm a / android / filament - android / src / main / java / com / google / android / filament / Camera . java <nl> ppp b / android / filament - android / src / main / java / com / google / android / filament / Camera . java <nl> public float getCullingFar ( ) { <nl> } <nl> <nl> / * * <nl> - * Sets this camera ' s exposure ( default is 16 , 1 / 125s , 100 ISO ) . <nl> - * < p > <nl> + * Sets this camera ' s exposure ( default is f / 16 , 1 / 125s , 100 ISO ) <nl> + * <nl> * The exposure ultimately controls the scene ' s brightness , just like with a real camera . <nl> * The default values provide adequate exposure for a camera placed outdoors on a sunny day <nl> * with the sun at the zenith . <nl> * <nl> + * With the default parameters , the scene must contain at least one Light of intensity <nl> + * similar to the sun ( e . g . : a 100 , 000 lux directional light ) and / or an indirect light <nl> + * of appropriate intensity ( 30 , 000 ) . <nl> + * <nl> * @ param aperture Aperture in f - stops , clamped between 0 . 5 and 64 . <nl> - * A lower < code > aperture < / code > value increases the exposure , leading to <nl> + * A lower aperture value increases the exposure , leading to <nl> * a brighter scene . Realistic values are between 0 . 95 and 32 . <nl> * <nl> * @ param shutterSpeed Shutter speed in seconds , clamped between 1 / 25 , 000 and 60 . <nl> public float getCullingFar ( ) { <nl> * between 1 / 8000 and 30 . <nl> * <nl> * @ param sensitivity Sensitivity in ISO , clamped between 10 and 204 , 800 . <nl> - * A higher < code > sensitivity < / code > increases the exposure . <nl> - * Realistic values are between 50 and 25600 . <nl> - * <nl> - * < p > <nl> - * With the default parameters , the scene must contain at least one light of intensity <nl> - * similar to the sun ( e . g . : a 100 , 000 lux directional light ) . <nl> + * A higher sensitivity increases the exposure . Realistic values are <nl> + * between 50 and 25600 . <nl> * <nl> * @ see LightManager <nl> + * @ see Exposure <nl> + * @ see # setExposure ( float ) <nl> * / <nl> public void setExposure ( float aperture , float shutterSpeed , float sensitivity ) { <nl> nSetExposure ( getNativeObject ( ) , aperture , shutterSpeed , sensitivity ) ; <nl> } <nl> <nl> / * * <nl> - * @ return aperture in f - stops <nl> + * Sets this camera ' s exposure directly . Calling this method will set the aperture <nl> + * to 1 . 0 , the shutter speed to 1 . 2 and the sensitivity will be computed to match <nl> + * the requested exposure ( for a desired exposure of 1 . 0 , the sensitivity will be <nl> + * set to 100 ISO ) . <nl> + * <nl> + * This method is useful when trying to match the lighting of other engines or tools . <nl> + * Many engines / tools use unit - less light intensities , which can be matched by setting <nl> + * the exposure manually . This can be typically achieved by setting the exposure to <nl> + * 1 . 0 . <nl> + * <nl> + * @ see Light <nl> + * @ see Exposure <nl> + * @ see # setExposure ( float , float , float ) <nl> + * / <nl> + public void setExposure ( float exposure ) { <nl> + setExposure ( 1 . 0f , 1 . 2f , 100 . 0f * ( 1 . 0f / exposure ) ) ; <nl> + } <nl> + <nl> + / * * <nl> + * @ return Aperture in f - stops <nl> * / <nl> public float getAperture ( ) { <nl> return nGetAperture ( getNativeObject ( ) ) ; <nl> } <nl> <nl> / * * <nl> - * @ return shutter speed in seconds <nl> + * @ return Shutter speed in seconds <nl> * / <nl> public float getShutterSpeed ( ) { <nl> return nGetShutterSpeed ( getNativeObject ( ) ) ; <nl> } <nl> <nl> / * * <nl> - * @ return sensitivity in ISO <nl> + * @ return Sensitivity in ISO <nl> * / <nl> public float getSensitivity ( ) { <nl> return nGetSensitivity ( getNativeObject ( ) ) ; <nl> mmm a / filament / include / filament / Camera . h <nl> ppp b / filament / include / filament / Camera . h <nl> class UTILS_PUBLIC Camera : public FilamentAPI { <nl> / / ! Returns the entity representing this camera <nl> utils : : Entity getEntity ( ) const noexcept ; <nl> <nl> - / * * Sets this camera ' s exposure ( default is 16 , 1 / 125s , 100 ISO ) <nl> + / * * Sets this camera ' s exposure ( default is f / 16 , 1 / 125s , 100 ISO ) <nl> * <nl> * The exposure ultimately controls the scene ' s brightness , just like with a real camera . <nl> * The default values provide adequate exposure for a camera placed outdoors on a sunny day <nl> class UTILS_PUBLIC Camera : public FilamentAPI { <nl> * With the default parameters , the scene must contain at least one Light of intensity <nl> * similar to the sun ( e . g . : a 100 , 000 lux directional light ) . <nl> * <nl> - * @ see Light , Exposure <nl> + * @ see LightManager , Exposure <nl> * / <nl> void setExposure ( float aperture , float shutterSpeed , float sensitivity ) noexcept ; <nl> <nl> + / * * Sets this camera ' s exposure directly . Calling this method will set the aperture <nl> + * to 1 . 0 , the shutter speed to 1 . 2 and the sensitivity will be computed to match <nl> + * the requested exposure ( for a desired exposure of 1 . 0 , the sensitivity will be <nl> + * set to 100 ISO ) . <nl> + * <nl> + * This method is useful when trying to match the lighting of other engines or tools . <nl> + * Many engines / tools use unit - less light intensities , which can be matched by setting <nl> + * the exposure manually . This can be typically achieved by setting the exposure to <nl> + * 1 . 0 . <nl> + * / <nl> + void setExposure ( float exposure ) noexcept { <nl> + setExposure ( 1 . 0f , 1 . 2f , 100 . 0f * ( 1 . 0f / exposure ) ) ; <nl> + } <nl> + <nl> / / ! returns this camera ' s aperture in f - stops <nl> float getAperture ( ) const noexcept ; <nl> <nl> mmm a / web / filament - js / jsbindings . cpp <nl> ppp b / web / filament - js / jsbindings . cpp <nl> class_ < Camera > ( " Camera " ) <nl> . function ( " getUpVector " , & Camera : : getUpVector ) <nl> . function ( " getForwardVector " , & Camera : : getForwardVector ) <nl> . function ( " getFrustum " , & Camera : : getFrustum ) <nl> - . function ( " setExposure " , & Camera : : setExposure ) <nl> + . function ( " setExposure " , ( void ( Camera : : * ) ( float , float , float ) ) & Camera : : setExposure ) <nl> . function ( " getAperture " , & Camera : : getAperture ) <nl> . function ( " getShutterSpeed " , & Camera : : getShutterSpeed ) <nl> . function ( " getSensitivity " , & Camera : : getSensitivity ) <nl> | Add new Camera : : setExposure ( float ) API ( ) | google/filament | c575fd73959181449f9ae4bac5aee16c2f438aea | 2019-09-26T17:08:46Z |
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_library ( <nl> " src / google / protobuf / timestamp . pb . cc " , <nl> " src / google / protobuf / type . pb . cc " , <nl> " src / google / protobuf / unknown_field_set . cc " , <nl> + " src / google / protobuf / util / delimited_message_util . cc " , <nl> " src / google / protobuf / util / field_comparator . cc " , <nl> " src / google / protobuf / util / field_mask_util . cc " , <nl> " src / google / protobuf / util / internal / datapiece . cc " , <nl> cc_test ( <nl> " src / google / protobuf / stubs / type_traits_unittest . cc " , <nl> " src / google / protobuf / text_format_unittest . cc " , <nl> " src / google / protobuf / unknown_field_set_unittest . cc " , <nl> + " src / google / protobuf / util / delimited_message_util_test . cc " , <nl> " src / google / protobuf / util / field_comparator_test . cc " , <nl> " src / google / protobuf / util / field_mask_util_test . cc " , <nl> " src / google / protobuf / util / internal / default_value_objectwriter_test . cc " , <nl> mmm a / cmake / libprotobuf . cmake <nl> ppp b / cmake / libprotobuf . cmake <nl> set ( libprotobuf_files <nl> $ { protobuf_source_dir } / src / google / protobuf / timestamp . pb . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / type . pb . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / unknown_field_set . cc <nl> + $ { protobuf_source_dir } / src / google / protobuf / util / delimited_message_util . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / field_comparator . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / field_mask_util . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / internal / datapiece . cc <nl> mmm a / cmake / tests . cmake <nl> ppp b / cmake / tests . cmake <nl> set ( tests_files <nl> $ { protobuf_source_dir } / src / google / protobuf / stubs / type_traits_unittest . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / text_format_unittest . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / unknown_field_set_unittest . cc <nl> + $ { protobuf_source_dir } / src / google / protobuf / util / delimited_message_util_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / field_comparator_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / field_mask_util_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / util / internal / default_value_objectwriter_test . cc <nl> mmm a / src / Makefile . am <nl> ppp b / src / Makefile . am <nl> nobase_include_HEADERS = \ <nl> google / protobuf / compiler / python / python_generator . h \ <nl> google / protobuf / compiler / ruby / ruby_generator . h \ <nl> google / protobuf / util / type_resolver . h \ <nl> + google / protobuf / util / delimited_message_util . h \ <nl> google / protobuf / util / field_comparator . h \ <nl> google / protobuf / util / field_mask_util . h \ <nl> google / protobuf / util / json_util . h \ <nl> libprotobuf_la_SOURCES = \ <nl> google / protobuf / io / zero_copy_stream_impl . cc \ <nl> google / protobuf / compiler / importer . cc \ <nl> google / protobuf / compiler / parser . cc \ <nl> + google / protobuf / util / delimited_message_util . cc \ <nl> google / protobuf / util / field_comparator . cc \ <nl> google / protobuf / util / field_mask_util . cc \ <nl> google / protobuf / util / internal / constants . h \ <nl> protobuf_test_SOURCES = \ <nl> google / protobuf / compiler / ruby / ruby_generator_unittest . cc \ <nl> google / protobuf / compiler / csharp / csharp_bootstrap_unittest . cc \ <nl> google / protobuf / compiler / csharp / csharp_generator_unittest . cc \ <nl> + google / protobuf / util / delimited_message_util_test . cc \ <nl> google / protobuf / util / field_comparator_test . cc \ <nl> google / protobuf / util / field_mask_util_test . cc \ <nl> google / protobuf / util / internal / default_value_objectwriter_test . cc \ <nl> new file mode 100644 <nl> index 0000000000 . . 1637878216 <nl> mmm / dev / null <nl> ppp b / src / google / protobuf / util / delimited_message_util . cc <nl> <nl> + / / Adapted from the patch of kenton @ google . com ( Kenton Varda ) <nl> + / / See https : / / github . com / google / protobuf / pull / 710 for details . <nl> + <nl> + # include < google / protobuf / util / delimited_message_util . h > <nl> + <nl> + namespace google { <nl> + namespace protobuf { <nl> + namespace util { <nl> + <nl> + bool SerializeDelimitedToFileDescriptor ( const MessageLite & message , int file_descriptor ) { <nl> + io : : FileOutputStream output ( file_descriptor ) ; <nl> + return SerializeDelimitedToZeroCopyStream ( message , & output ) ; <nl> + } <nl> + <nl> + bool SerializeDelimitedToOstream ( const MessageLite & message , ostream * output ) { <nl> + { <nl> + io : : OstreamOutputStream zero_copy_output ( output ) ; <nl> + if ( ! SerializeDelimitedToZeroCopyStream ( message , & zero_copy_output ) ) return false ; <nl> + } <nl> + return output - > good ( ) ; <nl> + } <nl> + <nl> + bool ParseDelimitedFromZeroCopyStream ( MessageLite * message , io : : ZeroCopyInputStream * input , bool * clean_eof ) { <nl> + google : : protobuf : : io : : CodedInputStream coded_input ( input ) ; <nl> + return ParseDelimitedFromCodedStream ( message , & coded_input , clean_eof ) ; <nl> + } <nl> + <nl> + bool ParseDelimitedFromCodedStream ( MessageLite * message , io : : CodedInputStream * input , bool * clean_eof ) { <nl> + if ( clean_eof ! = NULL ) * clean_eof = false ; <nl> + int start = input - > CurrentPosition ( ) ; <nl> + <nl> + / / Read the size . <nl> + uint32 size ; <nl> + if ( ! input - > ReadVarint32 ( & size ) ) { <nl> + if ( clean_eof ! = NULL ) * clean_eof = input - > CurrentPosition ( ) = = start ; <nl> + return false ; <nl> + } <nl> + <nl> + / / Tell the stream not to read beyond that size . <nl> + google : : protobuf : : io : : CodedInputStream : : Limit limit = input - > PushLimit ( size ) ; <nl> + <nl> + / / Parse the message . <nl> + if ( ! message - > MergeFromCodedStream ( input ) ) return false ; <nl> + if ( ! input - > ConsumedEntireMessage ( ) ) return false ; <nl> + <nl> + / / Release the limit . <nl> + input - > PopLimit ( limit ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool SerializeDelimitedToZeroCopyStream ( const MessageLite & message , io : : ZeroCopyOutputStream * output ) { <nl> + google : : protobuf : : io : : CodedOutputStream coded_output ( output ) ; <nl> + return SerializeDelimitedToCodedStream ( message , & coded_output ) ; <nl> + } <nl> + <nl> + bool SerializeDelimitedToCodedStream ( const MessageLite & message , io : : CodedOutputStream * output ) { <nl> + / / Write the size . <nl> + int size = message . ByteSize ( ) ; <nl> + output - > WriteVarint32 ( size ) ; <nl> + <nl> + / / Write the content . <nl> + uint8 * buffer = output - > GetDirectBufferForNBytesAndAdvance ( size ) ; <nl> + if ( buffer ! = NULL ) { <nl> + / / Optimization : The message fits in one buffer , so use the faster <nl> + / / direct - to - array serialization path . <nl> + message . SerializeWithCachedSizesToArray ( buffer ) ; <nl> + } else { <nl> + / / Slightly - slower path when the message is multiple buffers . <nl> + message . SerializeWithCachedSizes ( output ) ; <nl> + if ( output - > HadError ( ) ) return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + } / / namespace util <nl> + } / / namespace protobuf <nl> + } / / namespace google <nl> new file mode 100644 <nl> index 0000000000 . . 302d4781b3 <nl> mmm / dev / null <nl> ppp b / src / google / protobuf / util / delimited_message_util . h <nl> <nl> + / / Adapted from the patch of kenton @ google . com ( Kenton Varda ) <nl> + / / See https : / / github . com / google / protobuf / pull / 710 for details . <nl> + <nl> + # ifndef GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ <nl> + # define GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ <nl> + <nl> + # include < ostream > <nl> + <nl> + # include < google / protobuf / message_lite . h > <nl> + # include < google / protobuf / io / coded_stream . h > <nl> + # include < google / protobuf / io / zero_copy_stream_impl . h > <nl> + <nl> + namespace google { <nl> + namespace protobuf { <nl> + namespace util { <nl> + <nl> + / / Write a single size - delimited message from the given stream . Delimited <nl> + / / format allows a single file or stream to contain multiple messages , <nl> + / / whereas normally writing multiple non - delimited messages to the same <nl> + / / stream would cause them to be merged . A delimited message is a varint <nl> + / / encoding the message size followed by a message of exactly that size . <nl> + / / <nl> + / / Note that if you want to * read * a delimited message from a file descriptor <nl> + / / or istream , you will need to construct an io : : FileInputStream or <nl> + / / io : : OstreamInputStream ( implementations of io : : ZeroCopyStream ) and use the <nl> + / / utility function ParseDelimitedFromZeroCopyStream ( ) . You must then <nl> + / / continue to use the same ZeroCopyInputStream to read all further data from <nl> + / / the stream until EOF . This is because these ZeroCopyInputStream <nl> + / / implementations are buffered : they read a big chunk of data at a time , <nl> + / / then parse it . As a result , they may read past the end of the delimited <nl> + / / message . There is no way for them to push the extra data back into the <nl> + / / underlying source , so instead you must keep using the same stream object . <nl> + bool LIBPROTOBUF_EXPORT SerializeDelimitedToFileDescriptor ( const MessageLite & message , int file_descriptor ) ; <nl> + <nl> + bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream ( const MessageLite & message , ostream * output ) ; <nl> + <nl> + / / Read a single size - delimited message from the given stream . Delimited <nl> + / / format allows a single file or stream to contain multiple messages , <nl> + / / whereas normally parsing consumes the entire input . A delimited message <nl> + / / is a varint encoding the message size followed by a message of exactly <nl> + / / that size . <nl> + / / <nl> + / / If | clean_eof | is not NULL , then it will be set to indicate whether the <nl> + / / stream ended cleanly . That is , if the stream ends without this method <nl> + / / having read any data at all from it , then * clean_eof will be set true , <nl> + / / otherwise it will be set false . Note that these methods return false <nl> + / / on EOF , but they also return false on other errors , so | clean_eof | is <nl> + / / needed to distinguish a clean end from errors . <nl> + bool LIBPROTOBUF_EXPORT ParseDelimitedFromZeroCopyStream ( MessageLite * message , io : : ZeroCopyInputStream * input , bool * clean_eof ) ; <nl> + <nl> + bool LIBPROTOBUF_EXPORT ParseDelimitedFromCodedStream ( MessageLite * message , io : : CodedInputStream * input , bool * clean_eof ) ; <nl> + <nl> + / / Write a single size - delimited message from the given stream . Delimited <nl> + / / format allows a single file or stream to contain multiple messages , <nl> + / / whereas normally writing multiple non - delimited messages to the same <nl> + / / stream would cause them to be merged . A delimited message is a varint <nl> + / / encoding the message size followed by a message of exactly that size . <nl> + bool LIBPROTOBUF_EXPORT SerializeDelimitedToZeroCopyStream ( const MessageLite & message , io : : ZeroCopyOutputStream * output ) ; <nl> + <nl> + bool LIBPROTOBUF_EXPORT SerializeDelimitedToCodedStream ( const MessageLite & message , io : : CodedOutputStream * output ) ; <nl> + <nl> + } / / namespace util <nl> + } / / namespace protobuf <nl> + } / / namespace google <nl> + <nl> + # endif / / GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ <nl> new file mode 100644 <nl> index 0000000000 . . b261d43cc9 <nl> mmm / dev / null <nl> ppp b / src / google / protobuf / util / delimited_message_util_test . cc <nl> <nl> + / / Adapted from the patch of kenton @ google . com ( Kenton Varda ) <nl> + / / See https : / / github . com / google / protobuf / pull / 710 for details . <nl> + <nl> + # include < google / protobuf / util / delimited_message_util . h > <nl> + <nl> + # include < sstream > <nl> + <nl> + # include < google / protobuf / test_util . h > <nl> + # include < google / protobuf / unittest . pb . h > <nl> + # include < google / protobuf / testing / googletest . h > <nl> + # include < gtest / gtest . h > <nl> + <nl> + namespace google { <nl> + namespace protobuf { <nl> + namespace util { <nl> + <nl> + TEST ( DelimitedMessageUtilTest , DelimitedMessages ) { <nl> + stringstream stream ; <nl> + <nl> + { <nl> + protobuf_unittest : : TestAllTypes message1 ; <nl> + TestUtil : : SetAllFields ( & message1 ) ; <nl> + EXPECT_TRUE ( SerializeDelimitedToOstream ( message1 , & stream ) ) ; <nl> + <nl> + protobuf_unittest : : TestPackedTypes message2 ; <nl> + TestUtil : : SetPackedFields ( & message2 ) ; <nl> + EXPECT_TRUE ( SerializeDelimitedToOstream ( message2 , & stream ) ) ; <nl> + } <nl> + <nl> + { <nl> + bool clean_eof ; <nl> + io : : IstreamInputStream zstream ( & stream ) ; <nl> + <nl> + protobuf_unittest : : TestAllTypes message1 ; <nl> + clean_eof = true ; <nl> + EXPECT_TRUE ( ParseDelimitedFromZeroCopyStream ( & message1 , <nl> + & zstream , & clean_eof ) ) ; <nl> + EXPECT_FALSE ( clean_eof ) ; <nl> + TestUtil : : ExpectAllFieldsSet ( message1 ) ; <nl> + <nl> + protobuf_unittest : : TestPackedTypes message2 ; <nl> + clean_eof = true ; <nl> + EXPECT_TRUE ( ParseDelimitedFromZeroCopyStream ( & message2 , <nl> + & zstream , & clean_eof ) ) ; <nl> + EXPECT_FALSE ( clean_eof ) ; <nl> + TestUtil : : ExpectPackedFieldsSet ( message2 ) ; <nl> + <nl> + clean_eof = false ; <nl> + EXPECT_FALSE ( ParseDelimitedFromZeroCopyStream ( & message2 , <nl> + & zstream , & clean_eof ) ) ; <nl> + EXPECT_TRUE ( clean_eof ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace util <nl> + } / / namespace protobuf <nl> + } / / namespace google <nl> | Merge pull request from byronyi / | protocolbuffers/protobuf | ffa932bf10d958fc3dff3ac9153f1b4ef55d6024 | 2017-03-20T20:02:40Z |
mmm a / src / codegen / compiler . cc <nl> ppp b / src / codegen / compiler . cc <nl> BackgroundCompileTask : : BackgroundCompileTask ( ScriptStreamingData * streamed_data , <nl> : flags_ ( UnoptimizedCompileFlags : : ForToplevelCompile ( <nl> isolate , true , construct_language_mode ( FLAG_use_strict ) , <nl> REPLMode : : kNo ) ) , <nl> - info_ ( std : : make_unique < ParseInfo > ( isolate , flags_ ) ) , <nl> + compile_state_ ( isolate ) , <nl> + info_ ( std : : make_unique < ParseInfo > ( isolate , flags_ , & compile_state_ ) ) , <nl> start_position_ ( 0 ) , <nl> end_position_ ( 0 ) , <nl> function_literal_id_ ( kFunctionLiteralIdTopLevel ) , <nl> stack_size_ ( i : : FLAG_stack_size ) , <nl> worker_thread_runtime_call_stats_ ( <nl> isolate - > counters ( ) - > worker_thread_runtime_call_stats ( ) ) , <nl> - allocator_ ( isolate - > allocator ( ) ) , <nl> timer_ ( isolate - > counters ( ) - > compile_script_on_background ( ) ) , <nl> language_mode_ ( info_ - > language_mode ( ) ) , <nl> collected_source_positions_ ( false ) { <nl> BackgroundCompileTask : : BackgroundCompileTask ( ScriptStreamingData * streamed_data , <nl> } <nl> <nl> BackgroundCompileTask : : BackgroundCompileTask ( <nl> - AccountingAllocator * allocator , const ParseInfo * outer_parse_info , <nl> - const AstRawString * function_name , const FunctionLiteral * function_literal , <nl> + const ParseInfo * outer_parse_info , const AstRawString * function_name , <nl> + const FunctionLiteral * function_literal , <nl> WorkerThreadRuntimeCallStats * worker_thread_runtime_stats , <nl> TimedHistogram * timer , int max_stack_size ) <nl> : flags_ ( UnoptimizedCompileFlags : : ForToplevelFunction ( <nl> outer_parse_info - > flags ( ) , function_literal ) ) , <nl> - info_ ( ParseInfo : : FromParent ( outer_parse_info , flags_ , allocator , <nl> - function_literal , function_name ) ) , <nl> + compile_state_ ( * outer_parse_info - > state ( ) ) , <nl> + info_ ( ParseInfo : : ForToplevelFunction ( flags_ , & compile_state_ , <nl> + function_literal , function_name ) ) , <nl> start_position_ ( function_literal - > start_position ( ) ) , <nl> end_position_ ( function_literal - > end_position ( ) ) , <nl> function_literal_id_ ( function_literal - > function_literal_id ( ) ) , <nl> stack_size_ ( max_stack_size ) , <nl> worker_thread_runtime_call_stats_ ( worker_thread_runtime_stats ) , <nl> - allocator_ ( allocator ) , <nl> timer_ ( timer ) , <nl> language_mode_ ( info_ - > language_mode ( ) ) , <nl> collected_source_positions_ ( false ) , <nl> finalize_on_background_thread_ ( false ) { <nl> - DCHECK ( outer_parse_info - > flags ( ) . is_toplevel ( ) ) ; <nl> + DCHECK_EQ ( outer_parse_info - > parameters_end_pos ( ) , kNoSourcePosition ) ; <nl> + DCHECK_NULL ( outer_parse_info - > extension ( ) ) ; <nl> + <nl> DCHECK ( ! function_literal - > is_toplevel ( ) ) ; <nl> <nl> / / Clone the character stream so both can be accessed independently . <nl> class OffThreadParseInfoScope { <nl> original_runtime_call_stats_ ( parse_info_ - > runtime_call_stats ( ) ) , <nl> original_stack_limit_ ( parse_info_ - > stack_limit ( ) ) , <nl> worker_thread_scope_ ( worker_thread_runtime_stats ) { <nl> - parse_info_ - > set_runtime_call_stats ( worker_thread_scope_ . Get ( ) ) ; <nl> - parse_info_ - > set_stack_limit ( GetCurrentStackPosition ( ) - stack_size * KB ) ; <nl> + parse_info_ - > SetPerThreadState ( GetCurrentStackPosition ( ) - stack_size * KB , <nl> + worker_thread_scope_ . Get ( ) ) ; <nl> } <nl> <nl> ~ OffThreadParseInfoScope ( ) { <nl> DCHECK_NOT_NULL ( parse_info_ ) ; <nl> - parse_info_ - > set_stack_limit ( original_stack_limit_ ) ; <nl> - parse_info_ - > set_runtime_call_stats ( original_runtime_call_stats_ ) ; <nl> + parse_info_ - > SetPerThreadState ( original_stack_limit_ , <nl> + original_runtime_call_stats_ ) ; <nl> } <nl> <nl> private : <nl> void BackgroundCompileTask : : Run ( ) { <nl> function_literal_id_ ) ; <nl> if ( info_ - > literal ( ) ! = nullptr ) { <nl> / / Parsing has succeeded , compile . <nl> - outer_function_job_ = CompileOnBackgroundThread ( info_ . get ( ) , allocator_ , <nl> - & inner_function_jobs_ ) ; <nl> + outer_function_job_ = CompileOnBackgroundThread ( <nl> + info_ . get ( ) , compile_state_ . allocator ( ) , & inner_function_jobs_ ) ; <nl> / / Save the language mode and record whether we collected source positions . <nl> language_mode_ = info_ - > language_mode ( ) ; <nl> collected_source_positions_ = info_ - > flags ( ) . collect_source_positions ( ) ; <nl> bool Compiler : : CollectSourcePositions ( Isolate * isolate , <nl> flags . set_collect_source_positions ( true ) ; <nl> flags . set_allow_natives_syntax ( FLAG_allow_natives_syntax ) ; <nl> <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> <nl> / / Parse and update ParseInfo with the results . Don ' t update parsing <nl> / / statistics since we ' ve already parsed the code before . <nl> bool Compiler : : Compile ( Handle < SharedFunctionInfo > shared_info , <nl> UnoptimizedCompileFlags : : ForFunctionCompile ( isolate , * shared_info ) ; <nl> flags . set_is_lazy_compile ( true ) ; <nl> <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> <nl> / / Check if the compiler dispatcher has shared_info enqueued for compile . <nl> CompilerDispatcher * dispatcher = isolate - > compiler_dispatcher ( ) ; <nl> MaybeHandle < JSFunction > Compiler : : GetFunctionFromEval ( <nl> flags . set_is_eval ( true ) ; <nl> flags . set_parse_restriction ( restriction ) ; <nl> <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> parse_info . set_parameters_end_pos ( parameters_end_pos ) ; <nl> DCHECK ( ! parse_info . flags ( ) . is_module ( ) ) ; <nl> <nl> MaybeHandle < SharedFunctionInfo > Compiler : : GetSharedFunctionInfoForScript ( <nl> flags . set_is_module ( origin_options . IsModule ( ) ) ; <nl> flags . set_is_eager ( compile_options = = ScriptCompiler : : kEagerCompile ) ; <nl> <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> parse_info . set_extension ( extension ) ; <nl> <nl> Handle < Script > script = NewScript ( isolate , & parse_info , source , <nl> MaybeHandle < JSFunction > Compiler : : GetWrappedFunction ( <nl> flags . set_collect_source_positions ( true ) ; <nl> / / flags . set_eager ( compile_options = = ScriptCompiler : : kEagerCompile ) ; <nl> <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> + <nl> MaybeHandle < ScopeInfo > maybe_outer_scope_info ; <nl> if ( ! context - > IsNativeContext ( ) ) { <nl> maybe_outer_scope_info = handle ( context - > scope_info ( ) , isolate ) ; <nl> mmm a / src / codegen / compiler . h <nl> ppp b / src / codegen / compiler . h <nl> class V8_EXPORT_PRIVATE BackgroundCompileTask { <nl> / / | function_literal | and can be finalized with <nl> / / Compiler : : FinalizeBackgroundCompileTask . <nl> BackgroundCompileTask ( <nl> - AccountingAllocator * allocator , const ParseInfo * outer_parse_info , <nl> - const AstRawString * function_name , <nl> + const ParseInfo * outer_parse_info , const AstRawString * function_name , <nl> const FunctionLiteral * function_literal , <nl> WorkerThreadRuntimeCallStats * worker_thread_runtime_stats , <nl> TimedHistogram * timer , int max_stack_size ) ; <nl> class V8_EXPORT_PRIVATE BackgroundCompileTask { <nl> / / between parsing and compilation . These need to be initialized before the <nl> / / compilation starts . <nl> UnoptimizedCompileFlags flags_ ; <nl> + UnoptimizedCompileState compile_state_ ; <nl> std : : unique_ptr < ParseInfo > info_ ; <nl> std : : unique_ptr < Parser > parser_ ; <nl> <nl> class V8_EXPORT_PRIVATE BackgroundCompileTask { <nl> <nl> int stack_size_ ; <nl> WorkerThreadRuntimeCallStats * worker_thread_runtime_call_stats_ ; <nl> - AccountingAllocator * allocator_ ; <nl> TimedHistogram * timer_ ; <nl> LanguageMode language_mode_ ; <nl> bool collected_source_positions_ ; <nl> mmm a / src / compiler - dispatcher / compiler - dispatcher . cc <nl> ppp b / src / compiler - dispatcher / compiler - dispatcher . cc <nl> CompilerDispatcher : : Job : : ~ Job ( ) = default ; <nl> CompilerDispatcher : : CompilerDispatcher ( Isolate * isolate , Platform * platform , <nl> size_t max_stack_size ) <nl> : isolate_ ( isolate ) , <nl> - allocator_ ( isolate - > allocator ( ) ) , <nl> worker_thread_runtime_call_stats_ ( <nl> isolate - > counters ( ) - > worker_thread_runtime_call_stats ( ) ) , <nl> background_compile_timer_ ( <nl> base : : Optional < CompilerDispatcher : : JobId > CompilerDispatcher : : Enqueue ( <nl> if ( ! IsEnabled ( ) ) return base : : nullopt ; <nl> <nl> std : : unique_ptr < Job > job = std : : make_unique < Job > ( new BackgroundCompileTask ( <nl> - allocator_ , outer_parse_info , function_name , function_literal , <nl> + outer_parse_info , function_name , function_literal , <nl> worker_thread_runtime_call_stats_ , background_compile_timer_ , <nl> static_cast < int > ( max_stack_size_ ) ) ) ; <nl> JobMap : : const_iterator it = InsertJob ( std : : move ( job ) ) ; <nl> mmm a / src / compiler - dispatcher / compiler - dispatcher . h <nl> ppp b / src / compiler - dispatcher / compiler - dispatcher . h <nl> class V8_EXPORT_PRIVATE CompilerDispatcher { <nl> JobMap : : const_iterator RemoveJob ( JobMap : : const_iterator job ) ; <nl> <nl> Isolate * isolate_ ; <nl> - AccountingAllocator * allocator_ ; <nl> WorkerThreadRuntimeCallStats * worker_thread_runtime_call_stats_ ; <nl> TimedHistogram * background_compile_timer_ ; <nl> std : : shared_ptr < v8 : : TaskRunner > taskrunner_ ; <nl> mmm a / src / d8 / d8 . cc <nl> ppp b / src / d8 / d8 . cc <nl> bool Shell : : ExecuteString ( Isolate * isolate , Local < String > source , <nl> i : : Handle < i : : String > str = Utils : : OpenHandle ( * ( source ) ) ; <nl> <nl> / / Set up ParseInfo . <nl> + i : : UnoptimizedCompileState compile_state ( i_isolate ) ; <nl> + <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForToplevelCompile ( <nl> i_isolate , true , i : : construct_language_mode ( i : : FLAG_use_strict ) , <nl> i : : REPLMode : : kNo ) ; <nl> <nl> - i : : ParseInfo parse_info ( i_isolate , flags ) ; <nl> + i : : ParseInfo parse_info ( i_isolate , flags , & compile_state ) ; <nl> <nl> i : : Handle < i : : Script > script = parse_info . CreateScript ( <nl> i_isolate , str , i : : kNullMaybeHandle , options . compile_options ) ; <nl> mmm a / src / debug / debug - scopes . cc <nl> ppp b / src / debug / debug - scopes . cc <nl> void ScopeIterator : : TryParseAndRetrieveScopes ( ReparseStrategy strategy ) { <nl> scope_info - > scope_type ( ) = = FUNCTION_SCOPE ) ; <nl> } <nl> <nl> - info_ = std : : make_unique < ParseInfo > ( isolate_ , flags ) ; <nl> + UnoptimizedCompileState compile_state ( isolate_ ) ; <nl> + <nl> + info_ = std : : make_unique < ParseInfo > ( isolate_ , flags , & compile_state ) ; <nl> <nl> const bool parse_result = <nl> flags . is_toplevel ( ) <nl> mmm a / src / debug / liveedit . cc <nl> ppp b / src / debug / liveedit . cc <nl> void LiveEdit : : PatchScript ( Isolate * isolate , Handle < Script > script , <nl> return ; <nl> } <nl> <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> UnoptimizedCompileFlags flags = <nl> UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_eager ( true ) ; <nl> - ParseInfo parse_info ( isolate , flags ) ; <nl> + ParseInfo parse_info ( isolate , flags , & compile_state ) ; <nl> std : : vector < FunctionLiteral * > literals ; <nl> if ( ! ParseScript ( isolate , script , & parse_info , false , & literals , result ) ) <nl> return ; <nl> <nl> Handle < Script > new_script = isolate - > factory ( ) - > CloneScript ( script ) ; <nl> new_script - > set_source ( * new_source ) ; <nl> + UnoptimizedCompileState new_compile_state ( isolate ) ; <nl> UnoptimizedCompileFlags new_flags = <nl> UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * new_script ) ; <nl> new_flags . set_is_eager ( true ) ; <nl> - ParseInfo new_parse_info ( isolate , new_flags ) ; <nl> + ParseInfo new_parse_info ( isolate , new_flags , & new_compile_state ) ; <nl> std : : vector < FunctionLiteral * > new_literals ; <nl> if ( ! ParseScript ( isolate , new_script , & new_parse_info , true , & new_literals , <nl> result ) ) { <nl> mmm a / src / execution / messages . cc <nl> ppp b / src / execution / messages . cc <nl> Handle < String > RenderCallSite ( Isolate * isolate , Handle < Object > object , <nl> MessageLocation * location , <nl> CallPrinter : : ErrorHint * hint ) { <nl> if ( ComputeLocation ( isolate , location ) ) { <nl> - ParseInfo info ( isolate , i : : UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> - isolate , * location - > shared ( ) ) ) ; <nl> + UnoptimizedCompileFlags flags = UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> + isolate , * location - > shared ( ) ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo info ( isolate , flags , & compile_state ) ; <nl> if ( parsing : : ParseAny ( & info , location - > shared ( ) , isolate ) ) { <nl> info . ast_value_factory ( ) - > Internalize ( isolate ) ; <nl> CallPrinter printer ( isolate , location - > shared ( ) - > IsUserJavaScript ( ) ) ; <nl> Object ErrorUtils : : ThrowSpreadArgIsNullOrUndefinedError ( Isolate * isolate , <nl> MessageLocation location ; <nl> Handle < String > callsite ; <nl> if ( ComputeLocation ( isolate , & location ) ) { <nl> - ParseInfo info ( isolate , i : : UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> - isolate , * location . shared ( ) ) ) ; <nl> + UnoptimizedCompileFlags flags = UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> + isolate , * location . shared ( ) ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo info ( isolate , flags , & compile_state ) ; <nl> if ( parsing : : ParseAny ( & info , location . shared ( ) , isolate ) ) { <nl> info . ast_value_factory ( ) - > Internalize ( isolate ) ; <nl> CallPrinter printer ( isolate , location . shared ( ) - > IsUserJavaScript ( ) , <nl> Object ErrorUtils : : ThrowLoadFromNullOrUndefined ( Isolate * isolate , <nl> if ( ComputeLocation ( isolate , & location ) ) { <nl> location_computed = true ; <nl> <nl> - ParseInfo info ( isolate , i : : UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> - isolate , * location . shared ( ) ) ) ; <nl> + UnoptimizedCompileFlags flags = UnoptimizedCompileFlags : : ForFunctionCompile ( <nl> + isolate , * location . shared ( ) ) ; <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> + ParseInfo info ( isolate , flags , & compile_state ) ; <nl> if ( parsing : : ParseAny ( & info , location . shared ( ) , isolate ) ) { <nl> info . ast_value_factory ( ) - > Internalize ( isolate ) ; <nl> CallPrinter printer ( isolate , location . shared ( ) - > IsUserJavaScript ( ) ) ; <nl> mmm a / src / parsing / parse - info . cc <nl> ppp b / src / parsing / parse - info . cc <nl> void UnoptimizedCompileFlags : : SetFlagsForFunctionFromScript ( Script script ) { <nl> script . IsUserJavaScript ( ) ) ; <nl> } <nl> <nl> - ParseInfo : : ParseInfo ( AccountingAllocator * zone_allocator , <nl> - UnoptimizedCompileFlags flags ) <nl> + UnoptimizedCompileState : : UnoptimizedCompileState ( Isolate * isolate ) <nl> + : hash_seed_ ( HashSeed ( isolate ) ) , <nl> + allocator_ ( isolate - > allocator ( ) ) , <nl> + ast_string_constants_ ( isolate - > ast_string_constants ( ) ) , <nl> + logger_ ( isolate - > logger ( ) ) , <nl> + parallel_tasks_ ( isolate - > compiler_dispatcher ( ) - > IsEnabled ( ) <nl> + ? new ParallelTasks ( isolate - > compiler_dispatcher ( ) ) <nl> + : nullptr ) { } <nl> + <nl> + UnoptimizedCompileState : : UnoptimizedCompileState ( <nl> + const UnoptimizedCompileState & other ) V8_NOEXCEPT <nl> + : hash_seed_ ( other . hash_seed ( ) ) , <nl> + allocator_ ( other . allocator ( ) ) , <nl> + ast_string_constants_ ( other . ast_string_constants ( ) ) , <nl> + logger_ ( other . logger ( ) ) , <nl> + / / TODO ( leszeks ) : Should this create a new ParallelTasks instance ? <nl> + parallel_tasks_ ( nullptr ) { } <nl> + <nl> + ParseInfo : : ParseInfo ( const UnoptimizedCompileFlags flags , <nl> + UnoptimizedCompileState * state ) <nl> : flags_ ( flags ) , <nl> - zone_ ( std : : make_unique < Zone > ( zone_allocator , ZONE_NAME ) ) , <nl> + state_ ( state ) , <nl> + zone_ ( std : : make_unique < Zone > ( state - > allocator ( ) , ZONE_NAME ) ) , <nl> extension_ ( nullptr ) , <nl> script_scope_ ( nullptr ) , <nl> stack_limit_ ( 0 ) , <nl> - hash_seed_ ( 0 ) , <nl> parameters_end_pos_ ( kNoSourcePosition ) , <nl> max_function_literal_id_ ( kFunctionLiteralIdInvalid ) , <nl> character_stream_ ( nullptr ) , <nl> ast_value_factory_ ( nullptr ) , <nl> - ast_string_constants_ ( nullptr ) , <nl> function_name_ ( nullptr ) , <nl> runtime_call_stats_ ( nullptr ) , <nl> source_range_map_ ( nullptr ) , <nl> ParseInfo : : ParseInfo ( AccountingAllocator * zone_allocator , <nl> } <nl> } <nl> <nl> - ParseInfo : : ParseInfo ( Isolate * isolate , UnoptimizedCompileFlags flags ) <nl> - : ParseInfo ( isolate - > allocator ( ) , flags ) { <nl> - set_hash_seed ( HashSeed ( isolate ) ) ; <nl> - set_stack_limit ( isolate - > stack_guard ( ) - > real_climit ( ) ) ; <nl> - set_runtime_call_stats ( isolate - > counters ( ) - > runtime_call_stats ( ) ) ; <nl> - set_logger ( isolate - > logger ( ) ) ; <nl> - set_ast_string_constants ( isolate - > ast_string_constants ( ) ) ; <nl> - if ( isolate - > compiler_dispatcher ( ) - > IsEnabled ( ) ) { <nl> - parallel_tasks_ . reset ( new ParallelTasks ( isolate - > compiler_dispatcher ( ) ) ) ; <nl> - } <nl> + ParseInfo : : ParseInfo ( Isolate * isolate , const UnoptimizedCompileFlags flags , <nl> + UnoptimizedCompileState * state ) <nl> + : ParseInfo ( flags , state ) { <nl> + SetPerThreadState ( isolate - > stack_guard ( ) - > real_climit ( ) , <nl> + isolate - > counters ( ) - > runtime_call_stats ( ) ) ; <nl> } <nl> <nl> / / static <nl> - std : : unique_ptr < ParseInfo > ParseInfo : : FromParent ( <nl> - const ParseInfo * outer_parse_info , const UnoptimizedCompileFlags flags , <nl> - AccountingAllocator * zone_allocator , const FunctionLiteral * literal , <nl> - const AstRawString * function_name ) { <nl> - std : : unique_ptr < ParseInfo > result ( new ParseInfo ( zone_allocator , flags ) ) ; <nl> - <nl> - / / Replicate shared state of the outer_parse_info . <nl> - result - > set_logger ( outer_parse_info - > logger ( ) ) ; <nl> - result - > set_ast_string_constants ( outer_parse_info - > ast_string_constants ( ) ) ; <nl> - result - > set_hash_seed ( outer_parse_info - > hash_seed ( ) ) ; <nl> - <nl> - DCHECK_EQ ( outer_parse_info - > parameters_end_pos ( ) , kNoSourcePosition ) ; <nl> - DCHECK_NULL ( outer_parse_info - > extension ( ) ) ; <nl> + std : : unique_ptr < ParseInfo > ParseInfo : : ForToplevelFunction ( <nl> + const UnoptimizedCompileFlags flags , UnoptimizedCompileState * compile_state , <nl> + const FunctionLiteral * literal , const AstRawString * function_name ) { <nl> + std : : unique_ptr < ParseInfo > result ( new ParseInfo ( flags , compile_state ) ) ; <nl> <nl> / / Clone the function_name AstRawString into the ParseInfo ' s own <nl> / / AstValueFactory . <nl> void ParseInfo : : CheckFlagsForFunctionFromScript ( Script script ) { <nl> source_range_map ( ) ! = nullptr ) ; <nl> } <nl> <nl> - void ParseInfo : : ParallelTasks : : Enqueue ( ParseInfo * outer_parse_info , <nl> - const AstRawString * function_name , <nl> - FunctionLiteral * literal ) { <nl> + void UnoptimizedCompileState : : ParallelTasks : : Enqueue ( <nl> + ParseInfo * outer_parse_info , const AstRawString * function_name , <nl> + FunctionLiteral * literal ) { <nl> base : : Optional < CompilerDispatcher : : JobId > job_id = <nl> dispatcher_ - > Enqueue ( outer_parse_info , function_name , literal ) ; <nl> if ( job_id ) { <nl> mmm a / src / parsing / parse - info . h <nl> ppp b / src / parsing / parse - info . h <nl> <nl> # include " include / v8 . h " <nl> # include " src / base / bit - field . h " <nl> # include " src / base / export - template . h " <nl> + # include " src / base / logging . h " <nl> # include " src / common / globals . h " <nl> # include " src / handles / handles . h " <nl> # include " src / objects / function - kind . h " <nl> class V8_EXPORT_PRIVATE UnoptimizedCompileFlags { <nl> } ; <nl> <nl> # undef FLAG_FIELDS <nl> + class ParseInfo ; <nl> + <nl> + / / The mutable state for a parse + unoptimized compile operation . <nl> + class V8_EXPORT_PRIVATE UnoptimizedCompileState { <nl> + public : <nl> + explicit UnoptimizedCompileState ( Isolate * ) ; <nl> + UnoptimizedCompileState ( const UnoptimizedCompileState & other ) V8_NOEXCEPT ; <nl> + <nl> + class ParallelTasks { <nl> + public : <nl> + explicit ParallelTasks ( CompilerDispatcher * compiler_dispatcher ) <nl> + : dispatcher_ ( compiler_dispatcher ) { <nl> + DCHECK_NOT_NULL ( dispatcher_ ) ; <nl> + } <nl> + <nl> + void Enqueue ( ParseInfo * outer_parse_info , const AstRawString * function_name , <nl> + FunctionLiteral * literal ) ; <nl> + <nl> + using EnqueuedJobsIterator = <nl> + std : : forward_list < std : : pair < FunctionLiteral * , uintptr_t > > : : iterator ; <nl> + <nl> + EnqueuedJobsIterator begin ( ) { return enqueued_jobs_ . begin ( ) ; } <nl> + EnqueuedJobsIterator end ( ) { return enqueued_jobs_ . end ( ) ; } <nl> + <nl> + CompilerDispatcher * dispatcher ( ) { return dispatcher_ ; } <nl> + <nl> + private : <nl> + CompilerDispatcher * dispatcher_ ; <nl> + std : : forward_list < std : : pair < FunctionLiteral * , uintptr_t > > enqueued_jobs_ ; <nl> + } ; <nl> + <nl> + uint64_t hash_seed ( ) const { return hash_seed_ ; } <nl> + AccountingAllocator * allocator ( ) const { return allocator_ ; } <nl> + const AstStringConstants * ast_string_constants ( ) const { <nl> + return ast_string_constants_ ; <nl> + } <nl> + Logger * logger ( ) const { return logger_ ; } <nl> + PendingCompilationErrorHandler * pending_error_handler ( ) { <nl> + return & pending_error_handler_ ; <nl> + } <nl> + ParallelTasks * parallel_tasks ( ) const { return parallel_tasks_ . get ( ) ; } <nl> + <nl> + private : <nl> + uint64_t hash_seed_ ; <nl> + AccountingAllocator * allocator_ ; <nl> + const AstStringConstants * ast_string_constants_ ; <nl> + PendingCompilationErrorHandler pending_error_handler_ ; <nl> + Logger * logger_ ; <nl> + std : : unique_ptr < ParallelTasks > parallel_tasks_ ; <nl> + } ; <nl> <nl> / / A container for the inputs , configuration options , and outputs of parsing . <nl> class V8_EXPORT_PRIVATE ParseInfo { <nl> public : <nl> - ParseInfo ( Isolate * , const UnoptimizedCompileFlags flags ) ; <nl> + ParseInfo ( Isolate * isolate , const UnoptimizedCompileFlags flags , <nl> + UnoptimizedCompileState * state ) ; <nl> <nl> / / Creates a new parse info based on parent top - level | outer_parse_info | for <nl> / / function | literal | . <nl> - static std : : unique_ptr < ParseInfo > FromParent ( <nl> - const ParseInfo * outer_parse_info , const UnoptimizedCompileFlags flags , <nl> - AccountingAllocator * zone_allocator , const FunctionLiteral * literal , <nl> + static std : : unique_ptr < ParseInfo > ForToplevelFunction ( <nl> + const UnoptimizedCompileFlags flags , <nl> + UnoptimizedCompileState * compile_state , const FunctionLiteral * literal , <nl> const AstRawString * function_name ) ; <nl> <nl> ~ ParseInfo ( ) ; <nl> class V8_EXPORT_PRIVATE ParseInfo { <nl> <nl> const UnoptimizedCompileFlags & flags ( ) const { return flags_ ; } <nl> <nl> + / / Getters for state . <nl> + uint64_t hash_seed ( ) const { return state_ - > hash_seed ( ) ; } <nl> + AccountingAllocator * allocator ( ) const { return state_ - > allocator ( ) ; } <nl> + const AstStringConstants * ast_string_constants ( ) const { <nl> + return state_ - > ast_string_constants ( ) ; <nl> + } <nl> + Logger * logger ( ) const { return state_ - > logger ( ) ; } <nl> + PendingCompilationErrorHandler * pending_error_handler ( ) { <nl> + return state_ - > pending_error_handler ( ) ; <nl> + } <nl> + UnoptimizedCompileState : : ParallelTasks * parallel_tasks ( ) const { <nl> + return state_ - > parallel_tasks ( ) ; <nl> + } <nl> + const UnoptimizedCompileState * state ( ) const { return state_ ; } <nl> + <nl> + / / Accessors for per - thread state . <nl> + uintptr_t stack_limit ( ) const { return stack_limit_ ; } <nl> + RuntimeCallStats * runtime_call_stats ( ) const { return runtime_call_stats_ ; } <nl> + void SetPerThreadState ( uintptr_t stack_limit , <nl> + RuntimeCallStats * runtime_call_stats ) { <nl> + stack_limit_ = stack_limit ; <nl> + runtime_call_stats_ = runtime_call_stats ; <nl> + } <nl> + <nl> / / Accessor methods for output flags . <nl> bool allow_eval_cache ( ) const { return allow_eval_cache_ ; } <nl> void set_allow_eval_cache ( bool value ) { allow_eval_cache_ = value ; } <nl> class V8_EXPORT_PRIVATE ParseInfo { <nl> <nl> DeclarationScope * scope ( ) const ; <nl> <nl> - uintptr_t stack_limit ( ) const { return stack_limit_ ; } <nl> - void set_stack_limit ( uintptr_t stack_limit ) { stack_limit_ = stack_limit ; } <nl> - <nl> - uint64_t hash_seed ( ) const { return hash_seed_ ; } <nl> - void set_hash_seed ( uint64_t hash_seed ) { hash_seed_ = hash_seed ; } <nl> - <nl> int parameters_end_pos ( ) const { return parameters_end_pos_ ; } <nl> void set_parameters_end_pos ( int parameters_end_pos ) { <nl> parameters_end_pos_ = parameters_end_pos ; <nl> class V8_EXPORT_PRIVATE ParseInfo { <nl> max_function_literal_id_ = max_function_literal_id ; <nl> } <nl> <nl> - const AstStringConstants * ast_string_constants ( ) const { <nl> - return ast_string_constants_ ; <nl> - } <nl> - void set_ast_string_constants ( <nl> - const AstStringConstants * ast_string_constants ) { <nl> - ast_string_constants_ = ast_string_constants ; <nl> - } <nl> - <nl> - RuntimeCallStats * runtime_call_stats ( ) const { return runtime_call_stats_ ; } <nl> - void set_runtime_call_stats ( RuntimeCallStats * runtime_call_stats ) { <nl> - runtime_call_stats_ = runtime_call_stats ; <nl> - } <nl> - Logger * logger ( ) const { return logger_ ; } <nl> - void set_logger ( Logger * logger ) { logger_ = logger ; } <nl> - <nl> void AllocateSourceRangeMap ( ) ; <nl> SourceRangeMap * source_range_map ( ) const { return source_range_map_ ; } <nl> void set_source_range_map ( SourceRangeMap * source_range_map ) { <nl> source_range_map_ = source_range_map ; <nl> } <nl> <nl> - PendingCompilationErrorHandler * pending_error_handler ( ) { <nl> - return & pending_error_handler_ ; <nl> - } <nl> - <nl> - class ParallelTasks { <nl> - public : <nl> - explicit ParallelTasks ( CompilerDispatcher * compiler_dispatcher ) <nl> - : dispatcher_ ( compiler_dispatcher ) { <nl> - DCHECK ( dispatcher_ ) ; <nl> - } <nl> - <nl> - void Enqueue ( ParseInfo * outer_parse_info , const AstRawString * function_name , <nl> - FunctionLiteral * literal ) ; <nl> - <nl> - using EnqueuedJobsIterator = <nl> - std : : forward_list < std : : pair < FunctionLiteral * , uintptr_t > > : : iterator ; <nl> - <nl> - EnqueuedJobsIterator begin ( ) { return enqueued_jobs_ . begin ( ) ; } <nl> - EnqueuedJobsIterator end ( ) { return enqueued_jobs_ . end ( ) ; } <nl> - <nl> - CompilerDispatcher * dispatcher ( ) { return dispatcher_ ; } <nl> - <nl> - private : <nl> - CompilerDispatcher * dispatcher_ ; <nl> - std : : forward_list < std : : pair < FunctionLiteral * , uintptr_t > > enqueued_jobs_ ; <nl> - } ; <nl> - <nl> - ParallelTasks * parallel_tasks ( ) { return parallel_tasks_ . get ( ) ; } <nl> - <nl> void CheckFlagsForFunctionFromScript ( Script script ) ; <nl> <nl> private : <nl> - ParseInfo ( AccountingAllocator * zone_allocator , UnoptimizedCompileFlags flags ) ; <nl> + ParseInfo ( const UnoptimizedCompileFlags flags , <nl> + UnoptimizedCompileState * state ) ; <nl> <nl> void CheckFlagsForToplevelCompileFromScript ( Script script , <nl> bool is_collecting_type_profile ) ; <nl> <nl> / / mmmmmmmmmmmm - Inputs to parsing and scope analysis mmmmmmmmmmmmmmmmmmmmm - - <nl> const UnoptimizedCompileFlags flags_ ; <nl> + UnoptimizedCompileState * state_ ; <nl> + <nl> std : : unique_ptr < Zone > zone_ ; <nl> v8 : : Extension * extension_ ; <nl> DeclarationScope * script_scope_ ; <nl> uintptr_t stack_limit_ ; <nl> - uint64_t hash_seed_ ; <nl> int parameters_end_pos_ ; <nl> int max_function_literal_id_ ; <nl> <nl> class V8_EXPORT_PRIVATE ParseInfo { <nl> std : : unique_ptr < Utf16CharacterStream > character_stream_ ; <nl> std : : unique_ptr < ConsumedPreparseData > consumed_preparse_data_ ; <nl> std : : unique_ptr < AstValueFactory > ast_value_factory_ ; <nl> - const class AstStringConstants * ast_string_constants_ ; <nl> const AstRawString * function_name_ ; <nl> RuntimeCallStats * runtime_call_stats_ ; <nl> - Logger * logger_ ; <nl> SourceRangeMap * source_range_map_ ; / / Used when block coverage is enabled . <nl> - std : : unique_ptr < ParallelTasks > parallel_tasks_ ; <nl> <nl> / / mmmmmmmmm - - Output of parsing and scope analysis mmmmmmmmmmmmmmmmmmmmmmmm <nl> FunctionLiteral * literal_ ; <nl> - PendingCompilationErrorHandler pending_error_handler_ ; <nl> bool allow_eval_cache_ : 1 ; <nl> bool contains_asm_module_ : 1 ; <nl> LanguageMode language_mode_ : 1 ; <nl> mmm a / test / cctest / parsing / test - preparser . cc <nl> ppp b / test / cctest / parsing / test - preparser . cc <nl> TEST ( PreParserScopeAnalysis ) { <nl> flags . set_is_lazy_compile ( true ) ; <nl> <nl> / / Parse the lazy function using the scope data . <nl> - i : : ParseInfo using_scope_data ( isolate , flags ) ; <nl> + i : : UnoptimizedCompileState using_scope_state ( isolate ) ; <nl> + i : : ParseInfo using_scope_data ( isolate , flags , & using_scope_state ) ; <nl> using_scope_data . set_consumed_preparse_data ( <nl> i : : ConsumedPreparseData : : For ( isolate , produced_data_on_heap ) ) ; <nl> CHECK ( i : : parsing : : ParseFunction ( & using_scope_data , shared , isolate ) ) ; <nl> TEST ( PreParserScopeAnalysis ) { <nl> CHECK ( i : : DeclarationScope : : Analyze ( & using_scope_data ) ) ; <nl> <nl> / / Parse the lazy function again eagerly to produce baseline data . <nl> - i : : ParseInfo not_using_scope_data ( isolate , flags ) ; <nl> + i : : UnoptimizedCompileState not_using_scope_state ( isolate ) ; <nl> + i : : ParseInfo not_using_scope_data ( isolate , flags , & not_using_scope_state ) ; <nl> CHECK ( i : : parsing : : ParseFunction ( & not_using_scope_data , shared , isolate ) ) ; <nl> <nl> / / Verify that we didn ' t skip anything ( there ' s no preparsed scope data , <nl> TEST ( Regress753896 ) { <nl> i : : Handle < i : : String > source = factory - > InternalizeUtf8String ( <nl> " function lazy ( ) { let v = 0 ; if ( true ) { var v = 0 ; } } " ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & state ) ; <nl> <nl> / / We don ' t assert that parsing succeeded or that it failed ; currently the <nl> / / error is not detected inside lazy functions , but it might be in the future . <nl> mmm a / test / cctest / test - parsing . cc <nl> ppp b / test / cctest / test - parsing . cc <nl> TEST ( ScopeUsesArgumentsSuperThis ) { <nl> factory - > NewStringFromUtf8 ( i : : CStrVector ( program . begin ( ) ) ) <nl> . ToHandleChecked ( ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> / / The information we ' re checking is only produced when eager parsing . <nl> flags . set_allow_lazy_parsing ( false ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> CHECK ( i : : Rewriter : : Rewrite ( & info ) ) ; <nl> info . ast_value_factory ( ) - > Internalize ( isolate ) ; <nl> static void CheckParsesToNumber ( const char * source ) { <nl> <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source_code ) ; <nl> <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_allow_lazy_parsing ( false ) ; <nl> flags . set_is_toplevel ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> <nl> TEST ( ScopePositions ) { <nl> CHECK_EQ ( source - > length ( ) , kProgramSize ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_outer_language_mode ( source_data [ i ] . language_mode ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> i : : parsing : : ParseProgram ( & info , script , isolate ) ; <nl> CHECK_NOT_NULL ( info . literal ( ) ) ; <nl> <nl> TEST ( DiscardFunctionBody ) { <nl> i : : Handle < i : : String > source_code = <nl> factory - > NewStringFromUtf8 ( i : : CStrVector ( source ) ) . ToHandleChecked ( ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source_code ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> i : : parsing : : ParseProgram ( & info , script , isolate ) ; <nl> function = info . literal ( ) ; <nl> CHECK_NOT_NULL ( function ) ; <nl> void TestParserSyncWithFlags ( i : : Handle < i : : String > source , <nl> bool ignore_error_msg = false ) { <nl> i : : Isolate * isolate = CcTest : : i_isolate ( ) ; <nl> i : : Factory * factory = isolate - > factory ( ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags compile_flags = <nl> i : : UnoptimizedCompileFlags : : ForToplevelCompile ( <nl> isolate , true , LanguageMode : : kSloppy , REPLMode : : kNo ) ; <nl> void TestParserSyncWithFlags ( i : : Handle < i : : String > source , <nl> SetGlobalFlags ( flags ) ; <nl> i : : Handle < i : : Script > script = <nl> factory - > NewScriptWithId ( source , compile_flags . script_id ( ) ) ; <nl> - i : : ParseInfo info ( isolate , compile_flags ) ; <nl> + i : : ParseInfo info ( isolate , compile_flags , & compile_state ) ; <nl> i : : parsing : : ParseProgram ( & info , script , isolate ) ; <nl> function = info . literal ( ) ; <nl> } <nl> TEST ( InnerAssignment ) { <nl> i : : SNPrintF ( program , " % s % s % s % s % s " , prefix , outer , midfix , inner , <nl> suffix ) ; <nl> <nl> + UnoptimizedCompileState compile_state ( isolate ) ; <nl> std : : unique_ptr < i : : ParseInfo > info ; <nl> if ( lazy ) { <nl> printf ( " % s \ n " , program . begin ( ) ) ; <nl> TEST ( InnerAssignment ) { <nl> i : : handle ( f - > shared ( ) , isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForFunctionCompile ( isolate , * shared ) ; <nl> - info = std : : make_unique < i : : ParseInfo > ( isolate , flags ) ; <nl> + info = std : : make_unique < i : : ParseInfo > ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseFunction ( info . get ( ) , shared , isolate ) ) ; <nl> } else { <nl> i : : Handle < i : : String > source = <nl> TEST ( InnerAssignment ) { <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_allow_lazy_parsing ( false ) ; <nl> - info = std : : make_unique < i : : ParseInfo > ( isolate , flags ) ; <nl> + info = std : : make_unique < i : : ParseInfo > ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseProgram ( info . get ( ) , script , isolate ) ) ; <nl> } <nl> CHECK ( i : : Compiler : : Analyze ( info . get ( ) ) ) ; <nl> TEST ( MaybeAssignedParameters ) { <nl> i : : Handle < i : : Object > o = v8 : : Utils : : OpenHandle ( * v ) ; <nl> i : : Handle < i : : JSFunction > f = i : : Handle < i : : JSFunction > : : cast ( o ) ; <nl> i : : Handle < i : : SharedFunctionInfo > shared = i : : handle ( f - > shared ( ) , isolate ) ; <nl> + i : : UnoptimizedCompileState state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForFunctionCompile ( isolate , * shared ) ; <nl> flags . set_allow_lazy_parsing ( allow_lazy ) ; <nl> - info = std : : make_unique < i : : ParseInfo > ( isolate , flags ) ; <nl> + info = std : : make_unique < i : : ParseInfo > ( isolate , flags , & state ) ; <nl> CHECK ( i : : parsing : : ParseFunction ( info . get ( ) , shared , isolate ) ) ; <nl> CHECK ( i : : Compiler : : Analyze ( info . get ( ) ) ) ; <nl> CHECK_NOT_NULL ( info - > literal ( ) ) ; <nl> static void TestMaybeAssigned ( Input input , const char * variable , bool module , <nl> printf ( " \ n " ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( string ) ; <nl> <nl> + i : : UnoptimizedCompileState state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( module ) ; <nl> flags . set_allow_lazy_parsing ( allow_lazy_parsing ) ; <nl> std : : unique_ptr < i : : ParseInfo > info = <nl> - std : : make_unique < i : : ParseInfo > ( isolate , flags ) ; <nl> + std : : make_unique < i : : ParseInfo > ( isolate , flags , & state ) ; <nl> <nl> CHECK ( i : : parsing : : ParseProgram ( info . get ( ) , script , isolate ) ) ; <nl> CHECK ( i : : Compiler : : Analyze ( info . get ( ) ) ) ; <nl> TEST ( BasicImportExportParsing ) { <nl> / / Show that parsing as a module works <nl> { <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> if ( ! i : : parsing : : ParseProgram ( & info , script , isolate ) ) { <nl> i : : Handle < i : : JSObject > exception_handle ( <nl> i : : JSObject : : cast ( isolate - > pending_exception ( ) ) , isolate ) ; <nl> TEST ( BasicImportExportParsing ) { <nl> <nl> / / And that parsing a script does not . <nl> { <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( ! i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> isolate - > clear_pending_exception ( ) ; <nl> } <nl> TEST ( NamespaceExportParsing ) { <nl> i : : Handle < i : : String > source = <nl> factory - > NewStringFromAsciiChecked ( kSources [ i ] ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> } <nl> } <nl> TEST ( ImportExportParsingErrors ) { <nl> factory - > NewStringFromAsciiChecked ( kErrorSources [ i ] ) ; <nl> <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( ! i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> isolate - > clear_pending_exception ( ) ; <nl> } <nl> TEST ( ModuleTopLevelFunctionDecl ) { <nl> factory - > NewStringFromAsciiChecked ( kErrorSources [ i ] ) ; <nl> <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( ! i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> isolate - > clear_pending_exception ( ) ; <nl> } <nl> TEST ( ModuleParsingInternals ) { <nl> " export { foob } ; " ; <nl> i : : Handle < i : : String > source = factory - > NewStringFromAsciiChecked ( kSource ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_is_module ( true ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> CHECK ( i : : Compiler : : Analyze ( & info ) ) ; <nl> i : : FunctionLiteral * func = info . literal ( ) ; <nl> void TestLanguageMode ( const char * source , <nl> <nl> i : : Handle < i : : Script > script = <nl> factory - > NewScript ( factory - > NewStringFromAsciiChecked ( source ) ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> i : : parsing : : ParseProgram ( & info , script , isolate ) ; <nl> CHECK_NOT_NULL ( info . literal ( ) ) ; <nl> CHECK_EQ ( expected_language_mode , info . literal ( ) - > language_mode ( ) ) ; <nl> TEST ( NoPessimisticContextAllocation ) { <nl> printf ( " \ n " ) ; <nl> <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> CHECK ( i : : Compiler : : Analyze ( & info ) ) ; <nl> TEST ( LexicalLoopVariable ) { <nl> i : : Handle < i : : String > source = <nl> factory - > NewStringFromUtf8 ( i : : CStrVector ( program ) ) . ToHandleChecked ( ) ; <nl> i : : Handle < i : : Script > script = factory - > NewScript ( source ) ; <nl> + i : : UnoptimizedCompileState compile_state ( isolate ) ; <nl> i : : UnoptimizedCompileFlags flags = <nl> i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , * script ) ; <nl> flags . set_allow_lazy_parsing ( false ) ; <nl> - i : : ParseInfo info ( isolate , flags ) ; <nl> + i : : ParseInfo info ( isolate , flags , & compile_state ) ; <nl> CHECK ( i : : parsing : : ParseProgram ( & info , script , isolate ) ) ; <nl> CHECK ( i : : Rewriter : : Rewrite ( & info ) ) ; <nl> CHECK ( i : : DeclarationScope : : Analyze ( & info ) ) ; <nl> mmm a / test / fuzzer / parser . cc <nl> ppp b / test / fuzzer / parser . cc <nl> extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * data , size_t size ) { <nl> <nl> v8 : : internal : : Handle < v8 : : internal : : Script > script = <nl> factory - > NewScript ( source . ToHandleChecked ( ) ) ; <nl> + v8 : : internal : : UnoptimizedCompileState state ( i_isolate ) ; <nl> v8 : : internal : : UnoptimizedCompileFlags flags = <nl> v8 : : internal : : UnoptimizedCompileFlags : : ForScriptCompile ( i_isolate , <nl> * script ) ; <nl> - v8 : : internal : : ParseInfo info ( i_isolate , flags ) ; <nl> + v8 : : internal : : ParseInfo info ( i_isolate , flags , & state ) ; <nl> if ( ! v8 : : internal : : parsing : : ParseProgram ( & info , script , i_isolate ) ) { <nl> i_isolate - > OptionalRescheduleException ( true ) ; <nl> } <nl> mmm a / test / unittests / compiler - dispatcher / compiler - dispatcher - unittest . cc <nl> ppp b / test / unittests / compiler - dispatcher / compiler - dispatcher - unittest . cc <nl> class CompilerDispatcherTest : public TestWithNativeContext { <nl> static base : : Optional < CompilerDispatcher : : JobId > EnqueueUnoptimizedCompileJob ( <nl> CompilerDispatcher * dispatcher , Isolate * isolate , <nl> Handle < SharedFunctionInfo > shared ) { <nl> + UnoptimizedCompileState state ( isolate ) ; <nl> std : : unique_ptr < ParseInfo > outer_parse_info = <nl> - test : : OuterParseInfoForShared ( isolate , shared ) ; <nl> + test : : OuterParseInfoForShared ( isolate , shared , & state ) ; <nl> AstValueFactory * ast_value_factory = <nl> outer_parse_info - > GetOrCreateAstValueFactory ( ) ; <nl> AstNodeFactory ast_node_factory ( ast_value_factory , <nl> mmm a / test / unittests / heap / off - thread - factory - unittest . cc <nl> ppp b / test / unittests / heap / off - thread - factory - unittest . cc <nl> class OffThreadFactoryTest : public TestWithIsolateAndZone { <nl> public : <nl> OffThreadFactoryTest ( ) <nl> : TestWithIsolateAndZone ( ) , <nl> - parse_info_ ( isolate ( ) , UnoptimizedCompileFlags : : ForToplevelCompile ( <nl> - isolate ( ) , true , <nl> - construct_language_mode ( FLAG_use_strict ) , <nl> - REPLMode : : kNo ) ) , <nl> + state_ ( isolate ( ) ) , <nl> + parse_info_ ( <nl> + isolate ( ) , <nl> + UnoptimizedCompileFlags : : ForToplevelCompile ( <nl> + isolate ( ) , true , construct_language_mode ( FLAG_use_strict ) , <nl> + REPLMode : : kNo ) , <nl> + & state_ ) , <nl> off_thread_isolate_ ( isolate ( ) , parse_info_ . zone ( ) ) { } <nl> <nl> FunctionLiteral * ParseProgram ( const char * source ) { <nl> class OffThreadFactoryTest : public TestWithIsolateAndZone { <nl> } <nl> <nl> private : <nl> + UnoptimizedCompileState state_ ; <nl> ParseInfo parse_info_ ; <nl> OffThreadIsolate off_thread_isolate_ ; <nl> Handle < String > source_string_ ; <nl> mmm a / test / unittests / tasks / background - compile - task - unittest . cc <nl> ppp b / test / unittests / tasks / background - compile - task - unittest . cc <nl> class BackgroundCompileTaskTest : public TestWithNativeContext { <nl> BackgroundCompileTask * NewBackgroundCompileTask ( <nl> Isolate * isolate , Handle < SharedFunctionInfo > shared , <nl> size_t stack_size = FLAG_stack_size ) { <nl> + UnoptimizedCompileState state ( isolate ) ; <nl> std : : unique_ptr < ParseInfo > outer_parse_info = <nl> - test : : OuterParseInfoForShared ( isolate , shared ) ; <nl> + test : : OuterParseInfoForShared ( isolate , shared , & state ) ; <nl> AstValueFactory * ast_value_factory = <nl> outer_parse_info - > GetOrCreateAstValueFactory ( ) ; <nl> AstNodeFactory ast_node_factory ( ast_value_factory , <nl> class BackgroundCompileTaskTest : public TestWithNativeContext { <nl> shared - > function_literal_id ( ) , nullptr ) ; <nl> <nl> return new BackgroundCompileTask ( <nl> - allocator ( ) , outer_parse_info . get ( ) , function_name , function_literal , <nl> + outer_parse_info . get ( ) , function_name , function_literal , <nl> isolate - > counters ( ) - > worker_thread_runtime_call_stats ( ) , <nl> isolate - > counters ( ) - > compile_function_on_background ( ) , FLAG_stack_size ) ; <nl> } <nl> mmm a / test / unittests / test - helpers . cc <nl> ppp b / test / unittests / test - helpers . cc <nl> Handle < SharedFunctionInfo > CreateSharedFunctionInfo ( <nl> } <nl> <nl> std : : unique_ptr < ParseInfo > OuterParseInfoForShared ( <nl> - Isolate * isolate , Handle < SharedFunctionInfo > shared ) { <nl> + Isolate * isolate , Handle < SharedFunctionInfo > shared , <nl> + UnoptimizedCompileState * state ) { <nl> Script script = Script : : cast ( shared - > script ( ) ) ; <nl> std : : unique_ptr < ParseInfo > result = std : : make_unique < ParseInfo > ( <nl> - isolate , i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , script ) ) ; <nl> + isolate , i : : UnoptimizedCompileFlags : : ForScriptCompile ( isolate , script ) , <nl> + state ) ; <nl> <nl> / / Create a character stream to simulate the parser having done so for the <nl> - / / to - level ParseProgram . <nl> + / / top - level ParseProgram . <nl> Handle < String > source ( String : : cast ( script . source ( ) ) , isolate ) ; <nl> std : : unique_ptr < Utf16CharacterStream > stream ( <nl> ScannerStream : : For ( isolate , source ) ) ; <nl> mmm a / test / unittests / test - helpers . h <nl> ppp b / test / unittests / test - helpers . h <nl> Handle < SharedFunctionInfo > CreateSharedFunctionInfo ( <nl> Isolate * isolate , <nl> v8 : : String : : ExternalOneByteStringResource * maybe_resource ) ; <nl> std : : unique_ptr < ParseInfo > OuterParseInfoForShared ( <nl> - Isolate * isolate , Handle < SharedFunctionInfo > shared ) ; <nl> + Isolate * isolate , Handle < SharedFunctionInfo > shared , <nl> + UnoptimizedCompileState * state ) ; <nl> <nl> } / / namespace test <nl> } / / namespace internal <nl> | [ compile ] Add an UnoptimizedCompileState class | v8/v8 | 6458a5296bc1d9405246791da51dadbf2efa63f7 | 2020-04-23T07:08:28Z |
new file mode 100644 <nl> index 00000000000 . . f48898c83a6 <nl> mmm / dev / null <nl> ppp b / tests / queries / 0_stateless / 01423_if_nullable_cond . reference <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - 1 Nullable ( Int16 ) Nullable ( Int16 ) , Const ( size = 1 , Nullable ( size = 1 , Int16 ( size = 1 ) , UInt8 ( size = 1 ) ) ) <nl> new file mode 100644 <nl> index 00000000000 . . 9c56e9dbe26 <nl> mmm / dev / null <nl> ppp b / tests / queries / 0_stateless / 01423_if_nullable_cond . sql <nl> @ @ - 0 , 0 + 1 @ @ <nl> + SELECT CAST ( null , ' Nullable ( UInt8 ) ' ) = 1 ? CAST ( null , ' Nullable ( UInt8 ) ' ) : - 1 AS x , toTypeName ( x ) , dumpColumnStructure ( x ) ; <nl> | Add test | ClickHouse/ClickHouse | b47a02f20bc9bb58657e21e6f13f8ac5a131263d | 2020-08-02T02:00:08Z |
mmm a / extensions / CCBReader / CCData . h <nl> ppp b / extensions / CCBReader / CCData . h <nl> <nl> # define __CCB_CCDATA_H__ <nl> <nl> # include " cocos2d . h " <nl> - # include " cocos - ext . h " <nl> + # include " ExtensionMacros . h " " <nl> <nl> NS_CC_EXT_BEGIN <nl> <nl> mmm a / scripting / javascript / bindings / js_bindings_ccbreader . cpp <nl> ppp b / scripting / javascript / bindings / js_bindings_ccbreader . cpp <nl> <nl> USING_NS_CC ; <nl> USING_NS_CC_EXT ; <nl> <nl> + static void removeSelector ( std : : string & str ) { <nl> + size_t found ; <nl> + found = str . find ( " : " ) ; <nl> + while ( found ! = std : : string : : npos ) { <nl> + str . replace ( found , found + 1 , " " ) ; <nl> + found = str . find ( " : " ) ; <nl> + } <nl> + } <nl> <nl> SEL_MenuHandler CCBScriptCallbackProxy : : onResolveCCBCCMenuItemSelector ( cocos2d : : CCObject * pTarget , <nl> cocos2d : : CCString * pSelectorName ) { <nl> this - > callBackProp = pSelectorName - > getCString ( ) ; <nl> + removeSelector ( this - > callBackProp ) ; <nl> return menu_selector ( CCBScriptCallbackProxy : : menuItemCallback ) ; <nl> } <nl> <nl> SEL_CCControlHandler CCBScriptCallbackProxy : : onResolveCCBCCControlSelector ( CCObj <nl> CCString * pSelectorName ) { <nl> <nl> this - > callBackProp = pSelectorName - > getCString ( ) ; <nl> + removeSelector ( this - > callBackProp ) ; <nl> return cccontrol_selector ( CCBScriptCallbackProxy : : controlCallback ) ; <nl> } <nl> <nl> bool CCBScriptCallbackProxy : : onAssignCCBMemberVariable ( CCObject * pTarget , <nl> CCString * pMemberVariableName , <nl> CCNode * pNode ) { <nl> + return true ; <nl> } <nl> <nl> void CCBScriptCallbackProxy : : onNodeLoaded ( CCNode * pNode , <nl> static CCNode * loadReader ( const char * file , jsval owner ) { <nl> / / ccbReader - > setOwner ( dynamic_cast < CCObject * > ( ccBCallbackProxy ) ) ; <nl> <nl> CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast < CCBSelectorResolver * > ( ccBCallbackProxy ) ; <nl> - if ( targetAsCCBSelectorResolver ! = NULL ) { <nl> - js_log ( " NOT NULL " ) ; <nl> - } <nl> <nl> - CCNode * node = ccbReader - > readNodeGraphFromFile ( " . / " , file , dynamic_cast < CCObject * > ( ccBCallbackProxy ) ) ; <nl> + CCNode * node = ccbReader - > readNodeGraphFromFile ( file , dynamic_cast < CCObject * > ( ccBCallbackProxy ) ) ; <nl> <nl> return node ; <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . 18b9c22de9d0 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / Abadi40 - hd . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + f06c047dd32b61f12ad51e981afe518364512be6 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 717ceb89a1b8 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / Abadi40 - ipad . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 4b7c1e97acefff48ae3652f023e708245992f553 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . fb1884455ba8 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / Abadi40 . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + ae62d7b07ac3e7579ed7d6a2e1f903719e45c6d9 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 5067e00b744c <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / Gas40 - hd . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 12db20c3124e1bd864312257eb8cefe95d2ee349 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 8ddebffce202 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / Gas40 - ipad . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + e71140c1535f16b49980f3ea0cf7d3a29a8a9788 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 15f23ffc8557 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / konqa32 - hd . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + dc235c169030151e337ecbfa1fc6302fc909e500 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 2549ab636206 <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / konqa32 - ipad . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 9e95a02e6eb2944fea12a49eb3f2c6fe7505a3ce <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 83954562c04e <nl> mmm / dev / null <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / CCB / konqa32 . png . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 1423c81273926b3da9fb1cb36c9b710d3f14ee0e <nl> \ No newline at end of file <nl> mmm a / template / xcode4 / cocos2dx_js . xctemplate / Resources / hello . js <nl> ppp b / template / xcode4 / cocos2dx_js . xctemplate / Resources / hello . js <nl> <nl> + <nl> try { <nl> - <nl> + <nl> cc . p = cc . p | | function ( x , y ) { <nl> return { x : x , y : y } ; <nl> } ; <nl> try { <nl> cc . c4b = cc . c4 | | function ( r , g , b , o ) { <nl> return { r : r , g : g , b : b , a : o } ; <nl> } ; <nl> + <nl> + <nl> + cc . c3 = cc . c3 | | function ( r , g , b ) { <nl> + return { r : r , g : g , b : b } ; <nl> + } ; <nl> + cc . BLACK = cc . c3 ( 0 , 0 , 0 ) ; <nl> <nl> + <nl> director = cc . Director . getInstance ( ) ; <nl> winSize = director . getWinSize ( ) ; <nl> + centerPos = cc . p ( winSize . width / 2 , winSize . height / 2 ) ; <nl> <nl> - var scene = new cc . Scene ( ) ; <nl> - var layer = new cc . LayerGradient ( ) ; <nl> - <nl> - layer . init ( cc . c4b ( 0 , 0 , 0 , 255 ) , cc . c4b ( 0 , 128 , 255 , 255 ) ) ; <nl> + var GameCreator = function ( ) { <nl> + <nl> + var self = { } ; <nl> + self . callbacks = { } ; <nl> <nl> - var lab = " Houston we have liftoff ! " ; <nl> - var label = cc . LabelTTF . create ( lab , " Arial " , 28 ) ; <nl> - layer . addChild ( label , 1 ) ; <nl> - label . setPosition ( cc . p ( winSize . width / 2 , winSize . height / 2 ) ) ; <nl> + self . getPlayScene = function ( ) { <nl> + <nl> + var scene = new cc . Scene ( ) ; <nl> + var layer = new cc . LayerGradient ( ) ; <nl> + <nl> + layer . init ( cc . c4b ( 0 , 0 , 0 , 255 ) , cc . c4b ( 0 , 128 , 255 , 255 ) ) ; <nl> + <nl> + var lab = " Houston we have liftoff ! " ; <nl> + var label = cc . LabelTTF . create ( lab , " Arial " , 28 ) ; <nl> + layer . addChild ( label , 1 ) ; <nl> + label . setPosition ( cc . p ( winSize . width / 2 , winSize . height / 2 ) ) ; <nl> + <nl> + var back = cc . MenuItemFont . create ( " Back " , this . callbacks , this . callbacks . onBack ) ; <nl> + back . setColor ( cc . BLACK ) ; <nl> + <nl> + var menu = cc . Menu . create ( back ) ; <nl> + layer . addChild ( menu ) ; <nl> + menu . alignItemsVertically ( ) ; <nl> + menu . setPosition ( cc . p ( winSize . width - 50 , 50 ) ) ; <nl> + <nl> + scene . addChild ( layer ) ; <nl> + <nl> + return scene ; <nl> + } ; <nl> + <nl> + self . getMainMenuScene = function ( ) { <nl> + var l = cc . Layer . create ( ) ; <nl> + var scene = cc . Scene . create ( ) ; <nl> + <nl> + var node = cc . Reader . load ( " MainMenu . ccbi " , this , winSize ) ; <nl> + l . addChild ( node ) ; <nl> + <nl> + scene . addChild ( l ) ; <nl> + <nl> + return scene ; <nl> + } ; <nl> + <nl> + self . getOptionsScene = function ( ) { <nl> <nl> + var l = cc . LayerGradient . create ( ) ; <nl> + l . init ( cc . c4b ( 0 , 0 , 0 , 255 ) , cc . c4b ( 255 , 255 , 255 , 255 ) ) ; <nl> <nl> - scene . addChild ( layer ) ; <nl> + var scene = cc . Scene . create ( ) ; <nl> + <nl> + var label1 = cc . LabelBMFont . create ( " MUSIC ON " , " konqa32 . fnt " ) ; <nl> + var item1 = cc . MenuItemLabel . create ( label1 ) ; <nl> + var label2 = cc . LabelBMFont . create ( " MUSIC OFF " , " konqa32 . fnt " ) ; <nl> + var item2 = cc . MenuItemLabel . create ( label2 ) ; <nl> + var toggle = cc . MenuItemToggle . create ( item1 , item2 ) ; <nl> + <nl> + this . onMusicToggle = function ( sender ) { <nl> + } ; <nl> + <nl> + toggle . setCallback ( this , this . onMusicToggle ) ; <nl> + <nl> + var back = cc . MenuItemFont . create ( " Back " , this . callbacks , this . callbacks . onBack ) ; <nl> + var menu = cc . Menu . create ( toggle , back ) ; <nl> + l . addChild ( menu ) ; <nl> + menu . alignItemsVertically ( ) ; <nl> + menu . setPosition ( centerPos ) ; <nl> <nl> - director . runWithScene ( scene ) ; <nl> + scene . addChild ( l ) ; <nl> + <nl> + return scene ; <nl> + } ; <nl> + <nl> + <nl> + self . getAboutScene = function ( ) { <nl> + <nl> + var scene = cc . Scene . create ( ) ; <nl> + var l = cc . Layer . create ( ) ; <nl> + var about = cc . Reader . load ( " About . ccbi " , this ) ; <nl> + l . addChild ( about ) <nl> + <nl> + var back = cc . MenuItemFont . create ( " Back " , this . callbacks , this . callbacks . onBack ) ; <nl> + back . setColor ( cc . BLACK ) ; <nl> + var menu = cc . Menu . create ( back ) ; <nl> + l . addChild ( menu ) ; <nl> + menu . alignItemsVertically ( ) ; <nl> + menu . setPosition ( cc . p ( winSize . width - 50 , 50 ) ) ; <nl> + <nl> + scene . addChild ( l ) ; <nl> + <nl> + return scene ; <nl> + } ; <nl> + <nl> + <nl> + / / CCBuilder Selectors <nl> + <nl> + self . onPlay = function ( ) { <nl> + director . replaceScene ( cc . TransitionFade . create ( 1 , this . getPlayScene ( ) ) ) ; <nl> + } <nl> + <nl> + self . onAbout = function ( ) { <nl> + director . replaceScene ( cc . TransitionZoomFlipY . create ( 1 , this . getAboutScene ( ) ) ) ; <nl> + } ; <nl> + <nl> + self . onOptions = function ( ) { <nl> + director . replaceScene ( cc . TransitionZoomFlipY . create ( 1 , this . getOptionsScene ( ) ) ) ; <nl> + } ; <nl> + <nl> + <nl> + / / Manual Callbacks <nl> + <nl> + self . callbacks . onBack = function ( sender ) { <nl> + director . replaceScene ( cc . TransitionFlipX . create ( 1 , self . getMainMenuScene ( ) ) ) ; <nl> + } ; <nl> + <nl> + return self ; <nl> + <nl> + } ; <nl> + <nl> + var game = GameCreator ( ) ; <nl> + <nl> + __jsc__ . garbageCollect ( ) ; <nl> + <nl> + director . runWithScene ( game . getMainMenuScene ( ) ) ; <nl> + <nl> + } catch ( e ) { log ( e ) ; } <nl> <nl> - } catch ( e ) { log ( e ) ; } <nl> \ No newline at end of file <nl> | Adding sample game wrapper using CCBReader . Also includes small modification to CCBReader | cocos2d/cocos2d-x | 100a7a18838c2f78ecde470747644105876208cd | 2012-09-21T01:02:17Z |
mmm a / hphp / hack / src / server / serverCommand . ml <nl> ppp b / hphp / hack / src / server / serverCommand . ml <nl> let stream_response ( genv : ServerEnv . genv ) env ( ic , oc ) ~ cmd = <nl> | None - > ServerUtils . shutdown_client ( ic , oc ) <nl> | Some build_hook - > begin <nl> ServerTypeCheck . hook_after_parsing : = <nl> - Some ( fun genv old_env env updates - > <nl> + Some ( fun genv env - > <nl> ( * subtle : an exception there ( such as writing on a closed pipe ) <nl> * will not be caught by handle_connection ( ) because <nl> * we have already returned from handle_connection ( ) , hence <nl> let stream_response ( genv : ServerEnv . genv ) env ( ic , oc ) ~ cmd = <nl> with_context <nl> ~ enter : ( fun ( ) - > ( ) ) <nl> ~ exit : ( fun ( ) - > ServerUtils . shutdown_client ( ic , oc ) ) <nl> - ~ do_ : ( fun ( ) - > build_hook genv old_env env updates ) ; <nl> + ~ do_ : ( fun ( ) - > build_hook genv env ) ; <nl> with exn - > <nl> let msg = Printexc . to_string exn in <nl> Printf . printf " Exn in build_hook : % s " msg ; <nl> mmm a / hphp / hack / src / server / serverTypeCheck . ml <nl> ppp b / hphp / hack / src / server / serverTypeCheck . ml <nl> let type_check genv env = <nl> <nl> ( * UPDATE FILE INFO * ) <nl> let old_env = env in <nl> - let updates = old_env . failed_parsing in <nl> let files_info = update_file_info env fast_parsed in <nl> HackEventLogger . updating_deps_end t ; <nl> let t = Hh_logger . log_duration " Updating deps " t in <nl> <nl> ( * BUILDING AUTOLOADMAP * ) <nl> Option . iter ! hook_after_parsing begin fun f - > <nl> - f genv old_env { env with files_info } updates <nl> + f genv { env with files_info } <nl> end ; <nl> HackEventLogger . parsing_hook_end t ; <nl> let t = Hh_logger . log_duration " Parsing Hook " t in <nl> mmm a / hphp / hack / src / server / serverTypeCheck . mli <nl> ppp b / hphp / hack / src / server / serverTypeCheck . mli <nl> val type_check : ServerEnv . genv - > ServerEnv . env - > ServerEnv . env * int <nl> ( * just add also some debugging information on stdout * ) <nl> val check : ServerEnv . genv - > ServerEnv . env - > ServerEnv . env * int <nl> <nl> - val hook_after_parsing : ( ServerEnv . genv - > ( * old * ) ServerEnv . env - > <nl> - ( * new * ) ServerEnv . env - > Relative_path . Set . t - > unit ) option ref <nl> + val hook_after_parsing : ( ServerEnv . genv - > <nl> + ( * new * ) ServerEnv . env - > unit ) option ref <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Debugging : Declared here to stop ocamlc yelling at us for unused defs * ) <nl> mmm a / hphp / hack / src / stubs / buildMain . ml <nl> ppp b / hphp / hack / src / stubs / buildMain . ml <nl> <nl> * <nl> * ) <nl> <nl> - let go _ _ _ _ = Some ( fun _ _ _ _ - > ( ) ) <nl> + let go _ _ _ _ = Some ( fun _ _ - > ( ) ) <nl> let incremental_update _ _ _ _ = ( ) <nl> let get_live_targets _ = [ ] <nl> | Remove " incremental background autoloadmap build " . | facebook/hhvm | 9d0e1c51d1e3f70c2ac50783a3980576eb2b72fb | 2016-09-01T18:34:09Z |
mmm a / README . md <nl> ppp b / README . md <nl> <nl> # CNTK <nl> <nl> # # Latest news <nl> - * 2016 - 04 - 12 . * Added support for ND convolutions and pooling . Enabled CPU support for ` cudnn ` data layout . Added documentation for convolution , pooling and batch normalization nodes : https : / / github . com / Microsoft / CNTK / wiki / Full - NDL - Function - Reference <nl> + * 2016 - 04 - 12 . * CNTK is available as [ Azure Virtual Machines ] ( https : / / github . com / Microsoft / CNTK / wiki / CNTK - on - Azure ) and [ Docker Containers ] ( https : / / github . com / Microsoft / CNTK / wiki / CNTK - Docker - Containers ) <nl> + <nl> + * 2016 - 04 - 12 . * Added support for ND convolution and ND pooling and CPU support for ` cudnn ` layout in convolution , pooling and batch normalization nodes . <nl> + Read [ documentation ] ( https : / / github . com / Microsoft / CNTK / wiki / Full - NDL - Function - Reference ) on convolution , pooling and batch normalization nodes . <nl> <nl> * 2016 - 04 - 05 . * CUDA7 . 5 support for Windows Build : Windows project files have been updated to automatically utilize CUDA 7 . 5 if present <nl> <nl> + # # March 2016 <nl> * 2016 - 03 - 24 . * New Text Reader ( CNTKTextFormatReader ) is available <nl> Read description here https : / / github . com / Microsoft / CNTK / wiki / CNTKTextFormat - Reader <nl> <nl> - * 2016 - 02 - 29 . * Added ZIP files support to the ImageReader <nl> - Examples : https : / / github . com / Microsoft / CNTK / wiki / Image - reader <nl> - Updated build steps at https : / / github . com / Microsoft / CNTK / wiki / Setup - CNTK - on - your - machine <nl> - <nl> See [ all news ] ( https : / / github . com / Microsoft / CNTK / wiki / News ) . <nl> <nl> # # What is CNTK <nl> | Integrate alexeyo / ReadMe - News - April into master | microsoft/CNTK | 7b71179ced247f8cbf61b19877af5b531b8854e8 | 2016-04-13T21:40:06Z |
mmm a / src / builtins / builtins - json . cc <nl> ppp b / src / builtins / builtins - json . cc <nl> BUILTIN ( JsonParse ) { <nl> Object : : ToString ( isolate , source ) ) ; <nl> string = String : : Flatten ( isolate , string ) ; <nl> RETURN_RESULT_OR_FAILURE ( <nl> - isolate , string - > IsOneByteRepresentation ( ) <nl> + isolate , String : : IsOneByteRepresentationUnderneath ( * string ) <nl> ? JsonParser < uint8_t > : : Parse ( isolate , string , reviver ) <nl> : JsonParser < uint16_t > : : Parse ( isolate , string , reviver ) ) ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . d98c01adf33 <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - crbug - 967151 . js <nl> <nl> + / / Copyright 2019 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - expose - externalize - string <nl> + <nl> + __v_3 = " 100 external string turned into two byte " ; <nl> + __v_2 = __v_3 . substring ( 0 , 28 ) ; <nl> + try { <nl> + externalizeString ( __v_3 , true ) ; <nl> + } catch ( e ) { } <nl> + assertEquals ( 100 , JSON . parse ( __v_2 ) ) ; <nl> | [ json ] Strings can lie to us about representation , so check what ' s underneath | v8/v8 | f58b7e172777aaf37e1662234ca3e1d14bd0627c | 2019-05-27T10:56:44Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.